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" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 SkRect rect = SkRect::MakeLTRB(d->fRandom->nextSScalar1(), | 64 SkRect rect = SkRect::MakeLTRB(d->fRandom->nextSScalar1(), |
65 d->fRandom->nextSScalar1(), | 65 d->fRandom->nextSScalar1(), |
66 d->fRandom->nextSScalar1(), | 66 d->fRandom->nextSScalar1(), |
67 d->fRandom->nextSScalar1()); | 67 d->fRandom->nextSScalar1()); |
68 GrFragmentProcessor* fp; | 68 GrFragmentProcessor* fp; |
69 do { | 69 do { |
70 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 70 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
71 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); | 71 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); |
72 | 72 |
73 fp = AARectEffect::Create(edgeType, rect); | 73 fp = AARectEffect::Create(edgeType, rect); |
74 } while (NULL == fp); | 74 } while (nullptr == fp); |
75 return fp; | 75 return fp; |
76 } | 76 } |
77 | 77 |
78 ////////////////////////////////////////////////////////////////////////////// | 78 ////////////////////////////////////////////////////////////////////////////// |
79 | 79 |
80 class GLAARectEffect : public GrGLFragmentProcessor { | 80 class GLAARectEffect : public GrGLFragmentProcessor { |
81 public: | 81 public: |
82 GLAARectEffect(const GrProcessor&); | 82 GLAARectEffect(const GrProcessor&); |
83 | 83 |
84 virtual void emitCode(EmitArgs&) override; | 84 virtual void emitCode(EmitArgs&) override; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 GR_STATIC_ASSERT(kGrProcessorEdgeTypeCnt <= 8); | 236 GR_STATIC_ASSERT(kGrProcessorEdgeTypeCnt <= 8); |
237 uint32_t key = (cpe.getEdgeCount() << 3) | cpe.getEdgeType(); | 237 uint32_t key = (cpe.getEdgeCount() << 3) | cpe.getEdgeType(); |
238 b->add32(key); | 238 b->add32(key); |
239 } | 239 } |
240 | 240 |
241 ////////////////////////////////////////////////////////////////////////////// | 241 ////////////////////////////////////////////////////////////////////////////// |
242 | 242 |
243 GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType type, const
SkPath& path, | 243 GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType type, const
SkPath& path, |
244 const SkVector* offset) { | 244 const SkVector* offset) { |
245 if (kHairlineAA_GrProcessorEdgeType == type) { | 245 if (kHairlineAA_GrProcessorEdgeType == type) { |
246 return NULL; | 246 return nullptr; |
247 } | 247 } |
248 if (path.getSegmentMasks() != SkPath::kLine_SegmentMask || | 248 if (path.getSegmentMasks() != SkPath::kLine_SegmentMask || |
249 !path.isConvex()) { | 249 !path.isConvex()) { |
250 return NULL; | 250 return nullptr; |
251 } | 251 } |
252 | 252 |
253 if (path.countPoints() > kMaxEdges) { | 253 if (path.countPoints() > kMaxEdges) { |
254 return NULL; | 254 return nullptr; |
255 } | 255 } |
256 | 256 |
257 SkPoint pts[kMaxEdges]; | 257 SkPoint pts[kMaxEdges]; |
258 SkScalar edges[3 * kMaxEdges]; | 258 SkScalar edges[3 * kMaxEdges]; |
259 | 259 |
260 SkPathPriv::FirstDirection dir; | 260 SkPathPriv::FirstDirection dir; |
261 SkAssertResult(SkPathPriv::CheapComputeFirstDirection(path, &dir)); | 261 SkAssertResult(SkPathPriv::CheapComputeFirstDirection(path, &dir)); |
262 | 262 |
263 SkVector t; | 263 SkVector t; |
264 if (NULL == offset) { | 264 if (nullptr == offset) { |
265 t.set(0, 0); | 265 t.set(0, 0); |
266 } else { | 266 } else { |
267 t = *offset; | 267 t = *offset; |
268 } | 268 } |
269 | 269 |
270 int count = path.getPoints(pts, kMaxEdges); | 270 int count = path.getPoints(pts, kMaxEdges); |
271 int n = 0; | 271 int n = 0; |
272 for (int lastPt = count - 1, i = 0; i < count; lastPt = i++) { | 272 for (int lastPt = count - 1, i = 0; i < count; lastPt = i++) { |
273 if (pts[lastPt] != pts[i]) { | 273 if (pts[lastPt] != pts[i]) { |
274 SkVector v = pts[i] - pts[lastPt]; | 274 SkVector v = pts[i] - pts[lastPt]; |
(...skipping 11 matching lines...) Expand all Loading... |
286 } | 286 } |
287 } | 287 } |
288 if (path.isInverseFillType()) { | 288 if (path.isInverseFillType()) { |
289 type = GrInvertProcessorEdgeType(type); | 289 type = GrInvertProcessorEdgeType(type); |
290 } | 290 } |
291 return Create(type, n, edges); | 291 return Create(type, n, edges); |
292 } | 292 } |
293 | 293 |
294 GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, co
nst SkRect& rect) { | 294 GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, co
nst SkRect& rect) { |
295 if (kHairlineAA_GrProcessorEdgeType == edgeType){ | 295 if (kHairlineAA_GrProcessorEdgeType == edgeType){ |
296 return NULL; | 296 return nullptr; |
297 } | 297 } |
298 return AARectEffect::Create(edgeType, rect); | 298 return AARectEffect::Create(edgeType, rect); |
299 } | 299 } |
300 | 300 |
301 GrConvexPolyEffect::~GrConvexPolyEffect() {} | 301 GrConvexPolyEffect::~GrConvexPolyEffect() {} |
302 | 302 |
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 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 SkScalar edges[kMaxEdges * 3]; | 344 SkScalar edges[kMaxEdges * 3]; |
345 for (int i = 0; i < 3 * count; ++i) { | 345 for (int i = 0; i < 3 * count; ++i) { |
346 edges[i] = d->fRandom->nextSScalar1(); | 346 edges[i] = d->fRandom->nextSScalar1(); |
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 (nullptr == fp); |
355 return fp; | 355 return fp; |
356 } | 356 } |
OLD | NEW |