Commit 65a3d424 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

SkiaRenderer: Call DidLoseCurrent if we can't make current

This is consistent with InProcessCommandBuffer::MakeCurrent() and
CommandBufferStub::MakeCurrent().

TBR=boliu@chromium.org

Bug: 1011420
Change-Id: I3179d229c45b5dc27586cdddfe757596d1b85ae3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866606
Commit-Queue: Jonathan Backer <backer@chromium.org>
Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707112}
parent e6f859d6
...@@ -118,4 +118,11 @@ void SkiaOutputSurfaceDependencyWebView::UnregisterDisplayContext( ...@@ -118,4 +118,11 @@ void SkiaOutputSurfaceDependencyWebView::UnregisterDisplayContext(
// No GpuChannelManagerDelegate here, so leave it no-op for now. // No GpuChannelManagerDelegate here, so leave it no-op for now.
} }
void SkiaOutputSurfaceDependencyWebView::DidLoseContext(
bool offscreen,
gpu::error::ContextLostReason reason,
const GURL& active_url) {
// No GpuChannelManagerDelegate here, so leave it no-op for now.
}
} // namespace android_webview } // namespace android_webview
...@@ -45,6 +45,9 @@ class SkiaOutputSurfaceDependencyWebView ...@@ -45,6 +45,9 @@ class SkiaOutputSurfaceDependencyWebView
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub) override; base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub) override;
void RegisterDisplayContext(gpu::DisplayContext* display_context) override; void RegisterDisplayContext(gpu::DisplayContext* display_context) override;
void UnregisterDisplayContext(gpu::DisplayContext* display_context) override; void UnregisterDisplayContext(gpu::DisplayContext* display_context) override;
void DidLoseContext(bool offscreen,
gpu::error::ContextLostReason reason,
const GURL& active_url) override;
private: private:
gl::GLSurface* const gl_surface_; gl::GLSurface* const gl_surface_;
......
...@@ -12,9 +12,12 @@ ...@@ -12,9 +12,12 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/viz/service/viz_service_export.h" #include "components/viz/service/viz_service_export.h"
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/service/sequence_id.h" #include "gpu/command_buffer/service/sequence_id.h"
#include "gpu/ipc/common/surface_handle.h" #include "gpu/ipc/common/surface_handle.h"
class GURL;
namespace gl { namespace gl {
class GLSurface; class GLSurface;
} }
...@@ -91,6 +94,9 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceDependency { ...@@ -91,6 +94,9 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceDependency {
virtual void RegisterDisplayContext(gpu::DisplayContext* display_context) = 0; virtual void RegisterDisplayContext(gpu::DisplayContext* display_context) = 0;
virtual void UnregisterDisplayContext( virtual void UnregisterDisplayContext(
gpu::DisplayContext* display_context) = 0; gpu::DisplayContext* display_context) = 0;
virtual void DidLoseContext(bool offscreen,
gpu::error::ContextLostReason reason,
const GURL& active_url) = 0;
}; };
} // namespace viz } // namespace viz
......
...@@ -125,4 +125,11 @@ void SkiaOutputSurfaceDependencyImpl::UnregisterDisplayContext( ...@@ -125,4 +125,11 @@ void SkiaOutputSurfaceDependencyImpl::UnregisterDisplayContext(
gpu_service_impl_->UnregisterDisplayContext(display_context); gpu_service_impl_->UnregisterDisplayContext(display_context);
} }
void SkiaOutputSurfaceDependencyImpl::DidLoseContext(
bool offscreen,
gpu::error::ContextLostReason reason,
const GURL& active_url) {
gpu_service_impl_->DidLoseContext(offscreen, reason, active_url);
}
} // namespace viz } // namespace viz
...@@ -51,6 +51,9 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceDependencyImpl ...@@ -51,6 +51,9 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceDependencyImpl
void RegisterDisplayContext(gpu::DisplayContext* display_context) override; void RegisterDisplayContext(gpu::DisplayContext* display_context) override;
void UnregisterDisplayContext(gpu::DisplayContext* display_context) override; void UnregisterDisplayContext(gpu::DisplayContext* display_context) override;
void DidLoseContext(bool offscreen,
gpu::error::ContextLostReason reason,
const GURL& active_url) override;
private: private:
GpuServiceImpl* const gpu_service_impl_; GpuServiceImpl* const gpu_service_impl_;
......
...@@ -86,6 +86,12 @@ base::OnceCallback<void(Args...)> CreateSafeOnceCallback( ...@@ -86,6 +86,12 @@ base::OnceCallback<void(Args...)> CreateSafeOnceCallback(
std::move(callback)); std::move(callback));
} }
gpu::ContextUrl& GetActiveUrl() {
static base::NoDestructor<gpu::ContextUrl> active_url(
GURL("chrome://gpu/SkiaRenderer"));
return *active_url;
}
} // namespace } // namespace
SkiaOutputSurfaceImpl::ScopedPaint::ScopedPaint( SkiaOutputSurfaceImpl::ScopedPaint::ScopedPaint(
...@@ -787,9 +793,7 @@ void SkiaOutputSurfaceImpl::ScheduleGpuTask( ...@@ -787,9 +793,7 @@ void SkiaOutputSurfaceImpl::ScheduleGpuTask(
std::vector<gpu::SyncToken> sync_tokens) { std::vector<gpu::SyncToken> sync_tokens) {
auto wrapped_closure = base::BindOnce( auto wrapped_closure = base::BindOnce(
[](base::OnceClosure callback) { [](base::OnceClosure callback) {
static base::NoDestructor<gpu::ContextUrl> active_url( gpu::ContextUrl::SetActiveUrl(GetActiveUrl());
GURL("chrome://gpu/SkiaRenderer"));
gpu::ContextUrl::SetActiveUrl(*active_url);
std::move(callback).Run(); std::move(callback).Run();
}, },
std::move(callback)); std::move(callback));
......
...@@ -1372,6 +1372,9 @@ bool SkiaOutputSurfaceImplOnGpu::MakeCurrent(bool need_fbo0) { ...@@ -1372,6 +1372,9 @@ bool SkiaOutputSurfaceImplOnGpu::MakeCurrent(bool need_fbo0) {
// fbo0. // fbo0.
if (!context_state_->MakeCurrent(need_fbo0 ? gl_surface_.get() : nullptr)) { if (!context_state_->MakeCurrent(need_fbo0 ? gl_surface_.get() : nullptr)) {
LOG(ERROR) << "Failed to make current."; LOG(ERROR) << "Failed to make current.";
dependency_->DidLoseContext(
!need_fbo0 /* offscreen */, gpu::error::kMakeCurrentFailed,
GURL("chrome://gpu/SkiaOutputSurfaceImplOnGpu::MakeCurrent"));
MarkContextLost(); MarkContextLost();
return false; return false;
} }
......
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