Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Guarding EAGLContext used by Flutter" #13753

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,6 @@ FILE: ../../../flutter/shell/common/canvas_spy_unittests.cc
FILE: ../../../flutter/shell/common/engine.cc
FILE: ../../../flutter/shell/common/engine.h
FILE: ../../../flutter/shell/common/fixtures/shell_test.dart
FILE: ../../../flutter/shell/common/gl_context_switch_manager.cc
FILE: ../../../flutter/shell/common/gl_context_switch_manager.h
FILE: ../../../flutter/shell/common/input_events_unittests.cc
FILE: ../../../flutter/shell/common/isolate_configuration.cc
FILE: ../../../flutter/shell/common/isolate_configuration.h
Expand Down Expand Up @@ -801,8 +799,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 @@ -66,8 +66,6 @@ source_set("common") {
"canvas_spy.h",
"engine.cc",
"engine.h",
"gl_context_switch_manager.cc",
"gl_context_switch_manager.h",
"isolate_configuration.cc",
"isolate_configuration.h",
"persistent_cache.cc",
Expand Down
28 changes: 0 additions & 28 deletions shell/common/gl_context_switch_manager.cc

This file was deleted.

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

This file was deleted.

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

// |GPUSurfaceGLDelegate|
std::unique_ptr<GLContextSwitchManager::GLContextSwitch>
ShellTestPlatformView::GLContextMakeCurrent() {
return std::make_unique<GLContextSwitchManager::GLContextSwitchPureResult>(
gl_surface_.MakeCurrent());
bool ShellTestPlatformView::GLContextMakeCurrent() {
return gl_surface_.MakeCurrent();
}

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

std::shared_ptr<GLContextSwitchManager>
ShellTestPlatformView::GetGLContextSwitchManager() {
return nullptr;
}

} // namespace testing
} // namespace flutter
5 changes: 1 addition & 4 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<GLContextSwitchManager::GLContextSwitch>
GLContextMakeCurrent() override;
bool GLContextMakeCurrent() override;

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

std::shared_ptr<GLContextSwitchManager> GetGLContextSwitchManager() 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<GLContextSwitchManager::GLContextSwitch>
Surface::MakeRenderContextCurrent() {
return std::make_unique<GLContextSwitchManager::GLContextSwitchPureResult>(
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/gl_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<GLContextSwitchManager::GLContextSwitch>
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 @@ -8,7 +8,6 @@
#include "flutter/fml/logging.h"
#include "flutter/fml/size.h"
#include "flutter/fml/trace_event.h"
#include "flutter/shell/common/gl_context_switch_manager.h"
#include "flutter/shell/common/persistent_cache.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkSurface.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<GLContextSwitchManager::GLContextSwitch> 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<GLContextSwitchManager::GLContextSwitch> 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<GLContextSwitchManager::GLContextSwitch> 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<GLContextSwitchManager::GLContextSwitch> 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<GLContextSwitchManager::GLContextSwitch> 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<GLContextSwitchManager::GLContextSwitch>
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<GLContextSwitchManager::GLContextSwitch>
MakeRenderContextCurrent() override;
bool MakeRenderContextCurrent() override;

private:
GPUSurfaceGLDelegate* delegate_;
Expand Down
7 changes: 1 addition & 6 deletions shell/gpu/gpu_surface_gl_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "flutter/flow/embedded_views.h"
#include "flutter/fml/macros.h"
#include "flutter/shell/common/gl_context_switch_manager.h"
#include "flutter/shell/gpu/gpu_surface_delegate.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
Expand All @@ -17,8 +16,7 @@ namespace flutter {
class GPUSurfaceGLDelegate : public GPUSurfaceDelegate {
public:
// Called to make the main GL context current on the current thread.
virtual std::unique_ptr<GLContextSwitchManager::GLContextSwitch>
GLContextMakeCurrent() = 0;
virtual bool GLContextMakeCurrent() = 0;

// Called to clear the current GL context on the thread. This may be called on
// either the GPU or IO threads.
Expand Down Expand Up @@ -61,9 +59,6 @@ class GPUSurfaceGLDelegate : public GPUSurfaceDelegate {
// instrumentation to specific GL calls can specify custom GL functions
// here.
virtual GLProcResolver GetGLProcResolver() const;

virtual std::shared_ptr<GLContextSwitchManager>
GetGLContextSwitchManager() = 0;
};

} // namespace flutter
Expand Down
Loading