mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove DisplayList's dependency on SkAutoTMalloc (flutter/engine#38359)
SkAutoTMalloc is not a public Skia API
This commit is contained in:
parent
25ca78aaec
commit
46a94de351
@ -25,7 +25,7 @@ DisplayList::DisplayList()
|
||||
bounds_({0, 0, 0, 0}),
|
||||
can_apply_group_opacity_(true) {}
|
||||
|
||||
DisplayList::DisplayList(uint8_t* ptr,
|
||||
DisplayList::DisplayList(DisplayListStorage&& storage,
|
||||
size_t byte_count,
|
||||
unsigned int op_count,
|
||||
size_t nested_byte_count,
|
||||
@ -33,7 +33,7 @@ DisplayList::DisplayList(uint8_t* ptr,
|
||||
const SkRect& bounds,
|
||||
bool can_apply_group_opacity,
|
||||
sk_sp<const DlRTree> rtree)
|
||||
: storage_(ptr),
|
||||
: storage_(std::move(storage)),
|
||||
byte_count_(byte_count),
|
||||
op_count_(op_count),
|
||||
nested_byte_count_(nested_byte_count),
|
||||
|
||||
@ -215,6 +215,26 @@ class SaveLayerOptions {
|
||||
};
|
||||
};
|
||||
|
||||
// Manages a buffer allocated with malloc.
|
||||
class DisplayListStorage {
|
||||
public:
|
||||
DisplayListStorage() = default;
|
||||
DisplayListStorage(DisplayListStorage&&) = default;
|
||||
|
||||
uint8_t* get() const { return ptr_.get(); }
|
||||
|
||||
void realloc(size_t count) {
|
||||
ptr_.reset(static_cast<uint8_t*>(std::realloc(ptr_.release(), count)));
|
||||
FML_CHECK(ptr_);
|
||||
}
|
||||
|
||||
private:
|
||||
struct FreeDeleter {
|
||||
void operator()(uint8_t* p) { std::free(p); }
|
||||
};
|
||||
std::unique_ptr<uint8_t, FreeDeleter> ptr_;
|
||||
};
|
||||
|
||||
// The base class that contains a sequence of rendering operations
|
||||
// for dispatch to a Dispatcher. These objects must be instantiated
|
||||
// through an instance of DisplayListBuilder::build().
|
||||
@ -263,7 +283,7 @@ class DisplayList : public SkRefCnt {
|
||||
static void DisposeOps(uint8_t* ptr, uint8_t* end);
|
||||
|
||||
private:
|
||||
DisplayList(uint8_t* ptr,
|
||||
DisplayList(DisplayListStorage&& ptr,
|
||||
size_t byte_count,
|
||||
unsigned int op_count,
|
||||
size_t nested_byte_count,
|
||||
@ -272,10 +292,7 @@ class DisplayList : public SkRefCnt {
|
||||
bool can_apply_group_opacity,
|
||||
sk_sp<const DlRTree> rtree);
|
||||
|
||||
struct SkFreeDeleter {
|
||||
void operator()(uint8_t* p) { sk_free(p); }
|
||||
};
|
||||
std::unique_ptr<uint8_t, SkFreeDeleter> storage_;
|
||||
DisplayListStorage storage_;
|
||||
size_t byte_count_;
|
||||
unsigned int op_count_;
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ sk_sp<DisplayList> DisplayListBuilder::Build() {
|
||||
nested_bytes_ = nested_op_count_ = 0;
|
||||
storage_.realloc(bytes);
|
||||
bool compatible = layer_stack_.back().is_group_opacity_compatible();
|
||||
return sk_sp<DisplayList>(new DisplayList(storage_.release(), bytes, count,
|
||||
return sk_sp<DisplayList>(new DisplayList(std::move(storage_), bytes, count,
|
||||
nested_bytes, nested_count,
|
||||
bounds(), compatible, rtree()));
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
|
||||
private:
|
||||
void checkForDeferredSave();
|
||||
|
||||
SkAutoTMalloc<uint8_t> storage_;
|
||||
DisplayListStorage storage_;
|
||||
size_t used_ = 0;
|
||||
size_t allocated_ = 0;
|
||||
int op_count_ = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user