Index: tests/SkResourceCacheTest.cpp |
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp |
index e1f8a65bbca42b7d989e3dd56f3e88d357417dc5..179e771ed826ba3c00362544d70213a59567fb5b 100644 |
--- a/tests/SkResourceCacheTest.cpp |
+++ b/tests/SkResourceCacheTest.cpp |
@@ -22,28 +22,30 @@ static bool is_in_scaled_image_cache(const SkBitmap& orig, |
SkScalar yScale) { |
SkBitmap scaled; |
float roundedImageWidth = SkScalarRoundToScalar(orig.width() * xScale); |
- float roundedImageHeight = SkScalarRoundToScalar(orig.height() * xScale); |
+ float roundedImageHeight = SkScalarRoundToScalar(orig.height() * yScale); |
return SkBitmapCache::Find(orig, roundedImageWidth, roundedImageHeight, &scaled); |
} |
-// Draw a scaled bitmap, then return true iff it has been cached. |
-static bool test_scaled_image_cache_useage() { |
+// Draw a scaled bitmap, then return true if it has been cached. |
+static bool test_scaled_image_cache_usage() { |
SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(kCanvasSize, kCanvasSize)); |
SkCanvas* canvas = surface->getCanvas(); |
SkBitmap bitmap; |
bitmap.allocN32Pixels(kBitmapSize, kBitmapSize); |
bitmap.eraseColor(0xFFFFFFFF); |
- SkScalar scale = SkIntToScalar(kScale); |
- SkScalar scaledSize = SkIntToScalar(kBitmapSize) * scale; |
- canvas->clipRect(SkRect::MakeLTRB(0, 0, scaledSize, scaledSize)); |
+ SkScalar xScale = SkIntToScalar(kScale); |
+ SkScalar yScale = xScale / 2; |
+ SkScalar xScaledSize = SkIntToScalar(kBitmapSize) * xScale; |
+ SkScalar yScaledSize = SkIntToScalar(kBitmapSize) * yScale; |
+ canvas->clipRect(SkRect::MakeLTRB(0, 0, xScaledSize, yScaledSize)); |
SkPaint paint; |
paint.setFilterLevel(SkPaint::kHigh_FilterLevel); |
canvas->drawBitmapRect(bitmap, |
- SkRect::MakeLTRB(0, 0, scaledSize, scaledSize), |
+ SkRect::MakeLTRB(0, 0, xScaledSize, yScaledSize), |
&paint); |
- return is_in_scaled_image_cache(bitmap, scale, scale); |
+ return is_in_scaled_image_cache(bitmap, xScale, yScale); |
} |
// http://crbug.com/389439 |
@@ -59,19 +61,19 @@ DEF_TEST(ResourceCache_SingleAllocationByteLimit, reporter) { |
SkGraphics::SetResourceCacheTotalByteLimit(2 * size); |
SkGraphics::SetResourceCacheSingleAllocationByteLimit(0); // No limit |
- REPORTER_ASSERT(reporter, test_scaled_image_cache_useage()); |
+ REPORTER_ASSERT(reporter, test_scaled_image_cache_usage()); |
SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache |
SkGraphics::SetResourceCacheTotalByteLimit(2 * size); |
SkGraphics::SetResourceCacheSingleAllocationByteLimit(size * 2); // big enough |
- REPORTER_ASSERT(reporter, test_scaled_image_cache_useage()); |
+ REPORTER_ASSERT(reporter, test_scaled_image_cache_usage()); |
SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache |
SkGraphics::SetResourceCacheTotalByteLimit(2 * size); |
SkGraphics::SetResourceCacheSingleAllocationByteLimit(size / 2); // too small |
- REPORTER_ASSERT(reporter, !test_scaled_image_cache_useage()); |
+ REPORTER_ASSERT(reporter, !test_scaled_image_cache_usage()); |
SkGraphics::SetResourceCacheSingleAllocationByteLimit(originalAllocationLimit); |
SkGraphics::SetResourceCacheTotalByteLimit(originalByteLimit); |