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

Unified Diff: content/shell/android/shell_manager.cc

Issue 11108004: Android Browser Compositor: Add ScheduleComposite() callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address piman's comments Created 8 years, 2 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: 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(
« chrome/android/testshell/tab_manager.cc ('K') | « content/public/browser/android/draw_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698