Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f575435

Browse files
author
Chris Yang
authored
Revert "Reland "Guarding EAGLContext used by Flutter #13314" (#13755)" (#13757)
This reverts commit 618e666.
1 parent 7413304 commit f575435

39 files changed

+116
-713
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,6 @@ FILE: ../../../flutter/shell/common/canvas_spy_unittests.cc
495495
FILE: ../../../flutter/shell/common/engine.cc
496496
FILE: ../../../flutter/shell/common/engine.h
497497
FILE: ../../../flutter/shell/common/fixtures/shell_test.dart
498-
FILE: ../../../flutter/shell/common/gl_context_switch_manager.cc
499-
FILE: ../../../flutter/shell/common/gl_context_switch_manager.h
500498
FILE: ../../../flutter/shell/common/input_events_unittests.cc
501499
FILE: ../../../flutter/shell/common/isolate_configuration.cc
502500
FILE: ../../../flutter/shell/common/isolate_configuration.h
@@ -801,8 +799,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_gl.h
801799
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_gl.mm
802800
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context.h
803801
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context.mm
804-
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context_switch_manager.h
805-
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context_switch_manager.mm
806802
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_render_target.h
807803
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_render_target.mm
808804
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface.h

shell/common/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ source_set("common") {
6666
"canvas_spy.h",
6767
"engine.cc",
6868
"engine.h",
69-
"gl_context_switch_manager.cc",
70-
"gl_context_switch_manager.h",
7169
"isolate_configuration.cc",
7270
"isolate_configuration.h",
7371
"persistent_cache.cc",

shell/common/gl_context_switch_manager.cc

Lines changed: 0 additions & 28 deletions
This file was deleted.

shell/common/gl_context_switch_manager.h

Lines changed: 0 additions & 116 deletions
This file was deleted.

shell/common/shell_test.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,8 @@ PointerDataDispatcherMaker ShellTestPlatformView::GetDispatcherMaker() {
355355
}
356356

357357
// |GPUSurfaceGLDelegate|
358-
std::unique_ptr<GLContextSwitchManager::GLContextSwitch>
359-
ShellTestPlatformView::GLContextMakeCurrent() {
360-
return std::make_unique<GLContextSwitchManager::GLContextSwitchPureResult>(
361-
gl_surface_.MakeCurrent());
358+
bool ShellTestPlatformView::GLContextMakeCurrent() {
359+
return gl_surface_.MakeCurrent();
362360
}
363361

364362
// |GPUSurfaceGLDelegate|
@@ -389,10 +387,5 @@ ExternalViewEmbedder* ShellTestPlatformView::GetExternalViewEmbedder() {
389387
return nullptr;
390388
}
391389

392-
std::shared_ptr<GLContextSwitchManager>
393-
ShellTestPlatformView::GetGLContextSwitchManager() {
394-
return nullptr;
395-
}
396-
397390
} // namespace testing
398391
} // namespace flutter

shell/common/shell_test.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ class ShellTestPlatformView : public PlatformView, public GPUSurfaceGLDelegate {
144144
PointerDataDispatcherMaker GetDispatcherMaker() override;
145145

146146
// |GPUSurfaceGLDelegate|
147-
std::unique_ptr<GLContextSwitchManager::GLContextSwitch>
148-
GLContextMakeCurrent() override;
147+
bool GLContextMakeCurrent() override;
149148

150149
// |GPUSurfaceGLDelegate|
151150
bool GLContextClearCurrent() override;
@@ -162,8 +161,6 @@ class ShellTestPlatformView : public PlatformView, public GPUSurfaceGLDelegate {
162161
// |GPUSurfaceGLDelegate|
163162
ExternalViewEmbedder* GetExternalViewEmbedder() override;
164163

165-
std::shared_ptr<GLContextSwitchManager> GetGLContextSwitchManager() override;
166-
167164
FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformView);
168165
};
169166

shell/common/surface.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ flutter::ExternalViewEmbedder* Surface::GetExternalViewEmbedder() {
6060
return nullptr;
6161
}
6262

63-
std::unique_ptr<GLContextSwitchManager::GLContextSwitch>
64-
Surface::MakeRenderContextCurrent() {
65-
return std::make_unique<GLContextSwitchManager::GLContextSwitchPureResult>(
66-
true);
63+
bool Surface::MakeRenderContextCurrent() {
64+
return true;
6765
}
6866

6967
} // namespace flutter

shell/common/surface.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "flutter/flow/compositor_context.h"
1111
#include "flutter/flow/embedded_views.h"
1212
#include "flutter/fml/macros.h"
13-
#include "flutter/shell/common/gl_context_switch_manager.h"
1413
#include "third_party/skia/include/core/SkCanvas.h"
1514

1615
namespace flutter {
@@ -59,8 +58,7 @@ class Surface {
5958

6059
virtual flutter::ExternalViewEmbedder* GetExternalViewEmbedder();
6160

62-
virtual std::unique_ptr<GLContextSwitchManager::GLContextSwitch>
63-
MakeRenderContextCurrent();
61+
virtual bool MakeRenderContextCurrent();
6462

6563
private:
6664
FML_DISALLOW_COPY_AND_ASSIGN(Surface);

shell/gpu/gpu_surface_gl.cc

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "flutter/fml/logging.h"
99
#include "flutter/fml/size.h"
1010
#include "flutter/fml/trace_event.h"
11-
#include "flutter/shell/common/gl_context_switch_manager.h"
1211
#include "flutter/shell/common/persistent_cache.h"
1312
#include "third_party/skia/include/core/SkColorFilter.h"
1413
#include "third_party/skia/include/core/SkSurface.h"
@@ -40,10 +39,7 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate,
4039
: delegate_(delegate),
4140
render_to_surface_(render_to_surface),
4241
weak_factory_(this) {
43-
std::unique_ptr<GLContextSwitchManager::GLContextSwitch> context_switch =
44-
delegate_->GLContextMakeCurrent();
45-
46-
if (!context_switch->GetSwitchResult()) {
42+
if (!delegate_->GLContextMakeCurrent()) {
4743
FML_LOG(ERROR)
4844
<< "Could not make the context current to setup the gr context.";
4945
return;
@@ -91,6 +87,8 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate,
9187
}
9288
FML_LOG(INFO) << "Found " << caches.size() << " SkSL shaders; precompiled "
9389
<< compiled_count;
90+
91+
delegate_->GLContextClearCurrent();
9492
}
9593

9694
GPUSurfaceGL::GPUSurfaceGL(sk_sp<GrContext> gr_context,
@@ -100,9 +98,7 @@ GPUSurfaceGL::GPUSurfaceGL(sk_sp<GrContext> gr_context,
10098
context_(gr_context),
10199
render_to_surface_(render_to_surface),
102100
weak_factory_(this) {
103-
std::unique_ptr<GLContextSwitchManager::GLContextSwitch> context_switch =
104-
delegate_->GLContextMakeCurrent();
105-
if (!context_switch->GetSwitchResult()) {
101+
if (!delegate_->GLContextMakeCurrent()) {
106102
FML_LOG(ERROR)
107103
<< "Could not make the context current to setup the gr context.";
108104
return;
@@ -118,9 +114,8 @@ GPUSurfaceGL::~GPUSurfaceGL() {
118114
if (!valid_) {
119115
return;
120116
}
121-
std::unique_ptr<GLContextSwitchManager::GLContextSwitch> context_switch =
122-
delegate_->GLContextMakeCurrent();
123-
if (!context_switch->GetSwitchResult()) {
117+
118+
if (!delegate_->GLContextMakeCurrent()) {
124119
FML_LOG(ERROR) << "Could not make the context current to destroy the "
125120
"GrContext resources.";
126121
return;
@@ -131,6 +126,8 @@ GPUSurfaceGL::~GPUSurfaceGL() {
131126
context_->releaseResourcesAndAbandonContext();
132127
}
133128
context_ = nullptr;
129+
130+
delegate_->GLContextClearCurrent();
134131
}
135132

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

259-
std::unique_ptr<GLContextSwitchManager::GLContextSwitch> context_switch =
260-
delegate_->GLContextMakeCurrent();
261-
if (!context_switch->GetSwitchResult()) {
256+
if (!delegate_->GLContextMakeCurrent()) {
262257
FML_LOG(ERROR)
263258
<< "Could not make the context current to acquire the frame.";
264259
return nullptr;
@@ -290,18 +285,14 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceGL::AcquireFrame(const SkISize& size) {
290285
return weak ? weak->PresentSurface(canvas) : false;
291286
};
292287

293-
std::unique_ptr<SurfaceFrame> result =
294-
std::make_unique<SurfaceFrame>(surface, submit_callback);
295-
return result;
288+
return std::make_unique<SurfaceFrame>(surface, submit_callback);
296289
}
297290

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

303-
std::unique_ptr<GLContextSwitchManager::GLContextSwitch> context_switch =
304-
delegate_->GLContextMakeCurrent();
305296
if (offscreen_surface_ != nullptr) {
306297
TRACE_EVENT0("flutter", "CopyTextureOnscreen");
307298
SkPaint paint;
@@ -338,6 +329,7 @@ bool GPUSurfaceGL::PresentSurface(SkCanvas* canvas) {
338329

339330
onscreen_surface_ = std::move(new_onscreen_surface);
340331
}
332+
341333
return true;
342334
}
343335

@@ -368,8 +360,7 @@ flutter::ExternalViewEmbedder* GPUSurfaceGL::GetExternalViewEmbedder() {
368360
}
369361

370362
// |Surface|
371-
std::unique_ptr<GLContextSwitchManager::GLContextSwitch>
372-
GPUSurfaceGL::MakeRenderContextCurrent() {
363+
bool GPUSurfaceGL::MakeRenderContextCurrent() {
373364
return delegate_->GLContextMakeCurrent();
374365
}
375366

shell/gpu/gpu_surface_gl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ class GPUSurfaceGL : public Surface {
4444
flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override;
4545

4646
// |Surface|
47-
std::unique_ptr<GLContextSwitchManager::GLContextSwitch>
48-
MakeRenderContextCurrent() override;
47+
bool MakeRenderContextCurrent() override;
4948

5049
private:
5150
GPUSurfaceGLDelegate* delegate_;

0 commit comments

Comments
 (0)