Chromium Code Reviews| 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 "SkChunkAlloc.h" | 11 #include "SkChunkAlloc.h" |
| 12 #include "SkRecords.h" | 12 #include "SkRecords.h" |
| 13 #include "SkTLogic.h" | 13 #include "SkTLogic.h" |
| 14 #include "SkTemplates.h" | 14 #include "SkTemplates.h" |
| 15 | 15 |
| 16 struct SkRecordAnalysis { | |
| 17 SkRecordAnalysis() | |
| 18 : fWillPlaybackBitmaps(false) | |
| 19 , fSuitableForGpuRasterization(false) { } | |
| 20 | |
| 21 bool fWillPlaybackBitmaps; | |
| 22 bool fSuitableForGpuRasterization; | |
| 23 }; | |
| 24 | |
| 16 // SkRecord (REC-ord) represents a sequence of SkCanvas calls, saved for future use. | 25 // 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. | 26 // These future uses may include: replay, optimization, serialization, or combin ations of those. |
| 18 // | 27 // |
| 19 // Though an enterprising user may find calling alloc(), append(), visit(), and mutate() enough to | 28 // 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 | 29 // 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. | 30 // for creating an SkRecord, and SkRecordDraw which plays an SkRecord back into another SkCanvas. |
| 22 // | 31 // |
| 23 // SkRecord often looks like it's compatible with any type T, but really it's co mpatible with any | 32 // 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 | 33 // 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 | 34 // only with SkRecords::* structs defined in SkRecords.h. Your compiler will he lpfully yell if you |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 T* replace(unsigned i, const SkRecords::Adopted<Existing>& proofOfAdoption) { | 112 T* replace(unsigned i, const SkRecords::Adopted<Existing>& proofOfAdoption) { |
| 104 SkASSERT(i < this->count()); | 113 SkASSERT(i < this->count()); |
| 105 | 114 |
| 106 SkASSERT(Existing::kType == fTypes[i]); | 115 SkASSERT(Existing::kType == fTypes[i]); |
| 107 SkASSERT(proofOfAdoption == fRecords[i].ptr<Existing>()); | 116 SkASSERT(proofOfAdoption == fRecords[i].ptr<Existing>()); |
| 108 | 117 |
| 109 fTypes[i] = T::kType; | 118 fTypes[i] = T::kType; |
| 110 return fRecords[i].set(this->allocCommand<T>()); | 119 return fRecords[i].set(this->allocCommand<T>()); |
| 111 } | 120 } |
| 112 | 121 |
| 122 SkRecordAnalysis fAccelerationInfo; | |
|
mtklein
2014/08/18 16:34:58
Let's keep this parallel to SkRecord like fWillPla
tomhudson
2014/08/18 16:58:47
(This was intended to be a private member with acc
| |
| 123 | |
| 113 private: | 124 private: |
| 114 // Implementation notes! | 125 // Implementation notes! |
| 115 // | 126 // |
| 116 // Logically an SkRecord is structured as an array of pointers into a big ch unk of memory where | 127 // Logically an SkRecord is structured as an array of pointers into a big ch unk of memory where |
| 117 // records representing each canvas draw call are stored: | 128 // records representing each canvas draw call are stored: |
| 118 // | 129 // |
| 119 // fRecords: [*][*][*]... | 130 // fRecords: [*][*][*]... |
| 120 // | | | | 131 // | | | |
| 121 // | | | | 132 // | | | |
| 122 // | | +---------------------------------------+ | 133 // | | +---------------------------------------+ |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 SkChunkAlloc fAlloc; | 236 SkChunkAlloc fAlloc; |
| 226 SkAutoTMalloc<Record> fRecords; | 237 SkAutoTMalloc<Record> fRecords; |
| 227 SkAutoTMalloc<Type8> fTypes; | 238 SkAutoTMalloc<Type8> fTypes; |
| 228 // fCount and fReserved measure both fRecords and fTypes, which always grow in lock step. | 239 // fCount and fReserved measure both fRecords and fTypes, which always grow in lock step. |
| 229 unsigned fCount; | 240 unsigned fCount; |
| 230 unsigned fReserved; | 241 unsigned fReserved; |
| 231 const unsigned kFirstReserveCount; | 242 const unsigned kFirstReserveCount; |
| 232 }; | 243 }; |
| 233 | 244 |
| 234 #endif//SkRecord_DEFINED | 245 #endif//SkRecord_DEFINED |
| OLD | NEW |