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

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

Issue 1443743002: Rename some processor functions from GL to GLSL (Closed) Base URL: https://skia.googlesource.com/skia.git@primProcs
Patch Set: nits Created 5 years, 1 month 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 "glsl/GrGLSLFragmentProcessor.h" 11 #include "glsl/GrGLSLFragmentProcessor.h"
12 #include "glsl/GrGLSLFragmentShaderBuilder.h" 12 #include "glsl/GrGLSLFragmentShaderBuilder.h"
13 #include "glsl/GrGLSLProgramBuilder.h" 13 #include "glsl/GrGLSLProgramBuilder.h"
14 #include "glsl/GrGLSLProgramDataManager.h" 14 #include "glsl/GrGLSLProgramDataManager.h"
15 15
16 ////////////////////////////////////////////////////////////////////////////// 16 //////////////////////////////////////////////////////////////////////////////
17 class AARectEffect : public GrFragmentProcessor { 17 class AARectEffect : public GrFragmentProcessor {
18 public: 18 public:
19 const SkRect& getRect() const { return fRect; } 19 const SkRect& getRect() const { return fRect; }
20 20
21 static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRec t& rect) { 21 static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRec t& rect) {
22 return new AARectEffect(edgeType, rect); 22 return new AARectEffect(edgeType, rect);
23 } 23 }
24 24
25 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } 25 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
26 26
27 const char* name() const override { return "AARect"; } 27 const char* name() const override { return "AARect"; }
28 28
29 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride; 29 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) 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
38 GrGLSLFragmentProcessor* onCreateGLInstance() const override; 38 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
39 39
40 bool onIsEqual(const GrFragmentProcessor& other) const override { 40 bool onIsEqual(const GrFragmentProcessor& other) const override {
41 const AARectEffect& aare = other.cast<AARectEffect>(); 41 const AARectEffect& aare = other.cast<AARectEffect>();
42 return fRect == aare.fRect; 42 return fRect == aare.fRect;
43 } 43 }
44 44
45 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { 45 void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
46 if (fRect.isEmpty()) { 46 if (fRect.isEmpty()) {
47 // An empty rect will have no coverage anywhere. 47 // An empty rect will have no coverage anywhere.
48 inout->mulByKnownSingleComponent(0); 48 inout->mulByKnownSingleComponent(0);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 fPrevRect = rect; 149 fPrevRect = rect;
150 } 150 }
151 } 151 }
152 152
153 void GLAARectEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&, 153 void GLAARectEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
154 GrProcessorKeyBuilder* b) { 154 GrProcessorKeyBuilder* b) {
155 const AARectEffect& aare = processor.cast<AARectEffect>(); 155 const AARectEffect& aare = processor.cast<AARectEffect>();
156 b->add32(aare.getEdgeType()); 156 b->add32(aare.getEdgeType());
157 } 157 }
158 158
159 void AARectEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui lder* b) const { 159 void AARectEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB uilder* b) const {
160 GLAARectEffect::GenKey(*this, caps, b); 160 GLAARectEffect::GenKey(*this, caps, b);
161 } 161 }
162 162
163 GrGLSLFragmentProcessor* AARectEffect::onCreateGLInstance() const { 163 GrGLSLFragmentProcessor* AARectEffect::onCreateGLSLInstance() const {
164 return new GLAARectEffect(*this); 164 return new GLAARectEffect(*this);
165 } 165 }
166 166
167 ////////////////////////////////////////////////////////////////////////////// 167 //////////////////////////////////////////////////////////////////////////////
168 168
169 class GrGLConvexPolyEffect : public GrGLSLFragmentProcessor { 169 class GrGLConvexPolyEffect : public GrGLSLFragmentProcessor {
170 public: 170 public:
171 GrGLConvexPolyEffect(const GrProcessor&); 171 GrGLConvexPolyEffect(const GrProcessor&);
172 172
173 virtual void emitCode(EmitArgs&) override; 173 virtual void emitCode(EmitArgs&) override;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 return AARectEffect::Create(edgeType, rect); 297 return AARectEffect::Create(edgeType, rect);
298 } 298 }
299 299
300 GrConvexPolyEffect::~GrConvexPolyEffect() {} 300 GrConvexPolyEffect::~GrConvexPolyEffect() {}
301 301
302 void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons t { 302 void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons t {
303 inout->mulByUnknownSingleComponent(); 303 inout->mulByUnknownSingleComponent();
304 } 304 }
305 305
306 void GrConvexPolyEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, 306 void GrConvexPolyEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
307 GrProcessorKeyBuilder* b) const { 307 GrProcessorKeyBuilder* b) const {
308 GrGLConvexPolyEffect::GenKey(*this, caps, b); 308 GrGLConvexPolyEffect::GenKey(*this, caps, b);
309 } 309 }
310 310
311 GrGLSLFragmentProcessor* GrConvexPolyEffect::onCreateGLInstance() const { 311 GrGLSLFragmentProcessor* GrConvexPolyEffect::onCreateGLSLInstance() const {
312 return new GrGLConvexPolyEffect(*this); 312 return new GrGLConvexPolyEffect(*this);
313 } 313 }
314 314
315 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons t SkScalar edges[]) 315 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons t SkScalar edges[])
316 : fEdgeType(edgeType) 316 : fEdgeType(edgeType)
317 , fEdgeCount(n) { 317 , fEdgeCount(n) {
318 this->initClassID<GrConvexPolyEffect>(); 318 this->initClassID<GrConvexPolyEffect>();
319 // Factory function should have already ensured this. 319 // Factory function should have already ensured this.
320 SkASSERT(n <= kMaxEdges); 320 SkASSERT(n <= kMaxEdges);
321 memcpy(fEdges, edges, 3 * n * sizeof(SkScalar)); 321 memcpy(fEdges, edges, 3 * n * sizeof(SkScalar));
(...skipping 24 matching lines...) Expand all
346 } 346 }
347 347
348 GrFragmentProcessor* fp; 348 GrFragmentProcessor* fp;
349 do { 349 do {
350 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( 350 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
351 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); 351 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
352 fp = GrConvexPolyEffect::Create(edgeType, count, edges); 352 fp = GrConvexPolyEffect::Create(edgeType, count, edges);
353 } while (nullptr == fp); 353 } while (nullptr == fp);
354 return fp; 354 return fp;
355 } 355 }
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