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

Unified Diff: src/core/SkEdgeBuilder.cpp

Issue 2388213003: Revert of Analytic AntiAlias for Convex Shapes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkEdgeBuilder.h ('k') | src/core/SkScan.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkEdgeBuilder.cpp
diff --git a/src/core/SkEdgeBuilder.cpp b/src/core/SkEdgeBuilder.cpp
index 1a160882d466d3b3d71355ec560da7aa96f4a632..af68e0ff656ea0130851ce5bf0934403a34ebf9c 100644
--- a/src/core/SkEdgeBuilder.cpp
+++ b/src/core/SkEdgeBuilder.cpp
@@ -7,7 +7,6 @@
#include "SkEdgeBuilder.h"
#include "SkPath.h"
#include "SkEdge.h"
-#include "SkAnalyticEdge.h"
#include "SkEdgeClipper.h"
#include "SkLineClipper.h"
#include "SkGeometry.h"
@@ -63,135 +62,45 @@
return kNo_Combine;
}
-SkEdgeBuilder::Combine SkEdgeBuilder::CombineVertical(
- const SkAnalyticEdge* edge, SkAnalyticEdge* last) {
- SkASSERT(fAnalyticAA);
- if (last->fCurveCount || last->fDX || edge->fX != last->fX) {
- return kNo_Combine;
- }
- if (edge->fWinding == last->fWinding) {
- if (edge->fLowerY == last->fUpperY) {
- last->fUpperY = edge->fUpperY;
- last->fY = last->fUpperY;
- return kPartial_Combine;
- }
- if (edge->fUpperY == last->fLowerY) {
- last->fLowerY = edge->fLowerY;
- return kPartial_Combine;
- }
- return kNo_Combine;
- }
- if (edge->fUpperY == last->fUpperY) {
- if (edge->fLowerY == last->fLowerY) {
- return kTotal_Combine;
- }
- if (edge->fLowerY < last->fLowerY) {
- last->fUpperY = edge->fLowerY;
- last->fY = last->fUpperY;
- return kPartial_Combine;
- }
- last->fUpperY = last->fLowerY;
- last->fY = last->fUpperY;
- last->fLowerY = edge->fLowerY;
- last->fWinding = edge->fWinding;
- return kPartial_Combine;
- }
- if (edge->fLowerY == last->fLowerY) {
- if (edge->fUpperY > last->fUpperY) {
- last->fLowerY = edge->fUpperY;
- return kPartial_Combine;
- }
- last->fLowerY = last->fUpperY;
- last->fUpperY = edge->fUpperY;
- last->fY = last->fUpperY;
- last->fWinding = edge->fWinding;
- return kPartial_Combine;
- }
- return kNo_Combine;
-}
-
-bool SkEdgeBuilder::vertical_line(const SkEdge* edge) {
+static bool vertical_line(const SkEdge* edge) {
return !edge->fDX && !edge->fCurveCount;
}
-bool SkEdgeBuilder::vertical_line(const SkAnalyticEdge* edge) {
- SkASSERT(fAnalyticAA);
- return !edge->fDX && !edge->fCurveCount;
-}
-
void SkEdgeBuilder::addLine(const SkPoint pts[]) {
- if (fAnalyticAA) {
- SkAnalyticEdge* edge = typedAllocThrow<SkAnalyticEdge>(fAlloc);
- if (edge->setLine(pts[0], pts[1])) {
- if (vertical_line(edge) && fList.count()) {
- Combine combine = CombineVertical(edge, (SkAnalyticEdge*)*(fList.end() - 1));
- if (kNo_Combine != combine) {
- if (kTotal_Combine == combine) {
- fList.pop();
- }
- goto unallocate_analytic_edge;
- }
- }
- fList.push(edge);
- } else {
-unallocate_analytic_edge:
- ;
- // TODO: unallocate edge from storage...
- }
- } else {
- SkEdge* edge = typedAllocThrow<SkEdge>(fAlloc);
- if (edge->setLine(pts[0], pts[1], fShiftUp)) {
- if (vertical_line(edge) && fList.count()) {
- Combine combine = CombineVertical(edge, (SkEdge*)*(fList.end() - 1));
- if (kNo_Combine != combine) {
- if (kTotal_Combine == combine) {
- fList.pop();
- }
- goto unallocate_edge;
- }
- }
- fList.push(edge);
- } else {
+ SkEdge* edge = typedAllocThrow<SkEdge>(fAlloc);
+ if (edge->setLine(pts[0], pts[1], fShiftUp)) {
+ if (vertical_line(edge) && fList.count()) {
+ Combine combine = CombineVertical(edge, *(fList.end() - 1));
+ if (kNo_Combine != combine) {
+ if (kTotal_Combine == combine) {
+ fList.pop();
+ }
+ goto unallocate_edge;
+ }
+ }
+ fList.push(edge);
+ } else {
unallocate_edge:
- ;
- // TODO: unallocate edge from storage...
- }
+ ;
+ // TODO: unallocate edge from storage...
}
}
void SkEdgeBuilder::addQuad(const SkPoint pts[]) {
- if (fAnalyticAA) {
- SkAnalyticQuadraticEdge* edge = typedAllocThrow<SkAnalyticQuadraticEdge>(fAlloc);
- if (edge->setQuadratic(pts)) {
- fList.push(edge);
- } else {
- // TODO: unallocate edge from storage...
- }
- } else {
- SkQuadraticEdge* edge = typedAllocThrow<SkQuadraticEdge>(fAlloc);
- if (edge->setQuadratic(pts, fShiftUp)) {
- fList.push(edge);
- } else {
- // TODO: unallocate edge from storage...
- }
+ SkQuadraticEdge* edge = typedAllocThrow<SkQuadraticEdge>(fAlloc);
+ if (edge->setQuadratic(pts, fShiftUp)) {
+ fList.push(edge);
+ } else {
+ // TODO: unallocate edge from storage...
}
}
void SkEdgeBuilder::addCubic(const SkPoint pts[]) {
- if (fAnalyticAA) {
- SkAnalyticCubicEdge* edge = typedAllocThrow<SkAnalyticCubicEdge>(fAlloc);
- if (edge->setCubic(pts)) {
- fList.push(edge);
- } else {
- // TODO: unallocate edge from storage...
- }
- } else {
- SkCubicEdge* edge = typedAllocThrow<SkCubicEdge>(fAlloc);
- if (edge->setCubic(pts, fShiftUp)) {
- fList.push(edge);
- } else {
- // TODO: unallocate edge from storage...
- }
+ SkCubicEdge* edge = typedAllocThrow<SkCubicEdge>(fAlloc);
+ if (edge->setCubic(pts, fShiftUp)) {
+ fList.push(edge);
+ } else {
+ // TODO: unallocate edge from storage...
}
}
@@ -226,14 +135,7 @@
}
SkEdgeBuilder::Combine SkEdgeBuilder::checkVertical(const SkEdge* edge, SkEdge** edgePtr) {
- return !vertical_line(edge) || edgePtr <= (SkEdge**)fEdgeList ? kNo_Combine :
- CombineVertical(edge, edgePtr[-1]);
-}
-
-SkEdgeBuilder::Combine SkEdgeBuilder::checkVertical(const SkAnalyticEdge* edge,
- SkAnalyticEdge** edgePtr) {
- SkASSERT(fAnalyticAA);
- return !vertical_line(edge) || edgePtr <= (SkAnalyticEdge**)fEdgeList ? kNo_Combine :
+ return !vertical_line(edge) || edgePtr <= fEdgeList ? kNo_Combine :
CombineVertical(edge, edgePtr[-1]);
}
@@ -250,16 +152,15 @@
// segments.
maxEdgeCount *= SkLineClipper::kMaxClippedLineSegments;
}
- size_t edgeSize = fAnalyticAA ? sizeof(SkAnalyticEdge) : sizeof(SkEdge);
- size_t maxEdgeSize = maxEdgeCount * edgeSize;
- size_t maxEdgePtrSize = maxEdgeCount * sizeof(char*);
+ size_t maxEdgeSize = maxEdgeCount * sizeof(SkEdge);
+ size_t maxEdgePtrSize = maxEdgeCount * sizeof(SkEdge*);
// lets store the edges and their pointers in the same block
char* storage = (char*)fAlloc.allocThrow(maxEdgeSize + maxEdgePtrSize);
- char* edge = (char*)storage;
- char** edgePtr = (char**)(storage + maxEdgeSize);
+ SkEdge* edge = reinterpret_cast<SkEdge*>(storage);
+ SkEdge** edgePtr = reinterpret_cast<SkEdge**>(storage + maxEdgeSize);
// Record the beginning of our pointers, so we can return them to the caller
- fEdgeList = (void**)edgePtr;
+ fEdgeList = edgePtr;
if (iclip) {
SkRect clip;
@@ -277,16 +178,10 @@
int lineCount = SkLineClipper::ClipLine(pts, clip, lines, canCullToTheRight);
SkASSERT(lineCount <= SkLineClipper::kMaxClippedLineSegments);
for (int i = 0; i < lineCount; i++) {
- bool setLineResult = fAnalyticAA ?
- ((SkAnalyticEdge*)edge)->setLine(lines[i], lines[i + 1]) :
- ((SkEdge*)edge)->setLine(lines[i], lines[i + 1], shiftUp);
- if (setLineResult) {
- Combine combine = fAnalyticAA ?
- checkVertical((SkAnalyticEdge*)edge, (SkAnalyticEdge**)edgePtr) :
- checkVertical((SkEdge*)edge, (SkEdge**)edgePtr);
+ if (edge->setLine(lines[i], lines[i + 1], shiftUp)) {
+ Combine combine = checkVertical(edge, edgePtr);
if (kNo_Combine == combine) {
- *edgePtr++ = edge;
- edge += edgeSize;
+ *edgePtr++ = edge++;
} else if (kTotal_Combine == combine) {
--edgePtr;
}
@@ -307,23 +202,16 @@
// we ignore these, and just get the whole segment from
// the corresponding line/quad/cubic verbs
break;
- case SkPath::kLine_Verb: {
- bool setLineResult = fAnalyticAA ?
- ((SkAnalyticEdge*)edge)->setLine(pts[0], pts[1]) :
- ((SkEdge*)edge)->setLine(pts[0], pts[1], shiftUp);
- if (setLineResult) {
- Combine combine = fAnalyticAA ?
- checkVertical((SkAnalyticEdge*)edge, (SkAnalyticEdge**)edgePtr) :
- checkVertical((SkEdge*)edge, (SkEdge**)edgePtr);
+ case SkPath::kLine_Verb:
+ if (edge->setLine(pts[0], pts[1], shiftUp)) {
+ Combine combine = checkVertical(edge, edgePtr);
if (kNo_Combine == combine) {
- *edgePtr++ = edge;
- edge += edgeSize;
+ *edgePtr++ = edge++;
} else if (kTotal_Combine == combine) {
--edgePtr;
}
}
break;
- }
default:
SkDEBUGFAIL("unexpected verb");
break;
@@ -331,8 +219,8 @@
}
}
SkASSERT((char*)edge <= (char*)fEdgeList);
- SkASSERT(edgePtr - (char**)fEdgeList <= maxEdgeCount);
- return SkToInt(edgePtr - (char**)fEdgeList);
+ SkASSERT(edgePtr - fEdgeList <= maxEdgeCount);
+ return SkToInt(edgePtr - fEdgeList);
}
static void handle_quad(SkEdgeBuilder* builder, const SkPoint pts[3]) {
@@ -344,11 +232,10 @@
}
int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip, int shiftUp,
- bool canCullToTheRight, bool analyticAA) {
+ bool canCullToTheRight) {
fAlloc.reset();
fList.reset();
fShiftUp = shiftUp;
- fAnalyticAA = analyticAA;
if (SkPath::kLine_SegmentMask == path.getSegmentMasks()) {
return this->buildPoly(path, iclip, shiftUp, canCullToTheRight);
« no previous file with comments | « src/core/SkEdgeBuilder.h ('k') | src/core/SkScan.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698