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 <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
13 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
14 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "cc/layers/layer.h" | 18 #include "cc/layers/layer.h" |
19 #include "content/browser/android/content_view_core_impl.h" | |
20 #include "content/public/browser/android/compositor.h" | 19 #include "content/public/browser/android/compositor.h" |
21 #include "content/public/browser/android/content_view_layer_renderer.h" | 20 #include "content/public/browser/android/content_view_layer_renderer.h" |
| 21 #include "content/public/browser/web_contents.h" |
22 #include "jni/ContentViewRenderView_jni.h" | 22 #include "jni/ContentViewRenderView_jni.h" |
| 23 #include "ui/android/view_android.h" |
23 #include "ui/gfx/android/java_bitmap.h" | 24 #include "ui/gfx/android/java_bitmap.h" |
24 #include "ui/gfx/geometry/size.h" | 25 #include "ui/gfx/geometry/size.h" |
25 | 26 |
26 using base::android::ScopedJavaLocalRef; | 27 using base::android::ScopedJavaLocalRef; |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 | 30 |
30 // static | 31 // static |
31 bool ContentViewRenderView::RegisterContentViewRenderView(JNIEnv* env) { | 32 bool ContentViewRenderView::RegisterContentViewRenderView(JNIEnv* env) { |
32 return RegisterNativesImpl(env); | 33 return RegisterNativesImpl(env); |
(...skipping 18 matching lines...) Expand all Loading... |
51 ContentViewRenderView* content_view_render_view = | 52 ContentViewRenderView* content_view_render_view = |
52 new ContentViewRenderView(env, obj, root_window); | 53 new ContentViewRenderView(env, obj, root_window); |
53 return reinterpret_cast<intptr_t>(content_view_render_view); | 54 return reinterpret_cast<intptr_t>(content_view_render_view); |
54 } | 55 } |
55 | 56 |
56 void ContentViewRenderView::Destroy(JNIEnv* env, | 57 void ContentViewRenderView::Destroy(JNIEnv* env, |
57 const JavaParamRef<jobject>& obj) { | 58 const JavaParamRef<jobject>& obj) { |
58 delete this; | 59 delete this; |
59 } | 60 } |
60 | 61 |
61 void ContentViewRenderView::SetCurrentContentViewCore( | 62 void ContentViewRenderView::SetCurrentWebContents( |
62 JNIEnv* env, | 63 JNIEnv* env, |
63 const JavaParamRef<jobject>& obj, | 64 const JavaParamRef<jobject>& obj, |
64 jlong native_content_view_core) { | 65 const JavaParamRef<jobject>& jweb_contents) { |
65 InitCompositor(); | 66 InitCompositor(); |
66 ContentViewCoreImpl* content_view_core = | 67 WebContents* web_contents = WebContents::FromJavaWebContents(jweb_contents); |
67 reinterpret_cast<ContentViewCoreImpl*>(native_content_view_core); | 68 compositor_->SetRootLayer(web_contents |
68 compositor_->SetRootLayer(content_view_core ? content_view_core->GetLayer() | 69 ? web_contents->GetNativeView()->GetLayer() |
69 : scoped_refptr<cc::Layer>()); | 70 : scoped_refptr<cc::Layer>()); |
70 } | 71 } |
71 | 72 |
72 void ContentViewRenderView::SurfaceCreated(JNIEnv* env, | 73 void ContentViewRenderView::SurfaceCreated(JNIEnv* env, |
73 const JavaParamRef<jobject>& obj) { | 74 const JavaParamRef<jobject>& obj) { |
74 current_surface_format_ = 0; | 75 current_surface_format_ = 0; |
75 InitCompositor(); | 76 InitCompositor(); |
76 } | 77 } |
77 | 78 |
78 void ContentViewRenderView::SurfaceDestroyed(JNIEnv* env, | 79 void ContentViewRenderView::SurfaceDestroyed(JNIEnv* env, |
79 const JavaParamRef<jobject>& obj) { | 80 const JavaParamRef<jobject>& obj) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 JNIEnv* env = base::android::AttachCurrentThread(); | 113 JNIEnv* env = base::android::AttachCurrentThread(); |
113 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); | 114 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); |
114 } | 115 } |
115 | 116 |
116 void ContentViewRenderView::InitCompositor() { | 117 void ContentViewRenderView::InitCompositor() { |
117 if (!compositor_) | 118 if (!compositor_) |
118 compositor_.reset(Compositor::Create(this, root_window_)); | 119 compositor_.reset(Compositor::Create(this, root_window_)); |
119 } | 120 } |
120 | 121 |
121 } // namespace content | 122 } // namespace content |
OLD | NEW |