Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: tools/SkBitmapRegionDecoderInterface.h

Issue 1425833002: Add NewFromStream and getEncodedFormat to BitmapRegionDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@brd-design
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/SkBitmapRegionCodec.h ('k') | tools/SkBitmapRegionDecoderInterface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkStream.h" 13 #include "SkStream.h"
13 14
14 /* 15 /*
15 * 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
16 * SkBitmapRegionDecoder. 17 * SkBitmapRegionDecoder.
17 */ 18 */
18 class SkBitmapRegionDecoderInterface { 19 class SkBitmapRegionDecoderInterface {
19 public: 20 public:
20 21
21 enum Strategy { 22 enum Strategy {
22 kCanvas_Strategy, // Draw to the canvas, uses SkCodec 23 kCanvas_Strategy, // Draw to the canvas, uses SkCodec
23 kOriginal_Strategy, // Sampling, uses SkImageDecoder 24 kOriginal_Strategy, // Sampling, uses SkImageDecoder
24 kAndroidCodec_Strategy, // Uses SkAndroidCodec for scaling and subsettin g 25 kAndroidCodec_Strategy, // Uses SkAndroidCodec for scaling and subsettin g
25 }; 26 };
26 27
27 /* 28 /*
28 * @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
29 * @param strategy Strategy used for scaling and subsetting 30 * @param strategy Strategy used for scaling and subsetting
30 * @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure 31 * @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
31 */ 32 */
32 static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder( 33 static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder(
33 SkData* data, Strategy strategy); 34 SkData* data, Strategy strategy);
34 35
35 /* 36 /*
37 * @param stream Takes ownership of the stream
38 * @param strategy Strategy used for scaling and subsetting
39 * @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
40 */
41 static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder(
42 SkStreamRewindable* stream, Strategy strategy);
43
44 /*
36 * Decode a scaled region of the encoded image stream 45 * Decode a scaled region of the encoded image stream
37 * 46 *
38 * @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
39 * are initially unallocated and will be allocated by this function. 48 * are initially unallocated and will be allocated by this function.
40 * @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
41 * allocator (HeapAllocator) will be used. 50 * allocator (HeapAllocator) will be used.
42 * @param desiredSubset Subset of the original image to decode. 51 * @param desiredSubset Subset of the original image to decode.
43 * @param sampleSize An integer downscaling factor for the decode. 52 * @param sampleSize An integer downscaling factor for the decode.
44 * @param colorType Preferred output colorType. 53 * @param colorType Preferred output colorType.
45 * New implementations should return NULL if they do not support 54 * New implementations should return NULL if they do not support
46 * decoding to this color type. 55 * decoding to this color type.
47 * The old kOriginal_Strategy will decode to a defaul t color type 56 * The old kOriginal_Strategy will decode to a defaul t color type
48 * if this color type is unsupported. 57 * if this color type is unsupported.
49 * @param requireUnpremul If the image is not opaque, we will use this to de termine the 58 * @param requireUnpremul If the image is not opaque, we will use this to de termine the
50 * alpha type to use. 59 * alpha type to use.
51 * 60 *
52 */ 61 */
53 virtual bool decodeRegion(SkBitmap* bitmap, SkBitmap::Allocator* allocator, 62 virtual bool decodeRegion(SkBitmap* bitmap, SkBitmap::Allocator* allocator,
54 const SkIRect& desiredSubset, int sampleSize, 63 const SkIRect& desiredSubset, int sampleSize,
55 SkColorType colorType, bool requireUnpremul) = 0; 64 SkColorType colorType, bool requireUnpremul) = 0;
56 /* 65 /*
57 * @param Requested destination color type 66 * @param Requested destination color type
58 * @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
59 */ 68 */
60 virtual bool conversionSupported(SkColorType colorType) = 0; 69 virtual bool conversionSupported(SkColorType colorType) = 0;
61 70
71 virtual SkEncodedFormat getEncodedFormat() = 0;
72
62 int width() const { return fWidth; } 73 int width() const { return fWidth; }
63 int height() const { return fHeight; } 74 int height() const { return fHeight; }
64 75
65 virtual ~SkBitmapRegionDecoderInterface() {} 76 virtual ~SkBitmapRegionDecoderInterface() {}
66 77
67 protected: 78 protected:
68 79
69 SkBitmapRegionDecoderInterface(int width, int height) 80 SkBitmapRegionDecoderInterface(int width, int height)
70 : fWidth(width) 81 : fWidth(width)
71 , fHeight(height) 82 , fHeight(height)
72 {} 83 {}
73 84
74 private: 85 private:
75 const int fWidth; 86 const int fWidth;
76 const int fHeight; 87 const int fHeight;
77 }; 88 };
78 89
79 #endif 90 #endif
OLDNEW
« no previous file with comments | « tools/SkBitmapRegionCodec.h ('k') | tools/SkBitmapRegionDecoderInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698