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

Side by Side Diff: include/core/SkDataTable.h

Issue 26223009: Remove SkDataTable from SkFlattenable hierarchy. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/core/SkDataTable.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 2013 Google Inc. 2 * Copyright 2013 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 #ifndef SkDataTable_DEFINED 8 #ifndef SkDataTable_DEFINED
9 #define SkDataTable_DEFINED 9 #define SkDataTable_DEFINED
10 10
11 #include "SkChunkAlloc.h" 11 #include "SkChunkAlloc.h"
12 #include "SkData.h" 12 #include "SkData.h"
13 #include "SkFlattenable.h"
14 #include "SkString.h" 13 #include "SkString.h"
15 #include "SkTDArray.h" 14 #include "SkTDArray.h"
16 15
17 /** 16 /**
18 * Like SkData, SkDataTable holds an immutable data buffer. The data buffer is 17 * Like SkData, SkDataTable holds an immutable data buffer. The data buffer is
19 * organized into a table of entries, each with a length, so the entries are 18 * organized into a table of entries, each with a length, so the entries are
20 * not required to all be the same size. 19 * not required to all be the same size.
21 */ 20 */
22 class SK_API SkDataTable : public SkFlattenable { 21 class SK_API SkDataTable : public SkRefCnt {
23 public: 22 public:
24 SK_DECLARE_INST_COUNT(SkDataTable) 23 SK_DECLARE_INST_COUNT(SkDataTable)
25 24
26 /** 25 /**
27 * Returns true if the table is empty (i.e. has no entries). 26 * Returns true if the table is empty (i.e. has no entries).
28 */ 27 */
29 bool isEmpty() const { return 0 == fCount; } 28 bool isEmpty() const { return 0 == fCount; }
30 29
31 /** 30 /**
32 * Return the number of entries in the table. 0 for an empty table 31 * Return the number of entries in the table. 0 for an empty table
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 * @param elemSize byte-length for a given element. 86 * @param elemSize byte-length for a given element.
88 * @param count the number of entries to be copied out of array. The number 87 * @param count the number of entries to be copied out of array. The number
89 * of bytes that will be copied is count * elemSize. 88 * of bytes that will be copied is count * elemSize.
90 */ 89 */
91 static SkDataTable* NewCopyArray(const void* array, size_t elemSize, 90 static SkDataTable* NewCopyArray(const void* array, size_t elemSize,
92 int count); 91 int count);
93 92
94 static SkDataTable* NewArrayProc(const void* array, size_t elemSize, 93 static SkDataTable* NewArrayProc(const void* array, size_t elemSize,
95 int count, FreeProc proc, void* context); 94 int count, FreeProc proc, void* context);
96 95
97 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDataTable)
98
99 protected:
100 SkDataTable(SkFlattenableReadBuffer&);
101 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
102
103 private: 96 private:
104 struct Dir { 97 struct Dir {
105 const void* fPtr; 98 const void* fPtr;
106 uintptr_t fSize; 99 uintptr_t fSize;
107 }; 100 };
108 101
109 int fCount; 102 int fCount;
110 size_t fElemSize; 103 size_t fElemSize;
111 union { 104 union {
112 const Dir* fDir; 105 const Dir* fDir;
113 const char* fElems; 106 const char* fElems;
114 } fU; 107 } fU;
115 108
116 FreeProc fFreeProc; 109 FreeProc fFreeProc;
117 void* fFreeProcContext; 110 void* fFreeProcContext;
118 111
119 SkDataTable(); 112 SkDataTable();
120 SkDataTable(const void* array, size_t elemSize, int count, 113 SkDataTable(const void* array, size_t elemSize, int count,
121 FreeProc, void* context); 114 FreeProc, void* context);
122 SkDataTable(const Dir*, int count, FreeProc, void* context); 115 SkDataTable(const Dir*, int count, FreeProc, void* context);
123 virtual ~SkDataTable(); 116 virtual ~SkDataTable();
124 117
125 friend class SkDataTableBuilder; // access to Dir 118 friend class SkDataTableBuilder; // access to Dir
126 119
127 typedef SkFlattenable INHERITED; 120 typedef SkRefCnt INHERITED;
128 }; 121 };
129 122
130 /** 123 /**
131 * Helper class that allows for incrementally building up the data needed to 124 * Helper class that allows for incrementally building up the data needed to
132 * create a SkDataTable. 125 * create a SkDataTable.
133 */ 126 */
134 class SK_API SkDataTableBuilder : SkNoncopyable { 127 class SK_API SkDataTableBuilder : SkNoncopyable {
135 public: 128 public:
136 SkDataTableBuilder(size_t minChunkSize); 129 SkDataTableBuilder(size_t minChunkSize);
137 ~SkDataTableBuilder(); 130 ~SkDataTableBuilder();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 */ 168 */
176 SkDataTable* detachDataTable(); 169 SkDataTable* detachDataTable();
177 170
178 private: 171 private:
179 SkTDArray<SkDataTable::Dir> fDir; 172 SkTDArray<SkDataTable::Dir> fDir;
180 SkChunkAlloc* fHeap; 173 SkChunkAlloc* fHeap;
181 size_t fMinChunkSize; 174 size_t fMinChunkSize;
182 }; 175 };
183 176
184 #endif 177 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkDataTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698