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

Side by Side Diff: platform_tools/android/apps/sample_app/src/main/jni/com_skia_SkiaSampleRenderer.cpp

Issue 1547923002: SampleApp: remove SkWindow::onPDFSaved, it does not work (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 11 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
1 1
2 /* 2 /*
3 * Copyright 2011 Skia 3 * Copyright 2011 Skia
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "com_skia_SkiaSampleRenderer.h" 8 #include "com_skia_SkiaSampleRenderer.h"
9 9
10 #include "SampleApp.h" 10 #include "SampleApp.h"
11 #include "SkApplication.h" 11 #include "SkApplication.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkDevice.h" 13 #include "SkDevice.h"
14 #include "SkEvent.h" 14 #include "SkEvent.h"
15 #include "SkWindow.h" 15 #include "SkWindow.h"
16 16
17 #include <jni.h> 17 #include <jni.h>
18 #include "AndroidKeyToSkKey.h" 18 #include "AndroidKeyToSkKey.h"
19 19
20 20
21 /////////////////////////////////////////// 21 ///////////////////////////////////////////
22 ///////////////// Globals ///////////////// 22 ///////////////// Globals /////////////////
23 /////////////////////////////////////////// 23 ///////////////////////////////////////////
24 24
25 struct ActivityGlue { 25 struct ActivityGlue {
26 JNIEnv* m_env; 26 JNIEnv* m_env;
27 jweak m_obj; 27 jweak m_obj;
28 jmethodID m_setTitle; 28 jmethodID m_setTitle;
29 jmethodID m_setSlideList; 29 jmethodID m_setSlideList;
30 jmethodID m_addToDownloads;
31 ActivityGlue() { 30 ActivityGlue() {
32 m_env = nullptr; 31 m_env = nullptr;
33 m_obj = nullptr; 32 m_obj = nullptr;
34 m_setTitle = nullptr; 33 m_setTitle = nullptr;
35 m_setSlideList = nullptr; 34 m_setSlideList = nullptr;
36 m_addToDownloads = nullptr;
37 } 35 }
38 } gActivityGlue; 36 } gActivityGlue;
39 37
40 struct WindowGlue { 38 struct WindowGlue {
41 jweak m_obj; 39 jweak m_obj;
42 jmethodID m_inval; 40 jmethodID m_inval;
43 jmethodID m_queueSkEvent; 41 jmethodID m_queueSkEvent;
44 jmethodID m_startTimer; 42 jmethodID m_startTimer;
45 jmethodID m_getMSAASampleCount; 43 jmethodID m_getMSAASampleCount;
46 WindowGlue() { 44 WindowGlue() {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (!env || !gWindowGlue.m_inval || !gWindowGlue.m_obj) { 113 if (!env || !gWindowGlue.m_inval || !gWindowGlue.m_obj) {
116 return; 114 return;
117 } 115 }
118 if (env->IsSameObject(gWindowGlue.m_obj, nullptr)) { 116 if (env->IsSameObject(gWindowGlue.m_obj, nullptr)) {
119 SkDebugf("ERROR: The JNI WeakRef to the Window is invalid"); 117 SkDebugf("ERROR: The JNI WeakRef to the Window is invalid");
120 return; 118 return;
121 } 119 }
122 env->CallVoidMethod(gWindowGlue.m_obj, gWindowGlue.m_inval); 120 env->CallVoidMethod(gWindowGlue.m_obj, gWindowGlue.m_inval);
123 } 121 }
124 122
125 void SkOSWindow::onPDFSaved(const char title[], const char desc[],
126 const char path[])
127 {
128 JNIEnv* env = gActivityGlue.m_env;
129 if (!env || !gActivityGlue.m_addToDownloads || !gActivityGlue.m_obj) {
130 return;
131 }
132 if (env->IsSameObject(gActivityGlue.m_obj, nullptr)) {
133 SkDebugf("ERROR: The JNI WeakRef to the Activity is invalid");
134 return;
135 }
136
137 jstring jtitle = env->NewStringUTF(title);
138 jstring jdesc = env->NewStringUTF(desc);
139 jstring jpath = env->NewStringUTF(path);
140
141 env->CallVoidMethod(gActivityGlue.m_obj, gActivityGlue.m_addToDownloads,
142 jtitle, jdesc, jpath);
143
144 env->DeleteLocalRef(jtitle);
145 env->DeleteLocalRef(jdesc);
146 env->DeleteLocalRef(jpath);
147 }
148
149 /////////////////////////////////////////// 123 ///////////////////////////////////////////
150 /////////////// SkEvent impl ////////////// 124 /////////////// SkEvent impl //////////////
151 /////////////////////////////////////////// 125 ///////////////////////////////////////////
152 126
153 void SkEvent::SignalQueueTimer(SkMSec ms) 127 void SkEvent::SignalQueueTimer(SkMSec ms)
154 { 128 {
155 JNIEnv* env = gActivityGlue.m_env; 129 JNIEnv* env = gActivityGlue.m_env;
156 if (!env || !gWindowGlue.m_startTimer || !gWindowGlue.m_obj || !ms) { 130 if (!env || !gWindowGlue.m_startTimer || !gWindowGlue.m_obj || !ms) {
157 return; 131 return;
158 } 132 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 165
192 JNIEXPORT void JNICALL Java_com_skia_SkiaSampleRenderer_init(JNIEnv* env, 166 JNIEXPORT void JNICALL Java_com_skia_SkiaSampleRenderer_init(JNIEnv* env,
193 jobject thiz, jobject jsampleActivity, jstring cmdLineFlags, jint msaaSa mpleCount) 167 jobject thiz, jobject jsampleActivity, jstring cmdLineFlags, jint msaaSa mpleCount)
194 { 168 {
195 // setup jni hooks to the java activity 169 // setup jni hooks to the java activity
196 gActivityGlue.m_env = env; 170 gActivityGlue.m_env = env;
197 jclass clazz = env->FindClass("com/skia/SkiaSampleActivity"); 171 jclass clazz = env->FindClass("com/skia/SkiaSampleActivity");
198 gActivityGlue.m_obj = env->NewWeakGlobalRef(jsampleActivity); 172 gActivityGlue.m_obj = env->NewWeakGlobalRef(jsampleActivity);
199 gActivityGlue.m_setTitle = GetJMethod(env, clazz, "setTitle", "(Ljava/lang/C harSequence;)V"); 173 gActivityGlue.m_setTitle = GetJMethod(env, clazz, "setTitle", "(Ljava/lang/C harSequence;)V");
200 gActivityGlue.m_setSlideList = GetJMethod(env, clazz, "setSlideList", "([Lja va/lang/String;)V"); 174 gActivityGlue.m_setSlideList = GetJMethod(env, clazz, "setSlideList", "([Lja va/lang/String;)V");
201 gActivityGlue.m_addToDownloads = GetJMethod(env, clazz, "addToDownloads",
202 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
203 env->DeleteLocalRef(clazz); 175 env->DeleteLocalRef(clazz);
204 176
205 // setup jni hooks to the java renderer 177 // setup jni hooks to the java renderer
206 clazz = env->FindClass("com/skia/SkiaSampleRenderer"); 178 clazz = env->FindClass("com/skia/SkiaSampleRenderer");
207 gWindowGlue.m_obj = env->NewWeakGlobalRef(thiz); 179 gWindowGlue.m_obj = env->NewWeakGlobalRef(thiz);
208 gWindowGlue.m_inval = GetJMethod(env, clazz, "requestRender", "()V"); 180 gWindowGlue.m_inval = GetJMethod(env, clazz, "requestRender", "()V");
209 gWindowGlue.m_queueSkEvent = GetJMethod(env, clazz, "queueSkEvent", "()V"); 181 gWindowGlue.m_queueSkEvent = GetJMethod(env, clazz, "queueSkEvent", "()V");
210 gWindowGlue.m_startTimer = GetJMethod(env, clazz, "startTimer", "(I)V"); 182 gWindowGlue.m_startTimer = GetJMethod(env, clazz, "startTimer", "(I)V");
211 gWindowGlue.m_getMSAASampleCount = GetJMethod(env, clazz, "getMSAASampleCoun t", "()I"); 183 gWindowGlue.m_getMSAASampleCount = GetJMethod(env, clazz, "getMSAASampleCoun t", "()I");
212 env->DeleteLocalRef(clazz); 184 env->DeleteLocalRef(clazz);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 JNIEnv* env, jobject thiz) 347 JNIEnv* env, jobject thiz)
376 { 348 {
377 gWindow->saveToPdf(); 349 gWindow->saveToPdf();
378 } 350 }
379 351
380 JNIEXPORT void JNICALL Java_com_skia_SkiaSampleRenderer_postInval( 352 JNIEXPORT void JNICALL Java_com_skia_SkiaSampleRenderer_postInval(
381 JNIEnv* env, jobject thiz) 353 JNIEnv* env, jobject thiz)
382 { 354 {
383 gWindow->postInvalDelay(); 355 gWindow->postInvalDelay();
384 } 356 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698