OLD | NEW |
1 #ifndef DMSrcSink_DEFINED | 1 #ifndef DMSrcSink_DEFINED |
2 #define DMSrcSink_DEFINED | 2 #define DMSrcSink_DEFINED |
3 | 3 |
4 #include "DMGpuSupport.h" | 4 #include "DMGpuSupport.h" |
5 #include "SkBBHFactory.h" | 5 #include "SkBBHFactory.h" |
6 #include "SkBBoxHierarchy.h" | 6 #include "SkBBoxHierarchy.h" |
7 #include "SkBitmap.h" | 7 #include "SkBitmap.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkGPipe.h" | 10 #include "SkGPipe.h" |
11 #include "SkPicture.h" | 11 #include "SkPicture.h" |
12 #include "gm.h" | 12 #include "gm.h" |
13 | 13 |
14 namespace DM { | 14 namespace DM { |
15 | 15 |
16 // This is just convenience. It lets you use either return "foo" or return SkSt
ringPrintf(...). | 16 // This is just convenience. It lets you use either return "foo" or return SkSt
ringPrintf(...). |
17 struct ImplicitString : public SkString { | 17 struct ImplicitString : public SkString { |
18 template <typename T> | 18 template <typename T> |
19 ImplicitString(const T& s) : SkString(s) {} | 19 ImplicitString(const T& s) : SkString(s) {} |
20 }; | 20 }; |
21 typedef ImplicitString Error; | |
22 typedef ImplicitString Name; | 21 typedef ImplicitString Name; |
23 typedef ImplicitString Path; | 22 typedef ImplicitString Path; |
24 | 23 |
| 24 class Error { |
| 25 public: |
| 26 Error(const SkString& s) : fMsg(s), fFatal(!this->isEmpty()) {} |
| 27 Error(const char* s) : fMsg(s), fFatal(!this->isEmpty()) {} |
| 28 |
| 29 Error(const Error&) = default; |
| 30 Error& operator=(const Error&) = default; |
| 31 |
| 32 static Error Nonfatal(const SkString& s) { return Nonfatal(s.c_str()); } |
| 33 static Error Nonfatal(const char* s) { |
| 34 Error e(s); |
| 35 e.fFatal = false; |
| 36 return e; |
| 37 } |
| 38 |
| 39 const char* c_str() const { return fMsg.c_str(); } |
| 40 bool isEmpty() const { return fMsg.isEmpty(); } |
| 41 bool isFatal() const { return fFatal; } |
| 42 |
| 43 private: |
| 44 SkString fMsg; |
| 45 bool fFatal; |
| 46 }; |
| 47 |
25 struct Src { | 48 struct Src { |
26 // All Srcs must be thread safe. | 49 // All Srcs must be thread safe. |
27 virtual ~Src() {} | 50 virtual ~Src() {} |
28 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0; | 51 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0; |
29 virtual SkISize size() const = 0; | 52 virtual SkISize size() const = 0; |
30 virtual Name name() const = 0; | 53 virtual Name name() const = 0; |
31 }; | 54 }; |
32 | 55 |
33 struct Sink { | 56 struct Sink { |
34 virtual ~Sink() {} | 57 virtual ~Sink() {} |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 const char* fileExtension() const SK_OVERRIDE { return fSink->fileExtension(
); } | 238 const char* fileExtension() const SK_OVERRIDE { return fSink->fileExtension(
); } |
216 private: | 239 private: |
217 const int fW, fH; | 240 const int fW, fH; |
218 SkAutoTDelete<SkBBHFactory> fFactory; | 241 SkAutoTDelete<SkBBHFactory> fFactory; |
219 SkAutoTDelete<Sink> fSink; | 242 SkAutoTDelete<Sink> fSink; |
220 }; | 243 }; |
221 | 244 |
222 } // namespace DM | 245 } // namespace DM |
223 | 246 |
224 #endif//DMSrcSink_DEFINED | 247 #endif//DMSrcSink_DEFINED |
OLD | NEW |