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

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

Issue 2259493002: Fix assert caused by floating point error in tessellating path renderer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | tests/TessellatingPathRendererTests.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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "GrTessellator.h" 8 #include "GrTessellator.h"
9 9
10 #include "GrPathUtils.h" 10 #include "GrPathUtils.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 , fRight(nullptr) 246 , fRight(nullptr)
247 , fPrevEdgeAbove(nullptr) 247 , fPrevEdgeAbove(nullptr)
248 , fNextEdgeAbove(nullptr) 248 , fNextEdgeAbove(nullptr)
249 , fPrevEdgeBelow(nullptr) 249 , fPrevEdgeBelow(nullptr)
250 , fNextEdgeBelow(nullptr) 250 , fNextEdgeBelow(nullptr)
251 , fLeftPoly(nullptr) 251 , fLeftPoly(nullptr)
252 , fRightPoly(nullptr) 252 , fRightPoly(nullptr)
253 , fLeftPolyPrev(nullptr) 253 , fLeftPolyPrev(nullptr)
254 , fLeftPolyNext(nullptr) 254 , fLeftPolyNext(nullptr)
255 , fRightPolyPrev(nullptr) 255 , fRightPolyPrev(nullptr)
256 , fRightPolyNext(nullptr) { 256 , fRightPolyNext(nullptr)
257 , fUsedInLeftPoly(false)
258 , fUsedInRightPoly(false) {
257 recompute(); 259 recompute();
258 } 260 }
259 int fWinding; // 1 == edge goes downward; -1 = edge goes upwar d. 261 int fWinding; // 1 == edge goes downward; -1 = edge goes upwar d.
260 Vertex* fTop; // The top vertex in vertex-sort-order (sweep_lt ). 262 Vertex* fTop; // The top vertex in vertex-sort-order (sweep_lt ).
261 Vertex* fBottom; // The bottom vertex in vertex-sort-order. 263 Vertex* fBottom; // The bottom vertex in vertex-sort-order.
262 Edge* fLeft; // The linked list of edges in the active edge l ist. 264 Edge* fLeft; // The linked list of edges in the active edge l ist.
263 Edge* fRight; // " 265 Edge* fRight; // "
264 Edge* fPrevEdgeAbove; // The linked list of edges in the bottom Vertex 's "edges above". 266 Edge* fPrevEdgeAbove; // The linked list of edges in the bottom Vertex 's "edges above".
265 Edge* fNextEdgeAbove; // " 267 Edge* fNextEdgeAbove; // "
266 Edge* fPrevEdgeBelow; // The linked list of edges in the top Vertex's "edges below". 268 Edge* fPrevEdgeBelow; // The linked list of edges in the top Vertex's "edges below".
267 Edge* fNextEdgeBelow; // " 269 Edge* fNextEdgeBelow; // "
268 Poly* fLeftPoly; // The Poly to the left of this edge, if any. 270 Poly* fLeftPoly; // The Poly to the left of this edge, if any.
269 Poly* fRightPoly; // The Poly to the right of this edge, if any. 271 Poly* fRightPoly; // The Poly to the right of this edge, if any.
270 Edge* fLeftPolyPrev; 272 Edge* fLeftPolyPrev;
271 Edge* fLeftPolyNext; 273 Edge* fLeftPolyNext;
272 Edge* fRightPolyPrev; 274 Edge* fRightPolyPrev;
273 Edge* fRightPolyNext; 275 Edge* fRightPolyNext;
276 bool fUsedInLeftPoly;
277 bool fUsedInRightPoly;
274 double fDX; // The line equation for this edge, in implicit form. 278 double fDX; // The line equation for this edge, in implicit form.
275 double fDY; // fDY * x + fDX * y + fC = 0, for point (x, y) on the line. 279 double fDY; // fDY * x + fDX * y + fC = 0, for point (x, y) on the line.
276 double fC; 280 double fC;
277 double dist(const SkPoint& p) const { 281 double dist(const SkPoint& p) const {
278 return fDY * p.fX - fDX * p.fY + fC; 282 return fDY * p.fX - fDX * p.fY + fC;
279 } 283 }
280 bool isRightOf(Vertex* v) const { 284 bool isRightOf(Vertex* v) const {
281 return dist(v->fPoint) < 0.0; 285 return dist(v->fPoint) < 0.0;
282 } 286 }
283 bool isLeftOf(Vertex* v) const { 287 bool isLeftOf(Vertex* v) const {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 , fNext(nullptr) { 353 , fNext(nullptr) {
350 this->addEdge(edge); 354 this->addEdge(edge);
351 } 355 }
352 Side fSide; 356 Side fSide;
353 Edge* fFirstEdge; 357 Edge* fFirstEdge;
354 Edge* fLastEdge; 358 Edge* fLastEdge;
355 MonotonePoly* fPrev; 359 MonotonePoly* fPrev;
356 MonotonePoly* fNext; 360 MonotonePoly* fNext;
357 void addEdge(Edge* edge) { 361 void addEdge(Edge* edge) {
358 if (fSide == kRight_Side) { 362 if (fSide == kRight_Side) {
363 if (edge->fUsedInRightPoly) {
364 return;
365 }
359 list_insert<Edge, &Edge::fRightPolyPrev, &Edge::fRightPolyNext>( 366 list_insert<Edge, &Edge::fRightPolyPrev, &Edge::fRightPolyNext>(
360 edge, fLastEdge, nullptr, &fFirstEdge, &fLastEdge); 367 edge, fLastEdge, nullptr, &fFirstEdge, &fLastEdge);
368 edge->fUsedInRightPoly = true;
361 } else { 369 } else {
370 if (edge->fUsedInLeftPoly) {
371 return;
372 }
362 list_insert<Edge, &Edge::fLeftPolyPrev, &Edge::fLeftPolyNext>( 373 list_insert<Edge, &Edge::fLeftPolyPrev, &Edge::fLeftPolyNext>(
363 edge, fLastEdge, nullptr, &fFirstEdge, &fLastEdge); 374 edge, fLastEdge, nullptr, &fFirstEdge, &fLastEdge);
375 edge->fUsedInLeftPoly = true;
364 } 376 }
365 } 377 }
366 378
367 SkPoint* emit(SkPoint* data) { 379 SkPoint* emit(SkPoint* data) {
368 Edge* e = fFirstEdge; 380 Edge* e = fFirstEdge;
369 e->fTop->fPrev = e->fTop->fNext = nullptr; 381 e->fTop->fPrev = e->fTop->fNext = nullptr;
370 VertexList vertices; 382 VertexList vertices;
371 vertices.append(e->fTop); 383 vertices.append(e->fTop);
372 while (e != nullptr) { 384 while (e != nullptr) {
373 e->fBottom->fPrev = e->fBottom->fNext = nullptr; 385 e->fBottom->fPrev = e->fBottom->fNext = nullptr;
(...skipping 26 matching lines...) Expand all
400 v = v->fPrev; 412 v = v->fPrev;
401 } 413 }
402 } else { 414 } else {
403 v = v->fNext; 415 v = v->fNext;
404 } 416 }
405 } 417 }
406 return data; 418 return data;
407 } 419 }
408 }; 420 };
409 Poly* addEdge(Edge* e, Side side, SkChunkAlloc& alloc) { 421 Poly* addEdge(Edge* e, Side side, SkChunkAlloc& alloc) {
410 LOG("addEdge (%g,%g)-(%g,%g) to poly %d, %s side\n", 422 LOG("addEdge (%g -> %g) to poly %d, %s side\n",
411 e->fTop->fPoint.fX, e->fTop->fPoint.fY, e->fBottom->fPoint.fX, e- >fBottom->fPoint.fY, 423 e->fTop->fID, e->fBottom->fID, fID, side == kLeft_Side ? "left" : "right");
412 fID, side == kLeft_Side ? "left" : "right");
413 Poly* partner = fPartner; 424 Poly* partner = fPartner;
414 Poly* poly = this; 425 Poly* poly = this;
415 if (partner) { 426 if (partner) {
416 fPartner = partner->fPartner = nullptr; 427 fPartner = partner->fPartner = nullptr;
417 } 428 }
418 if (!fTail) { 429 if (!fTail) {
419 fHead = fTail = ALLOC_NEW(MonotonePoly, (e, side), alloc); 430 fHead = fTail = ALLOC_NEW(MonotonePoly, (e, side), alloc);
420 fCount += 2; 431 fCount += 2;
421 } else if (e->fBottom == fTail->fLastEdge->fBottom) { 432 } else if (e->fBottom == fTail->fLastEdge->fBottom) {
422 return poly; 433 return poly;
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 } 1451 }
1441 } 1452 }
1442 int actualCount = static_cast<int>(vertsEnd - *verts); 1453 int actualCount = static_cast<int>(vertsEnd - *verts);
1443 SkASSERT(actualCount <= count); 1454 SkASSERT(actualCount <= count);
1444 SkASSERT(pointsEnd - points == actualCount); 1455 SkASSERT(pointsEnd - points == actualCount);
1445 delete[] points; 1456 delete[] points;
1446 return actualCount; 1457 return actualCount;
1447 } 1458 }
1448 1459
1449 } // namespace 1460 } // namespace
OLDNEW
« no previous file with comments | « no previous file | tests/TessellatingPathRendererTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698