7#include "flutter/display_list/display_list.h"
8#include "flutter/display_list/dl_op_records.h"
9#include "flutter/fml/trace_event.h"
20 nested_byte_count_(0),
24 bounds_({0, 0, 0, 0}),
25 can_apply_group_opacity_(
true),
26 is_ui_thread_safe_(
true),
27 modifies_transparent_black_(
false),
28 root_has_backdrop_filter_(
false),
34 size_t nested_byte_count,
35 uint32_t nested_op_count,
38 bool can_apply_group_opacity,
39 bool is_ui_thread_safe,
40 bool modifies_transparent_black,
42 bool root_has_backdrop_filter,
44 : storage_(
std::move(storage)),
45 byte_count_(byte_count),
47 nested_byte_count_(nested_byte_count),
48 nested_op_count_(nested_op_count),
49 total_depth_(total_depth),
50 unique_id_(next_unique_id()),
52 can_apply_group_opacity_(can_apply_group_opacity),
53 is_ui_thread_safe_(is_ui_thread_safe),
54 modifies_transparent_black_(modifies_transparent_black),
55 root_has_backdrop_filter_(root_has_backdrop_filter),
56 max_root_blend_mode_(max_root_blend_mode),
57 rtree_(
std::move(rtree)) {}
60 const uint8_t* ptr = storage_.
get();
61 DisposeOps(ptr, ptr + byte_count_);
64uint32_t DisplayList::next_unique_id() {
65 static std::atomic<uint32_t>
next_id{1};
68 id =
next_id.fetch_add(+1, std::memory_order_relaxed);
100 : rtree_(rtree), cur_(rect_indices.
begin()), end_(rect_indices.
end()) {}
125 while (cur_ < end_) {
146 std::vector<int>::const_iterator cur_;
147 std::vector<int>::const_iterator end_;
151 const uint8_t* ptr = storage_.
get();
156 const SkIRect& cull_rect)
const {
161 const SkRect& cull_rect)
const {
171 const uint8_t* ptr = storage_.
get();
172 std::vector<int> rect_indices;
173 rtree->search(cull_rect, &rect_indices);
175 Dispatch(receiver, ptr, ptr + byte_count_, culler);
188 if (!culler.
init(context)) {
192 auto op =
reinterpret_cast<const DLOp*
>(ptr);
196#define DL_OP_DISPATCH(name) \
197 case DisplayListOpType::k##name: \
198 static_cast<const name##Op*>(op)->dispatch(context); \
202#ifdef IMPELLER_ENABLE_3D
216void DisplayList::DisposeOps(
const uint8_t* ptr,
const uint8_t* end) {
218 auto op =
reinterpret_cast<const DLOp*
>(ptr);
222#define DL_OP_DISPOSE(name) \
223 case DisplayListOpType::k##name: \
224 if (!std::is_trivially_destructible_v<name##Op>) { \
225 static_cast<const name##Op*>(op)->~name##Op(); \
230#ifdef IMPELLER_ENABLE_3D
246 const uint8_t* endB) {
250 const uint8_t* bulk_start_a = ptrA;
251 const uint8_t* bulk_start_b = ptrB;
252 while (ptrA < endA && ptrB < endB) {
253 auto opA =
reinterpret_cast<const DLOp*
>(ptrA);
254 auto opB =
reinterpret_cast<const DLOp*
>(ptrB);
255 if (opA->type != opB->type || opA->size != opB->size) {
264#define DL_OP_EQUALS(name) \
265 case DisplayListOpType::k##name: \
266 result = static_cast<const name##Op*>(opA)->equals( \
267 static_cast<const name##Op*>(opB)); \
271#ifdef IMPELLER_ENABLE_3D
289 auto bulk_bytes =
reinterpret_cast<const uint8_t*
>(opA) - bulk_start_a;
290 if (bulk_bytes > 0) {
291 if (memcmp(bulk_start_a, bulk_start_b, bulk_bytes) != 0) {
300 if (ptrA != endA || ptrB != endB) {
303 if (bulk_start_a < ptrA) {
305 if (memcmp(bulk_start_a, bulk_start_b, ptrA - bulk_start_a) != 0) {
316 if (byte_count_ != other->byte_count_ || op_count_ != other->op_count_) {
319 const uint8_t* ptr = storage_.
get();
320 const uint8_t* o_ptr = other->storage_.
get();
324 return CompareOps(ptr, ptr + byte_count_, o_ptr, o_ptr + other->byte_count_);
static uint32_t next_id()
virtual void update(DispatchContext &context)=0
virtual bool init(DispatchContext &context)=0
virtual ~Culler()=default
const SkRect & bounds() const
bool Equals(const DisplayList *other) const
void Dispatch(DlOpReceiver &ctx) const
sk_sp< const DlRTree > rtree() const
Internal API for rendering recorded display lists to backends.
int id(int result_index) const
void update(DispatchContext &context) override
bool init(DispatchContext &context) override
static NopCuller instance
static const SaveLayerOptions kNoAttributes
SaveLayerOptions with_renders_with_attributes() const
static const SaveLayerOptions kWithAttributes
bool init(DispatchContext &context) override
void update(DispatchContext &context) override
VectorCuller(const DlRTree *rtree, const std::vector< int > &rect_indices)
#define DL_OP_EQUALS(name)
#define DL_OP_DISPOSE(name)
#define DL_OP_DISPATCH(name)
#define FOR_EACH_DISPLAY_LIST_OP(V)
static const char * begin(const StringSlice &s)
#define FML_DCHECK(condition)
static float max(float r, float g, float b)
Optional< SkRect > bounds
static bool CompareOps(const uint8_t *ptrA, const uint8_t *endA, const uint8_t *ptrB, const uint8_t *endB)
flutter::SaveLayerOptions SaveLayerOptions
static SkRect Make(const SkISize &size)
bool contains(SkScalar x, SkScalar y) const