Commit 95fc6d23 authored by Nathan Zabriskie's avatar Nathan Zabriskie Committed by Commit Bot

Change IsGpuContextLost() to query RasterInterface

As part of the OOPR-Canvas2D project this CL changes IsGpuContextLost()
to query RasterInterface instead of the current GLES2Interface. This is
done with the goal of removing all references to the GLES2Interface in
Canvas2D code so that we can fully transition to RasterInterface for
oop-r.

Change-Id: Ib740d7f3554493e31429dd60e42198095a4c746b
Bug: 1018898
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1877109Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Nathan Zabriskie <nazabris@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#711009}
parent 564e0673
...@@ -40,6 +40,11 @@ gpu::gles2::GLES2Interface* WebGraphicsContext3DProviderImpl::ContextGL() { ...@@ -40,6 +40,11 @@ gpu::gles2::GLES2Interface* WebGraphicsContext3DProviderImpl::ContextGL() {
return provider_->ContextGL(); return provider_->ContextGL();
} }
gpu::raster::RasterInterface*
WebGraphicsContext3DProviderImpl::RasterInterface() {
return provider_->RasterInterface();
}
gpu::webgpu::WebGPUInterface* gpu::webgpu::WebGPUInterface*
WebGraphicsContext3DProviderImpl::WebGPUInterface() { WebGraphicsContext3DProviderImpl::WebGPUInterface() {
return provider_->WebGPUInterface(); return provider_->WebGPUInterface();
......
...@@ -20,6 +20,10 @@ namespace gpu { ...@@ -20,6 +20,10 @@ namespace gpu {
namespace gles2 { namespace gles2 {
class GLES2Interface; class GLES2Interface;
} // namespace gles2 } // namespace gles2
namespace raster {
class RasterInterface;
} // namespace raster
} // namespace gpu } // namespace gpu
namespace viz { namespace viz {
...@@ -40,6 +44,7 @@ class CONTENT_EXPORT WebGraphicsContext3DProviderImpl ...@@ -40,6 +44,7 @@ class CONTENT_EXPORT WebGraphicsContext3DProviderImpl
// WebGraphicsContext3DProvider implementation. // WebGraphicsContext3DProvider implementation.
bool BindToCurrentThread() override; bool BindToCurrentThread() override;
gpu::gles2::GLES2Interface* ContextGL() override; gpu::gles2::GLES2Interface* ContextGL() override;
gpu::raster::RasterInterface* RasterInterface() override;
gpu::webgpu::WebGPUInterface* WebGPUInterface() override; gpu::webgpu::WebGPUInterface* WebGPUInterface() override;
GrContext* GetGrContext() override; GrContext* GetGrContext() override;
const gpu::Capabilities& GetCapabilities() const override; const gpu::Capabilities& GetCapabilities() const override;
......
...@@ -56,6 +56,10 @@ namespace gles2 { ...@@ -56,6 +56,10 @@ namespace gles2 {
class GLES2Interface; class GLES2Interface;
} }
namespace raster {
class RasterInterface;
}
namespace webgpu { namespace webgpu {
class WebGPUInterface; class WebGPUInterface;
} }
...@@ -87,6 +91,7 @@ class WebGraphicsContext3DProvider { ...@@ -87,6 +91,7 @@ class WebGraphicsContext3DProvider {
virtual ~WebGraphicsContext3DProvider() = default; virtual ~WebGraphicsContext3DProvider() = default;
virtual gpu::gles2::GLES2Interface* ContextGL() = 0; virtual gpu::gles2::GLES2Interface* ContextGL() = 0;
virtual gpu::raster::RasterInterface* RasterInterface() = 0;
virtual gpu::webgpu::WebGPUInterface* WebGPUInterface() = 0; virtual gpu::webgpu::WebGPUInterface* WebGPUInterface() = 0;
virtual bool BindToCurrentThread() = 0; virtual bool BindToCurrentThread() = 0;
virtual GrContext* GetGrContext() = 0; virtual GrContext* GetGrContext() = 0;
......
...@@ -17,6 +17,7 @@ include_rules = [ ...@@ -17,6 +17,7 @@ include_rules = [
"+gpu/config", "+gpu/config",
"+gpu/command_buffer/client/gles2_interface.h", "+gpu/command_buffer/client/gles2_interface.h",
"+gpu/command_buffer/client/gpu_memory_buffer_manager.h", "+gpu/command_buffer/client/gpu_memory_buffer_manager.h",
"+gpu/command_buffer/client/raster_interface.h",
"+gpu/command_buffer/client/shared_image_interface.h", "+gpu/command_buffer/client/shared_image_interface.h",
"+gpu/command_buffer/common/gpu_memory_buffer_support.h", "+gpu/command_buffer/common/gpu_memory_buffer_support.h",
"+gpu/command_buffer/common/capabilities.h", "+gpu/command_buffer/common/capabilities.h",
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "base/timer/elapsed_timer.h" #include "base/timer/elapsed_timer.h"
#include "cc/layers/texture_layer.h" #include "cc/layers/texture_layer.h"
#include "components/viz/common/resources/transferable_resource.h" #include "components/viz/common/resources/transferable_resource.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
...@@ -150,7 +151,7 @@ bool Canvas2DLayerBridge::ShouldAccelerate(AccelerationHint hint) const { ...@@ -150,7 +151,7 @@ bool Canvas2DLayerBridge::ShouldAccelerate(AccelerationHint hint) const {
SharedGpuContext::ContextProviderWrapper(); SharedGpuContext::ContextProviderWrapper();
if (accelerate && (!context_provider_wrapper || if (accelerate && (!context_provider_wrapper ||
context_provider_wrapper->ContextProvider() context_provider_wrapper->ContextProvider()
->ContextGL() ->RasterInterface()
->GetGraphicsResetStatusKHR() != GL_NO_ERROR)) { ->GetGraphicsResetStatusKHR() != GL_NO_ERROR)) {
accelerate = false; accelerate = false;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "components/viz/common/resources/transferable_resource.h" #include "components/viz/common/resources/transferable_resource.h"
#include "gpu/GLES2/gl2extchromium.h" #include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "gpu/command_buffer/client/shared_image_interface.h" #include "gpu/command_buffer/client/shared_image_interface.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h" #include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "gpu/command_buffer/common/shared_image_usage.h" #include "gpu/command_buffer/common/shared_image_usage.h"
...@@ -77,6 +78,12 @@ gpu::gles2::GLES2Interface* CanvasResource::ContextGL() const { ...@@ -77,6 +78,12 @@ gpu::gles2::GLES2Interface* CanvasResource::ContextGL() const {
return ContextProviderWrapper()->ContextProvider()->ContextGL(); return ContextProviderWrapper()->ContextProvider()->ContextGL();
} }
gpu::raster::RasterInterface* CanvasResource::RasterInterface() const {
if (!ContextProviderWrapper())
return nullptr;
return ContextProviderWrapper()->ContextProvider()->RasterInterface();
}
void CanvasResource::WaitSyncToken(const gpu::SyncToken& sync_token) { void CanvasResource::WaitSyncToken(const gpu::SyncToken& sync_token) {
if (sync_token.HasData()) { if (sync_token.HasData()) {
auto* gl = ContextGL(); auto* gl = ContextGL();
......
...@@ -25,6 +25,14 @@ class GpuMemoryBuffer; ...@@ -25,6 +25,14 @@ class GpuMemoryBuffer;
} // namespace gfx } // namespace gfx
namespace gpu {
namespace raster {
class RasterInterface;
} // namespace raster
} // namespace gpu
namespace viz { namespace viz {
class SingleReleaseCallback; class SingleReleaseCallback;
...@@ -184,6 +192,7 @@ class PLATFORM_EXPORT CanvasResource ...@@ -184,6 +192,7 @@ class PLATFORM_EXPORT CanvasResource
virtual void TearDown() = 0; virtual void TearDown() = 0;
gpu::gles2::GLES2Interface* ContextGL() const; gpu::gles2::GLES2Interface* ContextGL() const;
gpu::raster::RasterInterface* RasterInterface() const;
GLenum GLFilter() const; GLenum GLFilter() const;
GrContext* GetGrContext() const; GrContext* GetGrContext() const;
virtual base::WeakPtr<WebGraphicsContext3DProviderWrapper> virtual base::WeakPtr<WebGraphicsContext3DProviderWrapper>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "cc/tiles/software_image_decode_cache.h" #include "cc/tiles/software_image_decode_cache.h"
#include "components/viz/common/resources/resource_format_utils.h" #include "components/viz/common/resources/resource_format_utils.h"
#include "gpu/GLES2/gl2extchromium.h" #include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "gpu/command_buffer/common/capabilities.h" #include "gpu/command_buffer/common/capabilities.h"
#include "gpu/config/gpu_driver_bug_workaround_type.h" #include "gpu/config/gpu_driver_bug_workaround_type.h"
#include "gpu/config/gpu_feature_info.h" #include "gpu/config/gpu_feature_info.h"
...@@ -1073,6 +1074,12 @@ gpu::gles2::GLES2Interface* CanvasResourceProvider::ContextGL() const { ...@@ -1073,6 +1074,12 @@ gpu::gles2::GLES2Interface* CanvasResourceProvider::ContextGL() const {
return context_provider_wrapper_->ContextProvider()->ContextGL(); return context_provider_wrapper_->ContextProvider()->ContextGL();
} }
gpu::raster::RasterInterface* CanvasResourceProvider::RasterInterface() const {
if (!context_provider_wrapper_)
return nullptr;
return context_provider_wrapper_->ContextProvider()->RasterInterface();
}
GrContext* CanvasResourceProvider::GetGrContext() const { GrContext* CanvasResourceProvider::GetGrContext() const {
if (!context_provider_wrapper_) if (!context_provider_wrapper_)
return nullptr; return nullptr;
...@@ -1084,8 +1091,9 @@ void CanvasResourceProvider::FlushSkia() const { ...@@ -1084,8 +1091,9 @@ void CanvasResourceProvider::FlushSkia() const {
} }
bool CanvasResourceProvider::IsGpuContextLost() const { bool CanvasResourceProvider::IsGpuContextLost() const {
auto* gl = ContextGL(); auto* raster_interface = RasterInterface();
return !gl || gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR; return !raster_interface ||
raster_interface->GetGraphicsResetStatusKHR() != GL_NO_ERROR;
} }
bool CanvasResourceProvider::WritePixels(const SkImageInfo& orig_info, bool CanvasResourceProvider::WritePixels(const SkImageInfo& orig_info,
......
...@@ -23,6 +23,12 @@ namespace gles2 { ...@@ -23,6 +23,12 @@ namespace gles2 {
class GLES2Interface; class GLES2Interface;
} // namespace gles2 } // namespace gles2
namespace raster {
class RasterInterface;
} // namespace raster
} // namespace gpu } // namespace gpu
namespace blink { namespace blink {
...@@ -192,6 +198,7 @@ class PLATFORM_EXPORT CanvasResourceProvider ...@@ -192,6 +198,7 @@ class PLATFORM_EXPORT CanvasResourceProvider
protected: protected:
gpu::gles2::GLES2Interface* ContextGL() const; gpu::gles2::GLES2Interface* ContextGL() const;
gpu::raster::RasterInterface* RasterInterface() const;
GrContext* GetGrContext() const; GrContext* GetGrContext() const;
base::WeakPtr<WebGraphicsContext3DProviderWrapper> ContextProviderWrapper() { base::WeakPtr<WebGraphicsContext3DProviderWrapper> ContextProviderWrapper() {
return context_provider_wrapper_; return context_provider_wrapper_;
......
...@@ -43,6 +43,7 @@ class WebGraphicsContext3DProviderForTests ...@@ -43,6 +43,7 @@ class WebGraphicsContext3DProviderForTests
: webgpu_(std::move(webgpu)) {} : webgpu_(std::move(webgpu)) {}
gpu::gles2::GLES2Interface* ContextGL() override { return gl_.get(); } gpu::gles2::GLES2Interface* ContextGL() override { return gl_.get(); }
gpu::raster::RasterInterface* RasterInterface() override { return nullptr; }
GrContext* GetGrContext() override { return nullptr; } GrContext* GetGrContext() override { return nullptr; }
gpu::webgpu::WebGPUInterface* WebGPUInterface() override { gpu::webgpu::WebGPUInterface* WebGPUInterface() override {
return webgpu_.get(); return webgpu_.get();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "gpu/config/gpu_driver_bug_workaround_type.h" #include "gpu/config/gpu_driver_bug_workaround_type.h"
#include "gpu/config/gpu_feature_info.h" #include "gpu/config/gpu_feature_info.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
...@@ -89,7 +90,7 @@ void SharedGpuContext::CreateContextProviderIfNeeded( ...@@ -89,7 +90,7 @@ void SharedGpuContext::CreateContextProviderIfNeeded(
// thread it was made on, or else lock it. // thread it was made on, or else lock it.
if (context_provider_wrapper_ && if (context_provider_wrapper_ &&
context_provider_wrapper_->ContextProvider() context_provider_wrapper_->ContextProvider()
->ContextGL() ->RasterInterface()
->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { ->GetGraphicsResetStatusKHR() == GL_NO_ERROR) {
// If the context isn't lost then |is_gpu_compositing_disabled_| state // If the context isn't lost then |is_gpu_compositing_disabled_| state
// hasn't changed yet. RenderThreadImpl::CompositingModeFallbackToSoftware() // hasn't changed yet. RenderThreadImpl::CompositingModeFallbackToSoftware()
......
...@@ -2,5 +2,6 @@ include_rules = [ ...@@ -2,5 +2,6 @@ include_rules = [
"+components/viz/test/test_gpu_memory_buffer_manager.h", "+components/viz/test/test_gpu_memory_buffer_manager.h",
"+components/viz/test/test_context_provider.h", "+components/viz/test/test_context_provider.h",
"+gpu/command_buffer/client/gles2_interface_stub.h", "+gpu/command_buffer/client/gles2_interface_stub.h",
"+gpu/command_buffer/client/raster_implementation_gles.h",
"+gpu/config/gpu_feature_info.h", "+gpu/config/gpu_feature_info.h",
] ]
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "cc/tiles/image_decode_cache.h" #include "cc/tiles/image_decode_cache.h"
#include "components/viz/test/test_context_provider.h" #include "components/viz/test/test_context_provider.h"
#include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/client/raster_implementation_gles.h"
#include "gpu/command_buffer/common/capabilities.h" #include "gpu/command_buffer/common/capabilities.h"
#include "gpu/config/gpu_feature_info.h" #include "gpu/config/gpu_feature_info.h"
#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h" #include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
...@@ -31,6 +32,12 @@ class FakeWebGraphicsContext3DProvider : public WebGraphicsContext3DProvider { ...@@ -31,6 +32,12 @@ class FakeWebGraphicsContext3DProvider : public WebGraphicsContext3DProvider {
GrMockOptions mockOptions; GrMockOptions mockOptions;
gr_context_ = GrContext::MakeMock(&mockOptions); gr_context_ = GrContext::MakeMock(&mockOptions);
} }
// TODO(nazabris, crbug.com/1017508) Use RasterImplementation after
// all references to GLES2Interface have been removed.
raster_interface_ =
std::make_unique<gpu::raster::RasterImplementationGLES>(gl_);
// enable all gpu features. // enable all gpu features.
for (unsigned feature = 0; feature < gpu::NUMBER_OF_GPU_FEATURE_TYPES; for (unsigned feature = 0; feature < gpu::NUMBER_OF_GPU_FEATURE_TYPES;
++feature) { ++feature) {
...@@ -57,6 +64,13 @@ class FakeWebGraphicsContext3DProvider : public WebGraphicsContext3DProvider { ...@@ -57,6 +64,13 @@ class FakeWebGraphicsContext3DProvider : public WebGraphicsContext3DProvider {
viz::GLHelper* GetGLHelper() override { return nullptr; } viz::GLHelper* GetGLHelper() override { return nullptr; }
gpu::gles2::GLES2Interface* ContextGL() override { return gl_; } gpu::gles2::GLES2Interface* ContextGL() override { return gl_; }
gpu::raster::RasterInterface* RasterInterface() override {
if (!raster_interface_)
return nullptr;
return raster_interface_.get();
}
gpu::webgpu::WebGPUInterface* WebGPUInterface() override { return nullptr; } gpu::webgpu::WebGPUInterface* WebGPUInterface() override { return nullptr; }
bool BindToCurrentThread() override { return false; } bool BindToCurrentThread() override { return false; }
...@@ -77,6 +91,7 @@ class FakeWebGraphicsContext3DProvider : public WebGraphicsContext3DProvider { ...@@ -77,6 +91,7 @@ class FakeWebGraphicsContext3DProvider : public WebGraphicsContext3DProvider {
cc::StubDecodeCache stub_image_decode_cache_; cc::StubDecodeCache stub_image_decode_cache_;
viz::TestSharedImageInterface test_shared_image_interface_; viz::TestSharedImageInterface test_shared_image_interface_;
gpu::gles2::GLES2Interface* gl_; gpu::gles2::GLES2Interface* gl_;
std::unique_ptr<gpu::raster::RasterInterface> raster_interface_;
sk_sp<GrContext> gr_context_; sk_sp<GrContext> gr_context_;
gpu::Capabilities capabilities_; gpu::Capabilities capabilities_;
gpu::GpuFeatureInfo gpu_feature_info_; gpu::GpuFeatureInfo gpu_feature_info_;
......
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