scroggo | 478652e | 2015-03-25 07:11:02 -0700 | [diff] [blame] | 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 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 8 | #ifndef DMSrcSink_DEFINED |
| 9 | #define DMSrcSink_DEFINED |
| 10 | |
| 11 | #include "DMGpuSupport.h" |
| 12 | #include "SkBBHFactory.h" |
| 13 | #include "SkBBoxHierarchy.h" |
| 14 | #include "SkBitmap.h" |
msarett | 5cb4885 | 2015-11-06 08:56:32 -0800 | [diff] [blame] | 15 | #include "SkBitmapRegionDecoder.h" |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 16 | #include "SkCanvas.h" |
| 17 | #include "SkData.h" |
| 18 | #include "SkGPipe.h" |
| 19 | #include "SkPicture.h" |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 20 | #include "gm.h" |
| 21 | |
| 22 | namespace DM { |
| 23 | |
| 24 | // This is just convenience. It lets you use either return "foo" or return SkStringPrintf(...). |
| 25 | struct ImplicitString : public SkString { |
| 26 | template <typename T> |
| 27 | ImplicitString(const T& s) : SkString(s) {} |
msarett | 9e707a0 | 2015-09-01 14:57:57 -0700 | [diff] [blame] | 28 | ImplicitString() : SkString("") {} |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 29 | }; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 30 | typedef ImplicitString Name; |
mtklein | 8d17a13 | 2015-01-30 11:42:31 -0800 | [diff] [blame] | 31 | typedef ImplicitString Path; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 32 | |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 33 | class Error { |
| 34 | public: |
| 35 | Error(const SkString& s) : fMsg(s), fFatal(!this->isEmpty()) {} |
| 36 | Error(const char* s) : fMsg(s), fFatal(!this->isEmpty()) {} |
| 37 | |
| 38 | Error(const Error&) = default; |
| 39 | Error& operator=(const Error&) = default; |
| 40 | |
| 41 | static Error Nonfatal(const SkString& s) { return Nonfatal(s.c_str()); } |
| 42 | static Error Nonfatal(const char* s) { |
| 43 | Error e(s); |
| 44 | e.fFatal = false; |
| 45 | return e; |
| 46 | } |
| 47 | |
| 48 | const char* c_str() const { return fMsg.c_str(); } |
| 49 | bool isEmpty() const { return fMsg.isEmpty(); } |
| 50 | bool isFatal() const { return fFatal; } |
| 51 | |
| 52 | private: |
| 53 | SkString fMsg; |
| 54 | bool fFatal; |
| 55 | }; |
| 56 | |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 57 | struct SinkFlags { |
| 58 | enum { kNull, kGPU, kVector, kRaster } type; |
| 59 | enum { kDirect, kIndirect } approach; |
| 60 | }; |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 61 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 62 | struct Src { |
| 63 | // All Srcs must be thread safe. |
| 64 | virtual ~Src() {} |
| 65 | virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0; |
| 66 | virtual SkISize size() const = 0; |
| 67 | virtual Name name() const = 0; |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 68 | virtual void modifyGrContextOptions(GrContextOptions* options) const {} |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 69 | virtual bool veto(SinkFlags) const { return false; } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | struct Sink { |
| 73 | virtual ~Sink() {} |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 74 | // You may write to either the bitmap or stream. If you write to log, we'll print that out. |
| 75 | virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log) |
| 76 | const = 0; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 77 | // Sinks in the same enclave (except kAnyThread_Enclave) will run serially on the same thread. |
| 78 | virtual int enclave() const = 0; |
| 79 | |
| 80 | // File extension for the content draw() outputs, e.g. "png", "pdf". |
| 81 | virtual const char* fileExtension() const = 0; |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 82 | |
| 83 | virtual SinkFlags flags() const = 0; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
halcanary | 792c80f | 2015-02-20 07:21:05 -0800 | [diff] [blame] | 86 | enum { kAnyThread_Enclave, kGPU_Enclave }; |
| 87 | static const int kNumEnclaves = kGPU_Enclave + 1; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 88 | |
| 89 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 90 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 91 | class GMSrc : public Src { |
| 92 | public: |
| 93 | explicit GMSrc(skiagm::GMRegistry::Factory); |
| 94 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 95 | Error draw(SkCanvas*) const override; |
| 96 | SkISize size() const override; |
| 97 | Name name() const override; |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 98 | void modifyGrContextOptions(GrContextOptions* options) const override; |
| 99 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 100 | private: |
| 101 | skiagm::GMRegistry::Factory fFactory; |
| 102 | }; |
| 103 | |
scroggo | 9b77ddd | 2015-03-19 06:03:39 -0700 | [diff] [blame] | 104 | class CodecSrc : public Src { |
| 105 | public: |
scroggo | 9c59ebc | 2015-03-25 13:48:49 -0700 | [diff] [blame] | 106 | enum Mode { |
msarett | 9e707a0 | 2015-09-01 14:57:57 -0700 | [diff] [blame] | 107 | kCodec_Mode, |
scroggo | 9c59ebc | 2015-03-25 13:48:49 -0700 | [diff] [blame] | 108 | kScanline_Mode, |
msarett | 0a24297 | 2015-06-11 14:27:27 -0700 | [diff] [blame] | 109 | kStripe_Mode, // Tests the skipping of scanlines |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 110 | kSubset_Mode, // For codecs that support subsets directly. |
scroggo | 9c59ebc | 2015-03-25 13:48:49 -0700 | [diff] [blame] | 111 | }; |
msarett | 438b2ad | 2015-04-09 12:43:10 -0700 | [diff] [blame] | 112 | enum DstColorType { |
| 113 | kGetFromCanvas_DstColorType, |
| 114 | kIndex8_Always_DstColorType, |
| 115 | kGrayscale_Always_DstColorType, |
| 116 | }; |
msarett | 0a24297 | 2015-06-11 14:27:27 -0700 | [diff] [blame] | 117 | CodecSrc(Path, Mode, DstColorType, float); |
scroggo | 9b77ddd | 2015-03-19 06:03:39 -0700 | [diff] [blame] | 118 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 119 | Error draw(SkCanvas*) const override; |
| 120 | SkISize size() const override; |
| 121 | Name name() const override; |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 122 | bool veto(SinkFlags) const override; |
scroggo | 9b77ddd | 2015-03-19 06:03:39 -0700 | [diff] [blame] | 123 | private: |
msarett | 9e707a0 | 2015-09-01 14:57:57 -0700 | [diff] [blame] | 124 | Path fPath; |
| 125 | Mode fMode; |
| 126 | DstColorType fDstColorType; |
| 127 | float fScale; |
scroggo | 9b77ddd | 2015-03-19 06:03:39 -0700 | [diff] [blame] | 128 | }; |
| 129 | |
msarett | 3d9d7a7 | 2015-10-21 10:27:10 -0700 | [diff] [blame] | 130 | class AndroidCodecSrc : public Src { |
| 131 | public: |
| 132 | enum Mode { |
| 133 | kFullImage_Mode, |
| 134 | // Splits the image into multiple subsets using a divisor and decodes the subsets |
| 135 | // separately. |
| 136 | kDivisor_Mode, |
| 137 | }; |
| 138 | |
| 139 | AndroidCodecSrc(Path, Mode, CodecSrc::DstColorType, int sampleSize); |
| 140 | |
| 141 | Error draw(SkCanvas*) const override; |
| 142 | SkISize size() const override; |
| 143 | Name name() const override; |
| 144 | bool veto(SinkFlags) const override; |
| 145 | private: |
| 146 | Path fPath; |
| 147 | Mode fMode; |
| 148 | CodecSrc::DstColorType fDstColorType; |
| 149 | int fSampleSize; |
| 150 | }; |
| 151 | |
msarett | a5783ae | 2015-09-08 15:35:32 -0700 | [diff] [blame] | 152 | // Allows for testing of various implementations of Android's BitmapRegionDecoder |
| 153 | class BRDSrc : public Src { |
| 154 | public: |
| 155 | enum Mode { |
| 156 | // Decode the entire image as one region. |
| 157 | kFullImage_Mode, |
| 158 | // Splits the image into multiple regions using a divisor and decodes the regions |
| 159 | // separately. Also, this test adds a border of a few pixels to each of the regions |
| 160 | // that it is decoding. This tests the behavior when a client asks for a region that |
| 161 | // does not fully fit in the image. |
| 162 | kDivisor_Mode, |
| 163 | }; |
| 164 | |
msarett | 5cb4885 | 2015-11-06 08:56:32 -0800 | [diff] [blame] | 165 | BRDSrc(Path, SkBitmapRegionDecoder::Strategy, Mode, CodecSrc::DstColorType, uint32_t); |
msarett | a5783ae | 2015-09-08 15:35:32 -0700 | [diff] [blame] | 166 | |
msarett | a5783ae | 2015-09-08 15:35:32 -0700 | [diff] [blame] | 167 | Error draw(SkCanvas*) const override; |
| 168 | SkISize size() const override; |
| 169 | Name name() const override; |
| 170 | bool veto(SinkFlags) const override; |
| 171 | private: |
| 172 | Path fPath; |
msarett | 5cb4885 | 2015-11-06 08:56:32 -0800 | [diff] [blame] | 173 | SkBitmapRegionDecoder::Strategy fStrategy; |
msarett | a5783ae | 2015-09-08 15:35:32 -0700 | [diff] [blame] | 174 | Mode fMode; |
| 175 | CodecSrc::DstColorType fDstColorType; |
| 176 | uint32_t fSampleSize; |
| 177 | }; |
scroggo | 9b77ddd | 2015-03-19 06:03:39 -0700 | [diff] [blame] | 178 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 179 | class ImageSrc : public Src { |
| 180 | public: |
msarett | 164d302 | 2015-11-10 15:09:03 -0800 | [diff] [blame] | 181 | explicit ImageSrc(Path path); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 182 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 183 | Error draw(SkCanvas*) const override; |
| 184 | SkISize size() const override; |
| 185 | Name name() const override; |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 186 | bool veto(SinkFlags) const override; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 187 | private: |
mtklein | 8d17a13 | 2015-01-30 11:42:31 -0800 | [diff] [blame] | 188 | Path fPath; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 189 | }; |
| 190 | |
| 191 | class SKPSrc : public Src { |
| 192 | public: |
mtklein | 8d17a13 | 2015-01-30 11:42:31 -0800 | [diff] [blame] | 193 | explicit SKPSrc(Path path); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 194 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 195 | Error draw(SkCanvas*) const override; |
| 196 | SkISize size() const override; |
| 197 | Name name() const override; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 198 | private: |
mtklein | 8d17a13 | 2015-01-30 11:42:31 -0800 | [diff] [blame] | 199 | Path fPath; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 200 | }; |
| 201 | |
| 202 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 203 | |
mtklein | ad66f9b | 2015-02-13 15:11:10 -0800 | [diff] [blame] | 204 | class NullSink : public Sink { |
| 205 | public: |
| 206 | NullSink() {} |
| 207 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 208 | Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override; |
| 209 | int enclave() const override { return kAnyThread_Enclave; } |
| 210 | const char* fileExtension() const override { return ""; } |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 211 | SinkFlags flags() const override { return SinkFlags{ SinkFlags::kNull, SinkFlags::kDirect }; } |
mtklein | ad66f9b | 2015-02-13 15:11:10 -0800 | [diff] [blame] | 212 | }; |
| 213 | |
| 214 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 215 | class GPUSink : public Sink { |
| 216 | public: |
kkinnunen | 5219fd9 | 2015-12-10 06:28:13 -0800 | [diff] [blame] | 217 | GPUSink(GrContextFactory::GLContextType, GrContextFactory::GLContextOptions, |
kkinnunen | c8b4336 | 2015-12-18 03:27:32 -0800 | [diff] [blame^] | 218 | int samples, bool diText, bool threaded); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 219 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 220 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
| 221 | int enclave() const override; |
| 222 | const char* fileExtension() const override { return "png"; } |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 223 | SinkFlags flags() const override { return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect }; } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 224 | private: |
kkinnunen | 5219fd9 | 2015-12-10 06:28:13 -0800 | [diff] [blame] | 225 | GrContextFactory::GLContextType fContextType; |
| 226 | GrContextFactory::GLContextOptions fContextOptions; |
kkinnunen | 5219fd9 | 2015-12-10 06:28:13 -0800 | [diff] [blame] | 227 | int fSampleCount; |
| 228 | bool fUseDIText; |
| 229 | bool fThreaded; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 230 | }; |
| 231 | |
| 232 | class PDFSink : public Sink { |
| 233 | public: |
halcanary | c11c62f | 2015-09-28 11:51:54 -0700 | [diff] [blame] | 234 | PDFSink(const char* rasterizer); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 235 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 236 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
| 237 | int enclave() const override { return kAnyThread_Enclave; } |
| 238 | const char* fileExtension() const override { return "pdf"; } |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 239 | SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } |
halcanary | c11c62f | 2015-09-28 11:51:54 -0700 | [diff] [blame] | 240 | private: |
| 241 | const char* fRasterizer; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 242 | }; |
| 243 | |
halcanary | 47ef4d5 | 2015-03-03 09:13:09 -0800 | [diff] [blame] | 244 | class XPSSink : public Sink { |
| 245 | public: |
| 246 | XPSSink(); |
| 247 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 248 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
| 249 | int enclave() const override { return kAnyThread_Enclave; } |
| 250 | const char* fileExtension() const override { return "xps"; } |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 251 | SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } |
halcanary | 47ef4d5 | 2015-03-03 09:13:09 -0800 | [diff] [blame] | 252 | }; |
| 253 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 254 | class RasterSink : public Sink { |
| 255 | public: |
| 256 | explicit RasterSink(SkColorType); |
| 257 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 258 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
| 259 | int enclave() const override { return kAnyThread_Enclave; } |
| 260 | const char* fileExtension() const override { return "png"; } |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 261 | SinkFlags flags() const override { return SinkFlags{ SinkFlags::kRaster, SinkFlags::kDirect }; } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 262 | private: |
| 263 | SkColorType fColorType; |
| 264 | }; |
| 265 | |
mtklein | 9c3f17d | 2015-01-28 11:35:18 -0800 | [diff] [blame] | 266 | class SKPSink : public Sink { |
| 267 | public: |
| 268 | SKPSink(); |
| 269 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 270 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
| 271 | int enclave() const override { return kAnyThread_Enclave; } |
| 272 | const char* fileExtension() const override { return "skp"; } |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 273 | SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } |
mtklein | 9c3f17d | 2015-01-28 11:35:18 -0800 | [diff] [blame] | 274 | }; |
| 275 | |
mtklein | 8a4527e | 2015-01-31 20:00:58 -0800 | [diff] [blame] | 276 | class SVGSink : public Sink { |
| 277 | public: |
| 278 | SVGSink(); |
| 279 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 280 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
| 281 | int enclave() const override { return kAnyThread_Enclave; } |
| 282 | const char* fileExtension() const override { return "svg"; } |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 283 | SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } |
mtklein | 8a4527e | 2015-01-31 20:00:58 -0800 | [diff] [blame] | 284 | }; |
| 285 | |
| 286 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 287 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 288 | |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 289 | class Via : public Sink { |
| 290 | public: |
msarett | 62d3b10 | 2015-12-10 15:14:27 -0800 | [diff] [blame] | 291 | explicit Via(Sink* sink) : fSink(sink) {} |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 292 | const char* fileExtension() const override { return fSink->fileExtension(); } |
| 293 | int enclave() const override { return fSink->enclave(); } |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame] | 294 | SinkFlags flags() const override { |
| 295 | SinkFlags flags = fSink->flags(); |
| 296 | flags.approach = SinkFlags::kIndirect; |
| 297 | return flags; |
| 298 | } |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 299 | protected: |
| 300 | SkAutoTDelete<Sink> fSink; |
| 301 | }; |
| 302 | |
| 303 | class ViaMatrix : public Via { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 304 | public: |
msarett | 62d3b10 | 2015-12-10 15:14:27 -0800 | [diff] [blame] | 305 | ViaMatrix(SkMatrix, Sink*); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 306 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 307 | private: |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 308 | const SkMatrix fMatrix; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 309 | }; |
| 310 | |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 311 | class ViaUpright : public Via { |
mtklein | d603b22 | 2015-02-17 11:13:33 -0800 | [diff] [blame] | 312 | public: |
msarett | 62d3b10 | 2015-12-10 15:14:27 -0800 | [diff] [blame] | 313 | ViaUpright(SkMatrix, Sink*); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 314 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
mtklein | d603b22 | 2015-02-17 11:13:33 -0800 | [diff] [blame] | 315 | private: |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 316 | const SkMatrix fMatrix; |
mtklein | d603b22 | 2015-02-17 11:13:33 -0800 | [diff] [blame] | 317 | }; |
| 318 | |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 319 | class ViaPipe : public Via { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 320 | public: |
msarett | 62d3b10 | 2015-12-10 15:14:27 -0800 | [diff] [blame] | 321 | explicit ViaPipe(Sink* sink) : Via(sink) {} |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 322 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 323 | }; |
| 324 | |
mtklein | 2e2ea38 | 2015-10-16 10:29:41 -0700 | [diff] [blame] | 325 | class ViaRemote : public Via { |
reed | 06a22f6 | 2015-05-05 08:11:33 -0700 | [diff] [blame] | 326 | public: |
msarett | 62d3b10 | 2015-12-10 15:14:27 -0800 | [diff] [blame] | 327 | ViaRemote(bool cache, Sink* sink) : Via(sink), fCache(cache) {} |
reed | 06a22f6 | 2015-05-05 08:11:33 -0700 | [diff] [blame] | 328 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
mtklein | 2e2ea38 | 2015-10-16 10:29:41 -0700 | [diff] [blame] | 329 | private: |
| 330 | bool fCache; |
reed | 06a22f6 | 2015-05-05 08:11:33 -0700 | [diff] [blame] | 331 | }; |
| 332 | |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 333 | class ViaSerialization : public Via { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 334 | public: |
msarett | 62d3b10 | 2015-12-10 15:14:27 -0800 | [diff] [blame] | 335 | explicit ViaSerialization(Sink* sink) : Via(sink) {} |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 336 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 337 | }; |
| 338 | |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 339 | class ViaTiles : public Via { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 340 | public: |
msarett | 62d3b10 | 2015-12-10 15:14:27 -0800 | [diff] [blame] | 341 | ViaTiles(int w, int h, SkBBHFactory*, Sink*); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 342 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 343 | private: |
| 344 | const int fW, fH; |
| 345 | SkAutoTDelete<SkBBHFactory> fFactory; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 346 | }; |
| 347 | |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 348 | class ViaSecondPicture : public Via { |
mtklein | b7e8d69 | 2015-04-07 08:30:32 -0700 | [diff] [blame] | 349 | public: |
msarett | 62d3b10 | 2015-12-10 15:14:27 -0800 | [diff] [blame] | 350 | explicit ViaSecondPicture(Sink* sink) : Via(sink) {} |
mtklein | b7e8d69 | 2015-04-07 08:30:32 -0700 | [diff] [blame] | 351 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
mtklein | b7e8d69 | 2015-04-07 08:30:32 -0700 | [diff] [blame] | 352 | }; |
| 353 | |
mtklein | 7882924 | 2015-05-06 07:54:07 -0700 | [diff] [blame] | 354 | class ViaSingletonPictures : public Via { |
mtklein | d31c13d | 2015-05-05 12:59:56 -0700 | [diff] [blame] | 355 | public: |
msarett | 62d3b10 | 2015-12-10 15:14:27 -0800 | [diff] [blame] | 356 | explicit ViaSingletonPictures(Sink* sink) : Via(sink) {} |
mtklein | d31c13d | 2015-05-05 12:59:56 -0700 | [diff] [blame] | 357 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
mtklein | d31c13d | 2015-05-05 12:59:56 -0700 | [diff] [blame] | 358 | }; |
| 359 | |
mtklein | 6fbf4b3 | 2015-05-06 11:35:40 -0700 | [diff] [blame] | 360 | class ViaTwice : public Via { |
| 361 | public: |
msarett | 62d3b10 | 2015-12-10 15:14:27 -0800 | [diff] [blame] | 362 | explicit ViaTwice(Sink* sink) : Via(sink) {} |
mtklein | 6fbf4b3 | 2015-05-06 11:35:40 -0700 | [diff] [blame] | 363 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
| 364 | }; |
| 365 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 366 | } // namespace DM |
| 367 | |
| 368 | #endif//DMSrcSink_DEFINED |