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" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkImageDecoder.h" | 12 #include "SkImageDecoder.h" |
13 #include "SkScaledBitmapSampler.h" | 13 #include "SkScaledBitmapSampler.h" |
14 #include "SkStream.h" | 14 #include "SkStream.h" |
15 #include "SkStreamHelpers.h" | 15 #include "SkStreamHelpers.h" |
16 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
17 #include "SkTRegistry.h" | |
18 | 17 |
19 class SkBMPImageDecoder : public SkImageDecoder { | 18 class SkBMPImageDecoder : public SkImageDecoder { |
20 public: | 19 public: |
21 SkBMPImageDecoder() {} | 20 SkBMPImageDecoder() {} |
22 | 21 |
23 virtual Format getFormat() const SK_OVERRIDE { | 22 virtual Format getFormat() const SK_OVERRIDE { |
24 return kBMP_Format; | 23 return kBMP_Format; |
25 } | 24 } |
26 | 25 |
27 protected: | 26 protected: |
(...skipping 17 matching lines...) Expand all Loading... |
45 !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic)); | 44 !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic)); |
46 } | 45 } |
47 | 46 |
48 static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) { | 47 static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) { |
49 if (is_bmp(stream)) { | 48 if (is_bmp(stream)) { |
50 return SkNEW(SkBMPImageDecoder); | 49 return SkNEW(SkBMPImageDecoder); |
51 } | 50 } |
52 return NULL; | 51 return NULL; |
53 } | 52 } |
54 | 53 |
55 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libbmp_dfactory); | 54 static SkImageDecoder_DecodeReg gReg(sk_libbmp_dfactory); |
56 | 55 |
57 static SkImageDecoder::Format get_format_bmp(SkStream* stream) { | 56 static SkImageDecoder::Format get_format_bmp(SkStream* stream) { |
58 if (is_bmp(stream)) { | 57 if (is_bmp(stream)) { |
59 return SkImageDecoder::kBMP_Format; | 58 return SkImageDecoder::kBMP_Format; |
60 } | 59 } |
61 return SkImageDecoder::kUnknown_Format; | 60 return SkImageDecoder::kUnknown_Format; |
62 } | 61 } |
63 | 62 |
64 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_bmp)
; | 63 static SkImageDecoder_FormatReg gFormatReg(get_format_bmp); |
65 | 64 |
66 /////////////////////////////////////////////////////////////////////////////// | 65 /////////////////////////////////////////////////////////////////////////////// |
67 | 66 |
68 class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback { | 67 class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback { |
69 public: | 68 public: |
70 // we don't copy the bitmap, just remember the pointer | 69 // we don't copy the bitmap, just remember the pointer |
71 SkBmpDecoderCallback(bool justBounds) : fJustBounds(justBounds) {} | 70 SkBmpDecoderCallback(bool justBounds) : fJustBounds(justBounds) {} |
72 | 71 |
73 // override from BmpDecoderCallback | 72 // override from BmpDecoderCallback |
74 virtual uint8* SetSize(int width, int height) { | 73 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(); | 154 const int dstHeight = sampler.scaledHeight(); |
156 const uint8_t* srcRow = callback.rgb(); | 155 const uint8_t* srcRow = callback.rgb(); |
157 | 156 |
158 srcRow += sampler.srcY0() * srcRowBytes; | 157 srcRow += sampler.srcY0() * srcRowBytes; |
159 for (int y = 0; y < dstHeight; y++) { | 158 for (int y = 0; y < dstHeight; y++) { |
160 sampler.next(srcRow); | 159 sampler.next(srcRow); |
161 srcRow += sampler.srcDY() * srcRowBytes; | 160 srcRow += sampler.srcDY() * srcRowBytes; |
162 } | 161 } |
163 return true; | 162 return true; |
164 } | 163 } |
OLD | NEW |