Skip to content

Commit

Permalink
Use the GPU thread for Android surface on-screen context lifecycle op…
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons authored Mar 21, 2019
1 parent 10e1add commit fa43538
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions shell/platform/android/platform_view_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,33 @@ void PlatformViewAndroid::NotifyCreated(
fml::RefPtr<AndroidNativeWindow> native_window) {
if (android_surface_) {
InstallFirstFrameCallback();
android_surface_->SetNativeWindow(native_window);

fml::AutoResetWaitableEvent latch;
fml::TaskRunner::RunNowOrPostTask(
task_runners_.GetGPUTaskRunner(),
[&latch, surface = android_surface_.get(),
native_window = std::move(native_window)]() {
surface->SetNativeWindow(native_window);
latch.Signal();
});
latch.Wait();
}

PlatformView::NotifyCreated();
}

void PlatformViewAndroid::NotifyDestroyed() {
PlatformView::NotifyDestroyed();

if (android_surface_) {
android_surface_->TeardownOnScreenContext();
fml::AutoResetWaitableEvent latch;
fml::TaskRunner::RunNowOrPostTask(
task_runners_.GetGPUTaskRunner(),
[&latch, surface = android_surface_.get()]() {
surface->TeardownOnScreenContext();
latch.Signal();
});
latch.Wait();
}
}

Expand Down

0 comments on commit fa43538

Please sign in to comment.