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

Side by Side Diff: tests/ScaledImageCache.cpp

Issue 397273006: erase bitmap to make valgrind happier (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "Test.h" 7 #include "Test.h"
8 #include "SkGraphics.h" 8 #include "SkGraphics.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 10
11 static const int kCanvasSize = 1; 11 static const int kCanvasSize = 1;
12 static const int kBitmapSize = 16; 12 static const int kBitmapSize = 16;
13 static const int kScale = 8; 13 static const int kScale = 8;
14 14
15 static size_t test_scaled_image_cache_useage() { 15 static size_t test_scaled_image_cache_useage() {
16 SkAutoTUnref<SkCanvas> canvas( 16 SkAutoTUnref<SkCanvas> canvas(
17 SkCanvas::NewRasterN32(kCanvasSize, kCanvasSize)); 17 SkCanvas::NewRasterN32(kCanvasSize, kCanvasSize));
18 SkBitmap bitmap; 18 SkBitmap bitmap;
19 SkAssertResult(bitmap.allocN32Pixels(kBitmapSize, kBitmapSize)); 19 SkAssertResult(bitmap.allocN32Pixels(kBitmapSize, kBitmapSize));
20 bitmap.eraseColor(0xFFFFFFFF);
20 SkScalar scaledSize = SkIntToScalar(kScale * kBitmapSize); 21 SkScalar scaledSize = SkIntToScalar(kScale * kBitmapSize);
21 canvas->clipRect(SkRect::MakeLTRB(0, 0, scaledSize, scaledSize)); 22 canvas->clipRect(SkRect::MakeLTRB(0, 0, scaledSize, scaledSize));
22 SkPaint paint; 23 SkPaint paint;
23 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); 24 paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
24 size_t bytesUsed = SkGraphics::GetImageCacheBytesUsed(); 25 size_t bytesUsed = SkGraphics::GetImageCacheBytesUsed();
25 canvas->drawBitmapRect(bitmap, 26 canvas->drawBitmapRect(bitmap,
26 SkRect::MakeLTRB(0, 0, scaledSize, scaledSize), 27 SkRect::MakeLTRB(0, 0, scaledSize, scaledSize),
27 &paint); 28 &paint);
28 return SkGraphics::GetImageCacheBytesUsed() - bytesUsed; 29 return SkGraphics::GetImageCacheBytesUsed() - bytesUsed;
29 } 30 }
(...skipping 21 matching lines...) Expand all
51 52
52 SkGraphics::SetImageCacheByteLimit(0); // clear cache 53 SkGraphics::SetImageCacheByteLimit(0); // clear cache
53 SkGraphics::SetImageCacheByteLimit(2 * size); 54 SkGraphics::SetImageCacheByteLimit(2 * size);
54 SkGraphics::SetImageCacheSingleAllocationByteLimit(size / 2); 55 SkGraphics::SetImageCacheSingleAllocationByteLimit(size / 2);
55 56
56 REPORTER_ASSERT(reporter, 0 == test_scaled_image_cache_useage()); 57 REPORTER_ASSERT(reporter, 0 == test_scaled_image_cache_useage());
57 58
58 SkGraphics::SetImageCacheSingleAllocationByteLimit(originalAllocationLimit); 59 SkGraphics::SetImageCacheSingleAllocationByteLimit(originalAllocationLimit);
59 SkGraphics::SetImageCacheByteLimit(originalByteLimit); 60 SkGraphics::SetImageCacheByteLimit(originalByteLimit);
60 } 61 }
OLDNEW
« 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