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" |
11 #include "SkFlattenable.h" | 11 #include "SkFlattenable.h" |
12 #include "SkOrderedWriteBuffer.h" | 12 #include "SkOrderedWriteBuffer.h" |
13 #include "SkPictureFlat.h" | 13 #include "SkPictureFlat.h" |
14 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
15 #include "SkShader.h" | 15 #include "SkShader.h" |
16 #include "Test.h" | 16 #include "Test.h" |
17 #include "TestClassDef.h" | |
18 | 17 |
19 struct SkShaderTraits { | 18 struct SkShaderTraits { |
20 static void flatten(SkOrderedWriteBuffer& buffer, const SkShader& shader) { | 19 static void flatten(SkOrderedWriteBuffer& buffer, const SkShader& shader) { |
21 buffer.writeFlattenable(&shader); | 20 buffer.writeFlattenable(&shader); |
22 } | 21 } |
23 }; | 22 }; |
24 typedef SkFlatDictionary<SkShader, SkShaderTraits> FlatDictionary; | 23 typedef SkFlatDictionary<SkShader, SkShaderTraits> FlatDictionary; |
25 | 24 |
26 class SkBitmapHeapTester { | 25 class SkBitmapHeapTester { |
27 | 26 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 heap.deferAddingOwners(); | 77 heap.deferAddingOwners(); |
79 index = dictionary.find(*bitmapShader); | 78 index = dictionary.find(*bitmapShader); |
80 heap.endAddingOwnersDeferral(false); | 79 heap.endAddingOwnersDeferral(false); |
81 | 80 |
82 // The dictionary should report the same index since the new entry is identi
cal. | 81 // The dictionary should report the same index since the new entry is identi
cal. |
83 // The bitmap heap should contain the bitmap, but with no references. | 82 // The bitmap heap should contain the bitmap, but with no references. |
84 REPORTER_ASSERT(reporter, 1 == index); | 83 REPORTER_ASSERT(reporter, 1 == index); |
85 REPORTER_ASSERT(reporter, heap.count() == 1); | 84 REPORTER_ASSERT(reporter, heap.count() == 1); |
86 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); | 85 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); |
87 } | 86 } |
OLD | NEW |