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

Side by Side Diff: dm/DMSrcSink.h

Issue 1263113002: DM: track a direct/indirect bit for each Sink too. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 }; 56 struct SinkFlags {
57 enum { kNull, kGPU, kVector, kRaster } type;
58 enum { kDirect, kIndirect } approach;
59 };
57 60
58 struct Src { 61 struct Src {
59 // All Srcs must be thread safe. 62 // All Srcs must be thread safe.
60 virtual ~Src() {} 63 virtual ~Src() {}
61 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0; 64 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0;
62 virtual SkISize size() const = 0; 65 virtual SkISize size() const = 0;
63 virtual Name name() const = 0; 66 virtual Name name() const = 0;
64 virtual void modifyGrContextOptions(GrContextOptions* options) const {} 67 virtual void modifyGrContextOptions(GrContextOptions* options) const {}
65 virtual bool veto(SinkType) const { return false; } 68 virtual bool veto(SinkFlags) const { return false; }
66 }; 69 };
67 70
68 struct Sink { 71 struct Sink {
69 virtual ~Sink() {} 72 virtual ~Sink() {}
70 // You may write to either the bitmap or stream. If you write to log, we'll print that out. 73 // You may write to either the bitmap or stream. If you write to log, we'll print that out.
71 virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log) 74 virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log)
72 const = 0; 75 const = 0;
73 // Sinks in the same enclave (except kAnyThread_Enclave) will run serially o n the same thread. 76 // Sinks in the same enclave (except kAnyThread_Enclave) will run serially o n the same thread.
74 virtual int enclave() const = 0; 77 virtual int enclave() const = 0;
75 78
76 // File extension for the content draw() outputs, e.g. "png", "pdf". 79 // File extension for the content draw() outputs, e.g. "png", "pdf".
77 virtual const char* fileExtension() const = 0; 80 virtual const char* fileExtension() const = 0;
81
82 virtual SinkFlags flags() const = 0;
78 }; 83 };
79 84
80 enum { kAnyThread_Enclave, kGPU_Enclave }; 85 enum { kAnyThread_Enclave, kGPU_Enclave };
81 static const int kNumEnclaves = kGPU_Enclave + 1; 86 static const int kNumEnclaves = kGPU_Enclave + 1;
82 87
83 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 88 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
84 89
85 class GMSrc : public Src { 90 class GMSrc : public Src {
86 public: 91 public:
87 explicit GMSrc(skiagm::GMRegistry::Factory); 92 explicit GMSrc(skiagm::GMRegistry::Factory);
(...skipping 19 matching lines...) Expand all
107 enum DstColorType { 112 enum DstColorType {
108 kGetFromCanvas_DstColorType, 113 kGetFromCanvas_DstColorType,
109 kIndex8_Always_DstColorType, 114 kIndex8_Always_DstColorType,
110 kGrayscale_Always_DstColorType, 115 kGrayscale_Always_DstColorType,
111 }; 116 };
112 CodecSrc(Path, Mode, DstColorType, float); 117 CodecSrc(Path, Mode, DstColorType, float);
113 118
114 Error draw(SkCanvas*) const override; 119 Error draw(SkCanvas*) const override;
115 SkISize size() const override; 120 SkISize size() const override;
116 Name name() const override; 121 Name name() const override;
117 bool veto(SinkType) const override; 122 bool veto(SinkFlags) const override;
118 private: 123 private:
119 Path fPath; 124 Path fPath;
120 Mode fMode; 125 Mode fMode;
121 DstColorType fDstColorType; 126 DstColorType fDstColorType;
122 float fScale; 127 float fScale;
123 }; 128 };
124 129
125 130
126 class ImageSrc : public Src { 131 class ImageSrc : public Src {
127 public: 132 public:
128 // divisor == 0 means decode the whole image 133 // divisor == 0 means decode the whole image
129 // divisor > 0 means decode in subsets, dividing into a divisor x divisor gr id. 134 // divisor > 0 means decode in subsets, dividing into a divisor x divisor gr id.
130 explicit ImageSrc(Path path, int divisor = 0); 135 explicit ImageSrc(Path path, int divisor = 0);
131 136
132 Error draw(SkCanvas*) const override; 137 Error draw(SkCanvas*) const override;
133 SkISize size() const override; 138 SkISize size() const override;
134 Name name() const override; 139 Name name() const override;
135 bool veto(SinkType) const override; 140 bool veto(SinkFlags) const override;
136 private: 141 private:
137 Path fPath; 142 Path fPath;
138 const int fDivisor; 143 const int fDivisor;
139 }; 144 };
140 145
141 class SKPSrc : public Src { 146 class SKPSrc : public Src {
142 public: 147 public:
143 explicit SKPSrc(Path path); 148 explicit SKPSrc(Path path);
144 149
145 Error draw(SkCanvas*) const override; 150 Error draw(SkCanvas*) const override;
146 SkISize size() const override; 151 SkISize size() const override;
147 Name name() const override; 152 Name name() const override;
148 private: 153 private:
149 Path fPath; 154 Path fPath;
150 }; 155 };
151 156
152 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 157 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
153 158
154 class NullSink : public Sink { 159 class NullSink : public Sink {
155 public: 160 public:
156 NullSink() {} 161 NullSink() {}
157 162
158 Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override; 163 Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override;
159 int enclave() const override { return kAnyThread_Enclave; } 164 int enclave() const override { return kAnyThread_Enclave; }
160 const char* fileExtension() const override { return ""; } 165 const char* fileExtension() const override { return ""; }
166 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kNull, SinkF lags::kDirect }; }
161 }; 167 };
162 168
163 169
164 class GPUSink : public Sink { 170 class GPUSink : public Sink {
165 public: 171 public:
166 GPUSink(GrContextFactory::GLContextType, GrGLStandard, int samples, bool dfT ext, bool threaded); 172 GPUSink(GrContextFactory::GLContextType, GrGLStandard, int samples, bool dfT ext, bool threaded);
167 173
168 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 174 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
169 int enclave() const override; 175 int enclave() const override;
170 const char* fileExtension() const override { return "png"; } 176 const char* fileExtension() const override { return "png"; }
177 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kGPU, SinkFl ags::kDirect }; }
171 private: 178 private:
172 GrContextFactory::GLContextType fContextType; 179 GrContextFactory::GLContextType fContextType;
173 GrGLStandard fGpuAPI; 180 GrGLStandard fGpuAPI;
174 int fSampleCount; 181 int fSampleCount;
175 bool fUseDFText; 182 bool fUseDFText;
176 bool fThreaded; 183 bool fThreaded;
177 }; 184 };
178 185
179 class PDFSink : public Sink { 186 class PDFSink : public Sink {
180 public: 187 public:
181 PDFSink(); 188 PDFSink();
182 189
183 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 190 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
184 int enclave() const override { return kAnyThread_Enclave; } 191 int enclave() const override { return kAnyThread_Enclave; }
185 const char* fileExtension() const override { return "pdf"; } 192 const char* fileExtension() const override { return "pdf"; }
193 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, Sin kFlags::kDirect }; }
186 }; 194 };
187 195
188 class XPSSink : public Sink { 196 class XPSSink : public Sink {
189 public: 197 public:
190 XPSSink(); 198 XPSSink();
191 199
192 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 200 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
193 int enclave() const override { return kAnyThread_Enclave; } 201 int enclave() const override { return kAnyThread_Enclave; }
194 const char* fileExtension() const override { return "xps"; } 202 const char* fileExtension() const override { return "xps"; }
203 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, Sin kFlags::kDirect }; }
195 }; 204 };
196 205
197 class RasterSink : public Sink { 206 class RasterSink : public Sink {
198 public: 207 public:
199 explicit RasterSink(SkColorType); 208 explicit RasterSink(SkColorType);
200 209
201 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 210 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
202 int enclave() const override { return kAnyThread_Enclave; } 211 int enclave() const override { return kAnyThread_Enclave; }
203 const char* fileExtension() const override { return "png"; } 212 const char* fileExtension() const override { return "png"; }
213 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kRaster, Sin kFlags::kDirect }; }
204 private: 214 private:
205 SkColorType fColorType; 215 SkColorType fColorType;
206 }; 216 };
207 217
208 class SKPSink : public Sink { 218 class SKPSink : public Sink {
209 public: 219 public:
210 SKPSink(); 220 SKPSink();
211 221
212 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 222 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
213 int enclave() const override { return kAnyThread_Enclave; } 223 int enclave() const override { return kAnyThread_Enclave; }
214 const char* fileExtension() const override { return "skp"; } 224 const char* fileExtension() const override { return "skp"; }
225 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, Sin kFlags::kDirect }; }
215 }; 226 };
216 227
217 class SVGSink : public Sink { 228 class SVGSink : public Sink {
218 public: 229 public:
219 SVGSink(); 230 SVGSink();
220 231
221 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 232 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
222 int enclave() const override { return kAnyThread_Enclave; } 233 int enclave() const override { return kAnyThread_Enclave; }
223 const char* fileExtension() const override { return "svg"; } 234 const char* fileExtension() const override { return "svg"; }
235 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, Sin kFlags::kDirect }; }
224 }; 236 };
225 237
226 238
227 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 239 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
228 240
229 class Via : public Sink { 241 class Via : public Sink {
230 public: 242 public:
231 explicit Via(Sink* sink) : fSink(sink) {} 243 explicit Via(Sink* sink) : fSink(sink) {}
232 const char* fileExtension() const override { return fSink->fileExtension(); } 244 const char* fileExtension() const override { return fSink->fileExtension(); }
233 int enclave() const override { return fSink->enclave(); } 245 int enclave() const override { return fSink->enclave(); }
246 SinkFlags flags() const override {
247 SinkFlags flags = fSink->flags();
248 flags.approach = SinkFlags::kIndirect;
249 return flags;
250 }
234 protected: 251 protected:
235 SkAutoTDelete<Sink> fSink; 252 SkAutoTDelete<Sink> fSink;
236 }; 253 };
237 254
238 class ViaMatrix : public Via { 255 class ViaMatrix : public Via {
239 public: 256 public:
240 ViaMatrix(SkMatrix, Sink*); 257 ViaMatrix(SkMatrix, Sink*);
241 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 258 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
242 private: 259 private:
243 const SkMatrix fMatrix; 260 const SkMatrix fMatrix;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 309
293 class ViaTwice : public Via { 310 class ViaTwice : public Via {
294 public: 311 public:
295 explicit ViaTwice(Sink* sink) : Via(sink) {} 312 explicit ViaTwice(Sink* sink) : Via(sink) {}
296 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 313 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
297 }; 314 };
298 315
299 } // namespace DM 316 } // namespace DM
300 317
301 #endif//DMSrcSink_DEFINED 318 #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