| 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 "SkStreamPriv.h" | 15 #include "SkStreamPriv.h" |
| 16 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
| 17 | 17 |
| 18 class SkBMPImageDecoder : public SkImageDecoder { | 18 class SkBMPImageDecoder : public SkImageDecoder { |
| 19 public: | 19 public: |
| 20 SkBMPImageDecoder() {} | 20 SkBMPImageDecoder() {} |
| 21 | 21 |
| 22 Format getFormat() const SK_OVERRIDE { | 22 SkEncodedFormat getFormat() const SK_OVERRIDE { |
| 23 return kBMP_Format; | 23 return kBMP_SkEncodedFormat; |
| 24 } | 24 } |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 Result onDecode(SkStream* stream, SkBitmap* bm, Mode mode) SK_OVERRIDE; | 27 Result 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 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 12 matching lines...) Expand all Loading... |
| 46 | 46 |
| 47 static SkImageDecoder* sk_libbmp_dfactory(SkStreamRewindable* 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(SkStreamRewindable* stream) { | 56 static SkEncodedFormat get_format_bmp(SkStreamRewindable* stream) { |
| 57 if (is_bmp(stream)) { | 57 if (is_bmp(stream)) { |
| 58 return SkImageDecoder::kBMP_Format; | 58 return kBMP_SkEncodedFormat; |
| 59 } | 59 } |
| 60 return SkImageDecoder::kUnknown_Format; | 60 return kUnknown_SkEncodedFormat; |
| 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 |
| 67 class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback { | 67 class SkBmpDecoderCallback : public image_codec::BmpDecoderCallback { |
| 68 public: | 68 public: |
| 69 // we don't copy the bitmap, just remember the pointer | 69 // we don't copy the bitmap, just remember the pointer |
| 70 SkBmpDecoderCallback(bool justBounds) : fJustBounds(justBounds) {} | 70 SkBmpDecoderCallback(bool justBounds) : fJustBounds(justBounds) {} |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 const int dstHeight = sampler.scaledHeight(); | 153 const int dstHeight = sampler.scaledHeight(); |
| 154 const uint8_t* srcRow = callback.rgb(); | 154 const uint8_t* srcRow = callback.rgb(); |
| 155 | 155 |
| 156 srcRow += sampler.srcY0() * srcRowBytes; | 156 srcRow += sampler.srcY0() * srcRowBytes; |
| 157 for (int y = 0; y < dstHeight; y++) { | 157 for (int y = 0; y < dstHeight; y++) { |
| 158 sampler.next(srcRow); | 158 sampler.next(srcRow); |
| 159 srcRow += sampler.srcDY() * srcRowBytes; | 159 srcRow += sampler.srcDY() * srcRowBytes; |
| 160 } | 160 } |
| 161 return kSuccess; | 161 return kSuccess; |
| 162 } | 162 } |
| OLD | NEW |