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 kAndroidCodec_Strategy, // Uses SkAndroidCodec for scaling and subsettin
g |
25 }; | 25 }; |
26 | 26 |
27 /* | 27 /* |
28 * @param stream Encoded image stream, takes ownership | 28 * @param data Refs the data while this object exists, unrefs on destruc
tion |
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 on
failure |
31 * on failure | |
32 */ | 31 */ |
33 static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder( | 32 static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder( |
34 SkStreamRewindable* stream, Strategy strategy); | 33 SkData* data, Strategy strategy); |
35 | 34 |
36 /* | 35 /* |
37 * Decode a scaled region of the encoded image stream | 36 * Decode a scaled region of the encoded image stream |
38 * | 37 * |
39 * @param start_x X-coordinate of upper-left corner of region. | 38 * @param start_x X-coordinate of upper-left corner of region. |
40 * This coordinate is unscaled, relative to the original d
imensions. | 39 * This coordinate is unscaled, relative to the original d
imensions. |
41 * @param start_y Y-coordinate of upper-left corner of region. | 40 * @param start_y Y-coordinate of upper-left corner of region. |
42 * This coordinate is unscaled, relative to the original d
imensions. | 41 * This coordinate is unscaled, relative to the original d
imensions. |
43 * @param width Width of the region to decode. | 42 * @param width Width of the region to decode. |
44 * This distance is unscaled, relative to the original dim
ensions. | 43 * This distance is unscaled, relative to the original dim
ensions. |
(...skipping 28 matching lines...) Expand all Loading... |
73 : fWidth(width) | 72 : fWidth(width) |
74 , fHeight(height) | 73 , fHeight(height) |
75 {} | 74 {} |
76 | 75 |
77 private: | 76 private: |
78 const int fWidth; | 77 const int fWidth; |
79 const int fHeight; | 78 const int fHeight; |
80 }; | 79 }; |
81 | 80 |
82 #endif | 81 #endif |
OLD | NEW |