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

Side by Side Diff: src/codec/SkCodec.cpp

Issue 1006583005: SkCodec: add wbmp class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-03-27 (Friday) 10:53:14 EDT Created 5 years, 8 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
« no previous file with comments | « resources/mandrill.wbmp ('k') | src/codec/SkCodec_libbmp.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 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
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 "SkCodec.h" 8 #include "SkCodec.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkCodec_libbmp.h" 10 #include "SkCodec_libbmp.h"
11 #include "SkCodec_libico.h" 11 #include "SkCodec_libico.h"
12 #include "SkCodec_libpng.h" 12 #include "SkCodec_libpng.h"
13 #include "SkCodec_wbmp.h"
13 #include "SkStream.h" 14 #include "SkStream.h"
14 15
15 struct DecoderProc { 16 struct DecoderProc {
16 bool (*IsFormat)(SkStream*); 17 bool (*IsFormat)(SkStream*);
17 SkCodec* (*NewFromStream)(SkStream*); 18 SkCodec* (*NewFromStream)(SkStream*);
18 }; 19 };
19 20
20 static const DecoderProc gDecoderProcs[] = { 21 static const DecoderProc gDecoderProcs[] = {
21 { SkPngCodec::IsPng, SkPngCodec::NewFromStream }, 22 { SkPngCodec::IsPng, SkPngCodec::NewFromStream },
22 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, 23 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream },
23 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream } 24 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream },
25 { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream }
24 }; 26 };
25 27
26 SkCodec* SkCodec::NewFromStream(SkStream* stream) { 28 SkCodec* SkCodec::NewFromStream(SkStream* stream) {
27 if (!stream) { 29 if (!stream) {
28 return NULL; 30 return NULL;
29 } 31 }
30 for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) { 32 for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) {
31 DecoderProc proc = gDecoderProcs[i]; 33 DecoderProc proc = gDecoderProcs[i];
32 const bool correctFormat = proc.IsFormat(stream); 34 const bool correctFormat = proc.IsFormat(stream);
33 if (!stream->rewind()) { 35 if (!stream->rewind()) {
(...skipping 15 matching lines...) Expand all
49 51
50 SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream) 52 SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream)
51 : INHERITED(info) 53 : INHERITED(info)
52 #ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO 54 #ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO
53 , fInfo(info) 55 , fInfo(info)
54 #endif 56 #endif
55 , fStream(stream) 57 , fStream(stream)
56 , fNeedsRewind(false) 58 , fNeedsRewind(false)
57 {} 59 {}
58 60
59 bool SkCodec::rewindIfNeeded() { 61 SkCodec::RewindState SkCodec::rewindIfNeeded() {
60 // Store the value of fNeedsRewind so we can update it. Next read will 62 // Store the value of fNeedsRewind so we can update it. Next read will
61 // require a rewind. 63 // require a rewind.
62 const bool neededRewind = fNeedsRewind; 64 const bool needsRewind = fNeedsRewind;
63 fNeedsRewind = true; 65 fNeedsRewind = true;
64 return !neededRewind || fStream->rewind(); 66 if (!needsRewind) {
67 return kNoRewindNecessary_RewindState;
68 }
69 return fStream->rewind() ? kRewound_RewindState
70 : kCouldNotRewind_RewindState;
65 } 71 }
66 72
67 SkScanlineDecoder* SkCodec::getScanlineDecoder(const SkImageInfo& dstInfo) { 73 SkScanlineDecoder* SkCodec::getScanlineDecoder(const SkImageInfo& dstInfo) {
68 fScanlineDecoder.reset(NULL); 74 fScanlineDecoder.reset(NULL);
69 if (!rewindIfNeeded()) { 75 if (!rewindIfNeeded()) {
70 return NULL; 76 return NULL;
71 } 77 }
72 fScanlineDecoder.reset(this->onGetScanlineDecoder(dstInfo)); 78 fScanlineDecoder.reset(this->onGetScanlineDecoder(dstInfo));
73 return fScanlineDecoder.get(); 79 return fScanlineDecoder.get();
74 } 80 }
OLDNEW
« no previous file with comments | « resources/mandrill.wbmp ('k') | src/codec/SkCodec_libbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698