141 {
143#ifdef IMPELLER_ENABLE_3D
145#endif
146};
147#undef DL_OP_TO_ENUM_VALUE
148
149class DlOpReceiver;
150class DisplayListBuilder;
151
152class SaveLayerOptions {
153 public:
154 static const SaveLayerOptions kWithAttributes;
155 static const SaveLayerOptions kNoAttributes;
156
157 SaveLayerOptions() : flags_(0) {}
158 SaveLayerOptions(
const SaveLayerOptions&
options) : flags_(
options.flags_) {}
159 explicit SaveLayerOptions(
const SaveLayerOptions*
options)
161
162 SaveLayerOptions without_optimizations() const {
164 options.fRendersWithAttributes = fRendersWithAttributes;
165 options.fBoundsFromCaller = fBoundsFromCaller;
167 }
168
169 bool renders_with_attributes() const { return fRendersWithAttributes; }
170 SaveLayerOptions with_renders_with_attributes() const {
171 SaveLayerOptions
options(
this);
172 options.fRendersWithAttributes =
true;
174 }
175
176 bool can_distribute_opacity() const { return fCanDistributeOpacity; }
177 SaveLayerOptions with_can_distribute_opacity() const {
178 SaveLayerOptions
options(
this);
179 options.fCanDistributeOpacity =
true;
181 }
182
183
184
185
186 bool bounds_from_caller() const { return fBoundsFromCaller; }
187 SaveLayerOptions with_bounds_from_caller() const {
188 SaveLayerOptions
options(
this);
189 options.fBoundsFromCaller =
true;
191 }
192 SaveLayerOptions without_bounds_from_caller() const {
193 SaveLayerOptions
options(
this);
194 options.fBoundsFromCaller =
false;
196 }
197 bool bounds_were_calculated() const { return !fBoundsFromCaller; }
198
199
200
201
202
203 bool content_is_clipped() const { return fContentIsClipped; }
204 SaveLayerOptions with_content_is_clipped() const {
205 SaveLayerOptions
options(
this);
206 options.fContentIsClipped =
true;
208 }
209
210 SaveLayerOptions& operator=(const SaveLayerOptions& other) {
211 flags_ = other.flags_;
212 return *this;
213 }
214 bool operator==(
const SaveLayerOptions& other)
const {
215 return flags_ == other.flags_;
216 }
217 bool operator!=(
const SaveLayerOptions& other)
const {
218 return flags_ != other.flags_;
219 }
220
221 private:
222 union {
223 struct {
224 unsigned fRendersWithAttributes : 1;
225 unsigned fCanDistributeOpacity : 1;
226 unsigned fBoundsFromCaller : 1;
227 unsigned fContentIsClipped : 1;
228 };
229 uint32_t flags_;
230 };
231};
232
233
234class DisplayListStorage {
235 public:
236 DisplayListStorage() = default;
237 DisplayListStorage(DisplayListStorage&&) = default;
238
239 uint8_t* get() const { return ptr_.get(); }
240
242 ptr_.reset(
static_cast<uint8_t*
>(std::realloc(ptr_.release(),
count)));
244 }
245
246 private:
247 struct FreeDeleter {
248 void operator()(uint8_t* p) { std::free(p); }
249 };
250 std::unique_ptr<uint8_t, FreeDeleter> ptr_;
251};
252
253class Culler;
254
255
256
257
258class DisplayList :
public SkRefCnt {
259 public:
260 DisplayList();
261
262 ~DisplayList();
263
264 void Dispatch(DlOpReceiver& ctx) const;
265 void Dispatch(DlOpReceiver& ctx,
const SkRect& cull_rect)
const;
266 void Dispatch(DlOpReceiver& ctx,
const SkIRect& cull_rect)
const;
267
268
269
270
271 size_t bytes(bool nested = true) const {
272 return sizeof(DisplayList) + byte_count_ +
273 (nested ? nested_byte_count_ : 0);
274 }
275
276 uint32_t op_count(bool nested = false) const {
277 return op_count_ + (nested ? nested_op_count_ : 0);
278 }
279
280 uint32_t total_depth() const { return total_depth_; }
281
282 uint32_t unique_id() const { return unique_id_; }
283
285
286 bool has_rtree() const { return rtree_ != nullptr; }
288
289 bool Equals(
const DisplayList* other)
const;
290 bool Equals(
const DisplayList& other)
const {
return Equals(&other); }
293 }
294
295 bool can_apply_group_opacity() const { return can_apply_group_opacity_; }
296 bool isUIThreadSafe() const { return is_ui_thread_safe_; }
297
298
299
300
301
302
303
304
305
306
307 bool modifies_transparent_black() const {
308 return modifies_transparent_black_;
309 }
310
311 private:
312 DisplayList(DisplayListStorage&& ptr,
313 size_t byte_count,
314 uint32_t op_count,
315 size_t nested_byte_count,
316 uint32_t nested_op_count,
317 uint32_t total_depth,
319 bool can_apply_group_opacity,
320 bool is_ui_thread_safe,
321 bool modifies_transparent_black,
323
324 static uint32_t next_unique_id();
325
326 static void DisposeOps(uint8_t* ptr, uint8_t*
end);
327
328 const DisplayListStorage storage_;
329 const size_t byte_count_;
330 const uint32_t op_count_;
331
332 const size_t nested_byte_count_;
333 const uint32_t nested_op_count_;
334
335 const uint32_t total_depth_;
336
337 const uint32_t unique_id_;
339
340 const bool can_apply_group_opacity_;
341 const bool is_ui_thread_safe_;
342 const bool modifies_transparent_black_;
343
345
346 void Dispatch(DlOpReceiver& ctx,
347 uint8_t* ptr,
349 Culler& culler) const;
350
351 friend class DisplayListBuilder;
352};
353
354}
355
356#endif
bool operator!=(const sk_sp< T > &a, const sk_sp< U > &b)
bool Equals(const SkPath &a, const SkPath &b)
#define FOR_EACH_DISPLAY_LIST_OP(V)
#define DL_OP_TO_ENUM_VALUE(name)
bool operator==(const FlutterPoint &a, const FlutterPoint &b)
#define FML_CHECK(condition)
Optional< SkRect > bounds
void * realloc(void *ptr, size_t size)