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 auto bitmapShader = SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMod
e, | 53 SkShader* bitmapShader = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_
TileMode, |
54 SkShader::kRepeat_TileMode); | 54 SkShader::kRepeat_Tile
Mode); |
| 55 SkAutoTUnref<SkShader> aur(bitmapShader); |
55 | 56 |
56 // Flatten, storing it in the bitmap heap. | 57 // Flatten, storing it in the bitmap heap. |
57 SkBitmapHeap heap(1, 1); | 58 SkBitmapHeap heap(1, 1); |
58 SimpleFlatController controller; | 59 SimpleFlatController controller; |
59 controller.setBitmapStorage(&heap); | 60 controller.setBitmapStorage(&heap); |
60 FlatDictionary dictionary(&controller); | 61 FlatDictionary dictionary(&controller); |
61 | 62 |
62 // Dictionary and heap start off empty. | 63 // Dictionary and heap start off empty. |
63 REPORTER_ASSERT(reporter, heap.count() == 0); | 64 REPORTER_ASSERT(reporter, heap.count() == 0); |
64 REPORTER_ASSERT(reporter, dictionary.count() == 0); | 65 REPORTER_ASSERT(reporter, dictionary.count() == 0); |
(...skipping 22 matching lines...) Expand all Loading... |
87 heap.deferAddingOwners(); | 88 heap.deferAddingOwners(); |
88 index = dictionary.find(*bitmapShader); | 89 index = dictionary.find(*bitmapShader); |
89 heap.endAddingOwnersDeferral(false); | 90 heap.endAddingOwnersDeferral(false); |
90 | 91 |
91 // The dictionary should report the same index since the new entry is identi
cal. | 92 // The dictionary should report the same index since the new entry is identi
cal. |
92 // The bitmap heap should contain the bitmap, but with no references. | 93 // The bitmap heap should contain the bitmap, but with no references. |
93 REPORTER_ASSERT(reporter, 1 == index); | 94 REPORTER_ASSERT(reporter, 1 == index); |
94 REPORTER_ASSERT(reporter, heap.count() == 1); | 95 REPORTER_ASSERT(reporter, heap.count() == 1); |
95 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); | 96 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); |
96 } | 97 } |
OLD | NEW |