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

Unified Diff: tests/SkResourceCacheTest.cpp

Issue 868613002: a typo in SkResourceCacheTest (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: to expose the error of previous code + more typos in this file Created 5 years, 11 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: 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);
« 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