aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SkResourceCacheTest.cpp
diff options
context:
space:
mode:
authorGravatar yunchao.he <yunchao.he@intel.com>2015-01-23 17:06:20 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-23 17:06:21 -0800
commit90acb8e97cb123adc25d030b6dbe868d32856f47 (patch)
tree63c4db756c1588c94bbec92fd8ca4fd50aefd4e5 /tests/SkResourceCacheTest.cpp
parent1eea9fcb2443192e9034eb520aff0564b0950364 (diff)
a typo in SkResourceCacheTest
Diffstat (limited to 'tests/SkResourceCacheTest.cpp')
-rw-r--r--tests/SkResourceCacheTest.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp
index e1f8a65bbc..179e771ed8 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);