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

Side by Side Diff: tools/android/SkBitmapRegionDecoder.h

Issue 1438873002: Move SkBitmapRegionDecoder to include/android and src/android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase (header guards) 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/android/SkBitmapRegionCodec.cpp ('k') | tools/android/SkBitmapRegionDecoder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkBitmapRegionDecoder_DEFINED
9 #define SkBitmapRegionDecoder_DEFINED
10
11 #include "SkBitmap.h"
12 #include "SkBRDAllocator.h"
13 #include "SkEncodedFormat.h"
14 #include "SkStream.h"
15
16 /*
17 * This class aims to provide an interface to test multiple implementations of
18 * SkBitmapRegionDecoder.
19 */
20 class SkBitmapRegionDecoder {
21 public:
22
23 enum Strategy {
24 kCanvas_Strategy, // Draw to the canvas, uses SkCodec
25 kAndroidCodec_Strategy, // Uses SkAndroidCodec for scaling and subsettin g
26 };
27
28 /*
29 * @param data Refs the data while this object exists, unrefs on destruc tion
30 * @param strategy Strategy used for scaling and subsetting
31 * @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
32 */
33 static SkBitmapRegionDecoder* Create(
34 SkData* data, Strategy strategy);
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 SkBitmapRegionDecoder* Create(
42 SkStreamRewindable* stream, Strategy strategy);
43
44 /*
45 * Decode a scaled region of the encoded image stream
46 *
47 * @param bitmap Container for decoded pixels. It is assumed that the pixels
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
50 * allocator (HeapAllocator) will be used.
51 * @param desiredSubset Subset of the original image to decode.
52 * @param sampleSize An integer downscaling factor for the decode.
53 * @param colorType Preferred output colorType.
54 * New implementations should return NULL if they do not support
55 * decoding to this color type.
56 * The old kOriginal_Strategy will decode to a defaul t color type
57 * if this color type is unsupported.
58 * @param requireUnpremul If the image is not opaque, we will use this to de termine the
59 * alpha type to use.
60 *
61 */
62 virtual bool decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
63 const SkIRect& desiredSubset, int sampleSize,
64 SkColorType colorType, bool requireUnpremul) = 0;
65 /*
66 * @param Requested destination color type
67 * @return true if we support the requested color type and false otherwise
68 */
69 virtual bool conversionSupported(SkColorType colorType) = 0;
70
71 virtual SkEncodedFormat getEncodedFormat() = 0;
72
73 int width() const { return fWidth; }
74 int height() const { return fHeight; }
75
76 virtual ~SkBitmapRegionDecoder() {}
77
78 protected:
79
80 SkBitmapRegionDecoder(int width, int height)
81 : fWidth(width)
82 , fHeight(height)
83 {}
84
85 private:
86 const int fWidth;
87 const int fHeight;
88 };
89
90 #endif
OLDNEW
« no previous file with comments | « tools/android/SkBitmapRegionCodec.cpp ('k') | tools/android/SkBitmapRegionDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698