aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xsrc/gpu/GrRectanizer_skyline.cpp5
-rw-r--r--src/gpu/GrRectanizer_skyline.h8
2 files changed, 11 insertions, 2 deletions
diff --git a/src/gpu/GrRectanizer_skyline.cpp b/src/gpu/GrRectanizer_skyline.cpp
index b759cb22ac..44da1c326a 100755
--- a/src/gpu/GrRectanizer_skyline.cpp
+++ b/src/gpu/GrRectanizer_skyline.cpp
@@ -81,8 +81,9 @@ void GrRectanizerSkyline::addSkylineLevel(int skylineIndex, int x, int y, int wi
SkASSERT(newSegment.fX + newSegment.fWidth <= this->width());
SkASSERT(newSegment.fY <= this->height());
- // delete width of this skyline segment from following ones
+ // delete width of the new skyline segment from following ones
for (int i = skylineIndex+1; i < fSkyline.count(); ++i) {
+ // The new segment subsumes all or part of fSkyline[i]
SkASSERT(fSkyline[i-1].fX <= fSkyline[i].fX);
if (fSkyline[i].fX < fSkyline[i-1].fX + fSkyline[i-1].fWidth) {
@@ -92,9 +93,11 @@ void GrRectanizerSkyline::addSkylineLevel(int skylineIndex, int x, int y, int wi
fSkyline[i].fWidth -= shrink;
if (fSkyline[i].fWidth <= 0) {
+ // fully consumed
fSkyline.remove(i);
--i;
} else {
+ // only partially consumed
break;
}
} else {
diff --git a/src/gpu/GrRectanizer_skyline.h b/src/gpu/GrRectanizer_skyline.h
index 2062667d7c..21043c0b6d 100644
--- a/src/gpu/GrRectanizer_skyline.h
+++ b/src/gpu/GrRectanizer_skyline.h
@@ -32,7 +32,7 @@ public:
virtual bool addRect(int w, int h, SkIPoint16* loc) SK_OVERRIDE;
- virtual float percentFull() const SK_OVERRIDE{
+ virtual float percentFull() const SK_OVERRIDE {
return fAreaSoFar / ((float)this->width() * this->height());
}
@@ -47,7 +47,13 @@ private:
int32_t fAreaSoFar;
+ // Can a width x height rectangle fit in the free space represented by
+ // the skyline segments >= 'skylineIndex'? If so, return true and fill in
+ // 'y' with the y-location at which it fits (the x location is pulled from
+ // 'skylineIndex's segment.
bool rectangleFits(int skylineIndex, int width, int height, int* y) const;
+ // Update the skyline structure to include a width x height rect located
+ // at x,y.
void addSkylineLevel(int skylineIndex, int x, int y, int width, int height);
typedef GrRectanizer INHERITED;