| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/client/app/android/blimp_view.h" | 5 #include "blimp/client/app/android/blimp_view.h" |
| 6 | 6 |
| 7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "blimp/client/app/android/blimp_client_session_android.h" | 10 #include "blimp/client/app/android/blimp_client_session_android.h" |
| 11 #include "blimp/client/app/compositor/browser_compositor.h" | 11 #include "blimp/client/app/compositor/browser_compositor.h" |
| 12 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" | 12 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" |
| 13 #include "blimp/client/core/compositor/blimp_compositor_manager.h" | 13 #include "blimp/client/core/compositor/blimp_compositor_manager.h" |
| 14 #include "blimp/client/core/render_widget/render_widget_feature.h" | 14 #include "blimp/client/core/render_widget/render_widget_feature.h" |
| 15 #include "blimp/client/support/compositor/compositor_dependencies_impl.h" | 15 #include "blimp/client/support/compositor/compositor_dependencies_impl.h" |
| 16 #include "jni/BlimpView_jni.h" | 16 #include "jni/BlimpView_jni.h" |
| 17 #include "ui/events/android/motion_event_android.h" | 17 #include "ui/events/android/motion_event_android.h" |
| 18 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
| 19 | 19 |
| 20 using base::android::JavaParamRef; | 20 using base::android::JavaParamRef; |
| 21 | 21 |
| 22 namespace { |
| 23 const int kDummyBlimpContentsId = 0; |
| 24 } // namespace |
| 25 |
| 22 namespace blimp { | 26 namespace blimp { |
| 23 namespace client { | 27 namespace client { |
| 24 namespace app { | 28 namespace app { |
| 25 | 29 |
| 26 static jlong Init(JNIEnv* env, | 30 static jlong Init(JNIEnv* env, |
| 27 const JavaParamRef<jobject>& jobj, | 31 const JavaParamRef<jobject>& jobj, |
| 28 const JavaParamRef<jobject>& blimp_client_session, | 32 const JavaParamRef<jobject>& blimp_client_session, |
| 29 jint real_width, | 33 jint real_width, |
| 30 jint real_height, | 34 jint real_height, |
| 31 jint width, | 35 jint width, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 61 weak_ptr_factory_(this) { | 65 weak_ptr_factory_(this) { |
| 62 compositor_dependencies_ = base::MakeUnique<BlimpCompositorDependencies>( | 66 compositor_dependencies_ = base::MakeUnique<BlimpCompositorDependencies>( |
| 63 base::MakeUnique<CompositorDependenciesImpl>()); | 67 base::MakeUnique<CompositorDependenciesImpl>()); |
| 64 | 68 |
| 65 compositor_ = base::MakeUnique<BrowserCompositor>( | 69 compositor_ = base::MakeUnique<BrowserCompositor>( |
| 66 compositor_dependencies_->GetEmbedderDependencies()); | 70 compositor_dependencies_->GetEmbedderDependencies()); |
| 67 compositor_->set_did_complete_swap_buffers_callback(base::Bind( | 71 compositor_->set_did_complete_swap_buffers_callback(base::Bind( |
| 68 &BlimpView::OnSwapBuffersCompleted, weak_ptr_factory_.GetWeakPtr())); | 72 &BlimpView::OnSwapBuffersCompleted, weak_ptr_factory_.GetWeakPtr())); |
| 69 | 73 |
| 70 compositor_manager_ = base::MakeUnique<BlimpCompositorManager>( | 74 compositor_manager_ = base::MakeUnique<BlimpCompositorManager>( |
| 71 render_widget_feature, compositor_dependencies_.get()); | 75 kDummyBlimpContentsId, render_widget_feature, |
| 76 compositor_dependencies_.get()); |
| 72 compositor_->SetContentLayer(compositor_manager_->layer()); | 77 compositor_->SetContentLayer(compositor_manager_->layer()); |
| 73 | 78 |
| 74 java_obj_.Reset(env, jobj); | 79 java_obj_.Reset(env, jobj); |
| 75 } | 80 } |
| 76 | 81 |
| 77 BlimpView::~BlimpView() { | 82 BlimpView::~BlimpView() { |
| 78 SetSurface(nullptr); | 83 SetSurface(nullptr); |
| 79 | 84 |
| 80 // Destroy the BrowserCompositor and the BlimpCompositorManager before the | 85 // Destroy the BrowserCompositor and the BlimpCompositorManager before the |
| 81 // BlimpCompositorDependencies. | 86 // BlimpCompositorDependencies. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 210 } |
| 206 | 211 |
| 207 void BlimpView::OnSwapBuffersCompleted() { | 212 void BlimpView::OnSwapBuffersCompleted() { |
| 208 JNIEnv* env = base::android::AttachCurrentThread(); | 213 JNIEnv* env = base::android::AttachCurrentThread(); |
| 209 Java_BlimpView_onSwapBuffersCompleted(env, java_obj_); | 214 Java_BlimpView_onSwapBuffersCompleted(env, java_obj_); |
| 210 } | 215 } |
| 211 | 216 |
| 212 } // namespace app | 217 } // namespace app |
| 213 } // namespace client | 218 } // namespace client |
| 214 } // namespace blimp | 219 } // namespace blimp |
| OLD | NEW |