| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 238 |
| 233 Error draw(SkCanvas*) const override; | 239 Error draw(SkCanvas*) const override; |
| 234 SkISize size() const override; | 240 SkISize size() const override; |
| 235 Name name() const override; | 241 Name name() const override; |
| 236 private: | 242 private: |
| 237 Path fPath; | 243 Path fPath; |
| 238 }; | 244 }; |
| 239 | 245 |
| 240 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 246 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 241 | 247 |
| 248 class MSKPSrc : public Src { |
| 249 public: |
| 250 explicit MSKPSrc(Path path); |
| 251 |
| 252 int pageCount() const override; |
| 253 Error draw(SkCanvas* c) const override; |
| 254 Error draw(int, SkCanvas*) const override; |
| 255 SkISize size() const override; |
| 256 SkISize size(int) const override; |
| 257 Name name() const override; |
| 258 |
| 259 private: |
| 260 Path fPath; |
| 261 SkMultiPictureDocumentReader fReader; |
| 262 }; |
| 263 |
| 264 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 265 |
| 242 class NullSink : public Sink { | 266 class NullSink : public Sink { |
| 243 public: | 267 public: |
| 244 NullSink() {} | 268 NullSink() {} |
| 245 | 269 |
| 246 Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override; | 270 Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override; |
| 247 const char* fileExtension() const override { return ""; } | 271 const char* fileExtension() const override { return ""; } |
| 248 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kNull, SinkF
lags::kDirect }; } | 272 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kNull, SinkF
lags::kDirect }; } |
| 249 }; | 273 }; |
| 250 | 274 |
| 251 | 275 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 416 |
| 393 class ViaMojo : public Via { | 417 class ViaMojo : public Via { |
| 394 public: | 418 public: |
| 395 explicit ViaMojo(Sink* sink) : Via(sink) {} | 419 explicit ViaMojo(Sink* sink) : Via(sink) {} |
| 396 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; | 420 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
| 397 }; | 421 }; |
| 398 | 422 |
| 399 } // namespace DM | 423 } // namespace DM |
| 400 | 424 |
| 401 #endif//DMSrcSink_DEFINED | 425 #endif//DMSrcSink_DEFINED |
| OLD | NEW |