/src/skia/src/gpu/ganesh/geometry/GrQuadBuffer.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2019 Google LLC |
3 | | * |
4 | | * Use of this source code is governed by a BSD-style license that can be |
5 | | * found in the LICENSE file. |
6 | | */ |
7 | | #ifndef GrQuadBuffer_DEFINED |
8 | | #define GrQuadBuffer_DEFINED |
9 | | |
10 | | #include "include/core/SkRect.h" |
11 | | #include "include/private/base/SkAssert.h" |
12 | | #include "include/private/base/SkDebug.h" |
13 | | #include "include/private/base/SkTDArray.h" |
14 | | #include "src/gpu/ganesh/geometry/GrQuad.h" |
15 | | |
16 | | #include <cstdint> |
17 | | #include <cstring> |
18 | | |
19 | | template<typename T> |
20 | | class GrQuadBuffer { |
21 | | public: |
22 | | GrQuadBuffer() |
23 | | : fCount(0) |
24 | | , fDeviceType(GrQuad::Type::kAxisAligned) |
25 | | , fLocalType(GrQuad::Type::kAxisAligned) { |
26 | | // Pre-allocate space for 1 2D device-space quad, metadata, and header |
27 | | fData.reserve(this->entrySize(fDeviceType, nullptr)); |
28 | | } |
29 | | |
30 | | // Reserves space for the given number of entries; if 'needsLocals' is true, space will be |
31 | | // reserved for each entry to also have a 2D local quad. The reserved space assumes 2D device |
32 | | // quad for simplicity. Since this buffer has a variable bitrate encoding for quads, this may |
33 | | // over or under reserve, but pre-allocating still helps when possible. |
34 | | GrQuadBuffer(int count, bool needsLocals = false) |
35 | | : fCount(0) |
36 | | , fDeviceType(GrQuad::Type::kAxisAligned) |
37 | 274k | , fLocalType(GrQuad::Type::kAxisAligned) { |
38 | 274k | int entrySize = this->entrySize(fDeviceType, needsLocals ? &fLocalType : nullptr); |
39 | 274k | fData.reserve(count * entrySize); |
40 | 274k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::GrQuadBuffer(int, bool) Line | Count | Source | 37 | 269k | , fLocalType(GrQuad::Type::kAxisAligned) { | 38 | 269k | int entrySize = this->entrySize(fDeviceType, needsLocals ? &fLocalType : nullptr); | 39 | 269k | fData.reserve(count * entrySize); | 40 | 269k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::GrQuadBuffer(int, bool) Line | Count | Source | 37 | 4.46k | , fLocalType(GrQuad::Type::kAxisAligned) { | 38 | 4.46k | int entrySize = this->entrySize(fDeviceType, needsLocals ? &fLocalType : nullptr); | 39 | 4.46k | fData.reserve(count * entrySize); | 40 | 4.46k | } |
|
41 | | |
42 | | // The number of device-space quads (and metadata, and optional local quads) that are in the |
43 | | // the buffer. |
44 | 1.39M | int count() const { return fCount; } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::count() const Line | Count | Source | 44 | 1.39M | int count() const { return fCount; } |
Unexecuted instantiation: TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::count() const |
45 | | |
46 | | // The most general type for the device-space quads in this buffer |
47 | 535k | GrQuad::Type deviceQuadType() const { return fDeviceType; } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::deviceQuadType() const Line | Count | Source | 47 | 531k | GrQuad::Type deviceQuadType() const { return fDeviceType; } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::deviceQuadType() const Line | Count | Source | 47 | 4.70k | GrQuad::Type deviceQuadType() const { return fDeviceType; } |
|
48 | | |
49 | | // The most general type for the local quads; if no local quads are ever added, this will |
50 | | // return kAxisAligned. |
51 | 535k | GrQuad::Type localQuadType() const { return fLocalType; } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::localQuadType() const Line | Count | Source | 51 | 531k | GrQuad::Type localQuadType() const { return fLocalType; } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::localQuadType() const Line | Count | Source | 51 | 4.52k | GrQuad::Type localQuadType() const { return fLocalType; } |
|
52 | | |
53 | | // Append the given 'deviceQuad' to this buffer, with its associated 'metadata'. If 'localQuad' |
54 | | // is not null, the local coordinates will also be attached to the entry. When an entry |
55 | | // has local coordinates, during iteration, the Iter::hasLocals() will return true and its |
56 | | // Iter::localQuad() will be equivalent to the provided local coordinates. If 'localQuad' is |
57 | | // null then Iter::hasLocals() will report false for the added entry. |
58 | | void append(const GrQuad& deviceQuad, T&& metadata, const GrQuad* localQuad = nullptr); |
59 | | |
60 | | // Copies all entries from 'that' to this buffer |
61 | | void concat(const GrQuadBuffer<T>& that); |
62 | | |
63 | | // Provides a read-only iterator over a quad buffer, giving access to the device quad, metadata |
64 | | // and optional local quad. |
65 | | class Iter { |
66 | | public: |
67 | | Iter(const GrQuadBuffer<T>* buffer) |
68 | | : fDeviceQuad(SkRect::MakeEmpty()) |
69 | | , fLocalQuad(SkRect::MakeEmpty()) |
70 | | , fBuffer(buffer) |
71 | | , fCurrentEntry(nullptr) |
72 | 363k | , fNextEntry(buffer->fData.begin()) { |
73 | 363k | SkDEBUGCODE(fExpectedCount = buffer->count();) |
74 | 363k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::Iter::Iter(GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA> const*) Line | Count | Source | 72 | 177k | , fNextEntry(buffer->fData.begin()) { | 73 | 177k | SkDEBUGCODE(fExpectedCount = buffer->count();) | 74 | 177k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::Iter::Iter(GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA> const*) Line | Count | Source | 72 | 4.45k | , fNextEntry(buffer->fData.begin()) { | 73 | 4.45k | SkDEBUGCODE(fExpectedCount = buffer->count();) | 74 | 4.45k | } |
FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::Iter::Iter(GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA> const*) Line | Count | Source | 72 | 177k | , fNextEntry(buffer->fData.begin()) { | 73 | 177k | SkDEBUGCODE(fExpectedCount = buffer->count();) | 74 | 177k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::Iter::Iter(GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA> const*) Line | Count | Source | 72 | 4.45k | , fNextEntry(buffer->fData.begin()) { | 73 | 4.45k | SkDEBUGCODE(fExpectedCount = buffer->count();) | 74 | 4.45k | } |
|
75 | | |
76 | | bool next(); |
77 | | |
78 | 273k | const T& metadata() const { this->validate(); return *(fBuffer->metadata(fCurrentEntry)); } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::Iter::metadata() const Line | Count | Source | 78 | 269k | const T& metadata() const { this->validate(); return *(fBuffer->metadata(fCurrentEntry)); } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::Iter::metadata() const Line | Count | Source | 78 | 4.52k | const T& metadata() const { this->validate(); return *(fBuffer->metadata(fCurrentEntry)); } |
|
79 | | |
80 | | // The returned pointer is mutable so that the object can be used for scratch calculations |
81 | | // during op preparation. However, any changes are not persisted in the GrQuadBuffer and |
82 | | // subsequent calls to next() will overwrite the state of the GrQuad. |
83 | 273k | GrQuad* deviceQuad() { this->validate(); return &fDeviceQuad; } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::Iter::deviceQuad() Line | Count | Source | 83 | 269k | GrQuad* deviceQuad() { this->validate(); return &fDeviceQuad; } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::Iter::deviceQuad() Line | Count | Source | 83 | 4.52k | GrQuad* deviceQuad() { this->validate(); return &fDeviceQuad; } |
|
84 | | |
85 | | // If isLocalValid() returns false, this returns nullptr. Otherwise, the returned pointer |
86 | | // is mutable in the same manner as deviceQuad(). |
87 | 273k | GrQuad* localQuad() { |
88 | 273k | this->validate(); |
89 | 273k | return this->isLocalValid() ? &fLocalQuad : nullptr; |
90 | 273k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::Iter::localQuad() Line | Count | Source | 87 | 269k | GrQuad* localQuad() { | 88 | 269k | this->validate(); | 89 | 269k | return this->isLocalValid() ? &fLocalQuad : nullptr; | 90 | 269k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::Iter::localQuad() Line | Count | Source | 87 | 4.52k | GrQuad* localQuad() { | 88 | 4.52k | this->validate(); | 89 | 4.52k | return this->isLocalValid() ? &fLocalQuad : nullptr; | 90 | 4.52k | } |
|
91 | | |
92 | 273k | bool isLocalValid() const { |
93 | 273k | this->validate(); |
94 | 273k | return fBuffer->header(fCurrentEntry)->fHasLocals; |
95 | 273k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::Iter::isLocalValid() const Line | Count | Source | 92 | 269k | bool isLocalValid() const { | 93 | 269k | this->validate(); | 94 | 269k | return fBuffer->header(fCurrentEntry)->fHasLocals; | 95 | 269k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::Iter::isLocalValid() const Line | Count | Source | 92 | 4.52k | bool isLocalValid() const { | 93 | 4.52k | this->validate(); | 94 | 4.52k | return fBuffer->header(fCurrentEntry)->fHasLocals; | 95 | 4.52k | } |
|
96 | | |
97 | | private: |
98 | | // Quads are stored locally so that calling code doesn't need to re-declare their own quads |
99 | | GrQuad fDeviceQuad; |
100 | | GrQuad fLocalQuad; |
101 | | |
102 | | const GrQuadBuffer<T>* fBuffer; |
103 | | // The pointer to the current entry to read metadata/header details from |
104 | | const char* fCurrentEntry; |
105 | | // The pointer to replace fCurrentEntry when next() is called, cached since it is calculated |
106 | | // automatically while unpacking the quad data. |
107 | | const char* fNextEntry; |
108 | | |
109 | | SkDEBUGCODE(int fExpectedCount;) |
110 | | |
111 | 2.19M | void validate() const { |
112 | 2.19M | SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);) |
113 | 2.19M | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::Iter::validate() const Line | Count | Source | 111 | 1.07M | void validate() const { | 112 | 1.07M | SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);) | 113 | 1.07M | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::Iter::validate() const Line | Count | Source | 111 | 18.1k | void validate() const { | 112 | 18.1k | SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);) | 113 | 18.1k | } |
FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::Iter::validate() const Line | Count | Source | 111 | 1.07M | void validate() const { | 112 | 1.07M | SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);) | 113 | 1.07M | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::Iter::validate() const Line | Count | Source | 111 | 18.1k | void validate() const { | 112 | 18.1k | SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);) | 113 | 18.1k | } |
|
114 | | }; |
115 | | |
116 | 181k | Iter iterator() const { return Iter(this); } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::iterator() const Line | Count | Source | 116 | 177k | Iter iterator() const { return Iter(this); } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::iterator() const Line | Count | Source | 116 | 4.45k | Iter iterator() const { return Iter(this); } |
|
117 | | |
118 | | // Provides a *mutable* iterator over just the metadata stored in the quad buffer. This skips |
119 | | // unpacking the device and local quads into GrQuads and is intended for use during op |
120 | | // finalization, which may require rewriting state such as color. |
121 | | class MetadataIter { |
122 | | public: |
123 | | MetadataIter(GrQuadBuffer<T>* list) |
124 | | : fBuffer(list) |
125 | 1.08M | , fCurrentEntry(nullptr) { |
126 | 1.08M | SkDEBUGCODE(fExpectedCount = list->count();) |
127 | 1.08M | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::MetadataIter::MetadataIter(GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>*) Line | Count | Source | 125 | 538k | , fCurrentEntry(nullptr) { | 126 | 538k | SkDEBUGCODE(fExpectedCount = list->count();) | 127 | 538k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::MetadataIter::MetadataIter(GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>*) Line | Count | Source | 125 | 4.45k | , fCurrentEntry(nullptr) { | 126 | 4.45k | SkDEBUGCODE(fExpectedCount = list->count();) | 127 | 4.45k | } |
FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::MetadataIter::MetadataIter(GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>*) Line | Count | Source | 125 | 538k | , fCurrentEntry(nullptr) { | 126 | 538k | SkDEBUGCODE(fExpectedCount = list->count();) | 127 | 538k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::MetadataIter::MetadataIter(GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>*) Line | Count | Source | 125 | 4.45k | , fCurrentEntry(nullptr) { | 126 | 4.45k | SkDEBUGCODE(fExpectedCount = list->count();) | 127 | 4.45k | } |
|
128 | | |
129 | | bool next(); |
130 | | |
131 | | T& operator*() { this->validate(); return *(fBuffer->metadata(fCurrentEntry)); } |
132 | | |
133 | 543k | T* operator->() { this->validate(); return fBuffer->metadata(fCurrentEntry); } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::MetadataIter::operator->() Line | Count | Source | 133 | 539k | T* operator->() { this->validate(); return fBuffer->metadata(fCurrentEntry); } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::MetadataIter::operator->() Line | Count | Source | 133 | 4.52k | T* operator->() { this->validate(); return fBuffer->metadata(fCurrentEntry); } |
|
134 | | |
135 | | private: |
136 | | GrQuadBuffer<T>* fBuffer; |
137 | | char* fCurrentEntry; |
138 | | |
139 | | SkDEBUGCODE(int fExpectedCount;) |
140 | | |
141 | 1.08M | void validate() const { |
142 | 1.08M | SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);) |
143 | 1.08M | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::MetadataIter::validate() const Line | Count | Source | 141 | 539k | void validate() const { | 142 | 539k | SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);) | 143 | 539k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::MetadataIter::validate() const Line | Count | Source | 141 | 4.52k | void validate() const { | 142 | 4.52k | SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);) | 143 | 4.52k | } |
FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::MetadataIter::validate() const Line | Count | Source | 141 | 539k | void validate() const { | 142 | 539k | SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);) | 143 | 539k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::MetadataIter::validate() const Line | Count | Source | 141 | 4.52k | void validate() const { | 142 | 4.52k | SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);) | 143 | 4.52k | } |
|
144 | | }; |
145 | | |
146 | 543k | MetadataIter metadata() { return MetadataIter(this); } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::metadata() Line | Count | Source | 146 | 538k | MetadataIter metadata() { return MetadataIter(this); } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::metadata() Line | Count | Source | 146 | 4.45k | MetadataIter metadata() { return MetadataIter(this); } |
|
147 | | |
148 | | private: |
149 | | struct alignas(int32_t) Header { |
150 | | unsigned fDeviceType : 2; |
151 | | unsigned fLocalType : 2; // Ignore if fHasLocals is false |
152 | | unsigned fHasLocals : 1; |
153 | | // Known value to detect if iteration doesn't properly advance through the buffer |
154 | | SkDEBUGCODE(unsigned fSentinel : 27;) |
155 | | }; |
156 | | static_assert(sizeof(Header) == sizeof(int32_t), "Header should be 4 bytes"); |
157 | | |
158 | | inline static constexpr unsigned kSentinel = 0xbaffe; |
159 | | inline static constexpr int kMetaSize = sizeof(Header) + sizeof(T); |
160 | | inline static constexpr int k2DQuadFloats = 8; |
161 | | inline static constexpr int k3DQuadFloats = 12; |
162 | | |
163 | | // Each logical entry in the buffer is a variable length tuple storing device coordinates, |
164 | | // optional local coordinates, and metadata. An entry always has a header that defines the |
165 | | // quad types of device and local coordinates, and always has metadata of type T. The device |
166 | | // and local quads' data follows as a variable length array of floats: |
167 | | // [ header ] = 4 bytes |
168 | | // [ metadata ] = sizeof(T), assert alignof(T) == 4 so that pointer casts are valid |
169 | | // [ device xs ] = 4 floats = 16 bytes |
170 | | // [ device ys ] = 4 floats |
171 | | // [ device ws ] = 4 floats or 0 floats depending on fDeviceType in header |
172 | | // [ local xs ] = 4 floats or 0 floats depending on fHasLocals in header |
173 | | // [ local ys ] = 4 floats or 0 floats depending on fHasLocals in header |
174 | | // [ local ws ] = 4 floats or 0 floats depending on fHasLocals and fLocalType in header |
175 | | // FIXME (michaelludwig) - Since this is intended only for ops, can we use the arena to |
176 | | // allocate storage for the quad buffer? Since this is forward-iteration only, could also |
177 | | // explore a linked-list structure for concatenating quads when batching ops |
178 | | SkTDArray<char> fData; |
179 | | |
180 | | int fCount; // Number of (device, local, metadata) entries |
181 | | GrQuad::Type fDeviceType; // Most general type of all entries |
182 | | GrQuad::Type fLocalType; |
183 | | |
184 | 1.09M | inline int entrySize(GrQuad::Type deviceType, const GrQuad::Type* localType) const { |
185 | 1.09M | int size = kMetaSize; |
186 | 1.09M | size += (deviceType == GrQuad::Type::kPerspective ? k3DQuadFloats |
187 | 1.09M | : k2DQuadFloats) * sizeof(float); |
188 | 1.09M | if (localType) { |
189 | 1.08M | size += (*localType == GrQuad::Type::kPerspective ? k3DQuadFloats |
190 | 1.08M | : k2DQuadFloats) * sizeof(float); |
191 | 1.08M | } |
192 | 1.09M | return size; |
193 | 1.09M | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::entrySize(GrQuad::Type, GrQuad::Type const*) const Line | Count | Source | 184 | 1.07M | inline int entrySize(GrQuad::Type deviceType, const GrQuad::Type* localType) const { | 185 | 1.07M | int size = kMetaSize; | 186 | 1.07M | size += (deviceType == GrQuad::Type::kPerspective ? k3DQuadFloats | 187 | 1.07M | : k2DQuadFloats) * sizeof(float); | 188 | 1.07M | if (localType) { | 189 | 1.07M | size += (*localType == GrQuad::Type::kPerspective ? k3DQuadFloats | 190 | 1.07M | : k2DQuadFloats) * sizeof(float); | 191 | 1.07M | } | 192 | 1.07M | return size; | 193 | 1.07M | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::entrySize(GrQuad::Type, GrQuad::Type const*) const Line | Count | Source | 184 | 13.5k | inline int entrySize(GrQuad::Type deviceType, const GrQuad::Type* localType) const { | 185 | 13.5k | int size = kMetaSize; | 186 | 13.5k | size += (deviceType == GrQuad::Type::kPerspective ? k3DQuadFloats | 187 | 13.5k | : k2DQuadFloats) * sizeof(float); | 188 | 13.5k | if (localType) { | 189 | 13.5k | size += (*localType == GrQuad::Type::kPerspective ? k3DQuadFloats | 190 | 13.5k | : k2DQuadFloats) * sizeof(float); | 191 | 13.5k | } | 192 | 13.5k | return size; | 193 | 13.5k | } |
|
194 | 543k | inline int entrySize(const Header* header) const { |
195 | 543k | if (header->fHasLocals) { |
196 | 542k | GrQuad::Type localType = static_cast<GrQuad::Type>(header->fLocalType); |
197 | 542k | return this->entrySize(static_cast<GrQuad::Type>(header->fDeviceType), &localType); |
198 | 542k | } else { |
199 | 1.65k | return this->entrySize(static_cast<GrQuad::Type>(header->fDeviceType), nullptr); |
200 | 1.65k | } |
201 | 543k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::entrySize(GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::Header const*) const Line | Count | Source | 194 | 539k | inline int entrySize(const Header* header) const { | 195 | 539k | if (header->fHasLocals) { | 196 | 537k | GrQuad::Type localType = static_cast<GrQuad::Type>(header->fLocalType); | 197 | 537k | return this->entrySize(static_cast<GrQuad::Type>(header->fDeviceType), &localType); | 198 | 537k | } else { | 199 | 1.65k | return this->entrySize(static_cast<GrQuad::Type>(header->fDeviceType), nullptr); | 200 | 1.65k | } | 201 | 539k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::entrySize(GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::Header const*) const Line | Count | Source | 194 | 4.52k | inline int entrySize(const Header* header) const { | 195 | 4.52k | if (header->fHasLocals) { | 196 | 4.52k | GrQuad::Type localType = static_cast<GrQuad::Type>(header->fLocalType); | 197 | 4.52k | return this->entrySize(static_cast<GrQuad::Type>(header->fDeviceType), &localType); | 198 | 4.52k | } else { | 199 | 0 | return this->entrySize(static_cast<GrQuad::Type>(header->fDeviceType), nullptr); | 200 | 0 | } | 201 | 4.52k | } |
|
202 | | |
203 | | // Helpers to access typed sections of the buffer, given the start of an entry |
204 | 818k | inline Header* header(char* entry) { |
205 | 818k | return static_cast<Header*>(static_cast<void*>(entry)); |
206 | 818k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::header(char*) Line | Count | Source | 204 | 809k | inline Header* header(char* entry) { | 205 | 809k | return static_cast<Header*>(static_cast<void*>(entry)); | 206 | 809k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::header(char*) Line | Count | Source | 204 | 9.06k | inline Header* header(char* entry) { | 205 | 9.06k | return static_cast<Header*>(static_cast<void*>(entry)); | 206 | 9.06k | } |
|
207 | 547k | inline const Header* header(const char* entry) const { |
208 | 547k | return static_cast<const Header*>(static_cast<const void*>(entry)); |
209 | 547k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::header(char const*) const Line | Count | Source | 207 | 538k | inline const Header* header(const char* entry) const { | 208 | 538k | return static_cast<const Header*>(static_cast<const void*>(entry)); | 209 | 538k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::header(char const*) const Line | Count | Source | 207 | 9.05k | inline const Header* header(const char* entry) const { | 208 | 9.05k | return static_cast<const Header*>(static_cast<const void*>(entry)); | 209 | 9.05k | } |
|
210 | | |
211 | 818k | inline T* metadata(char* entry) { |
212 | 818k | return static_cast<T*>(static_cast<void*>(entry + sizeof(Header))); |
213 | 818k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::metadata(char*) Line | Count | Source | 211 | 809k | inline T* metadata(char* entry) { | 212 | 809k | return static_cast<T*>(static_cast<void*>(entry + sizeof(Header))); | 213 | 809k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::metadata(char*) Line | Count | Source | 211 | 9.06k | inline T* metadata(char* entry) { | 212 | 9.06k | return static_cast<T*>(static_cast<void*>(entry + sizeof(Header))); | 213 | 9.06k | } |
|
214 | 273k | inline const T* metadata(const char* entry) const { |
215 | 273k | return static_cast<const T*>(static_cast<const void*>(entry + sizeof(Header))); |
216 | 273k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::metadata(char const*) const Line | Count | Source | 214 | 269k | inline const T* metadata(const char* entry) const { | 215 | 269k | return static_cast<const T*>(static_cast<const void*>(entry + sizeof(Header))); | 216 | 269k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::metadata(char const*) const Line | Count | Source | 214 | 4.52k | inline const T* metadata(const char* entry) const { | 215 | 4.52k | return static_cast<const T*>(static_cast<const void*>(entry + sizeof(Header))); | 216 | 4.52k | } |
|
217 | | |
218 | 274k | inline float* coords(char* entry) { |
219 | 274k | return static_cast<float*>(static_cast<void*>(entry + kMetaSize)); |
220 | 274k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::coords(char*) Line | Count | Source | 218 | 270k | inline float* coords(char* entry) { | 219 | 270k | return static_cast<float*>(static_cast<void*>(entry + kMetaSize)); | 220 | 270k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::coords(char*) Line | Count | Source | 218 | 4.53k | inline float* coords(char* entry) { | 219 | 4.53k | return static_cast<float*>(static_cast<void*>(entry + kMetaSize)); | 220 | 4.53k | } |
|
221 | 273k | inline const float* coords(const char* entry) const { |
222 | 273k | return static_cast<const float*>(static_cast<const void*>(entry + kMetaSize)); |
223 | 273k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::coords(char const*) const Line | Count | Source | 221 | 269k | inline const float* coords(const char* entry) const { | 222 | 269k | return static_cast<const float*>(static_cast<const void*>(entry + kMetaSize)); | 223 | 269k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::coords(char const*) const Line | Count | Source | 221 | 4.52k | inline const float* coords(const char* entry) const { | 222 | 4.52k | return static_cast<const float*>(static_cast<const void*>(entry + kMetaSize)); | 223 | 4.52k | } |
|
224 | | |
225 | | // Helpers to convert from coordinates to GrQuad and vice versa, returning pointer to the |
226 | | // next packed quad coordinates. |
227 | | float* packQuad(const GrQuad& quad, float* coords); |
228 | | const float* unpackQuad(GrQuad::Type type, const float* coords, GrQuad* quad) const; |
229 | | |
230 | | #ifdef SK_DEBUG |
231 | | void validate(const char* entry, int expectedCount) const; |
232 | | #endif |
233 | | }; |
234 | | |
235 | | /////////////////////////////////////////////////////////////////////////////////////////////////// |
236 | | // Buffer implementation |
237 | | /////////////////////////////////////////////////////////////////////////////////////////////////// |
238 | | |
239 | | template<typename T> |
240 | 548k | float* GrQuadBuffer<T>::packQuad(const GrQuad& quad, float* coords) { |
241 | | // Copies all 12 (or 8) floats at once, so requires the 3 arrays to be contiguous |
242 | | // FIXME(michaelludwig) - If this turns out not to be the case, just do 4 copies |
243 | 548k | SkASSERT(quad.xs() + 4 == quad.ys() && quad.xs() + 8 == quad.ws()); |
244 | 548k | if (quad.hasPerspective()) { |
245 | 9.80k | memcpy(coords, quad.xs(), k3DQuadFloats * sizeof(float)); |
246 | 9.80k | return coords + k3DQuadFloats; |
247 | 538k | } else { |
248 | 538k | memcpy(coords, quad.xs(), k2DQuadFloats * sizeof(float)); |
249 | 538k | return coords + k2DQuadFloats; |
250 | 538k | } |
251 | 548k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::packQuad(GrQuad const&, float*) Line | Count | Source | 240 | 539k | float* GrQuadBuffer<T>::packQuad(const GrQuad& quad, float* coords) { | 241 | | // Copies all 12 (or 8) floats at once, so requires the 3 arrays to be contiguous | 242 | | // FIXME(michaelludwig) - If this turns out not to be the case, just do 4 copies | 243 | 539k | SkASSERT(quad.xs() + 4 == quad.ys() && quad.xs() + 8 == quad.ws()); | 244 | 539k | if (quad.hasPerspective()) { | 245 | 9.65k | memcpy(coords, quad.xs(), k3DQuadFloats * sizeof(float)); | 246 | 9.65k | return coords + k3DQuadFloats; | 247 | 529k | } else { | 248 | 529k | memcpy(coords, quad.xs(), k2DQuadFloats * sizeof(float)); | 249 | 529k | return coords + k2DQuadFloats; | 250 | 529k | } | 251 | 539k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::packQuad(GrQuad const&, float*) Line | Count | Source | 240 | 9.07k | float* GrQuadBuffer<T>::packQuad(const GrQuad& quad, float* coords) { | 241 | | // Copies all 12 (or 8) floats at once, so requires the 3 arrays to be contiguous | 242 | | // FIXME(michaelludwig) - If this turns out not to be the case, just do 4 copies | 243 | 9.07k | SkASSERT(quad.xs() + 4 == quad.ys() && quad.xs() + 8 == quad.ws()); | 244 | 9.07k | if (quad.hasPerspective()) { | 245 | 152 | memcpy(coords, quad.xs(), k3DQuadFloats * sizeof(float)); | 246 | 152 | return coords + k3DQuadFloats; | 247 | 8.92k | } else { | 248 | 8.92k | memcpy(coords, quad.xs(), k2DQuadFloats * sizeof(float)); | 249 | 8.92k | return coords + k2DQuadFloats; | 250 | 8.92k | } | 251 | 9.07k | } |
|
252 | | |
253 | | template<typename T> |
254 | 547k | const float* GrQuadBuffer<T>::unpackQuad(GrQuad::Type type, const float* coords, GrQuad* quad) const { |
255 | 547k | SkASSERT(quad->xs() + 4 == quad->ys() && quad->xs() + 8 == quad->ws()); |
256 | 547k | if (type == GrQuad::Type::kPerspective) { |
257 | | // Fill in X, Y, and W in one go |
258 | 9.80k | memcpy(quad->xs(), coords, k3DQuadFloats * sizeof(float)); |
259 | 9.80k | coords = coords + k3DQuadFloats; |
260 | 537k | } else { |
261 | | // Fill in X and Y of the quad, the setQuadType() below will set Ws to 1 if needed |
262 | 537k | memcpy(quad->xs(), coords, k2DQuadFloats * sizeof(float)); |
263 | 537k | coords = coords + k2DQuadFloats; |
264 | 537k | } |
265 | | |
266 | 547k | quad->setQuadType(type); |
267 | 547k | return coords; |
268 | 547k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::unpackQuad(GrQuad::Type, float const*, GrQuad*) const Line | Count | Source | 254 | 538k | const float* GrQuadBuffer<T>::unpackQuad(GrQuad::Type type, const float* coords, GrQuad* quad) const { | 255 | 538k | SkASSERT(quad->xs() + 4 == quad->ys() && quad->xs() + 8 == quad->ws()); | 256 | 538k | if (type == GrQuad::Type::kPerspective) { | 257 | | // Fill in X, Y, and W in one go | 258 | 9.65k | memcpy(quad->xs(), coords, k3DQuadFloats * sizeof(float)); | 259 | 9.65k | coords = coords + k3DQuadFloats; | 260 | 528k | } else { | 261 | | // Fill in X and Y of the quad, the setQuadType() below will set Ws to 1 if needed | 262 | 528k | memcpy(quad->xs(), coords, k2DQuadFloats * sizeof(float)); | 263 | 528k | coords = coords + k2DQuadFloats; | 264 | 528k | } | 265 | | | 266 | 538k | quad->setQuadType(type); | 267 | 538k | return coords; | 268 | 538k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::unpackQuad(GrQuad::Type, float const*, GrQuad*) const Line | Count | Source | 254 | 9.05k | const float* GrQuadBuffer<T>::unpackQuad(GrQuad::Type type, const float* coords, GrQuad* quad) const { | 255 | 9.05k | SkASSERT(quad->xs() + 4 == quad->ys() && quad->xs() + 8 == quad->ws()); | 256 | 9.05k | if (type == GrQuad::Type::kPerspective) { | 257 | | // Fill in X, Y, and W in one go | 258 | 152 | memcpy(quad->xs(), coords, k3DQuadFloats * sizeof(float)); | 259 | 152 | coords = coords + k3DQuadFloats; | 260 | 8.90k | } else { | 261 | | // Fill in X and Y of the quad, the setQuadType() below will set Ws to 1 if needed | 262 | 8.90k | memcpy(quad->xs(), coords, k2DQuadFloats * sizeof(float)); | 263 | 8.90k | coords = coords + k2DQuadFloats; | 264 | 8.90k | } | 265 | | | 266 | 9.05k | quad->setQuadType(type); | 267 | 9.05k | return coords; | 268 | 9.05k | } |
|
269 | | |
270 | | template<typename T> |
271 | 274k | void GrQuadBuffer<T>::append(const GrQuad& deviceQuad, T&& metadata, const GrQuad* localQuad) { |
272 | 274k | GrQuad::Type localType = localQuad ? localQuad->quadType() : GrQuad::Type::kAxisAligned; |
273 | 274k | int entrySize = this->entrySize(deviceQuad.quadType(), localQuad ? &localType : nullptr); |
274 | | |
275 | | // Fill in the entry, as described in fData's declaration |
276 | 274k | char* entry = fData.append(entrySize); |
277 | | // First the header |
278 | 274k | Header* h = this->header(entry); |
279 | 274k | h->fDeviceType = static_cast<unsigned>(deviceQuad.quadType()); |
280 | 274k | h->fHasLocals = static_cast<unsigned>(localQuad != nullptr); |
281 | 274k | h->fLocalType = static_cast<unsigned>(localQuad ? localQuad->quadType() |
282 | 274k | : GrQuad::Type::kAxisAligned); |
283 | 274k | SkDEBUGCODE(h->fSentinel = static_cast<unsigned>(kSentinel);) |
284 | | |
285 | | // Second, the fixed-size metadata |
286 | 274k | static_assert(alignof(T) == 4, "Metadata must be 4 byte aligned"); |
287 | 274k | *(this->metadata(entry)) = std::move(metadata); |
288 | | |
289 | | // Then the variable blocks of x, y, and w float coordinates |
290 | 274k | float* coords = this->coords(entry); |
291 | 274k | coords = this->packQuad(deviceQuad, coords); |
292 | 274k | if (localQuad) { |
293 | 273k | coords = this->packQuad(*localQuad, coords); |
294 | 273k | } |
295 | 274k | SkASSERT((char*)coords - entry == entrySize); |
296 | | |
297 | | // Entry complete, update buffer-level state |
298 | 274k | fCount++; |
299 | 274k | if (deviceQuad.quadType() > fDeviceType) { |
300 | 4.01k | fDeviceType = deviceQuad.quadType(); |
301 | 4.01k | } |
302 | 274k | if (localQuad && localQuad->quadType() > fLocalType) { |
303 | 21.6k | fLocalType = localQuad->quadType(); |
304 | 21.6k | } |
305 | 274k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::append(GrQuad const&, (anonymous namespace)::FillRectOpImpl::ColorAndAA&&, GrQuad const*) Line | Count | Source | 271 | 270k | void GrQuadBuffer<T>::append(const GrQuad& deviceQuad, T&& metadata, const GrQuad* localQuad) { | 272 | 270k | GrQuad::Type localType = localQuad ? localQuad->quadType() : GrQuad::Type::kAxisAligned; | 273 | 270k | int entrySize = this->entrySize(deviceQuad.quadType(), localQuad ? &localType : nullptr); | 274 | | | 275 | | // Fill in the entry, as described in fData's declaration | 276 | 270k | char* entry = fData.append(entrySize); | 277 | | // First the header | 278 | 270k | Header* h = this->header(entry); | 279 | 270k | h->fDeviceType = static_cast<unsigned>(deviceQuad.quadType()); | 280 | 270k | h->fHasLocals = static_cast<unsigned>(localQuad != nullptr); | 281 | 270k | h->fLocalType = static_cast<unsigned>(localQuad ? localQuad->quadType() | 282 | 270k | : GrQuad::Type::kAxisAligned); | 283 | 270k | SkDEBUGCODE(h->fSentinel = static_cast<unsigned>(kSentinel);) | 284 | | | 285 | | // Second, the fixed-size metadata | 286 | 270k | static_assert(alignof(T) == 4, "Metadata must be 4 byte aligned"); | 287 | 270k | *(this->metadata(entry)) = std::move(metadata); | 288 | | | 289 | | // Then the variable blocks of x, y, and w float coordinates | 290 | 270k | float* coords = this->coords(entry); | 291 | 270k | coords = this->packQuad(deviceQuad, coords); | 292 | 270k | if (localQuad) { | 293 | 269k | coords = this->packQuad(*localQuad, coords); | 294 | 269k | } | 295 | 270k | SkASSERT((char*)coords - entry == entrySize); | 296 | | | 297 | | // Entry complete, update buffer-level state | 298 | 270k | fCount++; | 299 | 270k | if (deviceQuad.quadType() > fDeviceType) { | 300 | 3.76k | fDeviceType = deviceQuad.quadType(); | 301 | 3.76k | } | 302 | 270k | if (localQuad && localQuad->quadType() > fLocalType) { | 303 | 21.6k | fLocalType = localQuad->quadType(); | 304 | 21.6k | } | 305 | 270k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::append(GrQuad const&, (anonymous namespace)::TextureOpImpl::ColorSubsetAndAA&&, GrQuad const*) Line | Count | Source | 271 | 4.53k | void GrQuadBuffer<T>::append(const GrQuad& deviceQuad, T&& metadata, const GrQuad* localQuad) { | 272 | 4.53k | GrQuad::Type localType = localQuad ? localQuad->quadType() : GrQuad::Type::kAxisAligned; | 273 | 4.53k | int entrySize = this->entrySize(deviceQuad.quadType(), localQuad ? &localType : nullptr); | 274 | | | 275 | | // Fill in the entry, as described in fData's declaration | 276 | 4.53k | char* entry = fData.append(entrySize); | 277 | | // First the header | 278 | 4.53k | Header* h = this->header(entry); | 279 | 4.53k | h->fDeviceType = static_cast<unsigned>(deviceQuad.quadType()); | 280 | 4.53k | h->fHasLocals = static_cast<unsigned>(localQuad != nullptr); | 281 | 4.53k | h->fLocalType = static_cast<unsigned>(localQuad ? localQuad->quadType() | 282 | 4.53k | : GrQuad::Type::kAxisAligned); | 283 | 4.53k | SkDEBUGCODE(h->fSentinel = static_cast<unsigned>(kSentinel);) | 284 | | | 285 | | // Second, the fixed-size metadata | 286 | 4.53k | static_assert(alignof(T) == 4, "Metadata must be 4 byte aligned"); | 287 | 4.53k | *(this->metadata(entry)) = std::move(metadata); | 288 | | | 289 | | // Then the variable blocks of x, y, and w float coordinates | 290 | 4.53k | float* coords = this->coords(entry); | 291 | 4.53k | coords = this->packQuad(deviceQuad, coords); | 292 | 4.53k | if (localQuad) { | 293 | 4.53k | coords = this->packQuad(*localQuad, coords); | 294 | 4.53k | } | 295 | 4.53k | SkASSERT((char*)coords - entry == entrySize); | 296 | | | 297 | | // Entry complete, update buffer-level state | 298 | 4.53k | fCount++; | 299 | 4.53k | if (deviceQuad.quadType() > fDeviceType) { | 300 | 256 | fDeviceType = deviceQuad.quadType(); | 301 | 256 | } | 302 | 4.53k | if (localQuad && localQuad->quadType() > fLocalType) { | 303 | 76 | fLocalType = localQuad->quadType(); | 304 | 76 | } | 305 | 4.53k | } |
Unexecuted instantiation: FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::append(GrQuad const&, (anonymous namespace)::FillRectOpImpl::ColorAndAA&&, GrQuad const*) Unexecuted instantiation: TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::append(GrQuad const&, (anonymous namespace)::TextureOpImpl::ColorSubsetAndAA&&, GrQuad const*) |
306 | | |
307 | | template<typename T> |
308 | 92.2k | void GrQuadBuffer<T>::concat(const GrQuadBuffer<T>& that) { |
309 | 92.2k | fData.append(that.fData.size(), that.fData.begin()); |
310 | 92.2k | fCount += that.fCount; |
311 | 92.2k | if (that.fDeviceType > fDeviceType) { |
312 | 3 | fDeviceType = that.fDeviceType; |
313 | 3 | } |
314 | 92.2k | if (that.fLocalType > fLocalType) { |
315 | 4 | fLocalType = that.fLocalType; |
316 | 4 | } |
317 | 92.2k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::concat(GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA> const&) Line | Count | Source | 308 | 92.2k | void GrQuadBuffer<T>::concat(const GrQuadBuffer<T>& that) { | 309 | 92.2k | fData.append(that.fData.size(), that.fData.begin()); | 310 | 92.2k | fCount += that.fCount; | 311 | 92.2k | if (that.fDeviceType > fDeviceType) { | 312 | 3 | fDeviceType = that.fDeviceType; | 313 | 3 | } | 314 | 92.2k | if (that.fLocalType > fLocalType) { | 315 | 4 | fLocalType = that.fLocalType; | 316 | 4 | } | 317 | 92.2k | } |
Unexecuted instantiation: TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::concat(GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA> const&) |
318 | | |
319 | | #ifdef SK_DEBUG |
320 | | template<typename T> |
321 | 0 | void GrQuadBuffer<T>::validate(const char* entry, int expectedCount) const { |
322 | | // Triggers if accessing before next() is called on an iterator |
323 | 0 | SkASSERT(entry); |
324 | | // Triggers if accessing after next() returns false |
325 | 0 | SkASSERT(entry < fData.end()); |
326 | | // Triggers if elements have been added to the buffer while iterating entries |
327 | 0 | SkASSERT(expectedCount == fCount); |
328 | | // Make sure the start of the entry looks like a header |
329 | 0 | SkASSERT(this->header(entry)->fSentinel == kSentinel); |
330 | 0 | } Unexecuted instantiation: FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::validate(char const*, int) const Unexecuted instantiation: TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::validate(char const*, int) const |
331 | | #endif |
332 | | |
333 | | /////////////////////////////////////////////////////////////////////////////////////////////////// |
334 | | // Iterator implementations |
335 | | /////////////////////////////////////////////////////////////////////////////////////////////////// |
336 | | |
337 | | template<typename T> |
338 | 451k | bool GrQuadBuffer<T>::Iter::next() { |
339 | 451k | SkASSERT(fNextEntry); |
340 | 451k | if (fNextEntry >= fBuffer->fData.end()) { |
341 | 177k | return false; |
342 | 177k | } |
343 | | // There is at least one more entry, so store the current start for metadata access |
344 | 273k | fCurrentEntry = fNextEntry; |
345 | | |
346 | | // And then unpack the device and optional local coordinates into fDeviceQuad and fLocalQuad |
347 | 273k | const Header* h = fBuffer->header(fCurrentEntry); |
348 | 273k | const float* coords = fBuffer->coords(fCurrentEntry); |
349 | 273k | coords = fBuffer->unpackQuad(static_cast<GrQuad::Type>(h->fDeviceType), coords, &fDeviceQuad); |
350 | 273k | if (h->fHasLocals) { |
351 | 273k | coords = fBuffer->unpackQuad(static_cast<GrQuad::Type>(h->fLocalType), coords, &fLocalQuad); |
352 | 273k | } // else localQuad() will return a nullptr so no need to reset fLocalQuad |
353 | | |
354 | | // At this point, coords points to the start of the next entry |
355 | 273k | fNextEntry = static_cast<const char*>(static_cast<const void*>(coords)); |
356 | 273k | SkASSERT((fNextEntry - fCurrentEntry) == fBuffer->entrySize(h)); |
357 | 273k | return true; |
358 | 451k | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::Iter::next() Line | Count | Source | 338 | 446k | bool GrQuadBuffer<T>::Iter::next() { | 339 | 446k | SkASSERT(fNextEntry); | 340 | 446k | if (fNextEntry >= fBuffer->fData.end()) { | 341 | 177k | return false; | 342 | 177k | } | 343 | | // There is at least one more entry, so store the current start for metadata access | 344 | 269k | fCurrentEntry = fNextEntry; | 345 | | | 346 | | // And then unpack the device and optional local coordinates into fDeviceQuad and fLocalQuad | 347 | 269k | const Header* h = fBuffer->header(fCurrentEntry); | 348 | 269k | const float* coords = fBuffer->coords(fCurrentEntry); | 349 | 269k | coords = fBuffer->unpackQuad(static_cast<GrQuad::Type>(h->fDeviceType), coords, &fDeviceQuad); | 350 | 269k | if (h->fHasLocals) { | 351 | 268k | coords = fBuffer->unpackQuad(static_cast<GrQuad::Type>(h->fLocalType), coords, &fLocalQuad); | 352 | 268k | } // else localQuad() will return a nullptr so no need to reset fLocalQuad | 353 | | | 354 | | // At this point, coords points to the start of the next entry | 355 | 269k | fNextEntry = static_cast<const char*>(static_cast<const void*>(coords)); | 356 | 269k | SkASSERT((fNextEntry - fCurrentEntry) == fBuffer->entrySize(h)); | 357 | 269k | return true; | 358 | 446k | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::Iter::next() Line | Count | Source | 338 | 4.52k | bool GrQuadBuffer<T>::Iter::next() { | 339 | 4.52k | SkASSERT(fNextEntry); | 340 | 4.52k | if (fNextEntry >= fBuffer->fData.end()) { | 341 | 0 | return false; | 342 | 0 | } | 343 | | // There is at least one more entry, so store the current start for metadata access | 344 | 4.52k | fCurrentEntry = fNextEntry; | 345 | | | 346 | | // And then unpack the device and optional local coordinates into fDeviceQuad and fLocalQuad | 347 | 4.52k | const Header* h = fBuffer->header(fCurrentEntry); | 348 | 4.52k | const float* coords = fBuffer->coords(fCurrentEntry); | 349 | 4.52k | coords = fBuffer->unpackQuad(static_cast<GrQuad::Type>(h->fDeviceType), coords, &fDeviceQuad); | 350 | 4.52k | if (h->fHasLocals) { | 351 | 4.52k | coords = fBuffer->unpackQuad(static_cast<GrQuad::Type>(h->fLocalType), coords, &fLocalQuad); | 352 | 4.52k | } // else localQuad() will return a nullptr so no need to reset fLocalQuad | 353 | | | 354 | | // At this point, coords points to the start of the next entry | 355 | 4.52k | fNextEntry = static_cast<const char*>(static_cast<const void*>(coords)); | 356 | 4.52k | SkASSERT((fNextEntry - fCurrentEntry) == fBuffer->entrySize(h)); | 357 | 4.52k | return true; | 358 | 4.52k | } |
|
359 | | |
360 | | template<typename T> |
361 | 1.08M | bool GrQuadBuffer<T>::MetadataIter::next() { |
362 | 1.08M | if (fCurrentEntry) { |
363 | | // Advance pointer by entry size |
364 | 543k | if (fCurrentEntry < fBuffer->fData.end()) { |
365 | 543k | const Header* h = fBuffer->header(fCurrentEntry); |
366 | 543k | fCurrentEntry += fBuffer->entrySize(h); |
367 | 543k | } |
368 | 543k | } else { |
369 | | // First call to next |
370 | 543k | fCurrentEntry = fBuffer->fData.begin(); |
371 | 543k | } |
372 | | // Nothing else is needed to do but report whether or not the updated pointer is valid |
373 | 1.08M | return fCurrentEntry < fBuffer->fData.end(); |
374 | 1.08M | } FillRectOp.cpp:GrQuadBuffer<(anonymous namespace)::FillRectOpImpl::ColorAndAA>::MetadataIter::next() Line | Count | Source | 361 | 1.07M | bool GrQuadBuffer<T>::MetadataIter::next() { | 362 | 1.07M | if (fCurrentEntry) { | 363 | | // Advance pointer by entry size | 364 | 539k | if (fCurrentEntry < fBuffer->fData.end()) { | 365 | 539k | const Header* h = fBuffer->header(fCurrentEntry); | 366 | 539k | fCurrentEntry += fBuffer->entrySize(h); | 367 | 539k | } | 368 | 539k | } else { | 369 | | // First call to next | 370 | 538k | fCurrentEntry = fBuffer->fData.begin(); | 371 | 538k | } | 372 | | // Nothing else is needed to do but report whether or not the updated pointer is valid | 373 | 1.07M | return fCurrentEntry < fBuffer->fData.end(); | 374 | 1.07M | } |
TextureOp.cpp:GrQuadBuffer<(anonymous namespace)::TextureOpImpl::ColorSubsetAndAA>::MetadataIter::next() Line | Count | Source | 361 | 8.97k | bool GrQuadBuffer<T>::MetadataIter::next() { | 362 | 8.97k | if (fCurrentEntry) { | 363 | | // Advance pointer by entry size | 364 | 4.52k | if (fCurrentEntry < fBuffer->fData.end()) { | 365 | 4.52k | const Header* h = fBuffer->header(fCurrentEntry); | 366 | 4.52k | fCurrentEntry += fBuffer->entrySize(h); | 367 | 4.52k | } | 368 | 4.52k | } else { | 369 | | // First call to next | 370 | 4.45k | fCurrentEntry = fBuffer->fData.begin(); | 371 | 4.45k | } | 372 | | // Nothing else is needed to do but report whether or not the updated pointer is valid | 373 | 8.97k | return fCurrentEntry < fBuffer->fData.end(); | 374 | 8.97k | } |
|
375 | | #endif // GrQuadBuffer_DEFINED |