OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "blimp/client/android/blimp_view.h" |
| 6 |
| 7 #include "blimp/client/compositor/blimp_compositor_android.h" |
| 8 #include "jni/BlimpView_jni.h" |
| 9 #include "ui/gfx/geometry/size.h" |
| 10 |
| 11 namespace blimp { |
| 12 |
| 13 // static |
| 14 static jlong Init(JNIEnv* env, |
| 15 jobject jobj, |
| 16 jint physical_width, |
| 17 jint physical_height, |
| 18 jint display_width, |
| 19 jint display_height, |
| 20 jfloat dp_to_pixel) { |
| 21 return reinterpret_cast<intptr_t>( |
| 22 new BlimpView(env, jobj, gfx::Size(physical_width, physical_height), |
| 23 gfx::Size(display_width, display_height), dp_to_pixel)); |
| 24 } |
| 25 |
| 26 // static |
| 27 bool BlimpView::RegisterJni(JNIEnv* env) { |
| 28 return RegisterNativesImpl(env); |
| 29 } |
| 30 |
| 31 BlimpView::BlimpView(JNIEnv* env, |
| 32 jobject jobj, |
| 33 const gfx::Size& physical_size, |
| 34 const gfx::Size& display_size, |
| 35 float dp_to_pixel) |
| 36 : compositor_(BlimpCompositorAndroid::Create(physical_size, |
| 37 display_size, |
| 38 dp_to_pixel)), |
| 39 current_surface_format_(0) { |
| 40 java_obj_.Reset(env, jobj); |
| 41 } |
| 42 |
| 43 BlimpView::~BlimpView() { |
| 44 compositor_.reset(); |
| 45 } |
| 46 |
| 47 void BlimpView::Destroy(JNIEnv* env, jobject jobj) { |
| 48 delete this; |
| 49 } |
| 50 |
| 51 void BlimpView::SetNeedsComposite(JNIEnv* env, jobject jobj) {} |
| 52 |
| 53 void BlimpView::SurfaceChanged(JNIEnv* env, |
| 54 jobject jobj, |
| 55 jint format, |
| 56 jint width, |
| 57 jint height, |
| 58 jobject jsurface) { |
| 59 if (current_surface_format_ != format) { |
| 60 current_surface_format_ = format; |
| 61 compositor_->SetSurface(env, jsurface); |
| 62 } |
| 63 |
| 64 compositor_->SetSize(gfx::Size(width, height)); |
| 65 } |
| 66 |
| 67 void BlimpView::SurfaceCreated(JNIEnv* env, jobject jobj) { |
| 68 current_surface_format_ = 0; |
| 69 } |
| 70 |
| 71 void BlimpView::SurfaceDestroyed(JNIEnv* env, jobject jobj) { |
| 72 current_surface_format_ = 0; |
| 73 compositor_->SetSurface(env, 0 /** nullptr jobject */); |
| 74 } |
| 75 |
| 76 void BlimpView::SetVisibility(JNIEnv* env, jobject jobj, jboolean visible) { |
| 77 compositor_->SetVisible(visible); |
| 78 } |
| 79 |
| 80 } // namespace blimp |
OLD | NEW |