aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmap.cpp3
-rw-r--r--src/core/SkScaledImageCache.cpp7
2 files changed, 4 insertions, 6 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index d3bbecd706..128726cb63 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -911,9 +911,8 @@ bool get_upper_left_from_offset(SkBitmap::Config config, size_t offset, size_t r
return true;
}
// Use integer division to find the correct y position.
- *y = SkToS32(offset / rowBytes);
// The remainder will be the x position, after we reverse get_sub_offset.
- *x = SkToS32(offset % rowBytes);
+ SkTDivMod(offset, rowBytes, y, x);
switch (config) {
case SkBitmap::kA8_Config:
// Fall through.
diff --git a/src/core/SkScaledImageCache.cpp b/src/core/SkScaledImageCache.cpp
index 75dac78598..11a0ee448f 100644
--- a/src/core/SkScaledImageCache.cpp
+++ b/src/core/SkScaledImageCache.cpp
@@ -48,10 +48,9 @@ struct Key {
return false;
}
- size_t offset = bm.pixelRefOffset();
- size_t rowBytes = bm.rowBytes();
- int x = (offset % rowBytes) >> 2;
- int y = offset / rowBytes;
+ size_t x, y;
+ SkTDivMod(bm.pixelRefOffset(), bm.rowBytes(), &y, &x);
+ x >>= 2;
fGenID = pr->getGenerationID();
fBounds.set(x, y, x + bm.width(), y + bm.height());