| 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 "SkEncodedFormat.h" | 12 #include "SkEncodedFormat.h" |
| 13 #include "SkStream.h" | 13 #include "SkStream.h" |
| 14 | 14 |
| 15 /* | 15 /* |
| 16 * This class aims to provide an interface to test multiple implementations of | 16 * This class aims to provide an interface to test multiple implementations of |
| 17 * SkBitmapRegionDecoder. | 17 * SkBitmapRegionDecoder. |
| 18 */ | 18 */ |
| 19 class SkBitmapRegionDecoderInterface { | 19 class SkBitmapRegionDecoder { |
| 20 public: | 20 public: |
| 21 | 21 |
| 22 enum Strategy { | 22 enum Strategy { |
| 23 kCanvas_Strategy, // Draw to the canvas, uses SkCodec | 23 kCanvas_Strategy, // Draw to the canvas, uses SkCodec |
| 24 kOriginal_Strategy, // Sampling, uses SkImageDecoder | 24 kOriginal_Strategy, // Sampling, uses SkImageDecoder |
| 25 kAndroidCodec_Strategy, // Uses SkAndroidCodec for scaling and subsettin
g | 25 kAndroidCodec_Strategy, // Uses SkAndroidCodec for scaling and subsettin
g |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 /* | 28 /* |
| 29 * @param data Refs the data while this object exists, unrefs on destruc
tion | 29 * @param data Refs the data while this object exists, unrefs on destruc
tion |
| 30 * @param strategy Strategy used for scaling and subsetting | 30 * @param strategy Strategy used for scaling and subsetting |
| 31 * @return Tries to create an SkBitmapRegionDecoder, returns NULL on
failure | 31 * @return Tries to create an SkBitmapRegionDecoder, returns NULL on
failure |
| 32 */ | 32 */ |
| 33 static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder( | 33 static SkBitmapRegionDecoder* Create( |
| 34 SkData* data, Strategy strategy); | 34 SkData* data, Strategy strategy); |
| 35 | 35 |
| 36 /* | 36 /* |
| 37 * @param stream Takes ownership of the stream | 37 * @param stream Takes ownership of the stream |
| 38 * @param strategy Strategy used for scaling and subsetting | 38 * @param strategy Strategy used for scaling and subsetting |
| 39 * @return Tries to create an SkBitmapRegionDecoder, returns NULL on
failure | 39 * @return Tries to create an SkBitmapRegionDecoder, returns NULL on
failure |
| 40 */ | 40 */ |
| 41 static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder( | 41 static SkBitmapRegionDecoder* Create( |
| 42 SkStreamRewindable* stream, Strategy strategy); | 42 SkStreamRewindable* stream, Strategy strategy); |
| 43 | 43 |
| 44 /* | 44 /* |
| 45 * Decode a scaled region of the encoded image stream | 45 * Decode a scaled region of the encoded image stream |
| 46 * | 46 * |
| 47 * @param bitmap Container for decoded pixels. It is assumed that
the pixels | 47 * @param bitmap Container for decoded pixels. It is assumed that
the pixels |
| 48 * are initially unallocated and will be allocated by
this function. | 48 * are initially unallocated and will be allocated by
this function. |
| 49 * @param allocator Allocator for the pixels. If this is NULL, the de
fault | 49 * @param allocator Allocator for the pixels. If this is NULL, the de
fault |
| 50 * allocator (HeapAllocator) will be used. | 50 * allocator (HeapAllocator) will be used. |
| 51 * @param desiredSubset Subset of the original image to decode. | 51 * @param desiredSubset Subset of the original image to decode. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 66 * @param Requested destination color type | 66 * @param Requested destination color type |
| 67 * @return true if we support the requested color type and false otherwise | 67 * @return true if we support the requested color type and false otherwise |
| 68 */ | 68 */ |
| 69 virtual bool conversionSupported(SkColorType colorType) = 0; | 69 virtual bool conversionSupported(SkColorType colorType) = 0; |
| 70 | 70 |
| 71 virtual SkEncodedFormat getEncodedFormat() = 0; | 71 virtual SkEncodedFormat getEncodedFormat() = 0; |
| 72 | 72 |
| 73 int width() const { return fWidth; } | 73 int width() const { return fWidth; } |
| 74 int height() const { return fHeight; } | 74 int height() const { return fHeight; } |
| 75 | 75 |
| 76 virtual ~SkBitmapRegionDecoderInterface() {} | 76 virtual ~SkBitmapRegionDecoder() {} |
| 77 | 77 |
| 78 protected: | 78 protected: |
| 79 | 79 |
| 80 SkBitmapRegionDecoderInterface(int width, int height) | 80 SkBitmapRegionDecoder(int width, int height) |
| 81 : fWidth(width) | 81 : fWidth(width) |
| 82 , fHeight(height) | 82 , fHeight(height) |
| 83 {} | 83 {} |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 const int fWidth; | 86 const int fWidth; |
| 87 const int fHeight; | 87 const int fHeight; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 #endif | 90 #endif |
| OLD | NEW |