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

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: minor fixes 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
« no previous file with comments | « src/images/SkImageDecoder_libgif.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SK_OVERRIDE {
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) SK_OVERRIDE;
25
26 private:
27 typedef SkImageDecoder INHERITED;
25 }; 28 };
26 29
27 #if 0 // UNUSED
28 SkImageDecoder* SkCreateICOImageDecoder() {
29 return new SkICOImageDecoder;
30 }
31 #endif
32
33 //////////////////////////////////////////////////////////////////////////////// ///////// 30 //////////////////////////////////////////////////////////////////////////////// /////////
34 31
35 //read bytes starting from the begin-th index in the buffer 32 //read bytes starting from the begin-th index in the buffer
36 //read in Intel order, and return an integer 33 //read in Intel order, and return an integer
37 34
38 #define readByte(buffer,begin) buffer[begin] 35 #define readByte(buffer,begin) buffer[begin]
39 #define read2Bytes(buffer,begin) buffer[begin]+(buffer[begin+1]<<8) 36 #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) 37 #define read4Bytes(buffer,begin) buffer[begin]+(buffer[begin+1]<<8)+(buffer[begi n+2]<<16)+(buffer[begin+3]<<24)
41 38
42 //////////////////////////////////////////////////////////////////////////////// ///////// 39 //////////////////////////////////////////////////////////////////////////////// /////////
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 225
229 /*int */test = w & 0x1F; //the low 5 bits - we are rounding up to the next 32 (2^5) 226 /*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 227 /*int */mask = -(((test >> 4) | (test >> 3) | (test >> 2) | (test >> 1) | te st) & 0x1); //either 0xFFFFFFFF or 0
231 int andLineWidth = (w & 0xFFFFFFE0) + (0x20 & mask); 228 int andLineWidth = (w & 0xFFFFFFE0) + (0x20 & mask);
232 //if we allow different Configs, everything is the same til here 229 //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 230 //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? 231 //FIXME: what is the tradeoff in size?
235 //if the andbitmap (mask) is all zeroes, then we can easily do an index bitm ap 232 //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 233 //however, with small images with large colortables, maybe it's better to st ill do argb_8888
237 234
238 bm->setConfig(SkBitmap::kARGB_8888_Config, w, h, calculateRowBytesFor8888(w, bitCount));
239
240 if (SkImageDecoder::kDecodeBounds_Mode == mode) { 235 if (SkImageDecoder::kDecodeBounds_Mode == mode) {
236 bm->setConfig(SkBitmap::kARGB_8888_Config, w, h, calculateRowBytesFor888 8(w, bitCount));
241 delete[] colors; 237 delete[] colors;
242 return true; 238 return true;
243 } 239 }
240 // No Bitmap reuse supported for this format
241 if (!bm->isNull()) {
242 return false;
243 }
244 bm->setConfig(SkBitmap::kARGB_8888_Config, w, h, calculateRowBytesFor8888(w, bitCount));
244 245
245 if (!this->allocPixelRef(bm, NULL)) 246 if (!this->allocPixelRef(bm, NULL))
246 { 247 {
247 delete[] colors; 248 delete[] colors;
248 return false; 249 return false;
249 } 250 }
250 251
251 SkAutoLockPixels alp(*bm); 252 SkAutoLockPixels alp(*bm);
252 253
253 for (int y = 0; y < h; y++) 254 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); 384 int reserved = read2Bytes(buf, 0);
384 int type = read2Bytes(buf, 2); 385 int type = read2Bytes(buf, 2);
385 if (reserved != 0 || type != 1) { 386 if (reserved != 0 || type != 1) {
386 // This stream does not represent an ICO image. 387 // This stream does not represent an ICO image.
387 return NULL; 388 return NULL;
388 } 389 }
389 return SkNEW(SkICOImageDecoder); 390 return SkNEW(SkICOImageDecoder);
390 } 391 }
391 392
392 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libico_dfactory); 393 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libico_dfactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libgif.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698