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

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: Removed DCHECK, removed duplicate include. 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 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
45 void BlimpView::Destroy(JNIEnv* env, jobject jobj) {
46 delete this;
47 }
48
49 void BlimpView::SetNeedsComposite(JNIEnv* env, jobject jobj) {}
50
51 void BlimpView::OnSurfaceChanged(JNIEnv* env,
52 jobject jobj,
53 jint format,
54 jint width,
55 jint height,
56 jobject jsurface) {
57 if (current_surface_format_ != format) {
58 current_surface_format_ = format;
59 compositor_->SetSurface(env, jsurface);
60 }
61
62 compositor_->SetSize(gfx::Size(width, height));
63 }
64
65 void BlimpView::OnSurfaceCreated(JNIEnv* env, jobject jobj) {
66 current_surface_format_ = 0 /** PixelFormat.UNKNOWN */;
67 }
68
69 void BlimpView::OnSurfaceDestroyed(JNIEnv* env, jobject jobj) {
70 current_surface_format_ = 0 /** PixelFormat.UNKNOWN */;
71 compositor_->SetSurface(env, 0 /** nullptr jobject */);
72 }
73
74 void BlimpView::SetVisibility(JNIEnv* env, jobject jobj, jboolean visible) {
75 compositor_->SetVisible(visible);
76 }
77
78 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698