Chromium Code Reviews| 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 "blimp/client/app/android/blimp_client_session_android.h" | 10 #include "blimp/client/app/android/blimp_client_session_android.h" |
| 10 #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_impl.h" | |
| 13 #include "blimp/client/feature/compositor/blimp_compositor_manager.h" | |
| 14 #include "blimp/client/support/compositor/android/compositor_dependencies_impl_a ndroid.h" | |
| 11 #include "jni/BlimpView_jni.h" | 15 #include "jni/BlimpView_jni.h" |
| 12 #include "ui/events/android/motion_event_android.h" | 16 #include "ui/events/android/motion_event_android.h" |
| 13 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 14 | 18 |
| 15 using base::android::JavaParamRef; | 19 using base::android::JavaParamRef; |
| 16 | 20 |
| 17 namespace blimp { | 21 namespace blimp { |
| 18 namespace client { | 22 namespace client { |
| 19 | 23 |
| 20 static jlong Init(JNIEnv* env, | 24 static jlong Init(JNIEnv* env, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 43 return RegisterNativesImpl(env); | 47 return RegisterNativesImpl(env); |
| 44 } | 48 } |
| 45 | 49 |
| 46 BlimpView::BlimpView(JNIEnv* env, | 50 BlimpView::BlimpView(JNIEnv* env, |
| 47 const JavaParamRef<jobject>& jobj, | 51 const JavaParamRef<jobject>& jobj, |
| 48 const gfx::Size& real_size, | 52 const gfx::Size& real_size, |
| 49 const gfx::Size& size, | 53 const gfx::Size& size, |
| 50 float dp_to_px, | 54 float dp_to_px, |
| 51 RenderWidgetFeature* render_widget_feature) | 55 RenderWidgetFeature* render_widget_feature) |
| 52 : device_scale_factor_(dp_to_px), | 56 : device_scale_factor_(dp_to_px), |
| 53 compositor_(base::MakeUnique<BrowserCompositor>()), | |
| 54 current_surface_format_(0), | 57 current_surface_format_(0), |
| 55 window_(gfx::kNullAcceleratedWidget), | 58 window_(gfx::kNullAcceleratedWidget), |
| 56 weak_ptr_factory_(this) { | 59 weak_ptr_factory_(this) { |
| 57 compositor_manager_ = BlimpCompositorManagerAndroid::Create( | 60 compositor_dependencies_ = |
| 58 real_size, size, render_widget_feature, | 61 base::WrapUnique(new BlimpCompositorDependenciesImpl(base::WrapUnique( |
|
Khushal
2016/08/24 23:22:45
nit: MakeUnique!
David Trainor- moved to gerrit
2016/08/26 17:15:53
Done.
| |
| 59 BrowserCompositor::GetSurfaceManager(), | 62 new CompositorDependenciesImplAndroid(real_size, size)))); |
| 60 BrowserCompositor::GetGpuMemoryBufferManager(), | 63 |
| 61 base::Bind(&BrowserCompositor::AllocateSurfaceClientId)); | 64 compositor_ = base::MakeUnique<BrowserCompositor>( |
| 65 compositor_dependencies_->GetEmbedderDependencies()); | |
| 62 compositor_->set_did_complete_swap_buffers_callback(base::Bind( | 66 compositor_->set_did_complete_swap_buffers_callback(base::Bind( |
| 63 &BlimpView::OnSwapBuffersCompleted, weak_ptr_factory_.GetWeakPtr())); | 67 &BlimpView::OnSwapBuffersCompleted, weak_ptr_factory_.GetWeakPtr())); |
| 68 | |
| 69 compositor_manager_ = base::MakeUnique<BlimpCompositorManager>( | |
| 70 render_widget_feature, compositor_dependencies_.get()); | |
| 64 compositor_->SetContentLayer(compositor_manager_->layer()); | 71 compositor_->SetContentLayer(compositor_manager_->layer()); |
| 72 | |
| 65 java_obj_.Reset(env, jobj); | 73 java_obj_.Reset(env, jobj); |
| 66 } | 74 } |
| 67 | 75 |
| 68 BlimpView::~BlimpView() { | 76 BlimpView::~BlimpView() { |
| 69 SetSurface(nullptr); | 77 SetSurface(nullptr); |
| 78 | |
| 79 // Destroy the BrowserCompositor and the BlimpCompositorManager before the | |
| 80 // BlimpCompositorDependencies. | |
| 81 compositor_.reset(); | |
| 82 compositor_manager_.reset(); | |
| 83 compositor_dependencies_.reset(); | |
| 70 } | 84 } |
| 71 | 85 |
| 72 void BlimpView::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) { | 86 void BlimpView::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) { |
| 73 delete this; | 87 delete this; |
| 74 } | 88 } |
| 75 | 89 |
| 76 void BlimpView::OnContentAreaSizeChanged( | 90 void BlimpView::OnContentAreaSizeChanged( |
| 77 JNIEnv* env, | 91 JNIEnv* env, |
| 78 const base::android::JavaParamRef<jobject>& jobj, | 92 const base::android::JavaParamRef<jobject>& jobj, |
| 79 jint width, | 93 jint width, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 return compositor_manager_->OnTouchEvent(event); | 203 return compositor_manager_->OnTouchEvent(event); |
| 190 } | 204 } |
| 191 | 205 |
| 192 void BlimpView::OnSwapBuffersCompleted() { | 206 void BlimpView::OnSwapBuffersCompleted() { |
| 193 JNIEnv* env = base::android::AttachCurrentThread(); | 207 JNIEnv* env = base::android::AttachCurrentThread(); |
| 194 Java_BlimpView_onSwapBuffersCompleted(env, java_obj_); | 208 Java_BlimpView_onSwapBuffersCompleted(env, java_obj_); |
| 195 } | 209 } |
| 196 | 210 |
| 197 } // namespace client | 211 } // namespace client |
| 198 } // namespace blimp | 212 } // namespace blimp |
| OLD | NEW |