Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: blimp/client/app/android/blimp_view.cc

Issue 2274323002: Expose Blimp dependencies to the embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@khushal_baseline_1
Patch Set: Fix linux build break Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « blimp/client/app/android/blimp_view.h ('k') | blimp/client/app/compositor/browser_compositor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h"
13 #include "blimp/client/feature/compositor/blimp_compositor_manager.h"
14 #include "blimp/client/support/compositor/compositor_dependencies_impl.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
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_ = base::MakeUnique<BlimpCompositorDependencies>(
58 real_size, size, render_widget_feature, 61 base::MakeUnique<CompositorDependenciesImpl>());
59 BrowserCompositor::GetSurfaceManager(), 62
60 BrowserCompositor::GetGpuMemoryBufferManager(), 63 compositor_ = base::MakeUnique<BrowserCompositor>(
61 base::Bind(&BrowserCompositor::AllocateSurfaceClientId)); 64 compositor_dependencies_->GetEmbedderDependencies());
62 compositor_->set_did_complete_swap_buffers_callback(base::Bind( 65 compositor_->set_did_complete_swap_buffers_callback(base::Bind(
63 &BlimpView::OnSwapBuffersCompleted, weak_ptr_factory_.GetWeakPtr())); 66 &BlimpView::OnSwapBuffersCompleted, weak_ptr_factory_.GetWeakPtr()));
67
68 compositor_manager_ = base::MakeUnique<BlimpCompositorManager>(
69 render_widget_feature, compositor_dependencies_.get());
64 compositor_->SetContentLayer(compositor_manager_->layer()); 70 compositor_->SetContentLayer(compositor_manager_->layer());
71
65 java_obj_.Reset(env, jobj); 72 java_obj_.Reset(env, jobj);
66 } 73 }
67 74
68 BlimpView::~BlimpView() { 75 BlimpView::~BlimpView() {
69 SetSurface(nullptr); 76 SetSurface(nullptr);
77
78 // Destroy the BrowserCompositor and the BlimpCompositorManager before the
79 // BlimpCompositorDependencies.
80 compositor_.reset();
81 compositor_manager_.reset();
82 compositor_dependencies_.reset();
70 } 83 }
71 84
72 void BlimpView::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) { 85 void BlimpView::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
73 delete this; 86 delete this;
74 } 87 }
75 88
76 void BlimpView::OnContentAreaSizeChanged( 89 void BlimpView::OnContentAreaSizeChanged(
77 JNIEnv* env, 90 JNIEnv* env,
78 const base::android::JavaParamRef<jobject>& jobj, 91 const base::android::JavaParamRef<jobject>& jobj,
79 jint width, 92 jint width,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return compositor_manager_->OnTouchEvent(event); 202 return compositor_manager_->OnTouchEvent(event);
190 } 203 }
191 204
192 void BlimpView::OnSwapBuffersCompleted() { 205 void BlimpView::OnSwapBuffersCompleted() {
193 JNIEnv* env = base::android::AttachCurrentThread(); 206 JNIEnv* env = base::android::AttachCurrentThread();
194 Java_BlimpView_onSwapBuffersCompleted(env, java_obj_); 207 Java_BlimpView_onSwapBuffersCompleted(env, java_obj_);
195 } 208 }
196 209
197 } // namespace client 210 } // namespace client
198 } // namespace blimp 211 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/app/android/blimp_view.h ('k') | blimp/client/app/compositor/browser_compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698