[Merge to M76] Take a strong ref of SharedContextState.
Take a strong ref of SharedContextState in
AbstractTextureImplOnSharedContext. This is to avoid cases where during
shutdown SharedContextState can be destroyed before
AbstractTextureImplOnSharedContext.
(cherry picked from commit 65656ed3340bf45ceb9d060528bae34e16600fe1)
Bug: 972521
Change-Id: Ifd5be5505351cf0573ebf124014927911b184ff0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1651491
Reviewed-by: Frank Liberato <liberato@chromium.org>
Reviewed-by: Eric Karl <ericrk@chromium.org>
Commit-Queue: vikas soni <vikassoni@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#668255}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1658771
Reviewed-by: vikas soni <vikassoni@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#291}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/gpu/command_buffer/service/abstract_texture_impl_shared_context_state.cc b/gpu/command_buffer/service/abstract_texture_impl_shared_context_state.cc
index 2fe75b7..f133e9a 100644
--- a/gpu/command_buffer/service/abstract_texture_impl_shared_context_state.cc
+++ b/gpu/command_buffer/service/abstract_texture_impl_shared_context_state.cc
@@ -24,8 +24,8 @@
GLint border,
GLenum format,
GLenum type,
- gpu::SharedContextState* shared_context_state)
- : shared_context_state_(shared_context_state) {
+ scoped_refptr<gpu::SharedContextState> shared_context_state)
+ : shared_context_state_(std::move(shared_context_state)) {
DCHECK(shared_context_state_);
// The calling code which wants to create this abstract texture should have
@@ -113,7 +113,7 @@
if (cleanup_cb_)
std::move(cleanup_cb_).Run(this);
shared_context_state_->RemoveContextLostObserver(this);
- shared_context_state_ = nullptr;
+ shared_context_state_.reset();
}
} // namespace gles2
diff --git a/gpu/command_buffer/service/abstract_texture_impl_shared_context_state.h b/gpu/command_buffer/service/abstract_texture_impl_shared_context_state.h
index 78a9ae70..f9b8757 100644
--- a/gpu/command_buffer/service/abstract_texture_impl_shared_context_state.h
+++ b/gpu/command_buffer/service/abstract_texture_impl_shared_context_state.h
@@ -31,7 +31,7 @@
GLint border,
GLenum format,
GLenum type,
- gpu::SharedContextState* shared_context_state);
+ scoped_refptr<gpu::SharedContextState> shared_context_state);
~AbstractTextureImplOnSharedContext() override;
// AbstractTexture implementation.
@@ -49,7 +49,7 @@
private:
Texture* texture_;
- SharedContextState* shared_context_state_ = nullptr;
+ scoped_refptr<SharedContextState> shared_context_state_;
CleanupCallback cleanup_cb_;
};
diff --git a/media/gpu/android/texture_owner.cc b/media/gpu/android/texture_owner.cc
index d00fd6a..c5402531 100644
--- a/media/gpu/android/texture_owner.cc
+++ b/media/gpu/android/texture_owner.cc
@@ -57,7 +57,7 @@
// static
std::unique_ptr<gpu::gles2::AbstractTexture> TextureOwner::CreateTexture(
- gpu::SharedContextState* context_state) {
+ scoped_refptr<gpu::SharedContextState> context_state) {
DCHECK(context_state);
// This assumes a non-passthrough (validating) command decoder, which is safe
@@ -70,7 +70,7 @@
0, // height
1, // depth
0, // border
- GL_RGBA, GL_UNSIGNED_BYTE, context_state);
+ GL_RGBA, GL_UNSIGNED_BYTE, std::move(context_state));
}
GLuint TextureOwner::GetTextureId() const {
diff --git a/media/gpu/android/texture_owner.h b/media/gpu/android/texture_owner.h
index 93edf5b..afba4fc 100644
--- a/media/gpu/android/texture_owner.h
+++ b/media/gpu/android/texture_owner.h
@@ -59,7 +59,7 @@
// Create a texture that's appropriate for a TextureOwner.
static std::unique_ptr<gpu::gles2::AbstractTexture> CreateTexture(
- gpu::SharedContextState* context_state);
+ scoped_refptr<gpu::SharedContextState> context_state);
scoped_refptr<base::SingleThreadTaskRunner> task_runner() {
return task_runner_;
diff --git a/media/gpu/android/video_frame_factory_impl.cc b/media/gpu/android/video_frame_factory_impl.cc
index 1f99f89..a9351d3 100644
--- a/media/gpu/android/video_frame_factory_impl.cc
+++ b/media/gpu/android/video_frame_factory_impl.cc
@@ -318,7 +318,7 @@
ContextStateResultUMA(result);
return nullptr;
}
- return TextureOwner::Create(TextureOwner::CreateTexture(shared_context.get()),
+ return TextureOwner::Create(TextureOwner::CreateTexture(shared_context),
GetTextureOwnerMode(overlay_mode));
}