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

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: Some cleanup 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,
Wez 2015/08/27 02:01:50 Where is this called from? Can we give it a more h
David Trainor- moved to gerrit 2015/08/28 01:23:45 From Java. I'd like to keep the same name. It's
Wez 2015/09/03 00:49:26 Acknowledged.
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();
Wez 2015/08/27 02:01:50 Why do you need to reset explicitly here, rather t
David Trainor- moved to gerrit 2015/08/28 01:23:45 Ah I ended up refactoring some things so this migh
Wez 2015/09/03 00:49:26 Acknowledged.
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;
Wez 2015/08/27 02:01:50 nit: What does surface format of zero mean?
David Trainor- moved to gerrit 2015/08/28 01:23:45 In the Android SDK Java file it's defined as UNKNO
Wez 2015/09/03 00:49:26 Acknowledged. Thanks for adding the clarifying com
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698