OLD | NEW |
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 new 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 onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; | 27 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; |
28 | 28 |
29 private: | 29 private: |
30 AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) | 30 AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 GrProcessorKeyBuilder* b) { | 151 GrProcessorKeyBuilder* b) { |
152 const AARectEffect& aare = processor.cast<AARectEffect>(); | 152 const AARectEffect& aare = processor.cast<AARectEffect>(); |
153 b->add32(aare.getEdgeType()); | 153 b->add32(aare.getEdgeType()); |
154 } | 154 } |
155 | 155 |
156 void AARectEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui
lder* b) const { | 156 void AARectEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui
lder* b) const { |
157 GLAARectEffect::GenKey(*this, caps, b); | 157 GLAARectEffect::GenKey(*this, caps, b); |
158 } | 158 } |
159 | 159 |
160 GrGLFragmentProcessor* AARectEffect::onCreateGLInstance() const { | 160 GrGLFragmentProcessor* AARectEffect::onCreateGLInstance() const { |
161 return SkNEW_ARGS(GLAARectEffect, (*this)); | 161 return new GLAARectEffect(*this); |
162 } | 162 } |
163 | 163 |
164 ////////////////////////////////////////////////////////////////////////////// | 164 ////////////////////////////////////////////////////////////////////////////// |
165 | 165 |
166 class GrGLConvexPolyEffect : public GrGLFragmentProcessor { | 166 class GrGLConvexPolyEffect : public GrGLFragmentProcessor { |
167 public: | 167 public: |
168 GrGLConvexPolyEffect(const GrProcessor&); | 168 GrGLConvexPolyEffect(const GrProcessor&); |
169 | 169 |
170 virtual void emitCode(EmitArgs&) override; | 170 virtual void emitCode(EmitArgs&) override; |
171 | 171 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons
t { | 303 void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons
t { |
304 inout->mulByUnknownSingleComponent(); | 304 inout->mulByUnknownSingleComponent(); |
305 } | 305 } |
306 | 306 |
307 void GrConvexPolyEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 307 void GrConvexPolyEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
308 GrProcessorKeyBuilder* b) const { | 308 GrProcessorKeyBuilder* b) const { |
309 GrGLConvexPolyEffect::GenKey(*this, caps, b); | 309 GrGLConvexPolyEffect::GenKey(*this, caps, b); |
310 } | 310 } |
311 | 311 |
312 GrGLFragmentProcessor* GrConvexPolyEffect::onCreateGLInstance() const { | 312 GrGLFragmentProcessor* GrConvexPolyEffect::onCreateGLInstance() const { |
313 return SkNEW_ARGS(GrGLConvexPolyEffect, (*this)); | 313 return new GrGLConvexPolyEffect(*this); |
314 } | 314 } |
315 | 315 |
316 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons
t SkScalar edges[]) | 316 GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, cons
t SkScalar edges[]) |
317 : fEdgeType(edgeType) | 317 : fEdgeType(edgeType) |
318 , fEdgeCount(n) { | 318 , fEdgeCount(n) { |
319 this->initClassID<GrConvexPolyEffect>(); | 319 this->initClassID<GrConvexPolyEffect>(); |
320 // Factory function should have already ensured this. | 320 // Factory function should have already ensured this. |
321 SkASSERT(n <= kMaxEdges); | 321 SkASSERT(n <= kMaxEdges); |
322 memcpy(fEdges, edges, 3 * n * sizeof(SkScalar)); | 322 memcpy(fEdges, edges, 3 * n * sizeof(SkScalar)); |
323 // Outset the edges by 0.5 so that a pixel with center on an edge is 50% cov
ered in the AA case | 323 // Outset the edges by 0.5 so that a pixel with center on an edge is 50% cov
ered in the AA case |
(...skipping 23 matching lines...) Expand all Loading... |
347 } | 347 } |
348 | 348 |
349 GrFragmentProcessor* fp; | 349 GrFragmentProcessor* fp; |
350 do { | 350 do { |
351 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 351 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
352 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); | 352 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); |
353 fp = GrConvexPolyEffect::Create(edgeType, count, edges); | 353 fp = GrConvexPolyEffect::Create(edgeType, count, edges); |
354 } while (NULL == fp); | 354 } while (NULL == fp); |
355 return fp; | 355 return fp; |
356 } | 356 } |
OLD | NEW |