Commit fb7aa36c authored by Kramer Ge's avatar Kramer Ge Committed by Commit Bot

SkiaOutputDeviceGL estimates GPU memory for GLSurface

SkiatOutputDeviceGL allocates gl_surface_ that contains swapchain
images. Creation is abstract thus gpu memory consumption can only be
estimated.

Bug: 899905
Change-Id: Id2834a4b6cb34a6a4f8827ad0452cf7c93219600
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037950Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739002}
parent 0e5eeeda
......@@ -91,7 +91,10 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL(
supports_alpha_ = alpha_bits > 0;
}
SkiaOutputDeviceGL::~SkiaOutputDeviceGL() = default;
SkiaOutputDeviceGL::~SkiaOutputDeviceGL() {
// gl_surface_ will be destructed soon.
memory_type_tracker_->TrackMemFree(backbuffer_estimated_size_);
}
bool SkiaOutputDeviceGL::Reshape(const gfx::Size& size,
float device_scale_factor,
......@@ -139,6 +142,19 @@ bool SkiaOutputDeviceGL::Reshape(const gfx::Size& size,
<< framebuffer_info.fFormat << " " << color_space.ToString()
<< " " << size.ToString();
}
memory_type_tracker_->TrackMemFree(backbuffer_estimated_size_);
GLenum format = gpu::gles2::TextureManager::ExtractFormatFromStorageFormat(
framebuffer_info.fFormat);
GLenum type = gpu::gles2::TextureManager::ExtractTypeFromStorageFormat(
framebuffer_info.fFormat);
uint32_t estimated_size;
gpu::gles2::GLES2Util::ComputeImageDataSizes(
size.width(), size.height(), 1 /* depth */, format, type,
4 /* alignment */, &estimated_size, nullptr, nullptr);
backbuffer_estimated_size_ = estimated_size * gl_surface_->GetBufferCount();
memory_type_tracker_->TrackMemAlloc(backbuffer_estimated_size_);
return !!sk_surface_;
}
......
......@@ -93,6 +93,7 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice {
sk_sp<SkSurface> sk_surface_;
bool supports_alpha_ = false;
uint64_t backbuffer_estimated_size_ = 0;
base::WeakPtrFactory<SkiaOutputDeviceGL> weak_ptr_factory_{this};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment