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

Side by Side Diff: dm/DMSrcSink.h

Issue 1288963002: Provides multiple implementations of Android's SkBitmapRegionDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments 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 | « dm/DM.cpp ('k') | dm/DMSrcSink.cpp » ('j') | dm/DMSrcSink.cpp » ('J')
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 DMSrcSink_DEFINED 8 #ifndef DMSrcSink_DEFINED
9 #define DMSrcSink_DEFINED 9 #define DMSrcSink_DEFINED
10 10
11 #include "DMGpuSupport.h" 11 #include "DMGpuSupport.h"
12 #include "SkBBHFactory.h" 12 #include "SkBBHFactory.h"
13 #include "SkBBoxHierarchy.h" 13 #include "SkBBoxHierarchy.h"
14 #include "SkBitmap.h" 14 #include "SkBitmap.h"
15 #include "SkBitmapRegionDecoder.h"
15 #include "SkCanvas.h" 16 #include "SkCanvas.h"
16 #include "SkData.h" 17 #include "SkData.h"
17 #include "SkGPipe.h" 18 #include "SkGPipe.h"
18 #include "SkPicture.h" 19 #include "SkPicture.h"
19 #include "gm.h" 20 #include "gm.h"
20 21
21 namespace DM { 22 namespace DM {
22 23
23 // This is just convenience. It lets you use either return "foo" or return SkSt ringPrintf(...). 24 // This is just convenience. It lets you use either return "foo" or return SkSt ringPrintf(...).
24 struct ImplicitString : public SkString { 25 struct ImplicitString : public SkString {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 kCodec_Mode, 108 kCodec_Mode,
108 kScanline_Mode, 109 kScanline_Mode,
109 kScanline_Subset_Mode, 110 kScanline_Subset_Mode,
110 kStripe_Mode, // Tests the skipping of scanlines 111 kStripe_Mode, // Tests the skipping of scanlines
111 kSubset_Mode, // For codecs that support subsets directly. 112 kSubset_Mode, // For codecs that support subsets directly.
112 }; 113 };
113 enum DstColorType { 114 enum DstColorType {
114 kGetFromCanvas_DstColorType, 115 kGetFromCanvas_DstColorType,
115 kIndex8_Always_DstColorType, 116 kIndex8_Always_DstColorType,
116 kGrayscale_Always_DstColorType, 117 kGrayscale_Always_DstColorType,
118 kAlpha_Always_DstColorType,
scroggo 2015/09/03 20:07:41 Alpha8 is used as a hack for Grayscale. Maybe we s
msarett 2015/09/03 22:10:30 Yes I think this makes sense.
117 }; 119 };
118 CodecSrc(Path, Mode, DstColorType, float); 120 CodecSrc(Path, Mode, DstColorType, float);
119 121
120 Error draw(SkCanvas*) const override; 122 Error draw(SkCanvas*) const override;
121 SkISize size() const override; 123 SkISize size() const override;
122 Name name() const override; 124 Name name() const override;
123 bool veto(SinkFlags) const override; 125 bool veto(SinkFlags) const override;
124 private: 126 private:
125 Path fPath; 127 Path fPath;
126 Mode fMode; 128 Mode fMode;
127 DstColorType fDstColorType; 129 DstColorType fDstColorType;
128 float fScale; 130 float fScale;
129 }; 131 };
130 132
133 // Allows for testing of various implementations of Android's BitmapRegionDecode r
134 class BRDSrc : public Src {
135 public:
136 enum Mode {
137 // Decode the entire image as one region.
138 kFullImage_Mode,
139 // Splits the image into multiple regions using a divisor and decodes th e regions
140 // separately. Also, this test adds a border of a few pixels to each of the regions
141 // that it is decoding. This tests the behavior when a client asks for a region that
142 // does not fully fit in the image.
143 kDivisor_Mode,
144 };
145
146 BRDSrc(Path, SkBitmapRegionDecoder::Strategy, Mode, CodecSrc::DstColorType, uint32_t);
147
148 static float GetScale(uint32_t sampleSize) { return 1.0f / (float) sampleSiz e; }
149
150 Error draw(SkCanvas*) const override;
151 SkISize size() const override;
152 Name name() const override;
153 bool veto(SinkFlags) const override;
154 private:
155 Path fPath;
156 SkBitmapRegionDecoder::Strategy fStrategy;
157 Mode fMode;
158 CodecSrc::DstColorType fDstColorType;
159 uint32_t fSampleSize;
160 };
131 161
132 class ImageSrc : public Src { 162 class ImageSrc : public Src {
133 public: 163 public:
134 // divisor == 0 means decode the whole image 164 // divisor == 0 means decode the whole image
135 // divisor > 0 means decode in subsets, dividing into a divisor x divisor gr id. 165 // divisor > 0 means decode in subsets, dividing into a divisor x divisor gr id.
136 explicit ImageSrc(Path path, int divisor = 0); 166 explicit ImageSrc(Path path, int divisor = 0);
137 167
138 Error draw(SkCanvas*) const override; 168 Error draw(SkCanvas*) const override;
139 SkISize size() const override; 169 SkISize size() const override;
140 Name name() const override; 170 Name name() const override;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 340
311 class ViaTwice : public Via { 341 class ViaTwice : public Via {
312 public: 342 public:
313 explicit ViaTwice(Sink* sink) : Via(sink) {} 343 explicit ViaTwice(Sink* sink) : Via(sink) {}
314 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 344 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
315 }; 345 };
316 346
317 } // namespace DM 347 } // namespace DM
318 348
319 #endif//DMSrcSink_DEFINED 349 #endif//DMSrcSink_DEFINED
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | dm/DMSrcSink.cpp » ('j') | dm/DMSrcSink.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698