Skip to content

Commit

Permalink
Revert "Reland "Guarding EAGLContext used by Flutter flutter#13314" (f…
Browse files Browse the repository at this point in the history
…lutter#13759)" (flutter#13788)

This reverts commit 2dcfaae.
  • Loading branch information
Chris Yang authored Nov 12, 2019
1 parent 726e8f5 commit 6d66993
Show file tree
Hide file tree
Showing 44 changed files with 123 additions and 745 deletions.
4 changes: 0 additions & 4 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,6 @@ FILE: ../../../flutter/shell/common/pointer_data_dispatcher.cc
FILE: ../../../flutter/shell/common/pointer_data_dispatcher.h
FILE: ../../../flutter/shell/common/rasterizer.cc
FILE: ../../../flutter/shell/common/rasterizer.h
FILE: ../../../flutter/shell/common/renderer_context_switch_manager.cc
FILE: ../../../flutter/shell/common/renderer_context_switch_manager.h
FILE: ../../../flutter/shell/common/run_configuration.cc
FILE: ../../../flutter/shell/common/run_configuration.h
FILE: ../../../flutter/shell/common/shell.cc
Expand Down Expand Up @@ -802,8 +800,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_gl.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_gl.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context_switch_manager.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context_switch_manager.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_render_target.h
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_render_target.mm
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface.h
Expand Down
2 changes: 0 additions & 2 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ source_set("common") {
"pointer_data_dispatcher.h",
"rasterizer.cc",
"rasterizer.h",
"renderer_context_switch_manager.cc",
"renderer_context_switch_manager.h",
"run_configuration.cc",
"run_configuration.h",
"shell.cc",
Expand Down
4 changes: 1 addition & 3 deletions shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ sk_sp<SkImage> Rasterizer::MakeRasterSnapshot(sk_sp<SkPicture> picture,
// happen in case of software rendering.
surface = SkSurface::MakeRaster(image_info);
} else {
std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
context_switch = surface_->MakeRenderContextCurrent();
if (!context_switch->GetSwitchResult()) {
if (!surface_->MakeRenderContextCurrent()) {
return nullptr;
}

Expand Down
30 changes: 0 additions & 30 deletions shell/common/renderer_context_switch_manager.cc

This file was deleted.

116 changes: 0 additions & 116 deletions shell/common/renderer_context_switch_manager.h

This file was deleted.

12 changes: 2 additions & 10 deletions shell/common/shell_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,8 @@ PointerDataDispatcherMaker ShellTestPlatformView::GetDispatcherMaker() {
}

// |GPUSurfaceGLDelegate|
std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
ShellTestPlatformView::GLContextMakeCurrent() {
return std::make_unique<
RendererContextSwitchManager::RendererContextSwitchPureResult>(
gl_surface_.MakeCurrent());
bool ShellTestPlatformView::GLContextMakeCurrent() {
return gl_surface_.MakeCurrent();
}

// |GPUSurfaceGLDelegate|
Expand Down Expand Up @@ -390,10 +387,5 @@ ExternalViewEmbedder* ShellTestPlatformView::GetExternalViewEmbedder() {
return nullptr;
}

std::shared_ptr<RendererContextSwitchManager>
ShellTestPlatformView::GetRendererContextSwitchManager() {
return nullptr;
}

} // namespace testing
} // namespace flutter
6 changes: 1 addition & 5 deletions shell/common/shell_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ class ShellTestPlatformView : public PlatformView, public GPUSurfaceGLDelegate {
PointerDataDispatcherMaker GetDispatcherMaker() override;

// |GPUSurfaceGLDelegate|
std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
GLContextMakeCurrent() override;
bool GLContextMakeCurrent() override;

// |GPUSurfaceGLDelegate|
bool GLContextClearCurrent() override;
Expand All @@ -162,9 +161,6 @@ class ShellTestPlatformView : public PlatformView, public GPUSurfaceGLDelegate {
// |GPUSurfaceGLDelegate|
ExternalViewEmbedder* GetExternalViewEmbedder() override;

std::shared_ptr<RendererContextSwitchManager>
GetRendererContextSwitchManager() override;

FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformView);
};

Expand Down
6 changes: 2 additions & 4 deletions shell/common/surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ flutter::ExternalViewEmbedder* Surface::GetExternalViewEmbedder() {
return nullptr;
}

std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
Surface::MakeRenderContextCurrent() {
return std::make_unique<
RendererContextSwitchManager::RendererContextSwitchPureResult>(true);
bool Surface::MakeRenderContextCurrent() {
return true;
}

} // namespace flutter
4 changes: 1 addition & 3 deletions shell/common/surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "flutter/flow/compositor_context.h"
#include "flutter/flow/embedded_views.h"
#include "flutter/fml/macros.h"
#include "flutter/shell/common/renderer_context_switch_manager.h"
#include "third_party/skia/include/core/SkCanvas.h"

namespace flutter {
Expand Down Expand Up @@ -59,8 +58,7 @@ class Surface {

virtual flutter::ExternalViewEmbedder* GetExternalViewEmbedder();

virtual std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
MakeRenderContextCurrent();
virtual bool MakeRenderContextCurrent();

private:
FML_DISALLOW_COPY_AND_ASSIGN(Surface);
Expand Down
33 changes: 12 additions & 21 deletions shell/gpu/gpu_surface_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "flutter/fml/size.h"
#include "flutter/fml/trace_event.h"
#include "flutter/shell/common/persistent_cache.h"
#include "flutter/shell/common/renderer_context_switch_manager.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
Expand Down Expand Up @@ -40,10 +39,7 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate,
: delegate_(delegate),
render_to_surface_(render_to_surface),
weak_factory_(this) {
std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
context_switch = delegate_->GLContextMakeCurrent();

if (!context_switch->GetSwitchResult()) {
if (!delegate_->GLContextMakeCurrent()) {
FML_LOG(ERROR)
<< "Could not make the context current to setup the gr context.";
return;
Expand Down Expand Up @@ -91,6 +87,8 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate,
}
FML_LOG(INFO) << "Found " << caches.size() << " SkSL shaders; precompiled "
<< compiled_count;

delegate_->GLContextClearCurrent();
}

GPUSurfaceGL::GPUSurfaceGL(sk_sp<GrContext> gr_context,
Expand All @@ -100,9 +98,7 @@ GPUSurfaceGL::GPUSurfaceGL(sk_sp<GrContext> gr_context,
context_(gr_context),
render_to_surface_(render_to_surface),
weak_factory_(this) {
std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
context_switch = delegate_->GLContextMakeCurrent();
if (!context_switch->GetSwitchResult()) {
if (!delegate_->GLContextMakeCurrent()) {
FML_LOG(ERROR)
<< "Could not make the context current to setup the gr context.";
return;
Expand All @@ -118,9 +114,8 @@ GPUSurfaceGL::~GPUSurfaceGL() {
if (!valid_) {
return;
}
std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
context_switch = delegate_->GLContextMakeCurrent();
if (!context_switch->GetSwitchResult()) {

if (!delegate_->GLContextMakeCurrent()) {
FML_LOG(ERROR) << "Could not make the context current to destroy the "
"GrContext resources.";
return;
Expand All @@ -131,6 +126,8 @@ GPUSurfaceGL::~GPUSurfaceGL() {
context_->releaseResourcesAndAbandonContext();
}
context_ = nullptr;

delegate_->GLContextClearCurrent();
}

// |Surface|
Expand Down Expand Up @@ -256,9 +253,7 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceGL::AcquireFrame(const SkISize& size) {
return nullptr;
}

std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
context_switch = delegate_->GLContextMakeCurrent();
if (!context_switch->GetSwitchResult()) {
if (!delegate_->GLContextMakeCurrent()) {
FML_LOG(ERROR)
<< "Could not make the context current to acquire the frame.";
return nullptr;
Expand Down Expand Up @@ -290,18 +285,14 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceGL::AcquireFrame(const SkISize& size) {
return weak ? weak->PresentSurface(canvas) : false;
};

std::unique_ptr<SurfaceFrame> result =
std::make_unique<SurfaceFrame>(surface, submit_callback);
return result;
return std::make_unique<SurfaceFrame>(surface, submit_callback);
}

bool GPUSurfaceGL::PresentSurface(SkCanvas* canvas) {
if (delegate_ == nullptr || canvas == nullptr || context_ == nullptr) {
return false;
}

std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
context_switch = delegate_->GLContextMakeCurrent();
if (offscreen_surface_ != nullptr) {
TRACE_EVENT0("flutter", "CopyTextureOnscreen");
SkPaint paint;
Expand Down Expand Up @@ -338,6 +329,7 @@ bool GPUSurfaceGL::PresentSurface(SkCanvas* canvas) {

onscreen_surface_ = std::move(new_onscreen_surface);
}

return true;
}

Expand Down Expand Up @@ -368,8 +360,7 @@ flutter::ExternalViewEmbedder* GPUSurfaceGL::GetExternalViewEmbedder() {
}

// |Surface|
std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
GPUSurfaceGL::MakeRenderContextCurrent() {
bool GPUSurfaceGL::MakeRenderContextCurrent() {
return delegate_->GLContextMakeCurrent();
}

Expand Down
3 changes: 1 addition & 2 deletions shell/gpu/gpu_surface_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class GPUSurfaceGL : public Surface {
flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override;

// |Surface|
std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
MakeRenderContextCurrent() override;
bool MakeRenderContextCurrent() override;

private:
GPUSurfaceGLDelegate* delegate_;
Expand Down
Loading

0 comments on commit 6d66993

Please sign in to comment.