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

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
« no previous file with comments | « no previous file | tests/TileGridTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | tests/TileGridTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698