Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Unified Diff: sky/shell/ui/engine.cc

Issue 1230073002: Teach SkyShell.apk to stop posting frames when not visible (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/shell/ui/engine.cc
diff --git a/sky/shell/ui/engine.cc b/sky/shell/ui/engine.cc
index 7893ec51f4eb8db0c7761b700c1beee307ba28b6..75991d0a79d26bea109bdcf7d9f1d0deb22b9f7e 100644
--- a/sky/shell/ui/engine.cc
+++ b/sky/shell/ui/engine.cc
@@ -59,6 +59,8 @@ Engine::Engine(const Config& config)
: config_(config),
animator_(new Animator(config, this)),
binding_(this),
+ activity_running_(false),
+ have_surface_(false),
weak_factory_(this) {
}
@@ -118,11 +120,15 @@ void Engine::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) {
config_.gpu_task_runner->PostTask(
FROM_HERE, base::Bind(&GPUDelegate::OnAcceleratedWidgetAvailable,
config_.gpu_delegate, widget));
+ have_surface_ = true;
+ StartAnimatorIfPossible();
if (sky_view_)
ScheduleFrame();
}
void Engine::OnOutputSurfaceDestroyed() {
+ have_surface_ = false;
+ StopAnimator();
config_.gpu_task_runner->PostTask(
FROM_HERE,
base::Bind(&GPUDelegate::OnOutputSurfaceDestroyed, config_.gpu_delegate));
@@ -195,12 +201,31 @@ void Engine::RunFromBundle(const mojo::String& path) {
weak_factory_.GetWeakPtr(), path_str));
}
+void Engine::OnActivityPaused() {
+ activity_running_ = false;
+ StopAnimator();
+}
+
+void Engine::OnActivityResumed() {
+ activity_running_ = true;
+ StartAnimatorIfPossible();
+}
+
void Engine::DidCreateIsolate(Dart_Isolate isolate) {
Internals::Create(isolate,
CreateServiceProvider(config_.service_provider_context),
root_bundle_.Pass());
}
+void Engine::StopAnimator() {
+ animator_->Stop();
+}
+
+void Engine::StartAnimatorIfPossible() {
+ if (activity_running_ && have_surface_)
+ animator_->Start();
+}
+
void Engine::ScheduleFrame() {
animator_->RequestFrame();
}
« sky/shell/android/org/domokit/sky/shell/SkyActivity.java ('K') | « sky/shell/ui/engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698