Chromium Code Reviews| Index: blimp/client/android/blimp_view.cc |
| diff --git a/blimp/client/android/blimp_view.cc b/blimp/client/android/blimp_view.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..071cd9de0179fa30483aebe5f7e395d6934d5380 |
| --- /dev/null |
| +++ b/blimp/client/android/blimp_view.cc |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "blimp/client/android/blimp_view.h" |
| + |
| +#include "blimp/client/compositor/blimp_compositor_android.h" |
| +#include "jni/BlimpView_jni.h" |
| +#include "ui/gfx/geometry/size.h" |
| + |
| +namespace blimp { |
| + |
| +// static |
| +static jlong Init(JNIEnv* env, |
|
Wez
2015/08/27 02:01:50
Where is this called from? Can we give it a more h
David Trainor- moved to gerrit
2015/08/28 01:23:45
From Java. I'd like to keep the same name. It's
Wez
2015/09/03 00:49:26
Acknowledged.
|
| + jobject jobj, |
| + jint physical_width, |
| + jint physical_height, |
| + jint display_width, |
| + jint display_height, |
| + jfloat dp_to_pixel) { |
| + return reinterpret_cast<intptr_t>( |
| + new BlimpView(env, jobj, gfx::Size(physical_width, physical_height), |
| + gfx::Size(display_width, display_height), dp_to_pixel)); |
| +} |
| + |
| +// static |
| +bool BlimpView::RegisterJni(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +BlimpView::BlimpView(JNIEnv* env, |
| + jobject jobj, |
| + const gfx::Size& physical_size, |
| + const gfx::Size& display_size, |
| + float dp_to_pixel) |
| + : compositor_(BlimpCompositorAndroid::Create(physical_size, |
| + display_size, |
| + dp_to_pixel)), |
| + current_surface_format_(0) { |
| + java_obj_.Reset(env, jobj); |
| +} |
| + |
| +BlimpView::~BlimpView() { |
| + compositor_.reset(); |
|
Wez
2015/08/27 02:01:50
Why do you need to reset explicitly here, rather t
David Trainor- moved to gerrit
2015/08/28 01:23:45
Ah I ended up refactoring some things so this migh
Wez
2015/09/03 00:49:26
Acknowledged.
|
| +} |
| + |
| +void BlimpView::Destroy(JNIEnv* env, jobject jobj) { |
| + delete this; |
| +} |
| + |
| +void BlimpView::SetNeedsComposite(JNIEnv* env, jobject jobj) {} |
| + |
| +void BlimpView::SurfaceChanged(JNIEnv* env, |
| + jobject jobj, |
| + jint format, |
| + jint width, |
| + jint height, |
| + jobject jsurface) { |
| + if (current_surface_format_ != format) { |
| + current_surface_format_ = format; |
| + compositor_->SetSurface(env, jsurface); |
| + } |
| + |
| + compositor_->SetSize(gfx::Size(width, height)); |
| +} |
| + |
| +void BlimpView::SurfaceCreated(JNIEnv* env, jobject jobj) { |
| + current_surface_format_ = 0; |
|
Wez
2015/08/27 02:01:50
nit: What does surface format of zero mean?
David Trainor- moved to gerrit
2015/08/28 01:23:45
In the Android SDK Java file it's defined as UNKNO
Wez
2015/09/03 00:49:26
Acknowledged. Thanks for adding the clarifying com
|
| +} |
| + |
| +void BlimpView::SurfaceDestroyed(JNIEnv* env, jobject jobj) { |
| + current_surface_format_ = 0; |
| + compositor_->SetSurface(env, 0 /** nullptr jobject */); |
| +} |
| + |
| +void BlimpView::SetVisibility(JNIEnv* env, jobject jobj, jboolean visible) { |
| + compositor_->SetVisible(visible); |
| +} |
| + |
| +} // namespace blimp |