Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions flow/display_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -951,17 +951,19 @@ bool DisplayList::Equals(const DisplayList& other) const {
if (used_ != other.used_ || op_count_ != other.op_count_) {
return false;
}
if (ptr_ == other.ptr_) {
uint8_t* ptr = storage_.get();
uint8_t* o_ptr = other.storage_.get();
if (ptr == o_ptr) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you should be able to compare the unique_ptrs directly.

if (storage_ == other.storage_) {
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need them anyway for the next step.

return true;
}
return CompareOps(ptr_, ptr_ + used_, other.ptr_, other.ptr_ + other.used_);
return CompareOps(ptr, ptr + used_, o_ptr, o_ptr + other.used_);
}

DisplayList::DisplayList(uint8_t* ptr,
size_t used,
int op_count,
const SkRect& cull)
: ptr_(ptr),
: storage_(ptr),
used_(used),
op_count_(op_count),
bounds_({0, 0, -1, -1}),
Expand All @@ -973,7 +975,8 @@ DisplayList::DisplayList(uint8_t* ptr,
}

DisplayList::~DisplayList() {
DisposeOps(ptr_, ptr_ + used_);
uint8_t* ptr = storage_.get();
DisposeOps(ptr, ptr + used_);
}

#define DL_BUILDER_PAGE 4096
Expand Down
10 changes: 6 additions & 4 deletions flow/display_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,18 @@ class DisplayList : public SkRefCnt {
static const SkSamplingOptions CubicSampling;

DisplayList()
: ptr_(nullptr),
used_(0),
: used_(0),
op_count_(0),
unique_id_(0),
bounds_({0, 0, 0, 0}),
bounds_cull_({0, 0, 0, 0}) {}

~DisplayList();

void Dispatch(Dispatcher& ctx) const { Dispatch(ctx, ptr_, ptr_ + used_); }
void Dispatch(Dispatcher& ctx) const {
uint8_t* ptr = storage_.get();
Dispatch(ctx, ptr, ptr + used_);
}

void RenderTo(SkCanvas* canvas) const;

Expand All @@ -199,7 +201,7 @@ class DisplayList : public SkRefCnt {
private:
DisplayList(uint8_t* ptr, size_t used, int op_count, const SkRect& cull_rect);

uint8_t* ptr_;
std::unique_ptr<uint8_t, SkFunctionWrapper<void(void*), sk_free>> storage_;
size_t used_;
int op_count_;

Expand Down