OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 SkRecord_DEFINED | 8 #ifndef SkRecord_DEFINED |
9 #define SkRecord_DEFINED | 9 #define SkRecord_DEFINED |
10 | 10 |
11 #include "SkRecords.h" | 11 #include "SkRecords.h" |
12 #include "SkTLogic.h" | 12 #include "SkTLogic.h" |
13 #include "SkTemplates.h" | 13 #include "SkTemplates.h" |
14 #include "SkVarAlloc.h" | 14 #include "SkVarAlloc.h" |
15 | 15 |
16 // SkRecord (REC-ord) represents a sequence of SkCanvas calls, saved for future
use. | 16 // SkRecord (REC-ord) represents a sequence of SkCanvas calls, saved for future
use. |
17 // These future uses may include: replay, optimization, serialization, or combin
ations of those. | 17 // These future uses may include: replay, optimization, serialization, or combin
ations of those. |
18 // | 18 // |
19 // Though an enterprising user may find calling alloc(), append(), visit(), and
mutate() enough to | 19 // Though an enterprising user may find calling alloc(), append(), visit(), and
mutate() enough to |
20 // work with SkRecord, you probably want to look at SkRecorder which presents an
SkCanvas interface | 20 // work with SkRecord, you probably want to look at SkRecorder which presents an
SkCanvas interface |
21 // for creating an SkRecord, and SkRecordDraw which plays an SkRecord back into
another SkCanvas. | 21 // for creating an SkRecord, and SkRecordDraw which plays an SkRecord back into
another SkCanvas. |
22 // | 22 // |
23 // SkRecord often looks like it's compatible with any type T, but really it's co
mpatible with any | 23 // SkRecord often looks like it's compatible with any type T, but really it's co
mpatible with any |
24 // type T which has a static const SkRecords::Type kType. That is to say, SkRec
ord is compatible | 24 // type T which has a static const SkRecords::Type kType. That is to say, SkRec
ord is compatible |
25 // only with SkRecords::* structs defined in SkRecords.h. Your compiler will he
lpfully yell if you | 25 // only with SkRecords::* structs defined in SkRecords.h. Your compiler will he
lpfully yell if you |
26 // get this wrong. | 26 // get this wrong. |
27 | 27 |
28 class SkRecord : SkNoncopyable { | 28 class SkRecord : public SkNVRefCnt<SkRecord> { |
29 enum { | 29 enum { |
30 kFirstReserveCount = 64 / sizeof(void*), | 30 kFirstReserveCount = 64 / sizeof(void*), |
31 }; | 31 }; |
32 public: | 32 public: |
33 SkRecord() : fCount(0), fReserved(0) {} | 33 SkRecord() : fCount(0), fReserved(0) {} |
34 | 34 |
35 ~SkRecord() { | 35 ~SkRecord() { |
36 Destroyer destroyer; | 36 Destroyer destroyer; |
37 for (unsigned i = 0; i < this->count(); i++) { | 37 for (unsigned i = 0; i < this->count(); i++) { |
38 this->mutate<void>(i, destroyer); | 38 this->mutate<void>(i, destroyer); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 233 |
234 // fCount and fReserved measure both fRecords and fTypes, which always grow
in lock step. | 234 // fCount and fReserved measure both fRecords and fTypes, which always grow
in lock step. |
235 unsigned fCount; | 235 unsigned fCount; |
236 unsigned fReserved; | 236 unsigned fReserved; |
237 SkAutoTMalloc<Record> fRecords; | 237 SkAutoTMalloc<Record> fRecords; |
238 SkAutoTMalloc<Type8> fTypes; | 238 SkAutoTMalloc<Type8> fTypes; |
239 SkVarAlloc fAlloc; | 239 SkVarAlloc fAlloc; |
240 // Strangely the order of these fields matters. If the unsigneds don't go f
irst we're 56 bytes. | 240 // Strangely the order of these fields matters. If the unsigneds don't go f
irst we're 56 bytes. |
241 // tomhudson and mtklein have no idea why. | 241 // tomhudson and mtklein have no idea why. |
242 }; | 242 }; |
243 SK_COMPILE_ASSERT(sizeof(SkRecord) <= 48, SkRecordSize); | 243 SK_COMPILE_ASSERT(sizeof(SkRecord) <= 56, SkRecordSize); |
244 | 244 |
245 #endif//SkRecord_DEFINED | 245 #endif//SkRecord_DEFINED |
OLD | NEW |