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

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: Created 5 years, 4 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/android/compositor/blimp_compositor.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_(
37 BlimpCompositor::Create(physical_size, display_size, dp_to_pixel)),
38 current_surface_format_(0) {
39 java_obj_.Reset(env, jobj);
40 }
41
42 BlimpView::~BlimpView() {
43 compositor_.reset();
44 }
45
46 void BlimpView::Destroy(JNIEnv* env, jobject jobj) {
47 delete this;
48 }
49
50 void BlimpView::SetNeedsComposite(JNIEnv* env, jobject jobj) {}
51
52 void BlimpView::SurfaceChanged(JNIEnv* env,
53 jobject jobj,
54 jint format,
55 jint width,
56 jint height,
57 jobject jsurface) {
58 if (current_surface_format_ != format) {
59 current_surface_format_ = format;
60 compositor_->SetSurface(env, jsurface);
61 }
62
63 compositor_->SetSize(gfx::Size(width, height));
64 }
65
66 void BlimpView::SurfaceCreated(JNIEnv* env, jobject jobj) {
67 current_surface_format_ = 0;
68 }
69
70 void BlimpView::SurfaceDestroyed(JNIEnv* env, jobject jobj) {
71 current_surface_format_ = 0;
72 compositor_->SetSurface(env, 0 /** nullptr jobject */);
73 }
74
75 void BlimpView::SetVisibility(JNIEnv* env, jobject jobj, jboolean visible) {
76 compositor_->SetVisible(visible);
77 }
78
79 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698