OLD | NEW |
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 "SkBitmapRegionDecoder.h" |
16 #include "SkCanvas.h" | 16 #include "SkCanvas.h" |
17 #include "SkData.h" | 17 #include "SkData.h" |
| 18 #include "SkMultiPictureDocumentReader.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 { |
25 template <typename T> | 26 template <typename T> |
26 ImplicitString(const T& s) : SkString(s) {} | 27 ImplicitString(const T& s) : SkString(s) {} |
27 ImplicitString() : SkString("") {} | 28 ImplicitString() : SkString("") {} |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 }; | 60 }; |
60 | 61 |
61 struct Src { | 62 struct Src { |
62 virtual ~Src() {} | 63 virtual ~Src() {} |
63 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0; | 64 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0; |
64 virtual SkISize size() const = 0; | 65 virtual SkISize size() const = 0; |
65 virtual Name name() const = 0; | 66 virtual Name name() const = 0; |
66 virtual void modifyGrContextOptions(GrContextOptions* options) const {} | 67 virtual void modifyGrContextOptions(GrContextOptions* options) const {} |
67 virtual bool veto(SinkFlags) const { return false; } | 68 virtual bool veto(SinkFlags) const { return false; } |
68 | 69 |
| 70 virtual int pageCount() const { return 1; } |
| 71 virtual Error SK_WARN_UNUSED_RESULT draw(int, SkCanvas* canvas) const { |
| 72 return this->draw(canvas); |
| 73 } |
| 74 virtual SkISize size(int) const { return this->size(); } |
69 // Force Tasks using this Src to run on the main thread? | 75 // Force Tasks using this Src to run on the main thread? |
70 virtual bool serial() const { return false; } | 76 virtual bool serial() const { return false; } |
71 }; | 77 }; |
72 | 78 |
73 struct Sink { | 79 struct Sink { |
74 virtual ~Sink() {} | 80 virtual ~Sink() {} |
75 // You may write to either the bitmap or stream. If you write to log, we'll
print that out. | 81 // You may write to either the bitmap or stream. If you write to log, we'll
print that out. |
76 virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*,
SkString* log) | 82 virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*,
SkString* log) |
77 const = 0; | 83 const = 0; |
78 | 84 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 242 |
237 Error draw(SkCanvas*) const override; | 243 Error draw(SkCanvas*) const override; |
238 SkISize size() const override; | 244 SkISize size() const override; |
239 Name name() const override; | 245 Name name() const override; |
240 private: | 246 private: |
241 Path fPath; | 247 Path fPath; |
242 }; | 248 }; |
243 | 249 |
244 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 250 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
245 | 251 |
| 252 class MSKPSrc : public Src { |
| 253 public: |
| 254 explicit MSKPSrc(Path path); |
| 255 |
| 256 int pageCount() const override; |
| 257 Error draw(SkCanvas* c) const override; |
| 258 Error draw(int, SkCanvas*) const override; |
| 259 SkISize size() const override; |
| 260 SkISize size(int) const override; |
| 261 Name name() const override; |
| 262 |
| 263 private: |
| 264 Path fPath; |
| 265 SkMultiPictureDocumentReader fReader; |
| 266 }; |
| 267 |
| 268 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 269 |
246 class NullSink : public Sink { | 270 class NullSink : public Sink { |
247 public: | 271 public: |
248 NullSink() {} | 272 NullSink() {} |
249 | 273 |
250 Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override; | 274 Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override; |
251 const char* fileExtension() const override { return ""; } | 275 const char* fileExtension() const override { return ""; } |
252 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kNull, SinkF
lags::kDirect }; } | 276 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kNull, SinkF
lags::kDirect }; } |
253 }; | 277 }; |
254 | 278 |
255 | 279 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 420 |
397 class ViaMojo : public Via { | 421 class ViaMojo : public Via { |
398 public: | 422 public: |
399 explicit ViaMojo(Sink* sink) : Via(sink) {} | 423 explicit ViaMojo(Sink* sink) : Via(sink) {} |
400 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; | 424 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
401 }; | 425 }; |
402 | 426 |
403 } // namespace DM | 427 } // namespace DM |
404 | 428 |
405 #endif//DMSrcSink_DEFINED | 429 #endif//DMSrcSink_DEFINED |
OLD | NEW |