Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: src/images/SkImageDecoder_libico.cpp

Issue 12604006: Upstream Android modifications to the image encoders/decoders. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
11 #include "SkStream.h" 11 #include "SkStream.h"
12 #include "SkColorPriv.h" 12 #include "SkColorPriv.h"
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 14
15 class SkICOImageDecoder : public SkImageDecoder { 15 class SkICOImageDecoder : public SkImageDecoder {
16 public: 16 public:
17 SkICOImageDecoder(); 17 SkICOImageDecoder();
18 18
19 virtual Format getFormat() const { 19 virtual Format getFormat() const {
20 return kICO_Format; 20 return kICO_Format;
21 } 21 }
22 22
23 protected: 23 protected:
24 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode); 24 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode);
25 }; 25 };
26 26
27 #if 0 // UNUSED
28 SkImageDecoder* SkCreateICOImageDecoder() {
29 return new SkICOImageDecoder;
30 }
31 #endif
32
33 //////////////////////////////////////////////////////////////////////////////// ///////// 27 //////////////////////////////////////////////////////////////////////////////// /////////
34 28
35 //read bytes starting from the begin-th index in the buffer 29 //read bytes starting from the begin-th index in the buffer
36 //read in Intel order, and return an integer 30 //read in Intel order, and return an integer
37 31
38 #define readByte(buffer,begin) buffer[begin] 32 #define readByte(buffer,begin) buffer[begin]
39 #define read2Bytes(buffer,begin) buffer[begin]+(buffer[begin+1]<<8) 33 #define read2Bytes(buffer,begin) buffer[begin]+(buffer[begin+1]<<8)
40 #define read4Bytes(buffer,begin) buffer[begin]+(buffer[begin+1]<<8)+(buffer[begi n+2]<<16)+(buffer[begin+3]<<24) 34 #define read4Bytes(buffer,begin) buffer[begin]+(buffer[begin+1]<<8)+(buffer[begi n+2]<<16)+(buffer[begin+3]<<24)
41 35
42 //////////////////////////////////////////////////////////////////////////////// ///////// 36 //////////////////////////////////////////////////////////////////////////////// /////////
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 222
229 /*int */test = w & 0x1F; //the low 5 bits - we are rounding up to the next 32 (2^5) 223 /*int */test = w & 0x1F; //the low 5 bits - we are rounding up to the next 32 (2^5)
230 /*int */mask = -(((test >> 4) | (test >> 3) | (test >> 2) | (test >> 1) | te st) & 0x1); //either 0xFFFFFFFF or 0 224 /*int */mask = -(((test >> 4) | (test >> 3) | (test >> 2) | (test >> 1) | te st) & 0x1); //either 0xFFFFFFFF or 0
231 int andLineWidth = (w & 0xFFFFFFE0) + (0x20 & mask); 225 int andLineWidth = (w & 0xFFFFFFE0) + (0x20 & mask);
232 //if we allow different Configs, everything is the same til here 226 //if we allow different Configs, everything is the same til here
233 //change the config, and use different address getter, and place index vs co lor, and add the color table 227 //change the config, and use different address getter, and place index vs co lor, and add the color table
234 //FIXME: what is the tradeoff in size? 228 //FIXME: what is the tradeoff in size?
235 //if the andbitmap (mask) is all zeroes, then we can easily do an index bitm ap 229 //if the andbitmap (mask) is all zeroes, then we can easily do an index bitm ap
236 //however, with small images with large colortables, maybe it's better to st ill do argb_8888 230 //however, with small images with large colortables, maybe it's better to st ill do argb_8888
237 231
238 bm->setConfig(SkBitmap::kARGB_8888_Config, w, h, calculateRowBytesFor8888(w, bitCount));
239
240 if (SkImageDecoder::kDecodeBounds_Mode == mode) { 232 if (SkImageDecoder::kDecodeBounds_Mode == mode) {
233 bm->setConfig(SkBitmap::kARGB_8888_Config, w, h, calculateRowBytesFor888 8(w, bitCount));
241 delete[] colors; 234 delete[] colors;
242 return true; 235 return true;
243 } 236 }
237 // No Bitmap reuse supported for this format
238 if (!bm->isNull()) {
239 return false;
240 }
robertphillips 2013/03/11 18:25:55 Is this expensive enough to make duplicating the c
djsollen 2013/03/11 19:43:24 I supposed this was to work around some android bu
241 bm->setConfig(SkBitmap::kARGB_8888_Config, w, h, calculateRowBytesFor8888(w, bitCount));
244 242
245 if (!this->allocPixelRef(bm, NULL)) 243 if (!this->allocPixelRef(bm, NULL))
246 { 244 {
247 delete[] colors; 245 delete[] colors;
248 return false; 246 return false;
249 } 247 }
250 248
251 SkAutoLockPixels alp(*bm); 249 SkAutoLockPixels alp(*bm);
252 250
253 for (int y = 0; y < h; y++) 251 for (int y = 0; y < h; y++)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 int reserved = read2Bytes(buf, 0); 381 int reserved = read2Bytes(buf, 0);
384 int type = read2Bytes(buf, 2); 382 int type = read2Bytes(buf, 2);
385 if (reserved != 0 || type != 1) { 383 if (reserved != 0 || type != 1) {
386 // This stream does not represent an ICO image. 384 // This stream does not represent an ICO image.
387 return NULL; 385 return NULL;
388 } 386 }
389 return SkNEW(SkICOImageDecoder); 387 return SkNEW(SkICOImageDecoder);
390 } 388 }
391 389
392 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libico_dfactory); 390 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libico_dfactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698