OLD | NEW |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic)); | 45 !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic)); |
46 } | 46 } |
47 | 47 |
48 static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) { | 48 static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) { |
49 if (is_bmp(stream)) { | 49 if (is_bmp(stream)) { |
50 return SkNEW(SkBMPImageDecoder); | 50 return SkNEW(SkBMPImageDecoder); |
51 } | 51 } |
52 return NULL; | 52 return NULL; |
53 } | 53 } |
54 | 54 |
55 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libbmp_dfactory); | 55 static SkTRegistry<SkImageDecoder*(*)(SkStream*)> gReg(sk_libbmp_dfactory); |
56 | 56 |
57 static SkImageDecoder::Format get_format_bmp(SkStream* stream) { | 57 static SkImageDecoder::Format get_format_bmp(SkStream* stream) { |
58 if (is_bmp(stream)) { | 58 if (is_bmp(stream)) { |
59 return SkImageDecoder::kBMP_Format; | 59 return SkImageDecoder::kBMP_Format; |
60 } | 60 } |
61 return SkImageDecoder::kUnknown_Format; | 61 return SkImageDecoder::kUnknown_Format; |
62 } | 62 } |
63 | 63 |
64 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_bmp)
; | 64 static SkTRegistry<SkImageDecoder::Format(*)(SkStream*)> gFormatReg(get_format_b
mp); |
65 | 65 |
66 /////////////////////////////////////////////////////////////////////////////// | 66 /////////////////////////////////////////////////////////////////////////////// |
67 | 67 |
68 class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback { | 68 class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback { |
69 public: | 69 public: |
70 // we don't copy the bitmap, just remember the pointer | 70 // we don't copy the bitmap, just remember the pointer |
71 SkBmpDecoderCallback(bool justBounds) : fJustBounds(justBounds) {} | 71 SkBmpDecoderCallback(bool justBounds) : fJustBounds(justBounds) {} |
72 | 72 |
73 // override from BmpDecoderCallback | 73 // override from BmpDecoderCallback |
74 virtual uint8* SetSize(int width, int height) { | 74 virtual uint8* SetSize(int width, int height) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 const int dstHeight = sampler.scaledHeight(); | 155 const int dstHeight = sampler.scaledHeight(); |
156 const uint8_t* srcRow = callback.rgb(); | 156 const uint8_t* srcRow = callback.rgb(); |
157 | 157 |
158 srcRow += sampler.srcY0() * srcRowBytes; | 158 srcRow += sampler.srcY0() * srcRowBytes; |
159 for (int y = 0; y < dstHeight; y++) { | 159 for (int y = 0; y < dstHeight; y++) { |
160 sampler.next(srcRow); | 160 sampler.next(srcRow); |
161 srcRow += sampler.srcDY() * srcRowBytes; | 161 srcRow += sampler.srcDY() * srcRowBytes; |
162 } | 162 } |
163 return true; | 163 return true; |
164 } | 164 } |
OLD | NEW |