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

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

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

Powered by Google App Engine
This is Rietveld 408576698