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

Side by Side Diff: src/gpu/effects/GrConvexPolyEffect.cpp

Issue 1266633003: Added registerChild; transforms, textures, glKey automatically handled. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: refactored to onGetGLProcessorKey; removed emitSamplers specialized template; fixed nits 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 | « src/gpu/effects/GrConvexPolyEffect.h ('k') | src/gpu/effects/GrConvolutionEffect.h » ('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 2014 Google Inc. 2 * Copyright 2014 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 "GrConvexPolyEffect.h" 8 #include "GrConvexPolyEffect.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "SkPathPriv.h" 10 #include "SkPathPriv.h"
11 #include "gl/GrGLFragmentProcessor.h" 11 #include "gl/GrGLFragmentProcessor.h"
12 #include "gl/builders/GrGLProgramBuilder.h" 12 #include "gl/builders/GrGLProgramBuilder.h"
13 13
14 ////////////////////////////////////////////////////////////////////////////// 14 //////////////////////////////////////////////////////////////////////////////
15 class AARectEffect : public GrFragmentProcessor { 15 class AARectEffect : public GrFragmentProcessor {
16 public: 16 public:
17 const SkRect& getRect() const { return fRect; } 17 const SkRect& getRect() const { return fRect; }
18 18
19 static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRec t& rect) { 19 static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRec t& rect) {
20 return SkNEW_ARGS(AARectEffect, (edgeType, rect)); 20 return SkNEW_ARGS(AARectEffect, (edgeType, rect));
21 } 21 }
22 22
23 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } 23 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
24 24
25 const char* name() const override { return "AARect"; } 25 const char* name() const override { return "AARect"; }
26 26
27 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride; 27 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
28 28
29 GrGLFragmentProcessor* createGLInstance() const override; 29 GrGLFragmentProcessor* createGLInstance() const override;
30 30
31 private: 31 private:
32 AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) 32 AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect)
33 : fRect(rect), fEdgeType(edgeType) { 33 : fRect(rect), fEdgeType(edgeType) {
34 this->initClassID<AARectEffect>(); 34 this->initClassID<AARectEffect>();
35 this->setWillReadFragmentPosition(); 35 this->setWillReadFragmentPosition();
36 } 36 }
37 37
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 fPrevRect = rect; 145 fPrevRect = rect;
146 } 146 }
147 } 147 }
148 148
149 void GLAARectEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&, 149 void GLAARectEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
150 GrProcessorKeyBuilder* b) { 150 GrProcessorKeyBuilder* b) {
151 const AARectEffect& aare = processor.cast<AARectEffect>(); 151 const AARectEffect& aare = processor.cast<AARectEffect>();
152 b->add32(aare.getEdgeType()); 152 b->add32(aare.getEdgeType());
153 } 153 }
154 154
155 void AARectEffect::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuild er* b) const { 155 void AARectEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui lder* b) const {
156 GLAARectEffect::GenKey(*this, caps, b); 156 GLAARectEffect::GenKey(*this, caps, b);
157 } 157 }
158 158
159 GrGLFragmentProcessor* AARectEffect::createGLInstance() const { 159 GrGLFragmentProcessor* AARectEffect::createGLInstance() const {
160 return SkNEW_ARGS(GLAARectEffect, (*this)); 160 return SkNEW_ARGS(GLAARectEffect, (*this));
161 } 161 }
162 162
163 ////////////////////////////////////////////////////////////////////////////// 163 //////////////////////////////////////////////////////////////////////////////
164 164
165 class GrGLConvexPolyEffect : public GrGLFragmentProcessor { 165 class GrGLConvexPolyEffect : public GrGLFragmentProcessor {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 295 }
296 return AARectEffect::Create(edgeType, rect); 296 return AARectEffect::Create(edgeType, rect);
297 } 297 }
298 298
299 GrConvexPolyEffect::~GrConvexPolyEffect() {} 299 GrConvexPolyEffect::~GrConvexPolyEffect() {}
300 300
301 void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons t { 301 void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons t {
302 inout->mulByUnknownSingleComponent(); 302 inout->mulByUnknownSingleComponent();
303 } 303 }
304 304
305 void GrConvexPolyEffect::getGLProcessorKey(const GrGLSLCaps& caps, 305 void GrConvexPolyEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
306 GrProcessorKeyBuilder* b) const { 306 GrProcessorKeyBuilder* b) const {
307 GrGLConvexPolyEffect::GenKey(*this, caps, b); 307 GrGLConvexPolyEffect::GenKey(*this, caps, b);
308 } 308 }
309 309
310 GrGLFragmentProcessor* GrConvexPolyEffect::createGLInstance() const { 310 GrGLFragmentProcessor* GrConvexPolyEffect::createGLInstance() const {
311 return SkNEW_ARGS(GrGLConvexPolyEffect, (*this)); 311 return SkNEW_ARGS(GrGLConvexPolyEffect, (*this));
312 } 312 }
313 313
314 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons t SkScalar edges[]) 314 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons t SkScalar edges[])
315 : fEdgeType(edgeType) 315 : fEdgeType(edgeType)
(...skipping 29 matching lines...) Expand all
345 } 345 }
346 346
347 GrFragmentProcessor* fp; 347 GrFragmentProcessor* fp;
348 do { 348 do {
349 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( 349 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
350 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); 350 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
351 fp = GrConvexPolyEffect::Create(edgeType, count, edges); 351 fp = GrConvexPolyEffect::Create(edgeType, count, edges);
352 } while (NULL == fp); 352 } while (NULL == fp);
353 return fp; 353 return fp;
354 } 354 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConvexPolyEffect.h ('k') | src/gpu/effects/GrConvolutionEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698