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" |
11 #include "SkDiscardableMemoryPool.h" | 11 #include "SkDiscardableMemoryPool.h" |
12 #include "SkGraphics.h" | 12 #include "SkGraphics.h" |
13 #include "SkPicture.h" | 13 #include "SkPicture.h" |
14 #include "SkPictureRecorder.h" | 14 #include "SkPictureRecorder.h" |
15 #include "SkResourceCache.h" | 15 #include "SkResourceCache.h" |
16 #include "SkSurface.h" | 16 #include "SkSurface.h" |
17 | 17 |
18 ////////////////////////////////////////////////////////////////////////////////
//////// | 18 ////////////////////////////////////////////////////////////////////////////////
//////// |
19 | 19 |
20 static void make_bitmap(SkBitmap* bitmap, const SkImageInfo& info, SkBitmap::All
ocator* allocator) { | 20 static void make_bitmap(SkBitmap* bitmap, const SkImageInfo& info, SkBitmap::All
ocator* allocator) { |
21 if (allocator) { | 21 if (allocator) { |
22 bitmap->setInfo(info); | 22 bitmap->setInfo(info); |
23 allocator->allocPixelRef(bitmap, 0); | 23 allocator->allocPixelRef(bitmap, 0); |
24 } else { | 24 } else { |
25 bitmap->allocPixels(info); | 25 bitmap->allocPixels(info); |
26 } | 26 } |
27 } | 27 } |
28 | 28 |
29 // http://skbug.com/2894 | 29 // https://bug.skia.org/2894 |
30 DEF_TEST(BitmapCache_add_rect, reporter) { | 30 DEF_TEST(BitmapCache_add_rect, reporter) { |
31 SkResourceCache::DiscardableFactory factory = SkResourceCache::GetDiscardabl
eFactory(); | 31 SkResourceCache::DiscardableFactory factory = SkResourceCache::GetDiscardabl
eFactory(); |
32 SkBitmap::Allocator* allocator = SkBitmapCache::GetAllocator(); | 32 SkBitmap::Allocator* allocator = SkBitmapCache::GetAllocator(); |
33 | 33 |
34 SkAutoTDelete<SkResourceCache> cache; | 34 SkAutoTDelete<SkResourceCache> cache; |
35 if (factory) { | 35 if (factory) { |
36 cache.reset(new SkResourceCache(factory)); | 36 cache.reset(new SkResourceCache(factory)); |
37 } else { | 37 } else { |
38 const size_t byteLimit = 100 * 1024; | 38 const size_t byteLimit = 100 * 1024; |
39 cache.reset(new SkResourceCache(byteLimit)); | 39 cache.reset(new SkResourceCache(byteLimit)); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 280 |
281 test_discarded_image(reporter, xforms[i], []() { | 281 test_discarded_image(reporter, xforms[i], []() { |
282 SkPictureRecorder recorder; | 282 SkPictureRecorder recorder; |
283 SkCanvas* canvas = recorder.beginRecording(10, 10); | 283 SkCanvas* canvas = recorder.beginRecording(10, 10); |
284 canvas->clear(SK_ColorCYAN); | 284 canvas->clear(SK_ColorCYAN); |
285 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 285 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
286 return SkImage::NewFromPicture(picture, SkISize::Make(10, 10), nullp
tr, nullptr); | 286 return SkImage::NewFromPicture(picture, SkISize::Make(10, 10), nullp
tr, nullptr); |
287 }); | 287 }); |
288 } | 288 } |
289 } | 289 } |
OLD | NEW |