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 "effects/GrConstColorProcessor.h" |
11 #include "glsl/GrGLSLFragmentProcessor.h" | 12 #include "glsl/GrGLSLFragmentProcessor.h" |
12 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 13 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
13 #include "glsl/GrGLSLProgramDataManager.h" | 14 #include "glsl/GrGLSLProgramDataManager.h" |
14 #include "glsl/GrGLSLUniformHandler.h" | 15 #include "glsl/GrGLSLUniformHandler.h" |
15 | 16 |
16 ////////////////////////////////////////////////////////////////////////////// | 17 ////////////////////////////////////////////////////////////////////////////// |
17 class AARectEffect : public GrFragmentProcessor { | 18 class AARectEffect : public GrFragmentProcessor { |
18 public: | 19 public: |
19 const SkRect& getRect() const { return fRect; } | 20 const SkRect& getRect() const { return fRect; } |
20 | 21 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 248 } |
248 | 249 |
249 if (path.countPoints() > kMaxEdges) { | 250 if (path.countPoints() > kMaxEdges) { |
250 return nullptr; | 251 return nullptr; |
251 } | 252 } |
252 | 253 |
253 SkPoint pts[kMaxEdges]; | 254 SkPoint pts[kMaxEdges]; |
254 SkScalar edges[3 * kMaxEdges]; | 255 SkScalar edges[3 * kMaxEdges]; |
255 | 256 |
256 SkPathPriv::FirstDirection dir; | 257 SkPathPriv::FirstDirection dir; |
257 SkAssertResult(SkPathPriv::CheapComputeFirstDirection(path, &dir)); | 258 // The only way this should fail is if the clip is effectively a infinitely
thin line. In that |
| 259 // case nothing is inside the clip. It'd be nice to detect this at a higher
level and either |
| 260 // skip the draw or omit the clip element. |
| 261 if (!SkPathPriv::CheapComputeFirstDirection(path, &dir)) { |
| 262 if (GrProcessorEdgeTypeIsInverseFill(type)) { |
| 263 return GrConstColorProcessor::Create(0xFFFFFFFF, |
| 264 GrConstColorProcessor::kModulat
eRGBA_InputMode); |
| 265 } |
| 266 return GrConstColorProcessor::Create(0, GrConstColorProcessor::kIgnore_I
nputMode); |
| 267 } |
258 | 268 |
259 SkVector t; | 269 SkVector t; |
260 if (nullptr == offset) { | 270 if (nullptr == offset) { |
261 t.set(0, 0); | 271 t.set(0, 0); |
262 } else { | 272 } else { |
263 t = *offset; | 273 t = *offset; |
264 } | 274 } |
265 | 275 |
266 int count = path.getPoints(pts, kMaxEdges); | 276 int count = path.getPoints(pts, kMaxEdges); |
267 int n = 0; | 277 int n = 0; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 353 } |
344 | 354 |
345 GrFragmentProcessor* fp; | 355 GrFragmentProcessor* fp; |
346 do { | 356 do { |
347 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 357 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
348 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); | 358 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); |
349 fp = GrConvexPolyEffect::Create(edgeType, count, edges); | 359 fp = GrConvexPolyEffect::Create(edgeType, count, edges); |
350 } while (nullptr == fp); | 360 } while (nullptr == fp); |
351 return fp; | 361 return fp; |
352 } | 362 } |
OLD | NEW |