Chromium Code Reviews| 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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 | 46 |
| 47 void ContentViewRenderView::Destroy(JNIEnv* env, jobject obj) { | 47 void ContentViewRenderView::Destroy(JNIEnv* env, jobject obj) { |
| 48 delete this; | 48 delete this; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void ContentViewRenderView::SetCurrentContentView( | 51 void ContentViewRenderView::SetCurrentContentView( |
| 52 JNIEnv* env, jobject obj, int native_content_view) { | 52 JNIEnv* env, jobject obj, int native_content_view) { |
| 53 InitCompositor(); | 53 InitCompositor(); |
| 54 ContentViewCoreImpl* content_view = | 54 ContentViewCoreImpl* content_view = |
| 55 reinterpret_cast<ContentViewCoreImpl*>(native_content_view); | 55 reinterpret_cast<ContentViewCoreImpl*>(native_content_view); |
| 56 if (content_view) | 56 if (content_view) { |
| 57 compositor_->SetRootLayer(content_view->GetLayer()); | 57 compositor_->SetRootLayer(content_view->GetLayer()); |
| 58 else | 58 RenderWidgetHostViewAndroid* rwhva = |
| 59 content_view->GetRenderWidgetHostViewAndroid(); | |
| 60 if (rwhva) { | |
|
no sievers
2013/10/10 17:48:03
This is the sort of logic I was afraid of :)
And
powei
2013/10/16 22:42:35
Done. Good point. Please take a look at the new
| |
| 61 compositor_->AddObserver(rwhva); | |
| 62 } | |
| 63 } else | |
| 59 compositor_->SetRootLayer(cc::Layer::Create()); | 64 compositor_->SetRootLayer(cc::Layer::Create()); |
| 60 } | 65 } |
| 61 | 66 |
| 67 void ContentViewRenderView::RemovePreviousContentView(JNIEnv* env, | |
| 68 jobject obj, | |
| 69 int native_content_view) { | |
| 70 DCHECK(compositor_); | |
| 71 ContentViewCoreImpl* content_view = | |
| 72 reinterpret_cast<ContentViewCoreImpl*>(native_content_view); | |
| 73 if (content_view) { | |
| 74 RenderWidgetHostViewAndroid* rwhva = | |
| 75 content_view->GetRenderWidgetHostViewAndroid(); | |
| 76 if (rwhva) { | |
| 77 compositor_->RemoveObserver(rwhva); | |
| 78 } | |
| 79 } | |
| 80 } | |
| 81 | |
| 62 void ContentViewRenderView::SurfaceCreated( | 82 void ContentViewRenderView::SurfaceCreated( |
| 63 JNIEnv* env, jobject obj, jobject jsurface) { | 83 JNIEnv* env, jobject obj, jobject jsurface) { |
| 64 InitCompositor(); | 84 InitCompositor(); |
| 65 compositor_->SetSurface(jsurface); | 85 compositor_->SetSurface(jsurface); |
| 66 } | 86 } |
| 67 | 87 |
| 68 void ContentViewRenderView::SurfaceDestroyed(JNIEnv* env, jobject obj) { | 88 void ContentViewRenderView::SurfaceDestroyed(JNIEnv* env, jobject obj) { |
| 69 compositor_->SetSurface(NULL); | 89 compositor_->SetSurface(NULL); |
| 70 } | 90 } |
| 71 | 91 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 96 JNIEnv* env = base::android::AttachCurrentThread(); | 116 JNIEnv* env = base::android::AttachCurrentThread(); |
| 97 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); | 117 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); |
| 98 } | 118 } |
| 99 | 119 |
| 100 void ContentViewRenderView::InitCompositor() { | 120 void ContentViewRenderView::InitCompositor() { |
| 101 if (!compositor_) | 121 if (!compositor_) |
| 102 compositor_.reset(Compositor::Create(this)); | 122 compositor_.reset(Compositor::Create(this)); |
| 103 } | 123 } |
| 104 | 124 |
| 105 } // namespace content | 125 } // namespace content |
| OLD | NEW |