OLD | NEW |
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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkBitmapRegionDecoderInterface.h" | 9 #include "SkBitmapRegionDecoderInterface.h" |
10 #include "SkImageDecoder.h" | 10 #include "SkCodec.h" |
11 #include "SkTemplates.h" | |
12 | 11 |
13 /* | 12 /* |
14 * This class aims to duplicate the current implementation of | 13 * This class implements SkBitmapRegionDecoder using an SkScaledCodec. |
15 * SkBitmapRegionDecoder in Android. | |
16 */ | 14 */ |
17 class SkBitmapRegionSampler : public SkBitmapRegionDecoderInterface { | 15 class SkBitmapRegionCodec : public SkBitmapRegionDecoderInterface { |
18 public: | 16 public: |
19 | 17 |
20 /* | 18 /* |
21 * Takes ownership of pointer to decoder | 19 * Takes ownership of pointer to codec |
22 */ | 20 */ |
23 SkBitmapRegionSampler(SkImageDecoder* decoder, int width, int height); | 21 SkBitmapRegionCodec(SkCodec* codec); |
24 | 22 |
25 /* | 23 /* |
26 * Three differences from the Android version: | 24 * Three key differences from the Android version: |
27 * Returns a Skia bitmap instead of an Android bitmap. | 25 * Returns a Skia bitmap instead of an Android bitmap. |
28 * Android version attempts to reuse a recycled bitmap. | 26 * Android version attempts to reuse a recycled bitmap. |
29 * Removed the options object and used parameters for color type and | 27 * Removed the options object and used parameters for color type and |
30 * sample size. | 28 * sample size. |
31 */ | 29 */ |
32 SkBitmap* decodeRegion(int start_x, int start_y, int width, int height, | 30 SkBitmap* decodeRegion(int start_x, int start_y, int width, int height, |
33 int sampleSize, SkColorType prefColorType) override; | 31 int sampleSize, SkColorType prefColorType) override; |
34 | 32 |
| 33 bool conversionSupported(SkColorType colorType) override; |
| 34 |
35 private: | 35 private: |
36 | 36 |
37 SkAutoTDelete<SkImageDecoder> fDecoder; | 37 SkAutoTDelete<SkCodec> fCodec; |
38 | 38 |
39 typedef SkBitmapRegionDecoderInterface INHERITED; | 39 typedef SkBitmapRegionDecoderInterface INHERITED; |
40 | 40 |
41 }; | 41 }; |
OLD | NEW |