blob: b6e1b5955ceecb725cd748339e1b3bd849ee0af5 [file] [log] [blame]
scroggo478652e2015-03-25 07:11:02 -07001/*
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
mtklein748ca3b2015-01-15 10:56:12 -08008#ifndef DMSrcSink_DEFINED
9#define DMSrcSink_DEFINED
10
11#include "DMGpuSupport.h"
12#include "SkBBHFactory.h"
13#include "SkBBoxHierarchy.h"
14#include "SkBitmap.h"
msarett5cb48852015-11-06 08:56:32 -080015#include "SkBitmapRegionDecoder.h"
mtklein748ca3b2015-01-15 10:56:12 -080016#include "SkCanvas.h"
17#include "SkData.h"
halcanary45420a92016-06-02 12:41:14 -070018#include "SkMultiPictureDocumentReader.h"
mtklein748ca3b2015-01-15 10:56:12 -080019#include "SkPicture.h"
mtklein748ca3b2015-01-15 10:56:12 -080020#include "gm.h"
21
Mike Reedbae888e2017-02-18 16:50:45 -050022//#define TEST_VIA_SVG
23
mtklein748ca3b2015-01-15 10:56:12 -080024namespace DM {
25
26// This is just convenience. It lets you use either return "foo" or return SkStringPrintf(...).
27struct ImplicitString : public SkString {
28 template <typename T>
29 ImplicitString(const T& s) : SkString(s) {}
msarett9e707a02015-09-01 14:57:57 -070030 ImplicitString() : SkString("") {}
mtklein748ca3b2015-01-15 10:56:12 -080031};
mtklein748ca3b2015-01-15 10:56:12 -080032typedef ImplicitString Name;
mtklein8d17a132015-01-30 11:42:31 -080033typedef ImplicitString Path;
mtklein748ca3b2015-01-15 10:56:12 -080034
mtklein4089ef72015-03-05 08:40:28 -080035class Error {
36public:
37 Error(const SkString& s) : fMsg(s), fFatal(!this->isEmpty()) {}
38 Error(const char* s) : fMsg(s), fFatal(!this->isEmpty()) {}
39
40 Error(const Error&) = default;
41 Error& operator=(const Error&) = default;
42
43 static Error Nonfatal(const SkString& s) { return Nonfatal(s.c_str()); }
44 static Error Nonfatal(const char* s) {
45 Error e(s);
46 e.fFatal = false;
47 return e;
48 }
49
50 const char* c_str() const { return fMsg.c_str(); }
51 bool isEmpty() const { return fMsg.isEmpty(); }
52 bool isFatal() const { return fFatal; }
53
54private:
55 SkString fMsg;
56 bool fFatal;
57};
58
mtklein99cab4e2015-07-31 06:43:04 -070059struct SinkFlags {
Brian Salomonbd7c5512017-03-07 09:08:36 -050060 enum Type { kNull, kGPU, kVector, kRaster } type;
61 enum Approach { kDirect, kIndirect } approach;
62 enum Multisampled { kNotMultisampled, kMultisampled } multisampled;
63 SinkFlags(Type t, Approach a, Multisampled ms = kNotMultisampled)
64 : type(t), approach(a), multisampled(ms) {}
mtklein99cab4e2015-07-31 06:43:04 -070065};
mtkleine0effd62015-07-29 06:37:28 -070066
mtklein748ca3b2015-01-15 10:56:12 -080067struct Src {
mtklein748ca3b2015-01-15 10:56:12 -080068 virtual ~Src() {}
69 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0;
70 virtual SkISize size() const = 0;
71 virtual Name name() const = 0;
bsalomon4ee6bd82015-05-27 13:23:23 -070072 virtual void modifyGrContextOptions(GrContextOptions* options) const {}
mtklein99cab4e2015-07-31 06:43:04 -070073 virtual bool veto(SinkFlags) const { return false; }
mtklein21eaf3b2016-02-08 12:39:59 -080074
halcanary45420a92016-06-02 12:41:14 -070075 virtual int pageCount() const { return 1; }
76 virtual Error SK_WARN_UNUSED_RESULT draw(int, SkCanvas* canvas) const {
77 return this->draw(canvas);
78 }
79 virtual SkISize size(int) const { return this->size(); }
mtklein21eaf3b2016-02-08 12:39:59 -080080 // Force Tasks using this Src to run on the main thread?
81 virtual bool serial() const { return false; }
mtklein748ca3b2015-01-15 10:56:12 -080082};
83
84struct Sink {
85 virtual ~Sink() {}
mtkleinb9eb4ac2015-02-02 18:26:03 -080086 // You may write to either the bitmap or stream. If you write to log, we'll print that out.
87 virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log)
88 const = 0;
mtklein21eaf3b2016-02-08 12:39:59 -080089
90 // Force Tasks using this Sink to run on the main thread?
91 virtual bool serial() const { return false; }
mtklein748ca3b2015-01-15 10:56:12 -080092
93 // File extension for the content draw() outputs, e.g. "png", "pdf".
94 virtual const char* fileExtension() const = 0;
mtklein99cab4e2015-07-31 06:43:04 -070095
96 virtual SinkFlags flags() const = 0;
mtklein748ca3b2015-01-15 10:56:12 -080097};
98
mtklein748ca3b2015-01-15 10:56:12 -080099/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
100
mtklein748ca3b2015-01-15 10:56:12 -0800101class GMSrc : public Src {
102public:
103 explicit GMSrc(skiagm::GMRegistry::Factory);
104
mtklein36352bf2015-03-25 18:17:31 -0700105 Error draw(SkCanvas*) const override;
106 SkISize size() const override;
107 Name name() const override;
bsalomon4ee6bd82015-05-27 13:23:23 -0700108 void modifyGrContextOptions(GrContextOptions* options) const override;
109
mtklein748ca3b2015-01-15 10:56:12 -0800110private:
111 skiagm::GMRegistry::Factory fFactory;
112};
113
scroggo9b77ddd2015-03-19 06:03:39 -0700114class CodecSrc : public Src {
115public:
scroggo9c59ebc2015-03-25 13:48:49 -0700116 enum Mode {
msarett9e707a02015-09-01 14:57:57 -0700117 kCodec_Mode,
msarettbb25b532016-01-13 09:31:39 -0800118 // We choose to test only one mode with zero initialized memory.
119 // This will exercise all of the interesting cases in SkSwizzler
120 // without doubling the size of our test suite.
121 kCodecZeroInit_Mode,
scroggo9c59ebc2015-03-25 13:48:49 -0700122 kScanline_Mode,
msarett0a242972015-06-11 14:27:27 -0700123 kStripe_Mode, // Tests the skipping of scanlines
msarett91c22b22016-02-22 12:27:46 -0800124 kCroppedScanline_Mode, // Tests (jpeg) cropped scanline optimization
scroggob636b452015-07-22 07:16:20 -0700125 kSubset_Mode, // For codecs that support subsets directly.
scroggo19b91532016-10-24 09:03:26 -0700126 kAnimated_Mode, // For codecs that support animation.
scroggo9c59ebc2015-03-25 13:48:49 -0700127 };
msarett438b2ad2015-04-09 12:43:10 -0700128 enum DstColorType {
129 kGetFromCanvas_DstColorType,
130 kIndex8_Always_DstColorType,
131 kGrayscale_Always_DstColorType,
msarett34e0ec42016-04-22 16:27:24 -0700132 kNonNative8888_Always_DstColorType,
msarett438b2ad2015-04-09 12:43:10 -0700133 };
scroggoc5560be2016-02-03 09:42:42 -0800134 CodecSrc(Path, Mode, DstColorType, SkAlphaType, float);
scroggo9b77ddd2015-03-19 06:03:39 -0700135
mtklein36352bf2015-03-25 18:17:31 -0700136 Error draw(SkCanvas*) const override;
137 SkISize size() const override;
138 Name name() const override;
mtklein99cab4e2015-07-31 06:43:04 -0700139 bool veto(SinkFlags) const override;
scroggo3ac66e92016-02-08 15:09:48 -0800140 bool serial() const override { return fRunSerially; }
scroggo9b77ddd2015-03-19 06:03:39 -0700141private:
msarett9e707a02015-09-01 14:57:57 -0700142 Path fPath;
143 Mode fMode;
144 DstColorType fDstColorType;
scroggoc5560be2016-02-03 09:42:42 -0800145 SkAlphaType fDstAlphaType;
msarett9e707a02015-09-01 14:57:57 -0700146 float fScale;
scroggo3ac66e92016-02-08 15:09:48 -0800147 bool fRunSerially;
scroggo9b77ddd2015-03-19 06:03:39 -0700148};
149
msarett3d9d7a72015-10-21 10:27:10 -0700150class AndroidCodecSrc : public Src {
151public:
scroggof8dc9df2016-05-16 09:04:13 -0700152 AndroidCodecSrc(Path, CodecSrc::DstColorType, SkAlphaType, int sampleSize);
msarett3d9d7a72015-10-21 10:27:10 -0700153
154 Error draw(SkCanvas*) const override;
155 SkISize size() const override;
156 Name name() const override;
157 bool veto(SinkFlags) const override;
scroggo3ac66e92016-02-08 15:09:48 -0800158 bool serial() const override { return fRunSerially; }
msarett3d9d7a72015-10-21 10:27:10 -0700159private:
160 Path fPath;
msarett3d9d7a72015-10-21 10:27:10 -0700161 CodecSrc::DstColorType fDstColorType;
scroggoc5560be2016-02-03 09:42:42 -0800162 SkAlphaType fDstAlphaType;
msarett3d9d7a72015-10-21 10:27:10 -0700163 int fSampleSize;
scroggo3ac66e92016-02-08 15:09:48 -0800164 bool fRunSerially;
msarett3d9d7a72015-10-21 10:27:10 -0700165};
166
msaretta5783ae2015-09-08 15:35:32 -0700167// Allows for testing of various implementations of Android's BitmapRegionDecoder
168class BRDSrc : public Src {
169public:
170 enum Mode {
171 // Decode the entire image as one region.
172 kFullImage_Mode,
173 // Splits the image into multiple regions using a divisor and decodes the regions
174 // separately. Also, this test adds a border of a few pixels to each of the regions
175 // that it is decoding. This tests the behavior when a client asks for a region that
176 // does not fully fit in the image.
177 kDivisor_Mode,
178 };
179
msarettd1227a72016-05-18 06:23:57 -0700180 BRDSrc(Path, Mode, CodecSrc::DstColorType, uint32_t);
msaretta5783ae2015-09-08 15:35:32 -0700181
msaretta5783ae2015-09-08 15:35:32 -0700182 Error draw(SkCanvas*) const override;
183 SkISize size() const override;
184 Name name() const override;
185 bool veto(SinkFlags) const override;
186private:
187 Path fPath;
msaretta5783ae2015-09-08 15:35:32 -0700188 Mode fMode;
189 CodecSrc::DstColorType fDstColorType;
190 uint32_t fSampleSize;
191};
scroggo9b77ddd2015-03-19 06:03:39 -0700192
msarett18976312016-03-09 14:20:58 -0800193class ImageGenSrc : public Src {
194public:
195 enum Mode {
196 kCodec_Mode, // Use CodecImageGenerator
197 kPlatform_Mode, // Uses CG or WIC
198 };
199 ImageGenSrc(Path, Mode, SkAlphaType, bool);
200
201 Error draw(SkCanvas*) const override;
202 SkISize size() const override;
203 Name name() const override;
204 bool veto(SinkFlags) const override;
205 bool serial() const override { return fRunSerially; }
206private:
207 Path fPath;
208 Mode fMode;
209 SkAlphaType fDstAlphaType;
210 bool fIsGpu;
211 bool fRunSerially;
212};
213
msarett69deca82016-04-29 09:38:40 -0700214class ColorCodecSrc : public Src {
215public:
216 enum Mode {
217 // Mimic legacy behavior and apply no color correction.
218 kBaseline_Mode,
msarett888dc162016-05-23 10:21:17 -0700219
220 // Color correct images into a specific dst color space. If you happen to have this
221 // monitor, you're in luck! The unmarked outputs of this test should display
222 // correctly on this monitor in the Chrome browser. If not, it's useful to know
223 // that this monitor has a profile that is fairly similar to Adobe RGB.
msarett888dc162016-05-23 10:21:17 -0700224 kDst_HPZR30w_Mode,
msarett9876ac52016-06-01 14:47:18 -0700225
msarettd2809572016-06-20 06:07:45 -0700226 kDst_sRGB_Mode,
msarett69deca82016-04-29 09:38:40 -0700227 };
228
msarett9ce3a542016-07-15 13:54:38 -0700229 ColorCodecSrc(Path, Mode, SkColorType);
msarett69deca82016-04-29 09:38:40 -0700230
231 Error draw(SkCanvas*) const override;
232 SkISize size() const override;
233 Name name() const override;
234 bool veto(SinkFlags) const override;
235private:
236 Path fPath;
237 Mode fMode;
msarett9ce3a542016-07-15 13:54:38 -0700238 SkColorType fColorType;
msarett69deca82016-04-29 09:38:40 -0700239};
240
mtklein748ca3b2015-01-15 10:56:12 -0800241class SKPSrc : public Src {
242public:
mtklein8d17a132015-01-30 11:42:31 -0800243 explicit SKPSrc(Path path);
mtklein748ca3b2015-01-15 10:56:12 -0800244
mtklein36352bf2015-03-25 18:17:31 -0700245 Error draw(SkCanvas*) const override;
246 SkISize size() const override;
247 Name name() const override;
mtklein748ca3b2015-01-15 10:56:12 -0800248private:
mtklein8d17a132015-01-30 11:42:31 -0800249 Path fPath;
mtklein748ca3b2015-01-15 10:56:12 -0800250};
251
fmalitaa2b9fdf2016-08-03 19:53:36 -0700252#if defined(SK_XML)
fmalitabdf3e5c2016-09-17 07:26:26 -0700253} // namespace DM
254
255class SkSVGDOM;
256
257namespace DM {
258
fmalitaa2b9fdf2016-08-03 19:53:36 -0700259class SVGSrc : public Src {
260public:
261 explicit SVGSrc(Path path);
262
263 Error draw(SkCanvas*) const override;
264 SkISize size() const override;
265 Name name() const override;
fmalita179d8852016-08-16 14:23:29 -0700266 bool veto(SinkFlags) const override;
fmalitaa2b9fdf2016-08-03 19:53:36 -0700267
268private:
fmalitaacd2f5c2016-11-08 07:13:45 -0800269 Name fName;
270 sk_sp<SkSVGDOM> fDom;
271 SkScalar fScale;
fmalitaa2b9fdf2016-08-03 19:53:36 -0700272
273 typedef Src INHERITED;
274};
275#endif // SK_XML
mtklein748ca3b2015-01-15 10:56:12 -0800276/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
277
halcanary45420a92016-06-02 12:41:14 -0700278class MSKPSrc : public Src {
279public:
280 explicit MSKPSrc(Path path);
281
282 int pageCount() const override;
283 Error draw(SkCanvas* c) const override;
284 Error draw(int, SkCanvas*) const override;
285 SkISize size() const override;
286 SkISize size(int) const override;
287 Name name() const override;
288
289private:
290 Path fPath;
291 SkMultiPictureDocumentReader fReader;
292};
293
294/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
295
mtkleinad66f9b2015-02-13 15:11:10 -0800296class NullSink : public Sink {
297public:
298 NullSink() {}
299
mtklein36352bf2015-03-25 18:17:31 -0700300 Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override;
mtklein36352bf2015-03-25 18:17:31 -0700301 const char* fileExtension() const override { return ""; }
mtklein99cab4e2015-07-31 06:43:04 -0700302 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kNull, SinkFlags::kDirect }; }
mtkleinad66f9b2015-02-13 15:11:10 -0800303};
304
305
mtklein748ca3b2015-01-15 10:56:12 -0800306class GPUSink : public Sink {
307public:
bsalomon85b4b532016-04-05 11:06:27 -0700308 GPUSink(sk_gpu_test::GrContextFactory::ContextType,
csmartdaltone812d492017-02-21 12:36:05 -0700309 sk_gpu_test::GrContextFactory::ContextOverrides,
brianosmanb109b8c2016-06-16 13:03:24 -0700310 int samples, bool diText, SkColorType colorType, sk_sp<SkColorSpace> colorSpace,
brianosmand93c1202016-03-10 07:49:08 -0800311 bool threaded);
mtklein748ca3b2015-01-15 10:56:12 -0800312
mtklein36352bf2015-03-25 18:17:31 -0700313 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtklein21eaf3b2016-02-08 12:39:59 -0800314 bool serial() const override { return !fThreaded; }
mtklein36352bf2015-03-25 18:17:31 -0700315 const char* fileExtension() const override { return "png"; }
Brian Salomonbd7c5512017-03-07 09:08:36 -0500316 SinkFlags flags() const override {
Brian Salomonfd171ed2017-03-08 11:38:45 -0500317 SinkFlags::Multisampled ms = fSampleCount > 0 ? SinkFlags::kMultisampled
318 : SinkFlags::kNotMultisampled;
319 return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect, ms };
Brian Salomonbd7c5512017-03-07 09:08:36 -0500320 }
mtklein748ca3b2015-01-15 10:56:12 -0800321private:
csmartdaltone812d492017-02-21 12:36:05 -0700322 sk_gpu_test::GrContextFactory::ContextType fContextType;
323 sk_gpu_test::GrContextFactory::ContextOverrides fContextOverrides;
324 int fSampleCount;
325 bool fUseDIText;
326 SkColorType fColorType;
327 sk_sp<SkColorSpace> fColorSpace;
328 bool fThreaded;
mtklein748ca3b2015-01-15 10:56:12 -0800329};
330
331class PDFSink : public Sink {
332public:
halcanary4b656662016-04-27 07:45:18 -0700333 PDFSink(bool pdfa = false) : fPDFA(pdfa) {}
mtklein36352bf2015-03-25 18:17:31 -0700334 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtklein36352bf2015-03-25 18:17:31 -0700335 const char* fileExtension() const override { return "pdf"; }
mtklein99cab4e2015-07-31 06:43:04 -0700336 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
halcanary4b656662016-04-27 07:45:18 -0700337 bool fPDFA;
mtklein748ca3b2015-01-15 10:56:12 -0800338};
339
halcanary47ef4d52015-03-03 09:13:09 -0800340class XPSSink : public Sink {
341public:
342 XPSSink();
343
mtklein36352bf2015-03-25 18:17:31 -0700344 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtklein36352bf2015-03-25 18:17:31 -0700345 const char* fileExtension() const override { return "xps"; }
mtklein99cab4e2015-07-31 06:43:04 -0700346 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
halcanary47ef4d52015-03-03 09:13:09 -0800347};
348
reed54dc4872016-09-13 08:09:45 -0700349class PipeSink : public Sink {
350public:
351 PipeSink();
Mike Klein841101d2017-03-10 09:55:51 -0500352
reed54dc4872016-09-13 08:09:45 -0700353 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
354 const char* fileExtension() const override { return "skpipe"; }
355 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
356};
357
mtklein748ca3b2015-01-15 10:56:12 -0800358class RasterSink : public Sink {
359public:
brianosmanb109b8c2016-06-16 13:03:24 -0700360 explicit RasterSink(SkColorType, sk_sp<SkColorSpace> = nullptr);
mtklein748ca3b2015-01-15 10:56:12 -0800361
mtklein36352bf2015-03-25 18:17:31 -0700362 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtklein36352bf2015-03-25 18:17:31 -0700363 const char* fileExtension() const override { return "png"; }
mtklein99cab4e2015-07-31 06:43:04 -0700364 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kRaster, SinkFlags::kDirect }; }
mtklein748ca3b2015-01-15 10:56:12 -0800365private:
brianosmanb109b8c2016-06-16 13:03:24 -0700366 SkColorType fColorType;
367 sk_sp<SkColorSpace> fColorSpace;
mtklein748ca3b2015-01-15 10:56:12 -0800368};
369
mtklein9c3f17d2015-01-28 11:35:18 -0800370class SKPSink : public Sink {
371public:
372 SKPSink();
373
mtklein36352bf2015-03-25 18:17:31 -0700374 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtklein36352bf2015-03-25 18:17:31 -0700375 const char* fileExtension() const override { return "skp"; }
mtklein99cab4e2015-07-31 06:43:04 -0700376 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
mtklein9c3f17d2015-01-28 11:35:18 -0800377};
378
Hal Canary85c7fe82016-10-25 10:33:27 -0400379class DebugSink : public Sink {
380public:
381 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
382 const char* fileExtension() const override { return "json"; }
383 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
384};
385
mtklein8a4527e2015-01-31 20:00:58 -0800386class SVGSink : public Sink {
387public:
388 SVGSink();
389
mtklein36352bf2015-03-25 18:17:31 -0700390 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtklein36352bf2015-03-25 18:17:31 -0700391 const char* fileExtension() const override { return "svg"; }
mtklein99cab4e2015-07-31 06:43:04 -0700392 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; }
mtklein8a4527e2015-01-31 20:00:58 -0800393};
394
395
mtklein748ca3b2015-01-15 10:56:12 -0800396/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
397
mtklein78829242015-05-06 07:54:07 -0700398class Via : public Sink {
399public:
msarett62d3b102015-12-10 15:14:27 -0800400 explicit Via(Sink* sink) : fSink(sink) {}
mtklein78829242015-05-06 07:54:07 -0700401 const char* fileExtension() const override { return fSink->fileExtension(); }
mtklein21eaf3b2016-02-08 12:39:59 -0800402 bool serial() const override { return fSink->serial(); }
mtklein99cab4e2015-07-31 06:43:04 -0700403 SinkFlags flags() const override {
404 SinkFlags flags = fSink->flags();
405 flags.approach = SinkFlags::kIndirect;
406 return flags;
407 }
mtklein78829242015-05-06 07:54:07 -0700408protected:
Ben Wagner145dbcd2016-11-03 14:40:50 -0400409 std::unique_ptr<Sink> fSink;
mtklein78829242015-05-06 07:54:07 -0700410};
411
412class ViaMatrix : public Via {
mtklein748ca3b2015-01-15 10:56:12 -0800413public:
msarett62d3b102015-12-10 15:14:27 -0800414 ViaMatrix(SkMatrix, Sink*);
mtklein36352bf2015-03-25 18:17:31 -0700415 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtklein748ca3b2015-01-15 10:56:12 -0800416private:
mtklein78829242015-05-06 07:54:07 -0700417 const SkMatrix fMatrix;
mtklein748ca3b2015-01-15 10:56:12 -0800418};
419
mtklein78829242015-05-06 07:54:07 -0700420class ViaUpright : public Via {
mtkleind603b222015-02-17 11:13:33 -0800421public:
msarett62d3b102015-12-10 15:14:27 -0800422 ViaUpright(SkMatrix, Sink*);
mtklein36352bf2015-03-25 18:17:31 -0700423 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtkleind603b222015-02-17 11:13:33 -0800424private:
mtklein78829242015-05-06 07:54:07 -0700425 const SkMatrix fMatrix;
mtkleind603b222015-02-17 11:13:33 -0800426};
427
mtklein78829242015-05-06 07:54:07 -0700428class ViaSerialization : public Via {
mtklein748ca3b2015-01-15 10:56:12 -0800429public:
msarett62d3b102015-12-10 15:14:27 -0800430 explicit ViaSerialization(Sink* sink) : Via(sink) {}
mtklein36352bf2015-03-25 18:17:31 -0700431 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtklein748ca3b2015-01-15 10:56:12 -0800432};
433
mtklein4a34ecb2016-01-08 10:19:35 -0800434class ViaPicture : public Via {
435public:
436 explicit ViaPicture(Sink* sink) : Via(sink) {}
437 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
438};
439
reed54dc4872016-09-13 08:09:45 -0700440class ViaPipe : public Via {
441public:
442 explicit ViaPipe(Sink* sink) : Via(sink) {}
443 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
444};
445
reedbabc3de2016-07-08 08:43:27 -0700446class ViaDefer : public Via {
447public:
448 explicit ViaDefer(Sink* sink) : Via(sink) {}
449 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
450};
451
mtklein78829242015-05-06 07:54:07 -0700452class ViaTiles : public Via {
mtklein748ca3b2015-01-15 10:56:12 -0800453public:
msarett62d3b102015-12-10 15:14:27 -0800454 ViaTiles(int w, int h, SkBBHFactory*, Sink*);
mtklein36352bf2015-03-25 18:17:31 -0700455 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtklein748ca3b2015-01-15 10:56:12 -0800456private:
457 const int fW, fH;
Ben Wagner145dbcd2016-11-03 14:40:50 -0400458 std::unique_ptr<SkBBHFactory> fFactory;
mtklein748ca3b2015-01-15 10:56:12 -0800459};
460
mtklein78829242015-05-06 07:54:07 -0700461class ViaSecondPicture : public Via {
mtkleinb7e8d692015-04-07 08:30:32 -0700462public:
msarett62d3b102015-12-10 15:14:27 -0800463 explicit ViaSecondPicture(Sink* sink) : Via(sink) {}
mtkleinb7e8d692015-04-07 08:30:32 -0700464 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtkleinb7e8d692015-04-07 08:30:32 -0700465};
466
mtklein78829242015-05-06 07:54:07 -0700467class ViaSingletonPictures : public Via {
mtkleind31c13d2015-05-05 12:59:56 -0700468public:
msarett62d3b102015-12-10 15:14:27 -0800469 explicit ViaSingletonPictures(Sink* sink) : Via(sink) {}
mtkleind31c13d2015-05-05 12:59:56 -0700470 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
mtkleind31c13d2015-05-05 12:59:56 -0700471};
472
mtklein6fbf4b32015-05-06 11:35:40 -0700473class ViaTwice : public Via {
474public:
msarett62d3b102015-12-10 15:14:27 -0800475 explicit ViaTwice(Sink* sink) : Via(sink) {}
mtklein6fbf4b32015-05-06 11:35:40 -0700476 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
477};
478
Mike Reedf67c4592017-02-17 17:06:11 -0500479class ViaSVG : public Via {
480public:
481 explicit ViaSVG(Sink* sink) : Via(sink) {}
482 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
483};
484
halcanary7a76f9c2016-02-03 11:53:18 -0800485class ViaMojo : public Via {
486public:
487 explicit ViaMojo(Sink* sink) : Via(sink) {}
488 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
489};
490
mtklein9c5052f2016-08-06 12:51:51 -0700491class ViaLite : public Via {
492public:
493 explicit ViaLite(Sink* sink) : Via(sink) {}
494 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
495};
496
Mike Klein841101d2017-03-10 09:55:51 -0500497class ViaCSXform : public Via {
498public:
Mike Klein919cc452017-03-18 15:36:52 +0000499 explicit ViaCSXform(Sink*, sk_sp<SkColorSpace>, bool colorSpin);
Mike Klein841101d2017-03-10 09:55:51 -0500500 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
501private:
502 sk_sp<SkColorSpace> fCS;
Mike Klein919cc452017-03-18 15:36:52 +0000503 bool fColorSpin;
Mike Klein841101d2017-03-10 09:55:51 -0500504};
505
mtklein748ca3b2015-01-15 10:56:12 -0800506} // namespace DM
507
508#endif//DMSrcSink_DEFINED