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

Unified Diff: tools/viewer/sk_app/android/surface_glue_android.cpp

Issue 2004633002: Add drawer with state information (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Merge Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/viewer/sk_app/android/surface_glue_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/sk_app/android/surface_glue_android.cpp
diff --git a/tools/viewer/sk_app/android/surface_glue_android.cpp b/tools/viewer/sk_app/android/surface_glue_android.cpp
index 958b7876b8baa674aec32cc89c684d8f7db0edda..daf26a3852ed2c6275816f4756829dc2d06a0567 100644
--- a/tools/viewer/sk_app/android/surface_glue_android.cpp
+++ b/tools/viewer/sk_app/android/surface_glue_android.cpp
@@ -46,6 +46,7 @@ SkiaAndroidApp::SkiaAndroidApp(JNIEnv* env, jobject androidApp) {
fAndroidApp = env->NewGlobalRef(androidApp);
jclass cls = env->GetObjectClass(fAndroidApp);
fSetTitleMethodID = env->GetMethodID(cls, "setTitle", "(Ljava/lang/String;)V");
+ fSetStateMethodID = env->GetMethodID(cls, "setState", "(Ljava/lang/String;)V");
fNativeWindow = nullptr;
pthread_create(&fThread, nullptr, pthread_main, this);
}
@@ -70,6 +71,12 @@ void SkiaAndroidApp::setTitle(const char* title) const {
fPThreadEnv->DeleteLocalRef(titleString);
}
+void SkiaAndroidApp::setUIState(const Json::Value& state) const {
+ jstring jstr = fPThreadEnv->NewStringUTF(state.toStyledString().c_str());
+ fPThreadEnv->CallVoidMethod(fAndroidApp, fSetStateMethodID, jstr);
+ fPThreadEnv->DeleteLocalRef(jstr);
+}
+
void SkiaAndroidApp::postMessage(const Message& message) const {
SkDEBUGCODE(auto writeSize =) write(fPipes[1], &message, sizeof(message));
SkASSERT(writeSize == sizeof(message));
@@ -139,6 +146,12 @@ int SkiaAndroidApp::message_callback(int fd, int events, void* data) {
message.fTouchY);
break;
}
+ case kUIStateChanged: {
+ skiaAndroidApp->fWindow->onUIStateChanged(*message.stateName, *message.stateValue);
+ delete message.stateName;
+ delete message.stateValue;
+ break;
+ }
default: {
// do nothing
}
@@ -229,4 +242,17 @@ extern "C" JNIEXPORT void JNICALL Java_org_skia_viewer_ViewerActivity_onTouched(
skiaAndroidApp->postMessage(message);
}
+extern "C" JNIEXPORT void JNICALL Java_org_skia_viewer_ViewerActivity_onUIStateChanged(
+ JNIEnv* env, jobject activity, jlong handle, jstring stateName, jstring stateValue) {
+ auto skiaAndroidApp = (SkiaAndroidApp*)handle;
+ Message message(kUIStateChanged);
+ const char* nameChars = env->GetStringUTFChars(stateName, nullptr);
+ const char* valueChars = env->GetStringUTFChars(stateValue, nullptr);
+ message.stateName = new SkString(nameChars);
+ message.stateValue = new SkString(valueChars);
+ skiaAndroidApp->postMessage(message);
+ env->ReleaseStringUTFChars(stateName, nameChars);
+ env->ReleaseStringUTFChars(stateValue, valueChars);
+}
+
} // namespace sk_app
« no previous file with comments | « tools/viewer/sk_app/android/surface_glue_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698