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

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

Issue 670453002: Remove image decoder and encoder autoregistration (Closed) Base URL: https://skia.googlesource.com/skia.git@separate-image-decoder-01-skpicture
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « src/images/SkImageDecoder_libico.h ('k') | src/images/SkImageDecoder_libjpeg.h » ('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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkImageDecoder_libico.h"
8 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
9 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
10 #include "SkStream.h" 11 #include "SkStream.h"
11 #include "SkStreamPriv.h" 12 #include "SkStreamPriv.h"
12 #include "SkTypes.h" 13 #include "SkTypes.h"
13 14
14 class SkICOImageDecoder : public SkImageDecoder { 15 class SkICOImageDecoder : public SkImageDecoder {
15 public: 16 public:
16 SkICOImageDecoder(); 17 SkICOImageDecoder();
17 18
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 int green = readByte(buf, xorOffset + 4*pixelNo + 1); 392 int green = readByte(buf, xorOffset + 4*pixelNo + 1);
392 int red = readByte(buf, xorOffset + 4*pixelNo + 2); 393 int red = readByte(buf, xorOffset + 4*pixelNo + 2);
393 int alphaBit = (alphaByte & m) >> shift; 394 int alphaBit = (alphaByte & m) >> shift;
394 #if 1 // don't trust the alphaBit for 32bit images <mrr> 395 #if 1 // don't trust the alphaBit for 32bit images <mrr>
395 alphaBit = 0; 396 alphaBit = 0;
396 #endif 397 #endif
397 int alpha = readByte(buf, xorOffset + 4*pixelNo + 3) & ((alphaBit-1)&0xFF); 398 int alpha = readByte(buf, xorOffset + 4*pixelNo + 3) & ((alphaBit-1)&0xFF);
398 *address = SkPreMultiplyARGB(alpha, red, green, blue); 399 *address = SkPreMultiplyARGB(alpha, red, green, blue);
399 } 400 }
400 401
401 /////////////////////////////////////////////////////////////////////////////// 402 SkImageDecoder::Format SkDetectFormatICOImageDecoder(SkStreamRewindable* stream) {
402 DEFINE_DECODER_CREATOR(ICOImageDecoder);
403 //////////////////////////////////////////////////////////////////////////////// /////////
404
405 static bool is_ico(SkStreamRewindable* stream) {
406 // Check to see if the first four bytes are 0,0,1,0 403 // Check to see if the first four bytes are 0,0,1,0
407 // FIXME: Is that required and sufficient? 404 // FIXME: Is that required and sufficient?
408 char buf[4]; 405 char buf[4];
409 if (stream->read((void*)buf, 4) != 4) { 406 if (stream->read((void*)buf, 4) != 4) {
410 return false; 407 return SkImageDecoder::kUnknown_Format;
411 } 408 }
412 int reserved = read2Bytes(buf, 0); 409 int reserved = read2Bytes(buf, 0);
413 int type = read2Bytes(buf, 2); 410 int type = read2Bytes(buf, 2);
414 return 0 == reserved && 1 == type; 411 if (0 != reserved || 1 != type) {
412 return SkImageDecoder::kUnknown_Format;
413 }
414 return SkImageDecoder::kICO_Format;
415 } 415 }
416 416
417 static SkImageDecoder* sk_libico_dfactory(SkStreamRewindable* stream) { 417 SkImageDecoder* SkCreateICOImageDecoder(SkImageDecoder::Format format) {
418 if (is_ico(stream)) { 418 SkASSERT(SkImageDecoder::kICO_Format == format);
419 return SkNEW(SkICOImageDecoder); 419 return SkNEW(SkICOImageDecoder);
420 }
421 return NULL;
422 } 420 }
423 421
424 static SkImageDecoder_DecodeReg gReg(sk_libico_dfactory);
425
426 static SkImageDecoder::Format get_format_ico(SkStreamRewindable* stream) {
427 if (is_ico(stream)) {
428 return SkImageDecoder::kICO_Format;
429 }
430 return SkImageDecoder::kUnknown_Format;
431 }
432
433 static SkImageDecoder_FormatReg gFormatReg(get_format_ico);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libico.h ('k') | src/images/SkImageDecoder_libjpeg.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698