Chromium Code Reviews

Side by Side Diff: components/view_manager/native_viewport/platform_viewport_android.cc

Issue 1164553004: Revert of Mandoline: Remove native_viewport.mojom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/view_manager/native_viewport/platform_viewport_android.h" 5 #include "components/view_manager/native_viewport/platform_viewport_android.h"
6 6
7 #include <android/input.h> 7 #include <android/input.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
11 #include "components/view_manager/native_viewport/platform_viewport_headless.h"
12 #include "jni/PlatformViewportAndroid_jni.h" 11 #include "jni/PlatformViewportAndroid_jni.h"
13 #include "mojo/converters/geometry/geometry_type_converters.h" 12 #include "mojo/converters/geometry/geometry_type_converters.h"
14 #include "mojo/converters/input_events/input_events_type_converters.h" 13 #include "mojo/converters/input_events/input_events_type_converters.h"
15 #include "ui/events/event.h" 14 #include "ui/events/event.h"
16 #include "ui/events/keycodes/keyboard_code_conversion_android.h" 15 #include "ui/events/keycodes/keyboard_code_conversion_android.h"
17 #include "ui/gfx/geometry/point.h" 16 #include "ui/gfx/geometry/point.h"
18 17
19 namespace native_viewport { 18 namespace native_viewport {
20 namespace { 19 namespace {
21 20
(...skipping 70 matching lines...)
92 DCHECK(window_); 91 DCHECK(window_);
93 delegate_->OnAcceleratedWidgetDestroyed(); 92 delegate_->OnAcceleratedWidgetDestroyed();
94 ReleaseWindow(); 93 ReleaseWindow();
95 } 94 }
96 95
97 void PlatformViewportAndroid::SurfaceSetSize(JNIEnv* env, 96 void PlatformViewportAndroid::SurfaceSetSize(JNIEnv* env,
98 jobject obj, 97 jobject obj,
99 jint width, 98 jint width,
100 jint height, 99 jint height,
101 jfloat density) { 100 jfloat density) {
102 size_ = gfx::Size(static_cast<int>(width), static_cast<int>(height)); 101 metrics_ = mojo::ViewportMetrics::New();
103 delegate_->OnMetricsChanged(size_, density); 102 metrics_->size = mojo::Size::New();
103 metrics_->size->width = static_cast<int>(width);
104 metrics_->size->height = static_cast<int>(height);
105 metrics_->device_pixel_ratio = density;
106 delegate_->OnMetricsChanged(metrics_.Clone());
104 } 107 }
105 108
106 bool PlatformViewportAndroid::TouchEvent(JNIEnv* env, 109 bool PlatformViewportAndroid::TouchEvent(JNIEnv* env,
107 jobject obj, 110 jobject obj,
108 jlong time_ms, 111 jlong time_ms,
109 jint masked_action, 112 jint masked_action,
110 jint pointer_id, 113 jint pointer_id,
111 jfloat x, 114 jfloat x,
112 jfloat y, 115 jfloat y,
113 jfloat pressure, 116 jfloat pressure,
(...skipping 65 matching lines...)
179 } 182 }
180 183
181 void PlatformViewportAndroid::Close() { 184 void PlatformViewportAndroid::Close() {
182 // TODO(beng): close activity containing MojoView? 185 // TODO(beng): close activity containing MojoView?
183 186
184 // TODO(beng): perform this in response to view destruction. 187 // TODO(beng): perform this in response to view destruction.
185 delegate_->OnDestroyed(); 188 delegate_->OnDestroyed();
186 } 189 }
187 190
188 gfx::Size PlatformViewportAndroid::GetSize() { 191 gfx::Size PlatformViewportAndroid::GetSize() {
189 return size_; 192 return metrics_->size.To<gfx::Size>();
190 } 193 }
191 194
192 void PlatformViewportAndroid::SetBounds(const gfx::Rect& bounds) { 195 void PlatformViewportAndroid::SetBounds(const gfx::Rect& bounds) {
193 NOTIMPLEMENTED(); 196 NOTIMPLEMENTED();
194 } 197 }
195 198
196 //////////////////////////////////////////////////////////////////////////////// 199 ////////////////////////////////////////////////////////////////////////////////
197 // PlatformViewportAndroid, private: 200 // PlatformViewportAndroid, private:
198 201
199 void PlatformViewportAndroid::ReleaseWindow() { 202 void PlatformViewportAndroid::ReleaseWindow() {
200 ANativeWindow_release(window_); 203 ANativeWindow_release(window_);
201 window_ = NULL; 204 window_ = NULL;
202 } 205 }
203 206
204 //////////////////////////////////////////////////////////////////////////////// 207 ////////////////////////////////////////////////////////////////////////////////
205 // PlatformViewport, public: 208 // PlatformViewport, public:
206 209
207 // static 210 // static
208 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate, 211 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) {
209 bool headless) {
210 if (headless)
211 return PlatformViewportHeadless::Create(delegate);
212
213 return scoped_ptr<PlatformViewport>( 212 return scoped_ptr<PlatformViewport>(
214 new PlatformViewportAndroid(delegate)).Pass(); 213 new PlatformViewportAndroid(delegate)).Pass();
215 } 214 }
216 215
217 } // namespace native_viewport 216 } // namespace native_viewport
OLDNEW

Powered by Google App Engine