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

Side by Side Diff: tools/debugger/SkOverdrawMode.cpp

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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 | « tests/TessellatingPathRendererTests.cpp ('k') | no next file » | 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 2016 Google Inc. 2 * Copyright 2016 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 #include "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkOverdrawMode.h" 9 #include "SkOverdrawMode.h"
10 #include "SkString.h" 10 #include "SkString.h"
11 #include "SkXfermode.h" 11 #include "SkXfermode.h"
12 12
13 #if SK_SUPPORT_GPU 13 #if SK_SUPPORT_GPU
14 #include "GrFragmentProcessor.h" 14 #include "GrFragmentProcessor.h"
15 #include "GrInvariantOutput.h" 15 #include "GrInvariantOutput.h"
16 #include "GrXferProcessor.h" 16 #include "GrXferProcessor.h"
17 #include "glsl/GrGLSLFragmentProcessor.h" 17 #include "glsl/GrGLSLFragmentProcessor.h"
18 #include "glsl/GrGLSLFragmentShaderBuilder.h" 18 #include "glsl/GrGLSLFragmentShaderBuilder.h"
19 #include "glsl/GrGLSLXferProcessor.h" 19 #include "glsl/GrGLSLXferProcessor.h"
20 20
21 /////////////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////////////
22 // Fragment Processor 22 // Fragment Processor
23 /////////////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////////////
24 24
25 class GLOverdrawFP; 25 class GLOverdrawFP;
26 26
27 class GrOverdrawFP : public GrFragmentProcessor { 27 class GrOverdrawFP : public GrFragmentProcessor {
28 public: 28 public:
29 static const GrFragmentProcessor* Create(const GrFragmentProcessor* dst) { 29 static sk_sp<GrFragmentProcessor> Make(sk_sp<GrFragmentProcessor> dst) {
30 return new GrOverdrawFP(dst); 30 return sk_sp<GrFragmentProcessor>(new GrOverdrawFP(std::move(dst)));
31 } 31 }
32 32
33 ~GrOverdrawFP() override { } 33 ~GrOverdrawFP() override { }
34 34
35 const char* name() const override { return "Overdraw"; } 35 const char* name() const override { return "Overdraw"; }
36 36
37 SkString dumpInfo() const override { 37 SkString dumpInfo() const override {
38 SkString str; 38 SkString str;
39 return str; 39 return str;
40 } 40 }
41 41
42 private: 42 private:
43 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; 43 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
44 44
45 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) cons t override; 45 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) cons t override;
46 46
47 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } 47 bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
48 48
49 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { 49 void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
50 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); 50 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
51 } 51 }
52 52
53 GrOverdrawFP(const GrFragmentProcessor* dst) { 53 GrOverdrawFP(sk_sp<GrFragmentProcessor> dst) {
54 this->initClassID<GrOverdrawFP>(); 54 this->initClassID<GrOverdrawFP>();
55 55
56 SkASSERT(dst); 56 SkASSERT(dst);
57 SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst); 57 SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(std::move(dst)) ;
58 SkASSERT(0 == dstIndex); 58 SkASSERT(0 == dstIndex);
59 } 59 }
60 60
61 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 61 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
62 typedef GrFragmentProcessor INHERITED; 62 typedef GrFragmentProcessor INHERITED;
63 }; 63 };
64 64
65 /////////////////////////////////////////////////////////////////////////////// 65 ///////////////////////////////////////////////////////////////////////////////
66 66
67 static void add_overdraw_code(GrGLSLFragmentBuilder* fragBuilder, 67 static void add_overdraw_code(GrGLSLFragmentBuilder* fragBuilder,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 /////////////////////////////////////////////////////////////////////////////// 122 ///////////////////////////////////////////////////////////////////////////////
123 123
124 GrGLSLFragmentProcessor* GrOverdrawFP::onCreateGLSLInstance() const { 124 GrGLSLFragmentProcessor* GrOverdrawFP::onCreateGLSLInstance() const {
125 return new GLOverdrawFP; 125 return new GLOverdrawFP;
126 } 126 }
127 127
128 void GrOverdrawFP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB uilder* b) const { 128 void GrOverdrawFP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB uilder* b) const {
129 GLOverdrawFP::GenKey(*this, caps, b); 129 GLOverdrawFP::GenKey(*this, caps, b);
130 } 130 }
131 131
132 const GrFragmentProcessor* GrOverdrawFP::TestCreate(GrProcessorTestData* d) { 132 sk_sp<GrFragmentProcessor> GrOverdrawFP::TestCreate(GrProcessorTestData* d) {
133 SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChild FP(d)); 133 return GrOverdrawFP::Make(GrProcessorUnitTest::MakeChildFP(d));
134 return new GrOverdrawFP(dst);
135 } 134 }
136 135
137 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrOverdrawFP); 136 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrOverdrawFP);
138 137
139 /////////////////////////////////////////////////////////////////////////////// 138 ///////////////////////////////////////////////////////////////////////////////
140 // Xfer Processor 139 // Xfer Processor
141 /////////////////////////////////////////////////////////////////////////////// 140 ///////////////////////////////////////////////////////////////////////////////
142 141
143 class OverdrawXP : public GrXferProcessor { 142 class OverdrawXP : public GrXferProcessor {
144 public: 143 public:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 201
203 void OverdrawXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui lder* b) const { 202 void OverdrawXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui lder* b) const {
204 GLOverdrawXP::GenKey(*this, caps, b); 203 GLOverdrawXP::GenKey(*this, caps, b);
205 } 204 }
206 205
207 GrGLSLXferProcessor* OverdrawXP::createGLSLInstance() const { return new GLOverd rawXP(*this); } 206 GrGLSLXferProcessor* OverdrawXP::createGLSLInstance() const { return new GLOverd rawXP(*this); }
208 207
209 /////////////////////////////////////////////////////////////////////////////// 208 ///////////////////////////////////////////////////////////////////////////////
210 class GrOverdrawXPFactory : public GrXPFactory { 209 class GrOverdrawXPFactory : public GrXPFactory {
211 public: 210 public:
212 static GrXPFactory* Create() { return new GrOverdrawXPFactory(); } 211 static sk_sp<GrXPFactory> Make() { return sk_sp<GrXPFactory>(new GrOverdrawX PFactory()); }
213 212
214 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, 213 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
215 GrXPFactory::InvariantBlendedColor* blendedCol or) const override { 214 GrXPFactory::InvariantBlendedColor* blendedCol or) const override {
216 blendedColor->fWillBlendWithDst = true; 215 blendedColor->fWillBlendWithDst = true;
217 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; 216 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags;
218 } 217 }
219 218
220 private: 219 private:
221 GrOverdrawXPFactory() { 220 GrOverdrawXPFactory() {
222 this->initClassID<GrOverdrawXPFactory>(); 221 this->initClassID<GrOverdrawXPFactory>();
(...skipping 12 matching lines...) Expand all
235 234
236 bool onIsEqual(const GrXPFactory& xpfBase) const override { return true; } 235 bool onIsEqual(const GrXPFactory& xpfBase) const override { return true; }
237 236
238 GR_DECLARE_XP_FACTORY_TEST; 237 GR_DECLARE_XP_FACTORY_TEST;
239 238
240 typedef GrXPFactory INHERITED; 239 typedef GrXPFactory INHERITED;
241 }; 240 };
242 241
243 GR_DEFINE_XP_FACTORY_TEST(GrOverdrawXPFactory); 242 GR_DEFINE_XP_FACTORY_TEST(GrOverdrawXPFactory);
244 243
245 const GrXPFactory* GrOverdrawXPFactory::TestCreate(GrProcessorTestData* d) { 244 sk_sp<GrXPFactory> GrOverdrawXPFactory::TestCreate(GrProcessorTestData* d) {
246 return GrOverdrawXPFactory::Create(); 245 return GrOverdrawXPFactory::Make();
247 } 246 }
248 #endif 247 #endif
249 248
250 /////////////////////////////////////////////////////////////////////////////// 249 ///////////////////////////////////////////////////////////////////////////////
251 class SkOverdrawXfermode : public SkXfermode { 250 class SkOverdrawXfermode : public SkXfermode {
252 public: 251 public:
253 static SkXfermode* Create() { 252 static SkXfermode* Create() {
254 return new SkOverdrawXfermode; 253 return new SkOverdrawXfermode;
255 } 254 }
256 255
(...skipping 25 matching lines...) Expand all
282 nextIdx = 11 - (SkColorGetG(dst)+22)/45; 281 nextIdx = 11 - (SkColorGetG(dst)+22)/45;
283 } 282 }
284 SkASSERT(nextIdx < (int)SK_ARRAY_COUNT(gTable)); 283 SkASSERT(nextIdx < (int)SK_ARRAY_COUNT(gTable));
285 284
286 return gTable[nextIdx]; 285 return gTable[nextIdx];
287 } 286 }
288 287
289 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOverdrawXfermode) 288 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOverdrawXfermode)
290 289
291 #if SK_SUPPORT_GPU 290 #if SK_SUPPORT_GPU
292 const GrFragmentProcessor* getFragmentProcessorForImageFilter( 291 sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
293 const GrFragmentProcessor* dst) const override { 292 sk_sp<GrFragmentProcessor> dst) const override {
294 return GrOverdrawFP::Create(dst); 293 return GrOverdrawFP::Make(dst);
295 } 294 }
296 295
297 GrXPFactory* asXPFactory() const override { 296 sk_sp<GrXPFactory> asXPFactory() const override {
298 return GrOverdrawXPFactory::Create(); 297 return GrOverdrawXPFactory::Make();
299 } 298 }
300 #endif 299 #endif
301 300
302 #ifndef SK_IGNORE_TO_STRING 301 #ifndef SK_IGNORE_TO_STRING
303 void toString(SkString* str) const override { str->set("SkOverdrawXfermode") ; } 302 void toString(SkString* str) const override { str->set("SkOverdrawXfermode") ; }
304 #endif 303 #endif
305 304
306 private: 305 private:
307 friend class SkOverdrawMode; 306 friend class SkOverdrawMode;
308 307
309 void flatten(SkWriteBuffer& buffer) const override { } 308 void flatten(SkWriteBuffer& buffer) const override { }
310 309
311 typedef SkXfermode INHERITED; 310 typedef SkXfermode INHERITED;
312 }; 311 };
313 312
314 sk_sp<SkFlattenable> SkOverdrawXfermode::CreateProc(SkReadBuffer& buffer) { 313 sk_sp<SkFlattenable> SkOverdrawXfermode::CreateProc(SkReadBuffer& buffer) {
315 return sk_sp<SkFlattenable>(Create()); 314 return sk_sp<SkFlattenable>(Create());
316 } 315 }
317 316
318 sk_sp<SkXfermode> SkOverdrawMode::Make() { return sk_make_sp<SkOverdrawXfermode> (); } 317 sk_sp<SkXfermode> SkOverdrawMode::Make() { return sk_make_sp<SkOverdrawXfermode> (); }
319 318
320 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkOverdrawMode) 319 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkOverdrawMode)
321 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOverdrawXfermode) 320 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOverdrawXfermode)
322 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 321 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « tests/TessellatingPathRendererTests.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698