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 "SkPath.h" | 10 #include "SkPathPriv.h" |
11 #include "gl/GrGLProcessor.h" | 11 #include "gl/GrGLProcessor.h" |
12 #include "gl/GrGLSL.h" | 12 #include "gl/GrGLSL.h" |
13 #include "gl/builders/GrGLProgramBuilder.h" | 13 #include "gl/builders/GrGLProgramBuilder.h" |
14 | 14 |
15 ////////////////////////////////////////////////////////////////////////////// | 15 ////////////////////////////////////////////////////////////////////////////// |
16 class AARectEffect : public GrFragmentProcessor { | 16 class AARectEffect : public GrFragmentProcessor { |
17 public: | 17 public: |
18 const SkRect& getRect() const { return fRect; } | 18 const SkRect& getRect() const { return fRect; } |
19 | 19 |
20 static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRec
t& rect) { | 20 static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRec
t& rect) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 return NULL; | 272 return NULL; |
273 } | 273 } |
274 | 274 |
275 if (path.countPoints() > kMaxEdges) { | 275 if (path.countPoints() > kMaxEdges) { |
276 return NULL; | 276 return NULL; |
277 } | 277 } |
278 | 278 |
279 SkPoint pts[kMaxEdges]; | 279 SkPoint pts[kMaxEdges]; |
280 SkScalar edges[3 * kMaxEdges]; | 280 SkScalar edges[3 * kMaxEdges]; |
281 | 281 |
282 SkPath::Direction dir; | 282 SkPathPriv::FirstDirection dir; |
283 SkAssertResult(path.cheapComputeDirection(&dir)); | 283 SkAssertResult(SkPathPriv::CheapComputeFirstDirection(path, &dir)); |
284 | 284 |
285 SkVector t; | 285 SkVector t; |
286 if (NULL == offset) { | 286 if (NULL == offset) { |
287 t.set(0, 0); | 287 t.set(0, 0); |
288 } else { | 288 } else { |
289 t = *offset; | 289 t = *offset; |
290 } | 290 } |
291 | 291 |
292 int count = path.getPoints(pts, kMaxEdges); | 292 int count = path.getPoints(pts, kMaxEdges); |
293 int n = 0; | 293 int n = 0; |
294 for (int lastPt = count - 1, i = 0; i < count; lastPt = i++) { | 294 for (int lastPt = count - 1, i = 0; i < count; lastPt = i++) { |
295 if (pts[lastPt] != pts[i]) { | 295 if (pts[lastPt] != pts[i]) { |
296 SkVector v = pts[i] - pts[lastPt]; | 296 SkVector v = pts[i] - pts[lastPt]; |
297 v.normalize(); | 297 v.normalize(); |
298 if (SkPath::kCCW_Direction == dir) { | 298 if (SkPathPriv::kCCW_FirstDirection == dir) { |
299 edges[3 * n] = v.fY; | 299 edges[3 * n] = v.fY; |
300 edges[3 * n + 1] = -v.fX; | 300 edges[3 * n + 1] = -v.fX; |
301 } else { | 301 } else { |
302 edges[3 * n] = -v.fY; | 302 edges[3 * n] = -v.fY; |
303 edges[3 * n + 1] = v.fX; | 303 edges[3 * n + 1] = v.fX; |
304 } | 304 } |
305 SkPoint p = pts[i] + t; | 305 SkPoint p = pts[i] + t; |
306 edges[3 * n + 2] = -(edges[3 * n] * p.fX + edges[3 * n + 1] * p.fY); | 306 edges[3 * n + 2] = -(edges[3 * n] * p.fX + edges[3 * n + 1] * p.fY); |
307 ++n; | 307 ++n; |
308 } | 308 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 } | 372 } |
373 | 373 |
374 GrFragmentProcessor* fp; | 374 GrFragmentProcessor* fp; |
375 do { | 375 do { |
376 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 376 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
377 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); | 377 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); |
378 fp = GrConvexPolyEffect::Create(edgeType, count, edges); | 378 fp = GrConvexPolyEffect::Create(edgeType, count, edges); |
379 } while (NULL == fp); | 379 } while (NULL == fp); |
380 return fp; | 380 return fp; |
381 } | 381 } |
OLD | NEW |