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

Unified Diff: src/core/SkTileGrid.cpp

Issue 659823004: Treat (private, internal) grid bounds as doubly-inclusive in SkTileGrid. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTileGrid.cpp
diff --git a/src/core/SkTileGrid.cpp b/src/core/SkTileGrid.cpp
index 30ca4b9179b7e29d71425a65b0ad4d1dfd31fc8b..fd00253097ed87d578309d268254b4eccf50a7ef 100644
--- a/src/core/SkTileGrid.cpp
+++ b/src/core/SkTileGrid.cpp
@@ -62,12 +62,12 @@ void SkTileGrid::commonAdjust(SkRect* rect) const {
rect->fBottom -= SK_ScalarNearlyZero;
}
-// Convert user-space bounds to grid tiles they cover (LT inclusive, RB exclusive).
+// Convert user-space bounds to grid tiles they cover (LT and RB both inclusive).
void SkTileGrid::userToGrid(const SkRect& user, SkIRect* grid) const {
grid->fLeft = SkPin32(user.left() * fInvWidth , 0, fXTiles - 1);
grid->fTop = SkPin32(user.top() * fInvHeight, 0, fYTiles - 1);
- grid->fRight = SkPin32(user.right() * fInvWidth , 0, fXTiles - 1) + 1;
- grid->fBottom = SkPin32(user.bottom() * fInvHeight, 0, fYTiles - 1) + 1;
+ grid->fRight = SkPin32(user.right() * fInvWidth , 0, fXTiles - 1);
+ grid->fBottom = SkPin32(user.bottom() * fInvHeight, 0, fYTiles - 1);
}
void SkTileGrid::insert(unsigned opIndex, const SkRect& originalBounds, bool) {
@@ -84,8 +84,8 @@ void SkTileGrid::insert(unsigned opIndex, const SkRect& originalBounds, bool) {
SkIRect grid;
this->userToGrid(bounds, &grid);
- for (int y = grid.fTop; y < grid.fBottom; y++) {
- for (int x = grid.fLeft; x < grid.fRight; x++) {
+ for (int y = grid.fTop; y <= grid.fBottom; y++) {
+ for (int x = grid.fLeft; x <= grid.fRight; x++) {
fTiles[y * fXTiles + x].push(opIndex);
}
}
@@ -115,7 +115,7 @@ void SkTileGrid::search(const SkRect& originalQuery, SkTDArray<unsigned>* result
SkIRect grid;
this->userToGrid(query, &grid);
- const int tilesHit = (grid.fRight - grid.fLeft) * (grid.fBottom - grid.fTop);
+ const int tilesHit = (grid.fRight - grid.fLeft + 1) * (grid.fBottom - grid.fTop + 1);
SkASSERT(tilesHit > 0);
if (tilesHit == 1) {
@@ -130,8 +130,8 @@ void SkTileGrid::search(const SkRect& originalQuery, SkTDArray<unsigned>* result
// Gather pointers to the starts and ends of the tiles to merge.
SkAutoSTArray<kStackAllocationTileCount, const unsigned*> starts(tilesHit), ends(tilesHit);
int i = 0;
- for (int y = grid.fTop; y < grid.fBottom; y++) {
- for (int x = grid.fLeft; x < grid.fRight; x++) {
+ for (int y = grid.fTop; y <= grid.fBottom; y++) {
+ for (int x = grid.fLeft; x <= grid.fRight; x++) {
starts[i] = fTiles[y * fXTiles + x].begin();
ends[i] = fTiles[y * fXTiles + x].end();
i++;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698