Make GetAllocationSize const (flutter/engine#18713)
This commit is contained in:
@@ -18,7 +18,7 @@ EngineLayer::EngineLayer(std::shared_ptr<flutter::ContainerLayer> layer)
|
||||
|
||||
EngineLayer::~EngineLayer() = default;
|
||||
|
||||
size_t EngineLayer::GetAllocationSize() {
|
||||
size_t EngineLayer::GetAllocationSize() const {
|
||||
// Provide an approximation of the total memory impact of this object to the
|
||||
// Dart GC. The ContainerLayer may hold references to a tree of other layers,
|
||||
// which in turn may contain Skia objects.
|
||||
|
||||
@@ -23,7 +23,7 @@ class EngineLayer : public RefCountedDartWrappable<EngineLayer> {
|
||||
public:
|
||||
~EngineLayer() override;
|
||||
|
||||
size_t GetAllocationSize() override;
|
||||
size_t GetAllocationSize() const override;
|
||||
|
||||
static fml::RefPtr<EngineLayer> MakeRetained(
|
||||
std::shared_ptr<flutter::ContainerLayer> layer) {
|
||||
|
||||
@@ -40,7 +40,7 @@ void CanvasImage::dispose() {
|
||||
ClearDartWrapper();
|
||||
}
|
||||
|
||||
size_t CanvasImage::GetAllocationSize() {
|
||||
size_t CanvasImage::GetAllocationSize() const {
|
||||
if (auto image = image_.get()) {
|
||||
const auto& info = image->imageInfo();
|
||||
const auto kMipmapOverhead = 4.0 / 3.0;
|
||||
|
||||
@@ -39,7 +39,7 @@ class CanvasImage final : public RefCountedDartWrappable<CanvasImage> {
|
||||
image_ = std::move(image);
|
||||
}
|
||||
|
||||
size_t GetAllocationSize() override;
|
||||
size_t GetAllocationSize() const override;
|
||||
|
||||
static void RegisterNatives(tonic::DartLibraryNatives* natives);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ void Picture::dispose() {
|
||||
ClearDartWrapper();
|
||||
}
|
||||
|
||||
size_t Picture::GetAllocationSize() {
|
||||
size_t Picture::GetAllocationSize() const {
|
||||
if (auto picture = picture_.get()) {
|
||||
return picture->approximateBytesUsed();
|
||||
} else {
|
||||
|
||||
@@ -34,7 +34,7 @@ class Picture : public RefCountedDartWrappable<Picture> {
|
||||
|
||||
void dispose();
|
||||
|
||||
size_t GetAllocationSize() override;
|
||||
size_t GetAllocationSize() const override;
|
||||
|
||||
static void RegisterNatives(tonic::DartLibraryNatives* natives);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ Dart_Handle SingleFrameCodec::getNextFrame(Dart_Handle callback_handle) {
|
||||
return Dart_Null();
|
||||
}
|
||||
|
||||
size_t SingleFrameCodec::GetAllocationSize() {
|
||||
size_t SingleFrameCodec::GetAllocationSize() const {
|
||||
const auto& data = descriptor_.data;
|
||||
const auto data_byte_size = data ? data->size() : 0;
|
||||
const auto frame_byte_size = (cached_frame_ && cached_frame_->image())
|
||||
|
||||
@@ -28,7 +28,7 @@ class SingleFrameCodec : public Codec {
|
||||
Dart_Handle getNextFrame(Dart_Handle args) override;
|
||||
|
||||
// |DartWrappable|
|
||||
size_t GetAllocationSize() override;
|
||||
size_t GetAllocationSize() const override;
|
||||
|
||||
private:
|
||||
enum class Status { kNew, kInProgress, kComplete };
|
||||
|
||||
@@ -44,7 +44,7 @@ Paragraph::Paragraph(std::unique_ptr<txt::Paragraph> paragraph)
|
||||
|
||||
Paragraph::~Paragraph() = default;
|
||||
|
||||
size_t Paragraph::GetAllocationSize() {
|
||||
size_t Paragraph::GetAllocationSize() const {
|
||||
// We don't have an accurate accounting of the paragraph's memory consumption,
|
||||
// so return a fixed size to indicate that its impact is more than the size
|
||||
// of the Paragraph class.
|
||||
|
||||
@@ -53,7 +53,7 @@ class Paragraph : public RefCountedDartWrappable<Paragraph> {
|
||||
Dart_Handle getLineBoundary(unsigned offset);
|
||||
tonic::Float64List computeLineMetrics();
|
||||
|
||||
size_t GetAllocationSize() override;
|
||||
size_t GetAllocationSize() const override;
|
||||
|
||||
static void RegisterNatives(tonic::DartLibraryNatives* natives);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ void DartWrappable::FinalizeDartWrapper(void* isolate_callback_data,
|
||||
wrappable->ReleaseDartWrappableReference(); // Balanced in CreateDartWrapper.
|
||||
}
|
||||
|
||||
size_t DartWrappable::GetAllocationSize() {
|
||||
size_t DartWrappable::GetAllocationSize() const {
|
||||
return GetDartWrapperInfo().size_in_bytes;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class DartWrappable {
|
||||
// Override this to customize the object size reported to the Dart garbage
|
||||
// collector.
|
||||
// Implement using IMPLEMENT_WRAPPERTYPEINFO macro
|
||||
virtual size_t GetAllocationSize();
|
||||
virtual size_t GetAllocationSize() const;
|
||||
|
||||
virtual void RetainDartWrappableReference() const = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user