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

Unified Diff: src/core/SkTileGrid.cpp

Issue 13493016: Fixing SkTileGrid to clamp rather than clip content and querries that are outside the bounds of the… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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
Index: src/core/SkTileGrid.cpp
===================================================================
--- src/core/SkTileGrid.cpp (revision 8533)
+++ src/core/SkTileGrid.cpp (working copy)
@@ -39,9 +39,6 @@
SkIRect dilatedBounds = bounds;
dilatedBounds.outset(fInfo.fMargin.width(), fInfo.fMargin.height());
dilatedBounds.offset(fInfo.fOffset);
- if (!SkIRect::Intersects(dilatedBounds, fGridBounds)) {
- return;
- }
// Note: SkIRects are non-inclusive of the right() column and bottom() row,
// hence the "-1"s in the computations of maxTileX and maxTileY.
@@ -75,16 +72,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 = SkClampMinMax(tileStartX, 0, fXTileCount - 1);
+ tileEndX = SkClampMinMax(tileEndX, 1, fXTileCount);
+ tileStartY = SkClampMinMax(tileStartY, 0, fYTileCount - 1);
+ tileEndY = SkClampMinMax(tileEndY, 1, fYTileCount);
+
int queryTileCount = (tileEndX - tileStartX) * (tileEndY - tileStartY);
+ SkASSERT(queryTileCount);
if (queryTileCount == 1) {
*results = this->tile(tileStartX, tileStartY);
} else {
« include/core/SkMath.h ('K') | « include/core/SkMath.h ('k') | tests/TileGridTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698