Index: src/core/SkTileGrid.cpp |
=================================================================== |
--- src/core/SkTileGrid.cpp (revision 8533) |
+++ src/core/SkTileGrid.cpp (working copy) |
@@ -66,6 +66,7 @@ |
SkIRect adjustedQuery = query; |
adjustedQuery.inset(fInfo.fMargin.width(), fInfo.fMargin.height()); |
adjustedQuery.offset(fInfo.fOffset); |
+ adjustedQuery.sort(); // in case the inset inverted the rectangle |
reed1
2013/04/09 15:56:16
If we might invert, then (I presume) we are making
|
// Convert the query rectangle from device coordinates to tile coordinates |
// by rounding outwards to the nearest tile boundary so that the resulting tile |
// region includes the query rectangle. (using truncating division to "floor") |
@@ -75,16 +76,14 @@ |
int tileStartY = adjustedQuery.top() / fInfo.fTileInterval.height(); |
int tileEndY = (adjustedQuery.bottom() + fInfo.fTileInterval.height() - 1) / |
fInfo.fTileInterval.height(); |
- if (tileStartX >= fXTileCount || tileStartY >= fYTileCount || tileEndX <= 0 || tileEndY <= 0) { |
- return; // query does not intersect the grid |
- } |
- // clamp to grid |
- if (tileStartX < 0) tileStartX = 0; |
- if (tileStartY < 0) tileStartY = 0; |
- if (tileEndX > fXTileCount) tileEndX = fXTileCount; |
- if (tileEndY > fYTileCount) tileEndY = fYTileCount; |
+ tileStartX = SkPin32(tileStartX, 0, fXTileCount - 1); |
+ tileEndX = SkPin32(tileEndX, 1, fXTileCount); |
+ tileStartY = SkPin32(tileStartY, 0, fYTileCount - 1); |
+ tileEndY = SkPin32(tileEndY, 1, fYTileCount); |
+ |
int queryTileCount = (tileEndX - tileStartX) * (tileEndY - tileStartY); |
+ SkASSERT(queryTileCount); |
if (queryTileCount == 1) { |
*results = this->tile(tileStartX, tileStartY); |
} else { |