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

Side by Side Diff: src/gpu/GrAAConvexPathRenderer.cpp

Issue 22850006: Replace uses of GrAssert by SkASSERT. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | src/gpu/GrAAHairLinePathRenderer.cpp » ('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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAAConvexPathRenderer.h" 9 #include "GrAAConvexPathRenderer.h"
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 avg.scale(denom); 96 avg.scale(denom);
97 *c = avg; 97 *c = avg;
98 } else { 98 } else {
99 area *= 3; 99 area *= 3;
100 area = SkScalarDiv(SK_Scalar1, area); 100 area = SkScalarDiv(SK_Scalar1, area);
101 center.fX = SkScalarMul(center.fX, area); 101 center.fX = SkScalarMul(center.fX, area);
102 center.fY = SkScalarMul(center.fY, area); 102 center.fY = SkScalarMul(center.fY, area);
103 // undo the translate of p0 to the origin. 103 // undo the translate of p0 to the origin.
104 *c = center + p0; 104 *c = center + p0;
105 } 105 }
106 GrAssert(!SkScalarIsNaN(c->fX) && !SkScalarIsNaN(c->fY)); 106 SkASSERT(!SkScalarIsNaN(c->fX) && !SkScalarIsNaN(c->fY));
107 } 107 }
108 108
109 static void compute_vectors(SegmentArray* segments, 109 static void compute_vectors(SegmentArray* segments,
110 SkPoint* fanPt, 110 SkPoint* fanPt,
111 SkPath::Direction dir, 111 SkPath::Direction dir,
112 int* vCount, 112 int* vCount,
113 int* iCount) { 113 int* iCount) {
114 center_of_mass(*segments, fanPt); 114 center_of_mass(*segments, fanPt);
115 int count = segments->count(); 115 int count = segments->count();
116 116
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 default: 202 default:
203 GrCrash("Unexpected degenerate test stage."); 203 GrCrash("Unexpected degenerate test stage.");
204 } 204 }
205 } 205 }
206 206
207 static inline bool get_direction(const SkPath& path, const SkMatrix& m, SkPath:: Direction* dir) { 207 static inline bool get_direction(const SkPath& path, const SkMatrix& m, SkPath:: Direction* dir) {
208 if (!path.cheapComputeDirection(dir)) { 208 if (!path.cheapComputeDirection(dir)) {
209 return false; 209 return false;
210 } 210 }
211 // check whether m reverses the orientation 211 // check whether m reverses the orientation
212 GrAssert(!m.hasPerspective()); 212 SkASSERT(!m.hasPerspective());
213 SkScalar det2x2 = SkScalarMul(m.get(SkMatrix::kMScaleX), m.get(SkMatrix::kMS caleY)) - 213 SkScalar det2x2 = SkScalarMul(m.get(SkMatrix::kMScaleX), m.get(SkMatrix::kMS caleY)) -
214 SkScalarMul(m.get(SkMatrix::kMSkewX), m.get(SkMatrix::kMSk ewY)); 214 SkScalarMul(m.get(SkMatrix::kMSkewX), m.get(SkMatrix::kMSk ewY));
215 if (det2x2 < 0) { 215 if (det2x2 < 0) {
216 *dir = SkPath::OppositeDirection(*dir); 216 *dir = SkPath::OppositeDirection(*dir);
217 } 217 }
218 return true; 218 return true;
219 } 219 }
220 220
221 static inline void add_line_to_segment(const SkPoint& pt, SegmentArray* segments ) { 221 static inline void add_line_to_segment(const SkPoint& pt, SegmentArray* segments ) {
222 segments->push_back(); 222 segments->push_back();
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs)); 649 drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs));
650 650
651 static const int kEdgeAttrIndex = 1; 651 static const int kEdgeAttrIndex = 1;
652 GrEffectRef* quadEffect = QuadEdgeEffect::Create(); 652 GrEffectRef* quadEffect = QuadEdgeEffect::Create();
653 drawState->addCoverageEffect(quadEffect, kEdgeAttrIndex)->unref(); 653 drawState->addCoverageEffect(quadEffect, kEdgeAttrIndex)->unref();
654 654
655 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount); 655 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount);
656 if (!arg.succeeded()) { 656 if (!arg.succeeded()) {
657 return false; 657 return false;
658 } 658 }
659 GrAssert(sizeof(QuadVertex) == drawState->getVertexSize()); 659 SkASSERT(sizeof(QuadVertex) == drawState->getVertexSize());
660 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); 660 verts = reinterpret_cast<QuadVertex*>(arg.vertices());
661 idxs = reinterpret_cast<uint16_t*>(arg.indices()); 661 idxs = reinterpret_cast<uint16_t*>(arg.indices());
662 662
663 SkSTArray<kPreallocDrawCnt, Draw, true> draws; 663 SkSTArray<kPreallocDrawCnt, Draw, true> draws;
664 create_vertices(segments, fanPt, &draws, verts, idxs); 664 create_vertices(segments, fanPt, &draws, verts, idxs);
665 665
666 // This is valid because all the computed verts are within 1 pixel of the pa th control points. 666 // This is valid because all the computed verts are within 1 pixel of the pa th control points.
667 SkRect devBounds; 667 SkRect devBounds;
668 devBounds = path->getBounds(); 668 devBounds = path->getBounds();
669 viewMatrix.mapRect(&devBounds); 669 viewMatrix.mapRect(&devBounds);
670 devBounds.outset(SK_Scalar1, SK_Scalar1); 670 devBounds.outset(SK_Scalar1, SK_Scalar1);
671 671
672 // Check devBounds 672 // Check devBounds
673 #if GR_DEBUG 673 #if GR_DEBUG
674 SkRect tolDevBounds = devBounds; 674 SkRect tolDevBounds = devBounds;
675 tolDevBounds.outset(SK_Scalar1 / 10000, SK_Scalar1 / 10000); 675 tolDevBounds.outset(SK_Scalar1 / 10000, SK_Scalar1 / 10000);
676 SkRect actualBounds; 676 SkRect actualBounds;
677 actualBounds.set(verts[0].fPos, verts[1].fPos); 677 actualBounds.set(verts[0].fPos, verts[1].fPos);
678 for (int i = 2; i < vCount; ++i) { 678 for (int i = 2; i < vCount; ++i) {
679 actualBounds.growToInclude(verts[i].fPos.fX, verts[i].fPos.fY); 679 actualBounds.growToInclude(verts[i].fPos.fX, verts[i].fPos.fY);
680 } 680 }
681 GrAssert(tolDevBounds.contains(actualBounds)); 681 SkASSERT(tolDevBounds.contains(actualBounds));
682 #endif 682 #endif
683 683
684 int vOffset = 0; 684 int vOffset = 0;
685 for (int i = 0; i < draws.count(); ++i) { 685 for (int i = 0; i < draws.count(); ++i) {
686 const Draw& draw = draws[i]; 686 const Draw& draw = draws[i];
687 target->drawIndexed(kTriangles_GrPrimitiveType, 687 target->drawIndexed(kTriangles_GrPrimitiveType,
688 vOffset, // start vertex 688 vOffset, // start vertex
689 0, // start index 689 0, // start index
690 draw.fVertexCnt, 690 draw.fVertexCnt,
691 draw.fIndexCnt, 691 draw.fIndexCnt,
692 &devBounds); 692 &devBounds);
693 vOffset += draw.fVertexCnt; 693 vOffset += draw.fVertexCnt;
694 } 694 }
695 695
696 return true; 696 return true;
697 } 697 }
OLDNEW
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | src/gpu/GrAAHairLinePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698