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 ~SimpleFlatController() { fAllocations.freeAll(); } | 20 ~SimpleFlatController() { fAllocations.freeAll(); } |
21 void* allocThrow(size_t bytes) SK_OVERRIDE { | 21 void* allocThrow(size_t bytes) override { |
22 fAllocations.push(sk_malloc_throw(bytes)); | 22 fAllocations.push(sk_malloc_throw(bytes)); |
23 return fAllocations.top(); | 23 return fAllocations.top(); |
24 } | 24 } |
25 void unalloc(void*) SK_OVERRIDE { } | 25 void unalloc(void*) override { } |
26 void setBitmapStorage(SkBitmapHeap* h) { this->setBitmapHeap(h); } | 26 void setBitmapStorage(SkBitmapHeap* h) { this->setBitmapHeap(h); } |
27 private: | 27 private: |
28 SkTDArray<void*> fAllocations; | 28 SkTDArray<void*> fAllocations; |
29 }; | 29 }; |
30 | 30 |
31 struct SkShaderTraits { | 31 struct SkShaderTraits { |
32 static void Flatten(SkWriteBuffer& buffer, const SkShader& shader) { | 32 static void Flatten(SkWriteBuffer& buffer, const SkShader& shader) { |
33 buffer.writeFlattenable(&shader); | 33 buffer.writeFlattenable(&shader); |
34 } | 34 } |
35 }; | 35 }; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 heap.deferAddingOwners(); | 88 heap.deferAddingOwners(); |
89 index = dictionary.find(*bitmapShader); | 89 index = dictionary.find(*bitmapShader); |
90 heap.endAddingOwnersDeferral(false); | 90 heap.endAddingOwnersDeferral(false); |
91 | 91 |
92 // 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. |
93 // The bitmap heap should contain the bitmap, but with no references. | 93 // The bitmap heap should contain the bitmap, but with no references. |
94 REPORTER_ASSERT(reporter, 1 == index); | 94 REPORTER_ASSERT(reporter, 1 == index); |
95 REPORTER_ASSERT(reporter, heap.count() == 1); | 95 REPORTER_ASSERT(reporter, heap.count() == 1); |
96 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); | 96 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); |
97 } | 97 } |
OLD | NEW |