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

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

Issue 10823051: ContentShell rendering support on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix intents Created 8 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: content/shell/android/shell_manager.cc
diff --git a/content/shell/android/shell_manager.cc b/content/shell/android/shell_manager.cc
index 5972409ed639f2463ced406399487a43f0d99606..d7cf703edf61f3cec40f830ed317183acc3d66a7 100644
--- a/content/shell/android/shell_manager.cc
+++ b/content/shell/android/shell_manager.cc
@@ -7,24 +7,54 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
+#include "base/bind.h"
#include "base/lazy_instance.h"
#include "content/shell/shell.h"
#include "content/shell/shell_browser_context.h"
#include "content/shell/shell_content_browser_client.h"
#include "googleurl/src/gurl.h"
#include "jni/ShellManager_jni.h"
+#include "content/public/browser/android/draw_delegate.h"
+#include "content/public/browser/render_widget_host_view.h"
+#include "content/public/browser/web_contents.h"
+#include "content/shell/android/draw_context.h"
+#include "content/shell/shell.h"
+#include "ui/gfx/size.h"
+
+#include <android/native_window_jni.h>
using base::android::ScopedJavaLocalRef;
+using content::DrawContext;
+using content::DrawDelegate;
+
+namespace {
+
+struct GlobalState {
+ GlobalState()
+ : context(NULL) {
+ }
+ base::android::ScopedJavaGlobalRef<jobject> j_obj;
+ DrawContext* context;
+};
+
+base::LazyInstance<GlobalState> g_global_state = LAZY_INSTANCE_INITIALIZER;
+
+static void SurfaceUpdated(
+ uint64 texture,
+ content::RenderWidgetHostView* view,
+ const DrawDelegate::SurfacePresentedCallback& callback) {
+ uint32 sync_point = g_global_state.Get().context->Draw(texture);
+ callback.Run(sync_point);
+}
-base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> >
- g_content_shell_manager = LAZY_INSTANCE_INITIALIZER;
+} // anonymous namespace
namespace content {
jobject CreateShellView() {
JNIEnv* env = base::android::AttachCurrentThread();
return Java_ShellManager_createShell(
- env, g_content_shell_manager.Get().obj()).Release();
+ env, g_global_state.Get().j_obj.obj()).Release();
}
// Register native methods
@@ -33,8 +63,37 @@ bool RegisterShellManager(JNIEnv* env) {
}
static void Init(JNIEnv* env, jclass clazz, jobject obj) {
- g_content_shell_manager.Get().Reset(
+ 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(
+ JNIEnv* env, jclass clazz, jobject jsurface) {
+ ANativeWindow* native_window = ANativeWindow_fromSurface(env, jsurface);
+ if (native_window) {
+ if (g_global_state.Get().context)
+ delete g_global_state.Get().context;
+
+ g_global_state.Get().context = new DrawContext(native_window);
+ ANativeWindow_release(native_window);
+ }
+}
+
+static void SurfaceDestroyed(JNIEnv* env, jclass clazz) {
+ if (g_global_state.Get().context)
+ delete g_global_state.Get().context;
+ NOTIMPLEMENTED();
Ted C 2012/07/31 20:58:05 this seems like a bit of a fib...maybe make this a
no sievers 2012/07/31 21:17:17 I'll remove the NOTIMPLEMENTED() here. The problem
+}
+
+static void SurfaceSetSize(
+ JNIEnv* env, jclass clazz, jint width, jint height) {
+ gfx::Size size = gfx::Size(width, height);
+ DrawDelegate::GetInstance()->SetBounds(size);
+ DCHECK(g_global_state.Get().context);
+ g_global_state.Get().context->Reshape(width, height);
}
void LaunchShell(JNIEnv* env, jclass clazz, jstring jurl) {

Powered by Google App Engine
This is Rietveld 408576698