未验证 提交 ea07f279 编写于 作者: J Jason Simmons 提交者: GitHub

Detach the resource context before shutting down the IO thread (#6009)

上级 3ac46bcf
......@@ -73,6 +73,8 @@ sk_sp<GrContext> PlatformView::CreateResourceContext() const {
return nullptr;
}
void PlatformView::ReleaseResourceContext() const {}
fml::WeakPtr<PlatformView> PlatformView::GetWeakPtr() const {
return weak_factory_.GetWeakPtr();
}
......
......@@ -88,6 +88,10 @@ class PlatformView {
// non-platform task runner.
virtual sk_sp<GrContext> CreateResourceContext() const;
// Unlike all other methods on the platform view, this one may be called on a
// non-platform task runner.
virtual void ReleaseResourceContext() const;
fml::WeakPtr<PlatformView> GetWeakPtr() const;
virtual void UpdateSemantics(blink::SemanticsNodeUpdates updates,
......
......@@ -314,11 +314,15 @@ Shell::~Shell() {
fml::TaskRunner::RunNowOrPostTask(
task_runners_.GetIOTaskRunner(),
fml::MakeCopyable(
[io_manager = std::move(io_manager_), &io_latch]() mutable {
io_manager.reset();
io_latch.Signal();
}));
fml::MakeCopyable([io_manager = std::move(io_manager_),
platform_view = platform_view_.get(),
&io_latch]() mutable {
io_manager.reset();
if (platform_view) {
platform_view->ReleaseResourceContext();
}
io_latch.Signal();
}));
io_latch.Wait();
......
......@@ -33,6 +33,8 @@ class AndroidSurface {
virtual bool ResourceContextMakeCurrent() = 0;
virtual bool ResourceContextClearCurrent() = 0;
virtual bool SetNativeWindow(fml::RefPtr<AndroidNativeWindow> window) = 0;
};
......
......@@ -82,6 +82,11 @@ bool AndroidSurfaceGL::ResourceContextMakeCurrent() {
return offscreen_context_->MakeCurrent();
}
bool AndroidSurfaceGL::ResourceContextClearCurrent() {
FML_DCHECK(offscreen_context_ && offscreen_context_->IsValid());
return offscreen_context_->ClearCurrent();
}
bool AndroidSurfaceGL::SetNativeWindow(
fml::RefPtr<AndroidNativeWindow> window) {
// In any case, we want to get rid of our current onscreen context.
......
......@@ -40,6 +40,9 @@ class AndroidSurfaceGL final : public GPUSurfaceGLDelegate,
// |shell::AndroidSurface|
bool ResourceContextMakeCurrent() override;
// |shell::AndroidSurface|
bool ResourceContextClearCurrent() override;
// |shell::AndroidSurface|
bool SetNativeWindow(fml::RefPtr<AndroidNativeWindow> window) override;
......
......@@ -52,6 +52,10 @@ bool AndroidSurfaceSoftware::ResourceContextMakeCurrent() {
return false;
}
bool AndroidSurfaceSoftware::ResourceContextClearCurrent() {
return false;
}
std::unique_ptr<Surface> AndroidSurfaceSoftware::CreateGPUSurface() {
if (!IsValid()) {
return nullptr;
......
......@@ -26,6 +26,9 @@ class AndroidSurfaceSoftware final : public AndroidSurface,
// |shell::AndroidSurface|
bool ResourceContextMakeCurrent() override;
// |shell::AndroidSurface|
bool ResourceContextClearCurrent() override;
// |shell::AndroidSurface|
std::unique_ptr<Surface> CreateGPUSurface() override;
......
......@@ -65,6 +65,10 @@ bool AndroidSurfaceVulkan::ResourceContextMakeCurrent() {
return false;
}
bool AndroidSurfaceVulkan::ResourceContextClearCurrent() {
return false;
}
// |shell::AndroidSurface|
bool AndroidSurfaceVulkan::SetNativeWindow(
fml::RefPtr<AndroidNativeWindow> window) {
......
......@@ -385,6 +385,13 @@ sk_sp<GrContext> PlatformViewAndroid::CreateResourceContext() const {
return resource_context;
}
// |shell::PlatformView|
void PlatformViewAndroid::ReleaseResourceContext() const {
if (android_surface_) {
android_surface_->ResourceContextClearCurrent();
}
}
void PlatformViewAndroid::InstallFirstFrameCallback() {
// On Platform Task Runner.
SetNextFrameCallback(
......
......@@ -102,6 +102,9 @@ class PlatformViewAndroid final : public PlatformView {
// |shell::PlatformView|
sk_sp<GrContext> CreateResourceContext() const override;
// |shell::PlatformView|
void ReleaseResourceContext() const override;
void InstallFirstFrameCallback();
void FireFirstFrameCallback();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册