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

Unified Diff: tools/viewer/Viewer.cpp

Issue 2032623002: Implement OpenGL backend in Android viewer app (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean 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
Index: tools/viewer/Viewer.cpp
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 9f3b8f2e27df62d505737ac37a8d0503c7d63d98..4dc87226354bab741d07350522dd1ea6a377feb9 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -422,9 +422,11 @@ void Viewer::updateUIState() {
// We will be able to change the backend too.
Json::Value backendState(Json::objectValue);
backendState[kName] = kBackendStateName;
- backendState[kValue] = fBackendType == sk_app::Window::kVulkan_BackendType ?
- "Vulkan" : "Other than Vulkan";
+ backendState[kValue] = kBackendTypeStrings[fBackendType];
backendState[kOptions] = Json::Value(Json::arrayValue);
+ for(auto str : kBackendTypeStrings) {
+ backendState[kOptions].append(Json::Value(str));
+ }
Json::Value state(Json::arrayValue);
state.append(slideState);
@@ -434,7 +436,8 @@ void Viewer::updateUIState() {
}
void Viewer::onUIStateChanged(const SkString& stateName, const SkString& stateValue) {
- // Currently, we only recognize the Slide state
+ // After the change, please call updateUIState no notify the frontend (e.g., Android app).
scroggo 2016/06/02 18:25:16 to* notify? Also, who is this comment for? The ca
liyuqian 2016/06/02 18:47:13 This comment is for those who will add more featur
+ // For slide change, updateUIState is called inside setupCurrentSlide.
if (stateName.equals(kSlideStateName)) {
int previousSlide = fCurrentSlide;
fCurrentSlide = 0;
@@ -449,6 +452,20 @@ void Viewer::onUIStateChanged(const SkString& stateName, const SkString& stateVa
fCurrentSlide = previousSlide;
SkDebugf("Slide not found: %s", stateValue.c_str());
}
+ } else if (stateName.equals(kBackendStateName)) {
+ for(int i=0; i<sk_app::Window::kBackendTypeCount; i++) {
scroggo 2016/06/02 18:25:16 nit: Typically we put spaces around operators: fo
liyuqian 2016/06/02 18:47:13 Done.
+ if (stateValue.equals(kBackendTypeStrings[i])) {
+ if (fBackendType != i) {
+ fBackendType = (sk_app::Window::BackendType)i;
+ fWindow->detach();
+ fWindow->attach(fBackendType, DisplayParams());
+ fWindow->inval();
+ updateTitle();
+ updateUIState();
+ }
+ break;
+ }
+ }
} else {
SkDebugf("Unknown stateName: %s", stateName.c_str());
}
« no previous file with comments | « no previous file | tools/viewer/sk_app/GLWindowContext.h » ('j') | tools/viewer/sk_app/android/GLWindowContext_android.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698