comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/internal/image/PngChunk.d @ 120:536e43f63c81

Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661 ===D2=== * added [Try]Immutable/Const/Shared templates to work with differenses in D1/D2 instead of version statements used these templates to work with strict type storage rules of dmd-2.053 * com.ibm.icu now also compilable with D2, but not tested yet * small fixes Snippet288 - shared data is in TLS ===Phobos=== * fixed critical bugs in Phobos implemention completely incorrect segfault prone fromStringz (Linux's port ruthless killer) terrible, incorrect StringBuffer realization (StyledText killer) * fixed small bugs as well Snippet72 - misprint in the snippet * implemented missed functionality for Phobos ByteArrayOutputStream implemented (image loading available) formatting correctly works for all DWT's cases As a result, folowing snippets now works with Phobos (Snippet### - what is fixed): Snippet24, 42, 111, 115, 130, 235, 276 - bad string formatting Snippet48, 282 - crash on image loading Snippet163, 189, 211, 213, 217, 218, 222 - crash on copy/cut in StyledText Snippet244 - hang-up ===Tango=== * few changes for the latest Tango trunc-r5661 * few small performance improvments ===General=== * implMissing-s for only one version changed to implMissingInTango/InPhobos * incorrect calls to Format in toString-s fixed * fixed loading \uXXXX characters in ResourceBundle * added good UTF-8 support for StyledText, TextLayout (Win32) and friends UTF functions revised and tested. It is now in java.nonstandard.*Utf modules StyledText and TextLayout (Win32) modules revised for UTF-8 support * removed small diferences in most identical files in *.swt.* folders *.swt.internal.image, *.swt.events and *.swt.custom are identical in Win32/Linux32 now 179 of 576 (~31%) files in *.swt.* folders are fully identical * Win32: snippets now have right subsystem, pretty icons and native system style controls * small fixes in snippets Snippet44 - it's not Snippet44 Snippet212 - functions work with different images and offsets arrays Win32: Snippet282 - crash on close if the button has an image Snippet293 - setGrayed is commented and others Win32: As a result, folowing snippets now works Snippet68 - color doesn't change Snippet163, 189, 211, 213, 217, 218, 222 - UTF-8 issues (see above) Snippet193 - no tabel headers
author Denis Shelomovskij <verylonglogin.reg@gmail.com>
date Sat, 09 Jul 2011 15:50:20 +0300
parents fb3aa8075988
children
comparison
equal deleted inserted replaced
119:d00e8db0a568 120:536e43f63c81
42 static const int CHUNK_IDAT = 2; 42 static const int CHUNK_IDAT = 2;
43 static const int CHUNK_IEND = 3; 43 static const int CHUNK_IEND = 3;
44 // Non-critical chunks. 44 // Non-critical chunks.
45 static const int CHUNK_tRNS = 5; 45 static const int CHUNK_tRNS = 5;
46 46
47 static /+const+/ byte[] TYPE_IHDR = cast(byte[])"IHDR";//{(byte) 'I', (byte) 'H', (byte) 'D', (byte) 'R'}; 47 static const byte[] TYPE_IHDR = cast(byte[])"IHDR";//{(byte) 'I', (byte) 'H', (byte) 'D', (byte) 'R'};
48 static /+const+/ byte[] TYPE_PLTE = cast(byte[])"PLTE";//{(byte) 'P', (byte) 'L', (byte) 'T', (byte) 'E'}; 48 static const byte[] TYPE_PLTE = cast(byte[])"PLTE";//{(byte) 'P', (byte) 'L', (byte) 'T', (byte) 'E'};
49 static /+const+/ byte[] TYPE_IDAT = cast(byte[])"IDAT";//{(byte) 'I', (byte) 'D', (byte) 'A', (byte) 'T'}; 49 static const byte[] TYPE_IDAT = cast(byte[])"IDAT";//{(byte) 'I', (byte) 'D', (byte) 'A', (byte) 'T'};
50 static /+const+/ byte[] TYPE_IEND = cast(byte[])"IEND";//{(byte) 'I', (byte) 'E', (byte) 'N', (byte) 'D'}; 50 static const byte[] TYPE_IEND = cast(byte[])"IEND";//{(byte) 'I', (byte) 'E', (byte) 'N', (byte) 'D'};
51 static /+const+/ byte[] TYPE_tRNS = cast(byte[])"tRNS";//{(byte) 't', (byte) 'R', (byte) 'N', (byte) 'S'}; 51 static const byte[] TYPE_tRNS = cast(byte[])"tRNS";//{(byte) 't', (byte) 'R', (byte) 'N', (byte) 'S'};
52 52
53 private static int[] _CRC_TABLE = null; 53 private static int[] _CRC_TABLE = null;
54 54 static int[] CRC_TABLE() {
55 static int[] CRC_TABLE () { 55 if (!_CRC_TABLE) static_this();
56 if (!_CRC_TABLE)
57 static_this;
58
59 return _CRC_TABLE; 56 return _CRC_TABLE;
60 } 57 }
61 58 //public static void static_this() {
62 private static void static_this () { 59 private static void static_this() {
63 _CRC_TABLE = new int[256]; 60 _CRC_TABLE = new int[256];
64 for (int i = 0; i < 256; i++) { 61 for (int i = 0; i < 256; i++) {
65 _CRC_TABLE[i] = i; 62 _CRC_TABLE[i] = i;
66 for (int j = 0; j < 8; j++) { 63 for (int j = 0; j < 8; j++) {
67 if ((_CRC_TABLE[i] & 0x1) is 0) { 64 if ((_CRC_TABLE[i] & 0x1) is 0) {
191 * The second byte is upper case if the chunk is publicly defined. 188 * The second byte is upper case if the chunk is publicly defined.
192 * The third byte must be upper case. 189 * The third byte must be upper case.
193 * The fourth byte is upper case if the chunk is unsafe to copy. 190 * The fourth byte is upper case if the chunk is unsafe to copy.
194 * Public chunk types are defined by the PNG Development Group. 191 * Public chunk types are defined by the PNG Development Group.
195 */ 192 */
196 void setType(byte[] value) { 193 void setType(in byte[] value) {
197 if (value.length !is TYPE_FIELD_LENGTH) { 194 if (value.length !is TYPE_FIELD_LENGTH) {
198 SWT.error (SWT.ERROR_INVALID_ARGUMENT); 195 SWT.error (SWT.ERROR_INVALID_ARGUMENT);
199 } 196 }
200 System.arraycopy(value, 0, reference, TYPE_OFFSET, TYPE_FIELD_LENGTH); 197 System.arraycopy(value, 0, reference, TYPE_OFFSET, TYPE_FIELD_LENGTH);
201 } 198 }
219 * 1. It will set the length field to be the length 216 * 1. It will set the length field to be the length
220 * of the data array given. 217 * of the data array given.
221 * 2. It will set the CRC field to the computed CRC 218 * 2. It will set the CRC field to the computed CRC
222 * value of the data array given. 219 * value of the data array given.
223 */ 220 */
224 void setData(byte[] data) { 221 void setData(in byte[] data) {
225 setLength(data.length); 222 setLength(data.length);
226 System.arraycopy(data, 0, reference, DATA_OFFSET, data.length); 223 System.arraycopy(data, 0, reference, DATA_OFFSET, data.length);
227 setCRC(computeCRC()); 224 setCRC(computeCRC());
228 } 225 }
229 226
277 crc = CRC_TABLE[index] ^ ((crc >> 8) & 0x00FFFFFF); 274 crc = CRC_TABLE[index] ^ ((crc >> 8) & 0x00FFFFFF);
278 } 275 }
279 return ~crc; 276 return ~crc;
280 } 277 }
281 278
282 bool typeMatchesArray(byte[] array) { 279 bool typeMatchesArray(in byte[] array) {
283 for (int i = 0; i < TYPE_FIELD_LENGTH; i++) { 280 for (int i = 0; i < TYPE_FIELD_LENGTH; i++) {
284 if (reference[TYPE_OFFSET + i] !is array[i]){ 281 if (reference[TYPE_OFFSET + i] !is array[i]){
285 return false; 282 return false;
286 } 283 }
287 } 284 }