OLD | NEW |
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 | 7 |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "SkBitmapCache.h" | 9 #include "SkBitmapCache.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 SkCanvas* canvas = surface->getCanvas(); | 32 SkCanvas* canvas = surface->getCanvas(); |
33 SkBitmap bitmap; | 33 SkBitmap bitmap; |
34 bitmap.allocN32Pixels(kBitmapSize, kBitmapSize); | 34 bitmap.allocN32Pixels(kBitmapSize, kBitmapSize); |
35 bitmap.eraseColor(0xFFFFFFFF); | 35 bitmap.eraseColor(0xFFFFFFFF); |
36 SkScalar xScale = SkIntToScalar(kScale); | 36 SkScalar xScale = SkIntToScalar(kScale); |
37 SkScalar yScale = xScale / 2; | 37 SkScalar yScale = xScale / 2; |
38 SkScalar xScaledSize = SkIntToScalar(kBitmapSize) * xScale; | 38 SkScalar xScaledSize = SkIntToScalar(kBitmapSize) * xScale; |
39 SkScalar yScaledSize = SkIntToScalar(kBitmapSize) * yScale; | 39 SkScalar yScaledSize = SkIntToScalar(kBitmapSize) * yScale; |
40 canvas->clipRect(SkRect::MakeLTRB(0, 0, xScaledSize, yScaledSize)); | 40 canvas->clipRect(SkRect::MakeLTRB(0, 0, xScaledSize, yScaledSize)); |
41 SkPaint paint; | 41 SkPaint paint; |
42 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); | 42 paint.setFilterQuality(kHigh_SkFilterQuality); |
43 | 43 |
44 canvas->drawBitmapRect(bitmap, | 44 canvas->drawBitmapRect(bitmap, |
45 SkRect::MakeLTRB(0, 0, xScaledSize, yScaledSize), | 45 SkRect::MakeLTRB(0, 0, xScaledSize, yScaledSize), |
46 &paint); | 46 &paint); |
47 | 47 |
48 return is_in_scaled_image_cache(bitmap, xScale, yScale); | 48 return is_in_scaled_image_cache(bitmap, xScale, yScale); |
49 } | 49 } |
50 | 50 |
51 // http://crbug.com/389439 | 51 // http://crbug.com/389439 |
52 DEF_TEST(ResourceCache_SingleAllocationByteLimit, reporter) { | 52 DEF_TEST(ResourceCache_SingleAllocationByteLimit, reporter) { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 cachedBitmap.unlockPixels(); | 279 cachedBitmap.unlockPixels(); |
280 | 280 |
281 // We can add the bitmap back to the cache and find it again. | 281 // We can add the bitmap back to the cache and find it again. |
282 REPORTER_ASSERT(reporter, SkBitmapCache::Add(cachedBitmap.pixelRef(), rect,
cachedBitmap, cache)); | 282 REPORTER_ASSERT(reporter, SkBitmapCache::Add(cachedBitmap.pixelRef(), rect,
cachedBitmap, cache)); |
283 REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedBitmap.getGenerationID()
, rect, &bm, cache)); | 283 REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedBitmap.getGenerationID()
, rect, &bm, cache)); |
284 | 284 |
285 test_mipmapcache(reporter, cache); | 285 test_mipmapcache(reporter, cache); |
286 test_bitmap_notify(reporter, cache); | 286 test_bitmap_notify(reporter, cache); |
287 test_mipmap_notify(reporter, cache); | 287 test_mipmap_notify(reporter, cache); |
288 } | 288 } |
OLD | NEW |