Index: content/shell/android/shell_manager.cc |
diff --git a/content/shell/android/shell_manager.cc b/content/shell/android/shell_manager.cc |
index a7b6b263b25615e9c5307cded799bfe974496c03..9b8c19d0eafc7f086b7f26dd7b9477a02ac06623 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,8 +31,14 @@ using content::DrawDelegate; |
namespace { |
+class CompositorClient : public Compositor::Client { |
+ public: |
+ virtual void ScheduleComposite() OVERRIDE; |
+}; |
+ |
struct GlobalState { |
base::android::ScopedJavaGlobalRef<jobject> j_obj; |
+ CompositorClient client; |
scoped_ptr<content::Compositor> compositor; |
scoped_ptr<WebKit::WebLayer> root_layer; |
}; |
@@ -42,18 +49,19 @@ content::Compositor* GetCompositor() { |
return g_global_state.Get().compositor.get(); |
} |
-static void SurfacePresented( |
- const DrawDelegate::SurfacePresentedCallback& callback, |
- uint32 sync_point) { |
- callback.Run(sync_point); |
+bool g_scheduled_composite = false; |
piman
2012/10/13 18:04:21
nit: should this be in the global state?
|
+void Composite() { |
+ 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_scheduled_composite) { |
+ g_scheduled_composite = true; |
+ MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&Composite)); |
+ } |
} |
} // anonymous namespace |
@@ -64,7 +72,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 +89,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( |