Skip to content

Commit 6d66993

Browse files
author
Chris Yang
authored
Revert "Reland "Guarding EAGLContext used by Flutter flutter#13314" (flutter#13759)" (flutter#13788)
This reverts commit 2dcfaae.
1 parent 726e8f5 commit 6d66993

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+123
-745
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,6 @@ FILE: ../../../flutter/shell/common/pointer_data_dispatcher.cc
511511
FILE: ../../../flutter/shell/common/pointer_data_dispatcher.h
512512
FILE: ../../../flutter/shell/common/rasterizer.cc
513513
FILE: ../../../flutter/shell/common/rasterizer.h
514-
FILE: ../../../flutter/shell/common/renderer_context_switch_manager.cc
515-
FILE: ../../../flutter/shell/common/renderer_context_switch_manager.h
516514
FILE: ../../../flutter/shell/common/run_configuration.cc
517515
FILE: ../../../flutter/shell/common/run_configuration.h
518516
FILE: ../../../flutter/shell/common/shell.cc
@@ -802,8 +800,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_gl.h
802800
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_gl.mm
803801
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context.h
804802
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context.mm
805-
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context_switch_manager.h
806-
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_context_switch_manager.mm
807803
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_render_target.h
808804
FILE: ../../../flutter/shell/platform/darwin/ios/ios_gl_render_target.mm
809805
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
@@ -78,8 +78,6 @@ source_set("common") {
7878
"pointer_data_dispatcher.h",
7979
"rasterizer.cc",
8080
"rasterizer.h",
81-
"renderer_context_switch_manager.cc",
82-
"renderer_context_switch_manager.h",
8381
"run_configuration.cc",
8482
"run_configuration.h",
8583
"shell.cc",

shell/common/rasterizer.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ sk_sp<SkImage> Rasterizer::MakeRasterSnapshot(sk_sp<SkPicture> picture,
163163
// happen in case of software rendering.
164164
surface = SkSurface::MakeRaster(image_info);
165165
} else {
166-
std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
167-
context_switch = surface_->MakeRenderContextCurrent();
168-
if (!context_switch->GetSwitchResult()) {
166+
if (!surface_->MakeRenderContextCurrent()) {
169167
return nullptr;
170168
}
171169

shell/common/renderer_context_switch_manager.cc

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

shell/common/renderer_context_switch_manager.h

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

shell/common/shell_test.cc

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

357357
// |GPUSurfaceGLDelegate|
358-
std::unique_ptr<RendererContextSwitchManager::RendererContextSwitch>
359-
ShellTestPlatformView::GLContextMakeCurrent() {
360-
return std::make_unique<
361-
RendererContextSwitchManager::RendererContextSwitchPureResult>(
362-
gl_surface_.MakeCurrent());
358+
bool ShellTestPlatformView::GLContextMakeCurrent() {
359+
return gl_surface_.MakeCurrent();
363360
}
364361

365362
// |GPUSurfaceGLDelegate|
@@ -390,10 +387,5 @@ ExternalViewEmbedder* ShellTestPlatformView::GetExternalViewEmbedder() {
390387
return nullptr;
391388
}
392389

393-
std::shared_ptr<RendererContextSwitchManager>
394-
ShellTestPlatformView::GetRendererContextSwitchManager() {
395-
return nullptr;
396-
}
397-
398390
} // namespace testing
399391
} // namespace flutter

shell/common/shell_test.h

Lines changed: 1 addition & 5 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<RendererContextSwitchManager::RendererContextSwitch>
148-
GLContextMakeCurrent() override;
147+
bool GLContextMakeCurrent() override;
149148

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

165-
std::shared_ptr<RendererContextSwitchManager>
166-
GetRendererContextSwitchManager() override;
167-
168164
FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformView);
169165
};
170166

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<RendererContextSwitchManager::RendererContextSwitch>
64-
Surface::MakeRenderContextCurrent() {
65-
return std::make_unique<
66-
RendererContextSwitchManager::RendererContextSwitchPureResult>(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/renderer_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<RendererContextSwitchManager::RendererContextSwitch>
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
@@ -9,7 +9,6 @@
99
#include "flutter/fml/size.h"
1010
#include "flutter/fml/trace_event.h"
1111
#include "flutter/shell/common/persistent_cache.h"
12-
#include "flutter/shell/common/renderer_context_switch_manager.h"
1312
#include "third_party/skia/include/core/SkColorFilter.h"
1413
#include "third_party/skia/include/core/SkSurface.h"
1514
#include "third_party/skia/include/gpu/GrBackendSurface.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<RendererContextSwitchManager::RendererContextSwitch>
44-
context_switch = 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<RendererContextSwitchManager::RendererContextSwitch>
104-
context_switch = 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<RendererContextSwitchManager::RendererContextSwitch>
122-
context_switch = 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<RendererContextSwitchManager::RendererContextSwitch>
260-
context_switch = 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<RendererContextSwitchManager::RendererContextSwitch>
304-
context_switch = 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<RendererContextSwitchManager::RendererContextSwitch>
372-
GPUSurfaceGL::MakeRenderContextCurrent() {
363+
bool GPUSurfaceGL::MakeRenderContextCurrent() {
373364
return delegate_->GLContextMakeCurrent();
374365
}
375366

0 commit comments

Comments
 (0)