Commit 06884c3c authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

WrappedSkImage: keep a ref of SharedContextState

SharedContextState could be released before releasing all
WrappedSkImage backings. To avoid this problem, by holding a ref of
SharedContextState.

Bug: None
Change-Id: I2ebe99a18b939f77894ee24049b23d5e0cc6764e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438189
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811941}
parent 527adc13
......@@ -242,7 +242,13 @@ class SkiaOutputDeviceBufferQueueTest : public TestOnGpu {
output_device_ = std::move(onscreen_device);
}
void TearDownOnGpu() override { output_device_.reset(); }
void TearDownOnGpu() override {
output_device_.reset();
shared_image_representation_factory_.reset();
shared_image_factory_.reset();
memory_tracker_.reset();
gl_surface_.reset();
}
using Image = OutputPresenter::Image;
......
......@@ -56,7 +56,7 @@ class WrappedSkImage : public ClearTrackingSharedImageBacking {
context_state_->EraseCachedSkSurface(this);
if (backend_texture_.isValid())
DeleteGrBackendTexture(context_state_, &backend_texture_);
DeleteGrBackendTexture(context_state_.get(), &backend_texture_);
DCHECK(context_state_->context_lost() ||
context_state_->IsCurrent(nullptr));
......@@ -155,7 +155,7 @@ class WrappedSkImage : public ClearTrackingSharedImageBacking {
SkAlphaType alpha_type,
uint32_t usage,
size_t estimated_size,
SharedContextState* context_state)
scoped_refptr<SharedContextState> context_state)
: ClearTrackingSharedImageBacking(mailbox,
format,
size,
......@@ -165,7 +165,7 @@ class WrappedSkImage : public ClearTrackingSharedImageBacking {
usage,
estimated_size,
false /* is_thread_safe */),
context_state_(context_state) {
context_state_(std::move(context_state)) {
DCHECK(!!context_state_);
}
......@@ -283,7 +283,7 @@ class WrappedSkImage : public ClearTrackingSharedImageBacking {
return true;
}
SharedContextState* const context_state_;
scoped_refptr<SharedContextState> context_state_;
GrBackendTexture backend_texture_;
sk_sp<SkPromiseImageTexture> promise_texture_;
......@@ -355,8 +355,9 @@ class WrappedSkImageRepresentation : public SharedImageRepresentationSkia {
} // namespace
WrappedSkImageFactory::WrappedSkImageFactory(SharedContextState* context_state)
: context_state_(context_state) {}
WrappedSkImageFactory::WrappedSkImageFactory(
scoped_refptr<SharedContextState> context_state)
: context_state_(std::move(context_state)) {}
WrappedSkImageFactory::~WrappedSkImageFactory() = default;
......
......@@ -24,7 +24,8 @@ namespace raster {
class GPU_GLES2_EXPORT WrappedSkImageFactory
: public gpu::SharedImageBackingFactory {
public:
explicit WrappedSkImageFactory(SharedContextState* context_state);
explicit WrappedSkImageFactory(
scoped_refptr<SharedContextState> context_state);
~WrappedSkImageFactory() override;
// SharedImageBackingFactory implementation:
......@@ -62,7 +63,7 @@ class GPU_GLES2_EXPORT WrappedSkImageFactory
gfx::GpuMemoryBufferType memory_buffer_type) override;
private:
SharedContextState* const context_state_;
scoped_refptr<SharedContextState> context_state_;
DISALLOW_COPY_AND_ASSIGN(WrappedSkImageFactory);
};
......
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