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

Side by Side Diff: sky/shell/sky_view.cc

Issue 890803004: SkyShell should be able to draw a green square with GL (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« sky/shell/library_loader.cc ('K') | « sky/shell/sky_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sky/shell/sky_view.h"
6
7 #include <android/input.h>
8 #include <android/native_window_jni.h>
9
10 #include "base/android/jni_android.h"
11 #include "jni/SkyView_jni.h"
12
13 namespace sky {
14 namespace shell {
15
16 // static
17 bool SkyView::Register(JNIEnv* env) {
18 return RegisterNativesImpl(env);
19 }
20
21 SkyView::Delegate::~Delegate() {
22 }
23
24 SkyView::SkyView(Delegate* delegate) : delegate_(delegate), window_(NULL) {
25 }
26
27 SkyView::~SkyView() {
28 if (window_)
29 ReleaseWindow();
30 }
31
32 void SkyView::Init() {
33 JNIEnv* env = base::android::AttachCurrentThread();
34 Java_SkyView_createForActivity(env, base::android::GetApplicationContext(),
35 reinterpret_cast<jlong>(this));
36 }
37
38 void SkyView::Destroy(JNIEnv* env, jobject obj) {
39 delegate_->OnDestroyed();
40 }
41
42 void SkyView::SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface) {
43 base::android::ScopedJavaLocalRef<jobject> protector(env, jsurface);
44 // Note: This ensures that any local references used by
45 // ANativeWindow_fromSurface are released immediately. This is needed as a
46 // workaround for https://code.google.com/p/android/issues/detail?id=68174
47 {
48 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env);
49 window_ = ANativeWindow_fromSurface(env, jsurface);
50 }
51 delegate_->OnAcceleratedWidgetAvailable(window_);
52 }
53
54 void SkyView::SurfaceDestroyed(JNIEnv* env, jobject obj) {
55 DCHECK(window_);
56 ReleaseWindow();
57 }
58
59 void SkyView::SurfaceSetSize(JNIEnv* env,
60 jobject obj,
61 jint width,
62 jint height,
63 jfloat density) {
64 }
65
66 void SkyView::ReleaseWindow() {
67 ANativeWindow_release(window_);
68 window_ = NULL;
69 }
70
71 } // namespace shell
72 } // namespace sky
OLDNEW
« sky/shell/library_loader.cc ('K') | « sky/shell/sky_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698