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

Side by Side Diff: tools/SkBitmapRegionDecoderInterface.h

Issue 1288963002: Provides multiple implementations of Android's SkBitmapRegionDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Disable png subsets for SkImageDecoder Created 5 years, 3 months 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/SkBitmapRegionCanvas.cpp ('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
(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 "SkStream.h"
13
14 /*
15 * This class aims to provide an interface to test multiple implementations of
16 * SkBitmapRegionDecoder.
17 */
18 class SkBitmapRegionDecoderInterface {
19 public:
20
21 enum Strategy {
22 kCanvas_Strategy, // Draw to the canvas, uses SkCodec
23 kOriginal_Strategy, // Sampling, uses SkImageDecoder
24 // TODO (msarett): Add strategy for SkScaledCodec
25 };
26
27 /*
28 * @param stream Encoded image stream, takes ownership
29 * @param strategy Strategy used for scaling and subsetting
30 * @return Tries to create an SkBitmapRegionDecoder, returns NULL
31 * on failure
32 */
33 static SkBitmapRegionDecoderInterface* CreateBitmapRegionDecoder(
34 SkStreamRewindable* stream, Strategy strategy);
35
36 /*
37 * Decode a scaled region of the encoded image stream
38 *
39 * @param start_x X-coordinate of upper-left corner of region.
40 * This coordinate is unscaled, relative to the original d imensions.
41 * @param start_y Y-coordinate of upper-left corner of region.
42 * This coordinate is unscaled, relative to the original d imensions.
43 * @param width Width of the region to decode.
44 * This distance is unscaled, relative to the original dim ensions.
45 * @param height Height of the region to decode.
46 * This distance is unscaled, relative to the original dim ensions.
47 * @param sampleSize An integer downscaling factor for the decode.
48 * @param colorType Preferred output colorType.
49 * New implementations should return NULL if they do not s upport
50 * decoding to this color type.
51 * The old kOriginal_Strategy will decode to a default col or type
52 * if this color type is unsupported.
53 * @return Pointer to a bitmap of the decoded region on success, N ULL on
54 * failure.
55 */
56 virtual SkBitmap* decodeRegion(int start_x, int start_y, int width,
57 int height, int sampleSize,
58 SkColorType colorType) = 0;
59
60 int width() const { return fWidth; }
61 int height() const { return fHeight; }
62
63 virtual ~SkBitmapRegionDecoderInterface() {}
64
65 protected:
66
67 SkBitmapRegionDecoderInterface(int width, int height)
68 : fWidth(width)
69 , fHeight(height)
70 {}
71
72 private:
73 const int fWidth;
74 const int fHeight;
75 };
76
77 #endif
OLDNEW
« no previous file with comments | « tools/SkBitmapRegionCanvas.cpp ('k') | tools/SkBitmapRegionDecoderInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698