diff options
author | sievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-15 17:53:46 +0000 |
---|---|---|
committer | sievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-15 17:53:46 +0000 |
commit | 24a65cc07106a4fee36113eda05ffd58462ab11c (patch) | |
tree | ccb21a59a4ef944d396ea787f4b59ca6ba196d14 /content/shell | |
parent | 98ff4e6c8d35329d68de53d9e1e1ddf6ff1ff35f (diff) | |
download | chromium_src-24a65cc07106a4fee36113eda05ffd58462ab11c.zip chromium_src-24a65cc07106a4fee36113eda05ffd58462ab11c.tar.gz chromium_src-24a65cc07106a4fee36113eda05ffd58462ab11c.tar.bz2 |
Android Browser Compositor: Add ScheduleComposite() callback.
This tells the client that it should schedule a composite operation
(i.e. during next vsync signal).
Review URL: https://codereview.chromium.org/11108004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161887 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r-- | content/shell/android/shell_manager.cc | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/content/shell/android/shell_manager.cc b/content/shell/android/shell_manager.cc index a7b6b26..71ed3ab 100644 --- a/content/shell/android/shell_manager.cc +++ b/content/shell/android/shell_manager.cc @@ -10,6 +10,7 @@ #include "base/bind.h" #include "base/lazy_instance.h" #include "base/memory/scoped_ptr.h" +#include "base/message_loop.h" #include "content/shell/shell.h" #include "content/shell/shell_browser_context.h" #include "content/shell/shell_content_browser_client.h" @@ -30,10 +31,19 @@ using content::DrawDelegate; namespace { +class CompositorClient : public Compositor::Client { + public: + virtual void ScheduleComposite() OVERRIDE; +}; + struct GlobalState { + GlobalState() + : g_scheduled_composite(false) {} base::android::ScopedJavaGlobalRef<jobject> j_obj; + CompositorClient client; scoped_ptr<content::Compositor> compositor; scoped_ptr<WebKit::WebLayer> root_layer; + bool g_scheduled_composite; }; base::LazyInstance<GlobalState> g_global_state = LAZY_INSTANCE_INITIALIZER; @@ -42,18 +52,18 @@ content::Compositor* GetCompositor() { return g_global_state.Get().compositor.get(); } -static void SurfacePresented( - const DrawDelegate::SurfacePresentedCallback& callback, - uint32 sync_point) { - callback.Run(sync_point); +void Composite() { + g_global_state.Get().g_scheduled_composite = false; + if (GetCompositor()) { + GetCompositor()->Composite(); + } } -static void SurfaceUpdated( - uint64 texture, - content::RenderWidgetHostView* view, - const DrawDelegate::SurfacePresentedCallback& callback) { - GetCompositor()->OnSurfaceUpdated(base::Bind( - &SurfacePresented, callback)); +void CompositorClient::ScheduleComposite() { + if (!g_global_state.Get().g_scheduled_composite) { + g_global_state.Get().g_scheduled_composite = true; + MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&Composite)); + } } } // anonymous namespace @@ -64,7 +74,8 @@ jobject CreateShellView() { JNIEnv* env = base::android::AttachCurrentThread(); if (!GetCompositor()) { Compositor::Initialize(); - g_global_state.Get().compositor.reset(Compositor::Create()); + g_global_state.Get().compositor.reset(Compositor::Create( + &g_global_state.Get().client)); DCHECK(!g_global_state.Get().root_layer.get()); g_global_state.Get().root_layer.reset(WebKit::WebLayer::create()); } @@ -80,9 +91,6 @@ bool RegisterShellManager(JNIEnv* env) { static void Init(JNIEnv* env, jclass clazz, jobject obj) { g_global_state.Get().j_obj.Reset( base::android::ScopedJavaLocalRef<jobject>(env, obj)); - DrawDelegate::SurfaceUpdatedCallback cb = base::Bind( - &SurfaceUpdated); - DrawDelegate::GetInstance()->SetUpdateCallback(cb); } static void SurfaceCreated( |