Skip to content

Commit 5e54c70

Browse files
author
Emmanuel Garcia
authored
Reland: Enable hybrid composition by default on Android (flutter#20722) (flutter#20864)
This reverts commit 4de62c7.
1 parent 165abef commit 5e54c70

File tree

17 files changed

+36
-100
lines changed

17 files changed

+36
-100
lines changed

common/settings.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,6 @@ struct Settings {
223223
/// to log a timeline event that tracks the latency of engine startup.
224224
std::chrono::microseconds engine_start_timestamp = {};
225225

226-
/// Whether the application claims that it uses the android embedded view for
227-
/// platform views.
228-
///
229-
/// A `true` value will result the raster task runner always run on the
230-
/// platform thread.
231-
// TODO(cyanlaz): Remove this when dynamic thread merging is done.
232-
// https://github.com/flutter/flutter/issues/59930
233-
bool use_embedded_view = false;
234-
235226
std::string ToString() const;
236227
};
237228

flow/surface.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ std::unique_ptr<GLContextResult> Surface::MakeRenderContextCurrent() {
1818
return std::make_unique<GLContextDefaultResult>(true);
1919
}
2020

21+
bool Surface::ClearRenderContext() {
22+
return false;
23+
}
24+
2125
} // namespace flutter

flow/surface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class Surface {
3333

3434
virtual std::unique_ptr<GLContextResult> MakeRenderContextCurrent();
3535

36+
virtual bool ClearRenderContext();
37+
3638
private:
3739
FML_DISALLOW_COPY_AND_ASSIGN(Surface);
3840
};

shell/common/rasterizer.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ void Rasterizer::Draw(fml::RefPtr<Pipeline<flutter::LayerTree>> pipeline) {
178178
consume_result = PipelineConsumeResult::MoreAvailable;
179179
}
180180

181+
if (surface_ != nullptr) {
182+
surface_->ClearRenderContext();
183+
}
184+
181185
// Merging the thread as we know the next `Draw` should be run on the platform
182186
// thread.
183187
if (surface_ != nullptr && surface_->GetExternalViewEmbedder() != nullptr) {

shell/common/switches.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,6 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
229229
: "127.0.0.1";
230230
}
231231

232-
settings.use_embedded_view =
233-
command_line.HasOption(FlagForSwitch(Switch::UseEmbeddedView));
234-
235232
// Set Observatory Port
236233
if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryPort))) {
237234
if (!GetSwitchValue(command_line, Switch::DeviceObservatoryPort,

shell/common/switches.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,7 @@ DEF_SWITCH(
196196
"Uses separate threads for the platform, UI, GPU and IO task runners. "
197197
"By default, a single thread is used for all task runners. Only available "
198198
"in the flutter_tester.")
199-
// TODO(cyanlaz): Remove this when dynamic thread merging is done.
200-
// https://github.com/flutter/flutter/issues/59930
201-
DEF_SWITCH(UseEmbeddedView,
202-
"use-embedded-view",
203-
"Whether an android application uses embedded views."
204-
"This is a temporary flag to make the raster task runner runs on "
205-
"the platform thread."
206-
"This flag should be removed once the dynamic thread merging is "
207-
"enabled on android.")
199+
208200
DEF_SWITCHES_END
209201

210202
void PrintUsage(const std::string& executable_name);

shell/gpu/gpu_surface_gl.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,4 +346,9 @@ std::unique_ptr<GLContextResult> GPUSurfaceGL::MakeRenderContextCurrent() {
346346
return delegate_->GLContextMakeCurrent();
347347
}
348348

349+
// |Surface|
350+
bool GPUSurfaceGL::ClearRenderContext() {
351+
return delegate_->GLContextClearCurrent();
352+
}
353+
349354
} // namespace flutter

shell/gpu/gpu_surface_gl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class GPUSurfaceGL : public Surface {
4848
// |Surface|
4949
std::unique_ptr<GLContextResult> MakeRenderContextCurrent() override;
5050

51+
// |Surface|
52+
bool ClearRenderContext() override;
53+
5154
private:
5255
GPUSurfaceGLDelegate* delegate_;
5356
sk_sp<GrDirectContext> context_;

shell/platform/android/android_shell_holder.cc

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ static PlatformData GetDefaultPlatformData() {
2828
return platform_data;
2929
}
3030

31-
bool AndroidShellHolder::use_embedded_view;
32-
3331
AndroidShellHolder::AndroidShellHolder(
3432
flutter::Settings settings,
3533
std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
@@ -102,47 +100,21 @@ AndroidShellHolder::AndroidShellHolder(
102100
ui_runner = thread_host_.ui_thread->GetTaskRunner();
103101
io_runner = thread_host_.io_thread->GetTaskRunner();
104102
}
105-
if (settings.use_embedded_view) {
106-
use_embedded_view = true;
107-
// Embedded views requires the gpu and the platform views to be the same.
108-
// The plan is to eventually dynamically merge the threads when there's a
109-
// platform view in the layer tree.
110-
// For now we use a fixed thread configuration with the same thread used as
111-
// the gpu and platform task runner.
112-
// TODO(amirh/chinmaygarde): remove this, and dynamically change the thread
113-
// configuration. https://github.com/flutter/flutter/issues/23975
114-
// https://github.com/flutter/flutter/issues/59930
115-
flutter::TaskRunners task_runners(thread_label, // label
116-
platform_runner, // platform
117-
platform_runner, // raster
118-
ui_runner, // ui
119-
io_runner // io
120-
);
121-
122-
shell_ =
123-
Shell::Create(task_runners, // task runners
124-
GetDefaultPlatformData(), // window data
125-
settings_, // settings
126-
on_create_platform_view, // platform view create callback
127-
on_create_rasterizer // rasterizer create callback
128-
);
129-
} else {
130-
use_embedded_view = false;
131-
flutter::TaskRunners task_runners(thread_label, // label
132-
platform_runner, // platform
133-
gpu_runner, // raster
134-
ui_runner, // ui
135-
io_runner // io
136-
);
137-
138-
shell_ =
139-
Shell::Create(task_runners, // task runners
140-
GetDefaultPlatformData(), // window data
141-
settings_, // settings
142-
on_create_platform_view, // platform view create callback
143-
on_create_rasterizer // rasterizer create callback
144-
);
145-
}
103+
104+
flutter::TaskRunners task_runners(thread_label, // label
105+
platform_runner, // platform
106+
gpu_runner, // raster
107+
ui_runner, // ui
108+
io_runner // io
109+
);
110+
111+
shell_ =
112+
Shell::Create(task_runners, // task runners
113+
GetDefaultPlatformData(), // window data
114+
settings_, // settings
115+
on_create_platform_view, // platform view create callback
116+
on_create_rasterizer // rasterizer create callback
117+
);
146118

147119
platform_view_ = weak_platform_view;
148120
FML_DCHECK(platform_view_);

shell/platform/android/android_shell_holder.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ namespace flutter {
2121

2222
class AndroidShellHolder {
2323
public:
24-
// Whether the application sets to use embedded_view view
25-
// `io.flutter.embedded_views_preview` flag. This can be static because it is
26-
// determined by the application and it is safe when there are multiple
27-
// `AndroidSurface`s.
28-
// TODO(cyanglaz): remove this when dynamic thread merging is enabled on
29-
// android. https://github.com/flutter/flutter/issues/59930
30-
static bool use_embedded_view;
31-
3224
AndroidShellHolder(flutter::Settings settings,
3325
std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
3426
bool is_background_view);

0 commit comments

Comments
 (0)