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); |