OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkBitmapHeap.h" | 9 #include "SkBitmapHeap.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 }; | 43 }; |
44 | 44 |
45 DEF_TEST(BitmapHeap, reporter) { | 45 DEF_TEST(BitmapHeap, reporter) { |
46 // Create a bitmap shader. | 46 // Create a bitmap shader. |
47 SkBitmap bm; | 47 SkBitmap bm; |
48 bm.allocN32Pixels(2, 2); | 48 bm.allocN32Pixels(2, 2); |
49 bm.eraseColor(SK_ColorRED); | 49 bm.eraseColor(SK_ColorRED); |
50 uint32_t* pixel = bm.getAddr32(1,0); | 50 uint32_t* pixel = bm.getAddr32(1,0); |
51 *pixel = SK_ColorBLUE; | 51 *pixel = SK_ColorBLUE; |
52 | 52 |
53 SkShader* bitmapShader = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_
TileMode, | 53 auto bitmapShader = SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMod
e, |
54 SkShader::kRepeat_Tile
Mode); | 54 SkShader::kRepeat_TileMode); |
55 SkAutoTUnref<SkShader> aur(bitmapShader); | |
56 | 55 |
57 // Flatten, storing it in the bitmap heap. | 56 // Flatten, storing it in the bitmap heap. |
58 SkBitmapHeap heap(1, 1); | 57 SkBitmapHeap heap(1, 1); |
59 SimpleFlatController controller; | 58 SimpleFlatController controller; |
60 controller.setBitmapStorage(&heap); | 59 controller.setBitmapStorage(&heap); |
61 FlatDictionary dictionary(&controller); | 60 FlatDictionary dictionary(&controller); |
62 | 61 |
63 // Dictionary and heap start off empty. | 62 // Dictionary and heap start off empty. |
64 REPORTER_ASSERT(reporter, heap.count() == 0); | 63 REPORTER_ASSERT(reporter, heap.count() == 0); |
65 REPORTER_ASSERT(reporter, dictionary.count() == 0); | 64 REPORTER_ASSERT(reporter, dictionary.count() == 0); |
(...skipping 22 matching lines...) Expand all Loading... |
88 heap.deferAddingOwners(); | 87 heap.deferAddingOwners(); |
89 index = dictionary.find(*bitmapShader); | 88 index = dictionary.find(*bitmapShader); |
90 heap.endAddingOwnersDeferral(false); | 89 heap.endAddingOwnersDeferral(false); |
91 | 90 |
92 // The dictionary should report the same index since the new entry is identi
cal. | 91 // The dictionary should report the same index since the new entry is identi
cal. |
93 // The bitmap heap should contain the bitmap, but with no references. | 92 // The bitmap heap should contain the bitmap, but with no references. |
94 REPORTER_ASSERT(reporter, 1 == index); | 93 REPORTER_ASSERT(reporter, 1 == index); |
95 REPORTER_ASSERT(reporter, heap.count() == 1); | 94 REPORTER_ASSERT(reporter, heap.count() == 1); |
96 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); | 95 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); |
97 } | 96 } |
OLD | NEW |