Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: tests/BitmapHeapTest.cpp

Issue 123213004: Function pointers -> templates in SkPictureFlat. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: align storage Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pipe/SkGPipeWrite.cpp ('k') | tests/FlatDataTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 17 #include "TestClassDef.h"
18 18
19 class FlatDictionary : public SkFlatDictionary<SkShader> { 19 struct SkShaderTraits {
20 20 static void flatten(SkOrderedWriteBuffer& buffer, const SkShader& shader) {
21 public: 21 buffer.writeFlattenable(&shader);
22 FlatDictionary(SkFlatController* controller)
23 : SkFlatDictionary<SkShader>(controller) {
24 fFlattenProc = &flattenFlattenableProc;
25 // No need for an unflattenProc
26 }
27 static void flattenFlattenableProc(SkOrderedWriteBuffer& buffer, const void* obj) {
28 buffer.writeFlattenable((SkFlattenable*)obj);
29 } 22 }
30 }; 23 };
24 typedef SkFlatDictionary<SkShader, SkShaderTraits> FlatDictionary;
31 25
32 class SkBitmapHeapTester { 26 class SkBitmapHeapTester {
33 27
34 public: 28 public:
35 static int32_t GetRefCount(const SkBitmapHeapEntry* entry) { 29 static int32_t GetRefCount(const SkBitmapHeapEntry* entry) {
36 return entry->fRefCount; 30 return entry->fRefCount;
37 } 31 }
38 }; 32 };
39 33
40 DEF_TEST(BitmapHeap, reporter) { 34 DEF_TEST(BitmapHeap, reporter) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 heap.deferAddingOwners(); 78 heap.deferAddingOwners();
85 index = dictionary.find(*bitmapShader); 79 index = dictionary.find(*bitmapShader);
86 heap.endAddingOwnersDeferral(false); 80 heap.endAddingOwnersDeferral(false);
87 81
88 // The dictionary should report the same index since the new entry is identi cal. 82 // The dictionary should report the same index since the new entry is identi cal.
89 // The bitmap heap should contain the bitmap, but with no references. 83 // The bitmap heap should contain the bitmap, but with no references.
90 REPORTER_ASSERT(reporter, 1 == index); 84 REPORTER_ASSERT(reporter, 1 == index);
91 REPORTER_ASSERT(reporter, heap.count() == 1); 85 REPORTER_ASSERT(reporter, heap.count() == 1);
92 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0)) == 0); 86 REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0)) == 0);
93 } 87 }
OLDNEW
« no previous file with comments | « src/pipe/SkGPipeWrite.cpp ('k') | tests/FlatDataTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698