Fix viewer state that has empty state/option
If the value or option is empty (as was for kInstancedRenderingStateName),
our Android Java application will throw exception and skip the remaining
state objects. That would result in missing "Softkeys" and "FPS" for Raster
backend in Android Viewer app.
Bug: skia:
Change-Id: I6f600bbb94509ca5389eac2d681304a00427ecdb
Reviewed-on: https://skia-review.googlesource.com/26527
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 72c2f6c..6f01f2d 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -1320,13 +1320,12 @@
// Instanced rendering state
Json::Value instState(Json::objectValue);
instState[kName] = kInstancedRenderingStateName;
+ instState[kValue] = kOFF;
+ instState[kOptions] = Json::Value(Json::arrayValue);
if (ctx) {
if (fWindow->getRequestedDisplayParams().fGrContextOptions.fEnableInstancedRendering) {
instState[kValue] = kON;
- } else {
- instState[kValue] = kOFF;
}
- instState[kOptions] = Json::Value(Json::arrayValue);
instState[kOptions].append(kOFF);
instState[kOptions].append(kON);
}