Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: blimp/client/android/blimp_view.cc

Issue 1295243003: Initial commit of the blimp/ folder and target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address final nits. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 real_width,
17 jint real_height,
18 jint width,
19 jint height,
20 jfloat dp_to_px) {
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));
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& real_size,
34 const gfx::Size& size,
35 float dp_to_px)
36 : compositor_(BlimpCompositorAndroid::Create(real_size, size, dp_to_px)),
37 current_surface_format_(0) {
38 java_obj_.Reset(env, jobj);
39 }
40
41 BlimpView::~BlimpView() {}
42
43 void BlimpView::Destroy(JNIEnv* env, jobject jobj) {
44 delete this;
45 }
46
47 void BlimpView::SetNeedsComposite(JNIEnv* env, jobject jobj) {}
48
49 void BlimpView::OnSurfaceChanged(JNIEnv* env,
50 jobject jobj,
51 jint format,
52 jint width,
53 jint height,
54 jobject jsurface) {
55 if (current_surface_format_ != format) {
56 current_surface_format_ = format;
57 compositor_->SetSurface(env, jsurface);
58 }
59
60 compositor_->SetSize(gfx::Size(width, height));
61 }
62
63 void BlimpView::OnSurfaceCreated(JNIEnv* env, jobject jobj) {
64 current_surface_format_ = 0 /** PixelFormat.UNKNOWN */;
65 }
66
67 void BlimpView::OnSurfaceDestroyed(JNIEnv* env, jobject jobj) {
68 current_surface_format_ = 0 /** PixelFormat.UNKNOWN */;
69 compositor_->SetSurface(env, 0 /** nullptr jobject */);
70 }
71
72 void BlimpView::SetVisibility(JNIEnv* env, jobject jobj, jboolean visible) {
73 compositor_->SetVisible(visible);
74 }
75
76 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698