diff --git a/flow/display_list.cc b/flow/display_list.cc index 6178eb2fed93b..836181a622780 100644 --- a/flow/display_list.cc +++ b/flow/display_list.cc @@ -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) { 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}), @@ -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 diff --git a/flow/display_list.h b/flow/display_list.h index a765cfbf6ce6a..35087469b7f79 100644 --- a/flow/display_list.h +++ b/flow/display_list.h @@ -168,8 +168,7 @@ 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}), @@ -177,7 +176,10 @@ class DisplayList : public SkRefCnt { ~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; @@ -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> storage_; size_t used_; int op_count_;