Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: dm/DMSrcSink.h

Issue 1239953004: Allow Srcs to veto Sinks based on their broad type. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: scroggo Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dm/DM.cpp ('k') | dm/DMSrcSink.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 const char* c_str() const { return fMsg.c_str(); } 47 const char* c_str() const { return fMsg.c_str(); }
48 bool isEmpty() const { return fMsg.isEmpty(); } 48 bool isEmpty() const { return fMsg.isEmpty(); }
49 bool isFatal() const { return fFatal; } 49 bool isFatal() const { return fFatal; }
50 50
51 private: 51 private:
52 SkString fMsg; 52 SkString fMsg;
53 bool fFatal; 53 bool fFatal;
54 }; 54 };
55 55
56 enum SinkType { kGPU_SinkType, kVector_SinkType, kRaster_SinkType };
57
56 struct Src { 58 struct Src {
57 // All Srcs must be thread safe. 59 // All Srcs must be thread safe.
58 virtual ~Src() {} 60 virtual ~Src() {}
59 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0; 61 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0;
60 virtual SkISize size() const = 0; 62 virtual SkISize size() const = 0;
61 virtual Name name() const = 0; 63 virtual Name name() const = 0;
62 virtual void modifyGrContextOptions(GrContextOptions* options) const {} 64 virtual void modifyGrContextOptions(GrContextOptions* options) const {}
65 virtual bool veto(SinkType) const { return false; }
63 }; 66 };
64 67
65 struct Sink { 68 struct Sink {
66 virtual ~Sink() {} 69 virtual ~Sink() {}
67 // You may write to either the bitmap or stream. If you write to log, we'll print that out. 70 // You may write to either the bitmap or stream. If you write to log, we'll print that out.
68 virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log) 71 virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log)
69 const = 0; 72 const = 0;
70 // Sinks in the same enclave (except kAnyThread_Enclave) will run serially o n the same thread. 73 // Sinks in the same enclave (except kAnyThread_Enclave) will run serially o n the same thread.
71 virtual int enclave() const = 0; 74 virtual int enclave() const = 0;
72 75
(...skipping 30 matching lines...) Expand all
103 enum DstColorType { 106 enum DstColorType {
104 kGetFromCanvas_DstColorType, 107 kGetFromCanvas_DstColorType,
105 kIndex8_Always_DstColorType, 108 kIndex8_Always_DstColorType,
106 kGrayscale_Always_DstColorType, 109 kGrayscale_Always_DstColorType,
107 }; 110 };
108 CodecSrc(Path, Mode, DstColorType, float); 111 CodecSrc(Path, Mode, DstColorType, float);
109 112
110 Error draw(SkCanvas*) const override; 113 Error draw(SkCanvas*) const override;
111 SkISize size() const override; 114 SkISize size() const override;
112 Name name() const override; 115 Name name() const override;
116 bool veto(SinkType) const override;
113 private: 117 private:
114 Path fPath; 118 Path fPath;
115 Mode fMode; 119 Mode fMode;
116 DstColorType fDstColorType; 120 DstColorType fDstColorType;
117 float fScale; 121 float fScale;
118 }; 122 };
119 123
120 124
121 class ImageSrc : public Src { 125 class ImageSrc : public Src {
122 public: 126 public:
123 // divisor == 0 means decode the whole image 127 // divisor == 0 means decode the whole image
124 // divisor > 0 means decode in subsets, dividing into a divisor x divisor gr id. 128 // divisor > 0 means decode in subsets, dividing into a divisor x divisor gr id.
125 explicit ImageSrc(Path path, int divisor = 0); 129 explicit ImageSrc(Path path, int divisor = 0);
126 130
127 Error draw(SkCanvas*) const override; 131 Error draw(SkCanvas*) const override;
128 SkISize size() const override; 132 SkISize size() const override;
129 Name name() const override; 133 Name name() const override;
134 bool veto(SinkType) const override;
130 private: 135 private:
131 Path fPath; 136 Path fPath;
132 const int fDivisor; 137 const int fDivisor;
133 }; 138 };
134 139
135 class SKPSrc : public Src { 140 class SKPSrc : public Src {
136 public: 141 public:
137 explicit SKPSrc(Path path); 142 explicit SKPSrc(Path path);
138 143
139 Error draw(SkCanvas*) const override; 144 Error draw(SkCanvas*) const override;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 291
287 class ViaTwice : public Via { 292 class ViaTwice : public Via {
288 public: 293 public:
289 explicit ViaTwice(Sink* sink) : Via(sink) {} 294 explicit ViaTwice(Sink* sink) : Via(sink) {}
290 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 295 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
291 }; 296 };
292 297
293 } // namespace DM 298 } // namespace DM
294 299
295 #endif//DMSrcSink_DEFINED 300 #endif//DMSrcSink_DEFINED
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | dm/DMSrcSink.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698