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 "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.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 | 17 |
18 struct SimpleFlatController : public SkFlatController { | 18 struct SimpleFlatController : public SkFlatController { |
19 SimpleFlatController() : SkFlatController() {} | 19 SimpleFlatController() : SkFlatController() {} |
20 virtual void* allocThrow(size_t bytes) { return sk_malloc_throw(bytes); } | 20 virtual void* allocThrow(size_t bytes) SK_OVERRIDE { return sk_malloc_throw(
bytes); } |
21 virtual void unalloc(void* ptr) { sk_free(ptr); } | 21 virtual void unalloc(void* ptr) SK_OVERRIDE { sk_free(ptr); } |
22 void setBitmapStorage(SkBitmapHeap* h) { this->setBitmapHeap(h); } | 22 void setBitmapStorage(SkBitmapHeap* h) { this->setBitmapHeap(h); } |
23 }; | 23 }; |
24 | 24 |
25 struct SkShaderTraits { | 25 struct SkShaderTraits { |
26 static void Flatten(SkWriteBuffer& buffer, const SkShader& shader) { | 26 static void Flatten(SkWriteBuffer& buffer, const SkShader& shader) { |
27 buffer.writeFlattenable(&shader); | 27 buffer.writeFlattenable(&shader); |
28 } | 28 } |
29 }; | 29 }; |
30 typedef SkFlatDictionary<SkShader, SkShaderTraits> FlatDictionary; | 30 typedef SkFlatDictionary<SkShader, SkShaderTraits> FlatDictionary; |
31 | 31 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 heap.deferAddingOwners(); | 82 heap.deferAddingOwners(); |
83 index = dictionary.find(*bitmapShader); | 83 index = dictionary.find(*bitmapShader); |
84 heap.endAddingOwnersDeferral(false); | 84 heap.endAddingOwnersDeferral(false); |
85 | 85 |
86 // The dictionary should report the same index since the new entry is identi
cal. | 86 // The dictionary should report the same index since the new entry is identi
cal. |
87 // The bitmap heap should contain the bitmap, but with no references. | 87 // The bitmap heap should contain the bitmap, but with no references. |
88 REPORTER_ASSERT(reporter, 1 == index); | 88 REPORTER_ASSERT(reporter, 1 == index); |
89 REPORTER_ASSERT(reporter, heap.count() == 1); | 89 REPORTER_ASSERT(reporter, heap.count() == 1); |
90 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); | 90 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); |
91 } | 91 } |
OLD | NEW |