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.
5 #include "blimp/client/android/blimp_view.h"
7 #include "blimp/client/compositor/blimp_compositor_android.h"
8 #include "jni/BlimpView_jni.h"
9 #include "ui/gfx/geometry/size.h"
14 static jlong
Init(JNIEnv
* env
,
15 const JavaParamRef
<jobject
>& jobj
,
21 return reinterpret_cast<intptr_t>(
22 new BlimpView(env
, jobj
, gfx::Size(real_width
, real_height
),
23 gfx::Size(width
, height
), dp_to_px
));
27 bool BlimpView::RegisterJni(JNIEnv
* env
) {
28 return RegisterNativesImpl(env
);
31 BlimpView::BlimpView(JNIEnv
* env
,
32 const JavaParamRef
<jobject
>& jobj
,
33 const gfx::Size
& real_size
,
34 const gfx::Size
& size
,
36 : compositor_(BlimpCompositorAndroid::Create(real_size
, size
, dp_to_px
)),
37 current_surface_format_(0) {
38 java_obj_
.Reset(env
, jobj
);
41 BlimpView::~BlimpView() {}
43 void BlimpView::Destroy(JNIEnv
* env
, jobject jobj
) {
47 void BlimpView::SetNeedsComposite(JNIEnv
* env
, jobject jobj
) {}
49 void BlimpView::OnSurfaceChanged(JNIEnv
* env
,
55 if (current_surface_format_
!= format
) {
56 current_surface_format_
= format
;
57 compositor_
->SetSurface(env
, jsurface
);
60 compositor_
->SetSize(gfx::Size(width
, height
));
63 void BlimpView::OnSurfaceCreated(JNIEnv
* env
, jobject jobj
) {
64 current_surface_format_
= 0 /** PixelFormat.UNKNOWN */;
67 void BlimpView::OnSurfaceDestroyed(JNIEnv
* env
, jobject jobj
) {
68 current_surface_format_
= 0 /** PixelFormat.UNKNOWN */;
69 compositor_
->SetSurface(env
, 0 /** nullptr jobject */);
72 void BlimpView::SetVisibility(JNIEnv
* env
, jobject jobj
, jboolean visible
) {
73 compositor_
->SetVisible(visible
);