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

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

Issue 2241623002: blimp: Move compositing, input and render widget feature to client/core. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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 "blimp/client/app/android/blimp_client_session_android.h" 9 #include "blimp/client/app/android/blimp_client_session_android.h"
10 #include "blimp/client/core/contents/blimp_contents_impl.h"
11 #include "blimp/client/core/render_widget/blimp_render_widget.h"
10 #include "jni/BlimpView_jni.h" 12 #include "jni/BlimpView_jni.h"
11 #include "ui/events/android/motion_event_android.h" 13 #include "ui/events/android/motion_event_android.h"
12 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/geometry/size.h"
13 15
14 using base::android::JavaParamRef; 16 using base::android::JavaParamRef;
15 17
16 namespace blimp { 18 namespace blimp {
17 namespace client { 19 namespace client {
18 20
19 static jlong Init(JNIEnv* env, 21 static jlong Init(JNIEnv* env,
(...skipping 24 matching lines...) Expand all
44 } 46 }
45 47
46 BlimpView::BlimpView(JNIEnv* env, 48 BlimpView::BlimpView(JNIEnv* env,
47 const JavaParamRef<jobject>& jobj, 49 const JavaParamRef<jobject>& jobj,
48 const gfx::Size& real_size, 50 const gfx::Size& real_size,
49 const gfx::Size& size, 51 const gfx::Size& size,
50 float dp_to_px, 52 float dp_to_px,
51 RenderWidgetFeature* render_widget_feature, 53 RenderWidgetFeature* render_widget_feature,
52 BlimpConnectionStatistics* blimp_connection_statistics) 54 BlimpConnectionStatistics* blimp_connection_statistics)
53 : device_scale_factor_(dp_to_px), 55 : device_scale_factor_(dp_to_px),
54 compositor_manager_( 56 blimp_contents_manager_(true, render_widget_feature),
55 BlimpCompositorManagerAndroid::Create(real_size,
56 size,
57 render_widget_feature,
58 this)),
59 current_surface_format_(0), 57 current_surface_format_(0),
60 window_(gfx::kNullAcceleratedWidget), 58 window_(gfx::kNullAcceleratedWidget),
61 blimp_connection_statistics_(blimp_connection_statistics) { 59 // blimp_connection_statistics_(blimp_connection_statistics),
60 weak_ptr_factory_(this) {
62 java_obj_.Reset(env, jobj); 61 java_obj_.Reset(env, jobj);
62
63 blimp_contents_ = blimp_contents_manager_.CreateBlimpContents();
64
65 blimp_contents_->set_did_complete_swap_buffers_callback(base::Bind(
66 &BlimpView::OnSwapBuffersCompleted, weak_ptr_factory_.GetWeakPtr()));
63 } 67 }
64 68
65 BlimpView::~BlimpView() { 69 BlimpView::~BlimpView() {
66 ReleaseAcceleratedWidget(); 70 ReleaseAcceleratedWidget();
67 } 71 }
68 72
69 void BlimpView::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) { 73 void BlimpView::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
70 delete this; 74 delete this;
71 } 75 }
72 76
73 void BlimpView::SetNeedsComposite(JNIEnv* env, 77 void BlimpView::SetNeedsComposite(JNIEnv* env,
74 const JavaParamRef<jobject>& jobj) {} 78 const JavaParamRef<jobject>& jobj) {}
75 79
76 void BlimpView::OnSurfaceChanged(JNIEnv* env, 80 void BlimpView::OnSurfaceChanged(JNIEnv* env,
77 const JavaParamRef<jobject>& jobj, 81 const JavaParamRef<jobject>& jobj,
78 jint format, 82 jint format,
79 jint width, 83 jint width,
80 jint height, 84 jint height,
81 const JavaParamRef<jobject>& jsurface) { 85 const JavaParamRef<jobject>& jsurface) {
82 if (current_surface_format_ != format) { 86 if (current_surface_format_ != format) {
83 current_surface_format_ = format; 87 current_surface_format_ = format;
84 ReleaseAcceleratedWidget(); 88 ReleaseAcceleratedWidget();
85 89
86 if (jsurface) { 90 if (jsurface) {
87 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); 91 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env);
88 window_ = ANativeWindow_fromSurface(env, jsurface); 92 window_ = ANativeWindow_fromSurface(env, jsurface);
89 compositor_manager_->SetAcceleratedWidget(window_); 93 blimp_contents_->SetAcceleratedWidget(window_);
90 compositor_manager_->SetVisible(true); 94 blimp_contents_->SetVisible(true);
91 } 95 }
92 } 96 }
93 } 97 }
94 98
95 void BlimpView::OnSurfaceCreated(JNIEnv* env, 99 void BlimpView::OnSurfaceCreated(JNIEnv* env,
96 const JavaParamRef<jobject>& jobj) { 100 const JavaParamRef<jobject>& jobj) {
97 current_surface_format_ = 0 /** PixelFormat.UNKNOWN */; 101 current_surface_format_ = 0 /** PixelFormat.UNKNOWN */;
98 } 102 }
99 103
100 void BlimpView::OnSurfaceDestroyed(JNIEnv* env, 104 void BlimpView::OnSurfaceDestroyed(JNIEnv* env,
101 const JavaParamRef<jobject>& jobj) { 105 const JavaParamRef<jobject>& jobj) {
102 current_surface_format_ = 0 /** PixelFormat.UNKNOWN */; 106 current_surface_format_ = 0 /** PixelFormat.UNKNOWN */;
103 ReleaseAcceleratedWidget(); 107 ReleaseAcceleratedWidget();
104 } 108 }
105 109
106 void BlimpView::SetVisibility(JNIEnv* env, 110 void BlimpView::SetVisibility(JNIEnv* env,
107 const JavaParamRef<jobject>& jobj, 111 const JavaParamRef<jobject>& jobj,
108 jboolean visible) { 112 jboolean visible) {
109 compositor_manager_->SetVisible(visible); 113 blimp_contents_->SetVisible(visible);
110 } 114 }
111 115
112 void BlimpView::ReleaseAcceleratedWidget() { 116 void BlimpView::ReleaseAcceleratedWidget() {
113 if (window_ == gfx::kNullAcceleratedWidget) 117 if (window_ == gfx::kNullAcceleratedWidget)
114 return; 118 return;
115 119
116 compositor_manager_->ReleaseAcceleratedWidget(); 120 blimp_contents_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
117 ANativeWindow_release(window_); 121 ANativeWindow_release(window_);
118 window_ = gfx::kNullAcceleratedWidget; 122 window_ = gfx::kNullAcceleratedWidget;
119 } 123 }
120 124
121 jboolean BlimpView::OnTouchEvent(JNIEnv* env, 125 jboolean BlimpView::OnTouchEvent(JNIEnv* env,
122 const JavaParamRef<jobject>& obj, 126 const JavaParamRef<jobject>& obj,
123 const JavaParamRef<jobject>& motion_event, 127 const JavaParamRef<jobject>& motion_event,
124 jlong time_ms, 128 jlong time_ms,
125 jint android_action, 129 jint android_action,
126 jint pointer_count, 130 jint pointer_count,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 pointer_count, 174 pointer_count,
171 history_size, 175 history_size,
172 action_index, 176 action_index,
173 android_button_state, 177 android_button_state,
174 android_meta_state, 178 android_meta_state,
175 raw_pos_x - pos_x_0, 179 raw_pos_x - pos_x_0,
176 raw_pos_y - pos_y_0, 180 raw_pos_y - pos_y_0,
177 pointer0, 181 pointer0,
178 pointer1); 182 pointer1);
179 183
180 return compositor_manager_->OnTouchEvent(event); 184 if (blimp_contents_->GetActiveWidget())
185 return blimp_contents_->GetActiveWidget()->OnTouchEvent(event);
nyquist 2016/08/12 07:34:28 Opposite of //cc, where curly brackets are ... "op
Khushal 2016/08/13 00:03:21 Done. You know I'm in that land most of the time.
186
187 return false;
181 } 188 }
182 189
183 void BlimpView::OnSwapBuffersCompleted() { 190 void BlimpView::OnSwapBuffersCompleted() {
184 JNIEnv* env = base::android::AttachCurrentThread(); 191 JNIEnv* env = base::android::AttachCurrentThread();
185 Java_BlimpView_onSwapBuffersCompleted(env, java_obj_.obj()); 192 Java_BlimpView_onSwapBuffersCompleted(env, java_obj_.obj());
186 } 193 }
187 194
188 void BlimpView::DidCommitAndDrawFrame() {
189 DCHECK(blimp_connection_statistics_);
190 blimp_connection_statistics_->Add(BlimpConnectionStatistics::COMMIT, 1);
191 }
192
193 } // namespace client 195 } // namespace client
194 } // namespace blimp 196 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698