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 #ifndef SkBitmapRegionDecoder_DEFINED | 8 #ifndef SkBitmapRegionDecoder_DEFINED |
9 #define SkBitmapRegionDecoder_DEFINED | 9 #define SkBitmapRegionDecoder_DEFINED |
10 | 10 |
11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 #include "SkStream.h" | 12 #include "SkStream.h" |
13 | 13 |
14 /* | 14 /* |
15 * This class aims to provide an interface to test multiple implementations of | 15 * This class aims to provide an interface to test multiple implementations of |
16 * SkBitmapRegionDecoder. | 16 * SkBitmapRegionDecoder. |
17 */ | 17 */ |
18 class SkBitmapRegionDecoderInterface { | 18 class SkBitmapRegionDecoderInterface { |
19 public: | 19 public: |
20 | 20 |
21 enum Strategy { | 21 enum Strategy { |
22 kCanvas_Strategy, // Draw to the canvas, uses SkCodec | 22 kCanvas_Strategy, // Draw to the canvas, uses SkCodec |
23 kOriginal_Strategy, // Sampling, uses SkImageDecoder | 23 kOriginal_Strategy, // Sampling, uses SkImageDecoder |
24 // TODO (msarett): Add strategy for SkScaledCodec | 24 kCodec_Strategy, // Uses SkScaledCodec for scaling and subsetting |
25 }; | 25 }; |
26 | 26 |
27 /* | 27 /* |
28 * @param stream Encoded image stream, takes ownership | 28 * @param stream Encoded image stream, takes ownership |
29 * @param strategy Strategy used for scaling and subsetting | 29 * @param strategy Strategy used for scaling and subsetting |
30 * @return Tries to create an SkBitmapRegionDecoder, returns NULL | 30 * @return Tries to create an SkBitmapRegionDecoder, returns NULL |
31 * on failure | 31 * on failure |
32 */ | 32 */ |
33 static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder( | 33 static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder( |
34 SkStreamRewindable* stream, Strategy strategy); | 34 SkStreamRewindable* stream, Strategy strategy); |
(...skipping 15 matching lines...) Expand all Loading... |
50 * decoding to this color type. | 50 * decoding to this color type. |
51 * The old kOriginal_Strategy will decode to a default col
or type | 51 * The old kOriginal_Strategy will decode to a default col
or type |
52 * if this color type is unsupported. | 52 * if this color type is unsupported. |
53 * @return Pointer to a bitmap of the decoded region on success, N
ULL on | 53 * @return Pointer to a bitmap of the decoded region on success, N
ULL on |
54 * failure. | 54 * failure. |
55 */ | 55 */ |
56 virtual SkBitmap* decodeRegion(int start_x, int start_y, int width, | 56 virtual SkBitmap* decodeRegion(int start_x, int start_y, int width, |
57 int height, int sampleSize, | 57 int height, int sampleSize, |
58 SkColorType colorType) = 0; | 58 SkColorType colorType) = 0; |
59 | 59 |
| 60 /* |
| 61 * @param Requested destination color type |
| 62 * @return true if we support the requested color type and false otherwise |
| 63 */ |
| 64 virtual bool conversionSupported(SkColorType colorType) = 0; |
| 65 |
60 int width() const { return fWidth; } | 66 int width() const { return fWidth; } |
61 int height() const { return fHeight; } | 67 int height() const { return fHeight; } |
62 | 68 |
63 virtual ~SkBitmapRegionDecoderInterface() {} | 69 virtual ~SkBitmapRegionDecoderInterface() {} |
64 | 70 |
65 protected: | 71 protected: |
66 | 72 |
67 SkBitmapRegionDecoderInterface(int width, int height) | 73 SkBitmapRegionDecoderInterface(int width, int height) |
68 : fWidth(width) | 74 : fWidth(width) |
69 , fHeight(height) | 75 , fHeight(height) |
70 {} | 76 {} |
71 | 77 |
72 private: | 78 private: |
73 const int fWidth; | 79 const int fWidth; |
74 const int fHeight; | 80 const int fHeight; |
75 }; | 81 }; |
76 | 82 |
77 #endif | 83 #endif |
OLD | NEW |