| 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 SkShaderTraits { | 18 struct SkShaderTraits { |
| 19 static void flatten(SkWriteBuffer& buffer, const SkShader& shader) { | 19 static void Flatten(SkWriteBuffer& buffer, const SkShader& shader) { |
| 20 buffer.writeFlattenable(&shader); | 20 buffer.writeFlattenable(&shader); |
| 21 } | 21 } |
| 22 }; | 22 }; |
| 23 typedef SkFlatDictionary<SkShader, SkShaderTraits> FlatDictionary; | 23 typedef SkFlatDictionary<SkShader, SkShaderTraits> FlatDictionary; |
| 24 | 24 |
| 25 class SkBitmapHeapTester { | 25 class SkBitmapHeapTester { |
| 26 | 26 |
| 27 public: | 27 public: |
| 28 static int32_t GetRefCount(const SkBitmapHeapEntry* entry) { | 28 static int32_t GetRefCount(const SkBitmapHeapEntry* entry) { |
| 29 return entry->fRefCount; | 29 return entry->fRefCount; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 heap.deferAddingOwners(); | 76 heap.deferAddingOwners(); |
| 77 index = dictionary.find(*bitmapShader); | 77 index = dictionary.find(*bitmapShader); |
| 78 heap.endAddingOwnersDeferral(false); | 78 heap.endAddingOwnersDeferral(false); |
| 79 | 79 |
| 80 // The dictionary should report the same index since the new entry is identi
cal. | 80 // The dictionary should report the same index since the new entry is identi
cal. |
| 81 // The bitmap heap should contain the bitmap, but with no references. | 81 // The bitmap heap should contain the bitmap, but with no references. |
| 82 REPORTER_ASSERT(reporter, 1 == index); | 82 REPORTER_ASSERT(reporter, 1 == index); |
| 83 REPORTER_ASSERT(reporter, heap.count() == 1); | 83 REPORTER_ASSERT(reporter, heap.count() == 1); |
| 84 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); | 84 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0))
== 0); |
| 85 } | 85 } |
| OLD | NEW |