| OLD | NEW |
| 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/native_viewport/platform_viewport_android.h" | 5 #include "components/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" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 env, java_platform_viewport_android_.get(env).obj()); | 67 env, java_platform_viewport_android_.get(env).obj()); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void PlatformViewportAndroid::Destroy(JNIEnv* env, jobject obj) { | 71 void PlatformViewportAndroid::Destroy(JNIEnv* env, jobject obj) { |
| 72 delegate_->OnDestroyed(); | 72 delegate_->OnDestroyed(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void PlatformViewportAndroid::SurfaceCreated(JNIEnv* env, | 75 void PlatformViewportAndroid::SurfaceCreated(JNIEnv* env, |
| 76 jobject obj, | 76 jobject obj, |
| 77 jobject jsurface) { | 77 jobject jsurface, |
| 78 float device_pixel_ratio) { |
| 78 base::android::ScopedJavaLocalRef<jobject> protector(env, jsurface); | 79 base::android::ScopedJavaLocalRef<jobject> protector(env, jsurface); |
| 79 // Note: This ensures that any local references used by | 80 // Note: This ensures that any local references used by |
| 80 // ANativeWindow_fromSurface are released immediately. This is needed as a | 81 // ANativeWindow_fromSurface are released immediately. This is needed as a |
| 81 // workaround for https://code.google.com/p/android/issues/detail?id=68174 | 82 // workaround for https://code.google.com/p/android/issues/detail?id=68174 |
| 82 { | 83 { |
| 83 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); | 84 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); |
| 84 window_ = ANativeWindow_fromSurface(env, jsurface); | 85 window_ = ANativeWindow_fromSurface(env, jsurface); |
| 85 } | 86 } |
| 86 delegate_->OnAcceleratedWidgetAvailable(window_); | 87 delegate_->OnAcceleratedWidgetAvailable(window_, device_pixel_ratio); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void PlatformViewportAndroid::SurfaceDestroyed(JNIEnv* env, jobject obj) { | 90 void PlatformViewportAndroid::SurfaceDestroyed(JNIEnv* env, jobject obj) { |
| 90 DCHECK(window_); | 91 DCHECK(window_); |
| 91 delegate_->OnAcceleratedWidgetDestroyed(); | 92 delegate_->OnAcceleratedWidgetDestroyed(); |
| 92 ReleaseWindow(); | 93 ReleaseWindow(); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void PlatformViewportAndroid::SurfaceSetSize(JNIEnv* env, | 96 void PlatformViewportAndroid::SurfaceSetSize(JNIEnv* env, |
| 96 jobject obj, | 97 jobject obj, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 //////////////////////////////////////////////////////////////////////////////// | 207 //////////////////////////////////////////////////////////////////////////////// |
| 207 // PlatformViewport, public: | 208 // PlatformViewport, public: |
| 208 | 209 |
| 209 // static | 210 // static |
| 210 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { | 211 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { |
| 211 return scoped_ptr<PlatformViewport>( | 212 return scoped_ptr<PlatformViewport>( |
| 212 new PlatformViewportAndroid(delegate)).Pass(); | 213 new PlatformViewportAndroid(delegate)).Pass(); |
| 213 } | 214 } |
| 214 | 215 |
| 215 } // namespace native_viewport | 216 } // namespace native_viewport |
| OLD | NEW |