| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/android/content_view_render_view.h" | 5 #include "content/browser/android/content_view_render_view.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "cc/layers/layer.h" | 14 #include "cc/layers/layer.h" |
| 15 #include "content/browser/android/content_view_core_impl.h" | 15 #include "content/browser/android/content_view_core_impl.h" |
| 16 #include "content/public/browser/android/compositor.h" | 16 #include "content/public/browser/android/compositor.h" |
| 17 #include "content/public/browser/android/content_view_layer_renderer.h" | 17 #include "content/public/browser/android/content_view_layer_renderer.h" |
| 18 #include "jni/ContentViewRenderView_jni.h" | 18 #include "jni/ContentViewRenderView_jni.h" |
| 19 #include "ui/base/android/window_android.h" |
| 19 #include "ui/gfx/android/java_bitmap.h" | 20 #include "ui/gfx/android/java_bitmap.h" |
| 20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 21 | 22 |
| 22 #include <android/bitmap.h> | 23 #include <android/bitmap.h> |
| 23 #include <android/native_window_jni.h> | 24 #include <android/native_window_jni.h> |
| 24 | 25 |
| 25 using base::android::ScopedJavaLocalRef; | 26 using base::android::ScopedJavaLocalRef; |
| 26 | 27 |
| 27 namespace content { | 28 namespace content { |
| 28 | 29 |
| 29 // static | 30 // static |
| 30 bool ContentViewRenderView::RegisterContentViewRenderView(JNIEnv* env) { | 31 bool ContentViewRenderView::RegisterContentViewRenderView(JNIEnv* env) { |
| 31 return RegisterNativesImpl(env); | 32 return RegisterNativesImpl(env); |
| 32 } | 33 } |
| 33 | 34 |
| 34 ContentViewRenderView::ContentViewRenderView(JNIEnv* env, jobject obj) | 35 ContentViewRenderView::ContentViewRenderView(JNIEnv* env, |
| 35 : buffers_swapped_during_composite_(false) { | 36 jobject obj, |
| 37 ui::WindowAndroid* window_android) |
| 38 : buffers_swapped_during_composite_(false), |
| 39 window_android_(window_android) { |
| 36 java_obj_.Reset(env, obj); | 40 java_obj_.Reset(env, obj); |
| 37 } | 41 } |
| 38 | 42 |
| 39 ContentViewRenderView::~ContentViewRenderView() { | 43 ContentViewRenderView::~ContentViewRenderView() { |
| 40 } | 44 } |
| 41 | 45 |
| 42 // static | 46 // static |
| 43 static jint Init(JNIEnv* env, jobject obj) { | 47 static jint Init(JNIEnv* env, jobject obj, jlong native_window_android) { |
| 48 ui::WindowAndroid* window_android = |
| 49 reinterpret_cast<ui::WindowAndroid*>(native_window_android); |
| 44 ContentViewRenderView* content_view_render_view = | 50 ContentViewRenderView* content_view_render_view = |
| 45 new ContentViewRenderView(env, obj); | 51 new ContentViewRenderView(env, obj, window_android); |
| 46 return reinterpret_cast<jint>(content_view_render_view); | 52 return reinterpret_cast<jint>(content_view_render_view); |
| 47 } | 53 } |
| 48 | 54 |
| 49 void ContentViewRenderView::Destroy(JNIEnv* env, jobject obj) { | 55 void ContentViewRenderView::Destroy(JNIEnv* env, jobject obj) { |
| 50 delete this; | 56 delete this; |
| 51 } | 57 } |
| 52 | 58 |
| 53 void ContentViewRenderView::SetCurrentContentView( | 59 void ContentViewRenderView::SetCurrentContentView( |
| 54 JNIEnv* env, jobject obj, int native_content_view) { | 60 JNIEnv* env, jobject obj, int native_content_view) { |
| 55 InitCompositor(); | 61 InitCompositor(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 buffers_swapped_during_composite_ = true; | 109 buffers_swapped_during_composite_ = true; |
| 104 } | 110 } |
| 105 | 111 |
| 106 void ContentViewRenderView::OnSwapBuffersCompleted() { | 112 void ContentViewRenderView::OnSwapBuffersCompleted() { |
| 107 JNIEnv* env = base::android::AttachCurrentThread(); | 113 JNIEnv* env = base::android::AttachCurrentThread(); |
| 108 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); | 114 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); |
| 109 } | 115 } |
| 110 | 116 |
| 111 void ContentViewRenderView::InitCompositor() { | 117 void ContentViewRenderView::InitCompositor() { |
| 112 if (!compositor_) | 118 if (!compositor_) |
| 113 compositor_.reset(Compositor::Create(this)); | 119 compositor_.reset(Compositor::Create(this, window_android_)); |
| 114 } | 120 } |
| 115 | 121 |
| 116 } // namespace content | 122 } // namespace content |
| OLD | NEW |