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

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

Issue 23477009: Change SkImageDecoders to take an SkStreamRewindable. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Only switch to SkStreamRewindable when necessary. Created 7 years, 2 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_FactoryRegistrar.cpp ('k') | src/images/SkImageDecoder_libgif.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 2007 The Android Open Source Project 3 * Copyright 2007 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 "bmpdecoderhelper.h" 10 #include "bmpdecoderhelper.h"
(...skipping 16 matching lines...) Expand all
27 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode mode) SK_OVERRIDE ; 27 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode mode) SK_OVERRIDE ;
28 28
29 private: 29 private:
30 typedef SkImageDecoder INHERITED; 30 typedef SkImageDecoder INHERITED;
31 }; 31 };
32 32
33 /////////////////////////////////////////////////////////////////////////////// 33 ///////////////////////////////////////////////////////////////////////////////
34 DEFINE_DECODER_CREATOR(BMPImageDecoder); 34 DEFINE_DECODER_CREATOR(BMPImageDecoder);
35 /////////////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////////////
36 36
37 static bool is_bmp(SkStream* stream) { 37 static bool is_bmp(SkStreamRewindable* stream) {
38 static const char kBmpMagic[] = { 'B', 'M' }; 38 static const char kBmpMagic[] = { 'B', 'M' };
39 39
40 40
41 char buffer[sizeof(kBmpMagic)]; 41 char buffer[sizeof(kBmpMagic)];
42 42
43 return stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) && 43 return stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) &&
44 !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic)); 44 !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic));
45 } 45 }
46 46
47 static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) { 47 static SkImageDecoder* sk_libbmp_dfactory(SkStreamRewindable* stream) {
48 if (is_bmp(stream)) { 48 if (is_bmp(stream)) {
49 return SkNEW(SkBMPImageDecoder); 49 return SkNEW(SkBMPImageDecoder);
50 } 50 }
51 return NULL; 51 return NULL;
52 } 52 }
53 53
54 static SkImageDecoder_DecodeReg gReg(sk_libbmp_dfactory); 54 static SkImageDecoder_DecodeReg gReg(sk_libbmp_dfactory);
55 55
56 static SkImageDecoder::Format get_format_bmp(SkStream* stream) { 56 static SkImageDecoder::Format get_format_bmp(SkStreamRewindable* stream) {
57 if (is_bmp(stream)) { 57 if (is_bmp(stream)) {
58 return SkImageDecoder::kBMP_Format; 58 return SkImageDecoder::kBMP_Format;
59 } 59 }
60 return SkImageDecoder::kUnknown_Format; 60 return SkImageDecoder::kUnknown_Format;
61 } 61 }
62 62
63 static SkImageDecoder_FormatReg gFormatReg(get_format_bmp); 63 static SkImageDecoder_FormatReg gFormatReg(get_format_bmp);
64 64
65 /////////////////////////////////////////////////////////////////////////////// 65 ///////////////////////////////////////////////////////////////////////////////
66 66
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 const int dstHeight = sampler.scaledHeight(); 154 const int dstHeight = sampler.scaledHeight();
155 const uint8_t* srcRow = callback.rgb(); 155 const uint8_t* srcRow = callback.rgb();
156 156
157 srcRow += sampler.srcY0() * srcRowBytes; 157 srcRow += sampler.srcY0() * srcRowBytes;
158 for (int y = 0; y < dstHeight; y++) { 158 for (int y = 0; y < dstHeight; y++) {
159 sampler.next(srcRow); 159 sampler.next(srcRow);
160 srcRow += sampler.srcDY() * srcRowBytes; 160 srcRow += sampler.srcDY() * srcRowBytes;
161 } 161 }
162 return true; 162 return true;
163 } 163 }
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_FactoryRegistrar.cpp ('k') | src/images/SkImageDecoder_libgif.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698