| Index: sky/shell/platform_view.cc
|
| diff --git a/sky/shell/sky_view.cc b/sky/shell/platform_view.cc
|
| similarity index 63%
|
| rename from sky/shell/sky_view.cc
|
| rename to sky/shell/platform_view.cc
|
| index d7b22112192344c5b5ccc79c5091b42069f49313..e31498dcb39722b110723b8b354f9f0329b0960b 100644
|
| --- a/sky/shell/sky_view.cc
|
| +++ b/sky/shell/platform_view.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "sky/shell/sky_view.h"
|
| +#include "sky/shell/platform_view.h"
|
|
|
| #include <android/input.h>
|
| #include <android/native_window_jni.h>
|
| @@ -10,31 +10,35 @@
|
| #include "base/android/jni_android.h"
|
| #include "base/bind.h"
|
| #include "base/location.h"
|
| -#include "jni/SkyView_jni.h"
|
| +#include "jni/PlatformView_jni.h"
|
| +#include "sky/shell/shell.h"
|
|
|
| namespace sky {
|
| namespace shell {
|
|
|
| +static jlong Attach(JNIEnv* env, jclass clazz) {
|
| + return reinterpret_cast<jlong>(Shell::Shared().view());
|
| +}
|
| +
|
| // static
|
| -bool SkyView::Register(JNIEnv* env) {
|
| +bool PlatformView::Register(JNIEnv* env) {
|
| return RegisterNativesImpl(env);
|
| }
|
|
|
| -SkyView::SkyView(const Config& config) : config_(config), window_(nullptr) {
|
| - JNIEnv* env = base::android::AttachCurrentThread();
|
| - Java_SkyView_createForActivity(env, base::android::GetApplicationContext(),
|
| - reinterpret_cast<jlong>(this));
|
| +PlatformView::PlatformView(const Config& config)
|
| + : config_(config), window_(nullptr) {
|
| }
|
|
|
| -SkyView::~SkyView() {
|
| +PlatformView::~PlatformView() {
|
| if (window_)
|
| ReleaseWindow();
|
| }
|
|
|
| -void SkyView::Destroy(JNIEnv* env, jobject obj) {
|
| +void PlatformView::Detach(JNIEnv* env, jobject obj) {
|
| + DCHECK(!window_);
|
| }
|
|
|
| -void SkyView::SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface) {
|
| +void PlatformView::SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface) {
|
| base::android::ScopedJavaLocalRef<jobject> protector(env, jsurface);
|
| // Note: This ensures that any local references used by
|
| // ANativeWindow_fromSurface are released immediately. This is needed as a
|
| @@ -48,7 +52,7 @@ void SkyView::SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface) {
|
| config_.gpu_delegate, window_));
|
| }
|
|
|
| -void SkyView::SurfaceDestroyed(JNIEnv* env, jobject obj) {
|
| +void PlatformView::SurfaceDestroyed(JNIEnv* env, jobject obj) {
|
| DCHECK(window_);
|
| config_.gpu_task_runner->PostTask(
|
| FROM_HERE,
|
| @@ -56,18 +60,18 @@ void SkyView::SurfaceDestroyed(JNIEnv* env, jobject obj) {
|
| ReleaseWindow();
|
| }
|
|
|
| -void SkyView::SurfaceSetSize(JNIEnv* env,
|
| - jobject obj,
|
| - jint width,
|
| - jint height,
|
| - jfloat density) {
|
| +void PlatformView::SurfaceSetSize(JNIEnv* env,
|
| + jobject obj,
|
| + jint width,
|
| + jint height,
|
| + jfloat density) {
|
| config_.ui_task_runner->PostTask(
|
| FROM_HERE,
|
| base::Bind(&UIDelegate::OnViewportMetricsChanged, config_.ui_delegate,
|
| gfx::Size(width, height), density));
|
| }
|
|
|
| -void SkyView::ReleaseWindow() {
|
| +void PlatformView::ReleaseWindow() {
|
| ANativeWindow_release(window_);
|
| window_ = nullptr;
|
| }
|
|
|