Remove SampleApp and convert HelloWorld to sk_app
There is still a large amount of views code that could be trimmed down,
but which is used to implement samples (in viewer). Seemed simpler to
remove some of this code in pieces.
Bug: skia:
Change-Id: Ia3415060d03c8de604a154e3dc38379b754daab6
Reviewed-on: https://skia-review.googlesource.com/72801
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/tools/viewer/sk_app/Application.h b/tools/sk_app/Application.h
similarity index 100%
rename from tools/viewer/sk_app/Application.h
rename to tools/sk_app/Application.h
diff --git a/tools/viewer/sk_app/CommandSet.cpp b/tools/sk_app/CommandSet.cpp
similarity index 100%
rename from tools/viewer/sk_app/CommandSet.cpp
rename to tools/sk_app/CommandSet.cpp
diff --git a/tools/viewer/sk_app/CommandSet.h b/tools/sk_app/CommandSet.h
similarity index 100%
rename from tools/viewer/sk_app/CommandSet.h
rename to tools/sk_app/CommandSet.h
diff --git a/tools/viewer/sk_app/DisplayParams.h b/tools/sk_app/DisplayParams.h
similarity index 100%
rename from tools/viewer/sk_app/DisplayParams.h
rename to tools/sk_app/DisplayParams.h
diff --git a/tools/viewer/sk_app/GLWindowContext.cpp b/tools/sk_app/GLWindowContext.cpp
similarity index 100%
rename from tools/viewer/sk_app/GLWindowContext.cpp
rename to tools/sk_app/GLWindowContext.cpp
diff --git a/tools/viewer/sk_app/GLWindowContext.h b/tools/sk_app/GLWindowContext.h
similarity index 100%
rename from tools/viewer/sk_app/GLWindowContext.h
rename to tools/sk_app/GLWindowContext.h
diff --git a/tools/viewer/sk_app/RasterWindowContext.h b/tools/sk_app/RasterWindowContext.h
similarity index 100%
rename from tools/viewer/sk_app/RasterWindowContext.h
rename to tools/sk_app/RasterWindowContext.h
diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp
similarity index 100%
rename from tools/viewer/sk_app/VulkanWindowContext.cpp
rename to tools/sk_app/VulkanWindowContext.cpp
diff --git a/tools/viewer/sk_app/VulkanWindowContext.h b/tools/sk_app/VulkanWindowContext.h
similarity index 100%
rename from tools/viewer/sk_app/VulkanWindowContext.h
rename to tools/sk_app/VulkanWindowContext.h
diff --git a/tools/viewer/sk_app/Window.cpp b/tools/sk_app/Window.cpp
similarity index 100%
rename from tools/viewer/sk_app/Window.cpp
rename to tools/sk_app/Window.cpp
diff --git a/tools/viewer/sk_app/Window.h b/tools/sk_app/Window.h
similarity index 98%
rename from tools/viewer/sk_app/Window.h
rename to tools/sk_app/Window.h
index 7357860..4d407809 100644
--- a/tools/viewer/sk_app/Window.h
+++ b/tools/sk_app/Window.h
@@ -12,7 +12,6 @@
#include "SkRect.h"
#include "SkTouchGesture.h"
#include "SkTypes.h"
-#include "SkJSONCPP.h"
class GrContext;
class SkCanvas;
@@ -30,7 +29,9 @@
virtual void setTitle(const char*) = 0;
virtual void show() = 0;
- virtual void setUIState(const Json::Value& state) {} // do nothing in default
+
+ // JSON-formatted UI state for Android. Do nothing by default
+ virtual void setUIState(const char*) {}
// Shedules an invalidation event for window if one is not currently pending.
// Make sure that either onPaint or markInvalReceived is called when the client window consumes
diff --git a/tools/viewer/sk_app/WindowContext.h b/tools/sk_app/WindowContext.h
similarity index 100%
rename from tools/viewer/sk_app/WindowContext.h
rename to tools/sk_app/WindowContext.h
diff --git a/tools/viewer/sk_app/android/GLWindowContext_android.cpp b/tools/sk_app/android/GLWindowContext_android.cpp
similarity index 100%
rename from tools/viewer/sk_app/android/GLWindowContext_android.cpp
rename to tools/sk_app/android/GLWindowContext_android.cpp
diff --git a/tools/viewer/sk_app/android/RasterWindowContext_android.cpp b/tools/sk_app/android/RasterWindowContext_android.cpp
similarity index 100%
rename from tools/viewer/sk_app/android/RasterWindowContext_android.cpp
rename to tools/sk_app/android/RasterWindowContext_android.cpp
diff --git a/tools/viewer/sk_app/android/VulkanWindowContext_android.cpp b/tools/sk_app/android/VulkanWindowContext_android.cpp
similarity index 100%
rename from tools/viewer/sk_app/android/VulkanWindowContext_android.cpp
rename to tools/sk_app/android/VulkanWindowContext_android.cpp
diff --git a/tools/viewer/sk_app/android/WindowContextFactory_android.h b/tools/sk_app/android/WindowContextFactory_android.h
similarity index 100%
rename from tools/viewer/sk_app/android/WindowContextFactory_android.h
rename to tools/sk_app/android/WindowContextFactory_android.h
diff --git a/tools/viewer/sk_app/android/Window_android.cpp b/tools/sk_app/android/Window_android.cpp
similarity index 97%
rename from tools/viewer/sk_app/android/Window_android.cpp
rename to tools/sk_app/android/Window_android.cpp
index 16ad430..96acfc6 100644
--- a/tools/viewer/sk_app/android/Window_android.cpp
+++ b/tools/sk_app/android/Window_android.cpp
@@ -31,7 +31,7 @@
fSkiaAndroidApp->setTitle(title);
}
-void Window_android::setUIState(const Json::Value& state) {
+void Window_android::setUIState(const char* state) {
fSkiaAndroidApp->setUIState(state);
}
diff --git a/tools/viewer/sk_app/android/Window_android.h b/tools/sk_app/android/Window_android.h
similarity index 93%
rename from tools/viewer/sk_app/android/Window_android.h
rename to tools/sk_app/android/Window_android.h
index 7918011..9e28a80 100644
--- a/tools/viewer/sk_app/android/Window_android.h
+++ b/tools/sk_app/android/Window_android.h
@@ -27,7 +27,7 @@
bool attach(BackendType) override;
void onInval() override;
- void setUIState(const Json::Value& state) override;
+ void setUIState(const char* state) override;
void paintIfNeeded();
diff --git a/tools/viewer/sk_app/android/main_android.cpp b/tools/sk_app/android/main_android.cpp
similarity index 100%
rename from tools/viewer/sk_app/android/main_android.cpp
rename to tools/sk_app/android/main_android.cpp
diff --git a/tools/viewer/sk_app/android/surface_glue_android.cpp b/tools/sk_app/android/surface_glue_android.cpp
similarity index 98%
rename from tools/viewer/sk_app/android/surface_glue_android.cpp
rename to tools/sk_app/android/surface_glue_android.cpp
index 4fb6c3d..9c73424 100644
--- a/tools/viewer/sk_app/android/surface_glue_android.cpp
+++ b/tools/sk_app/android/surface_glue_android.cpp
@@ -71,8 +71,8 @@
fPThreadEnv->DeleteLocalRef(titleString);
}
-void SkiaAndroidApp::setUIState(const Json::Value& state) const {
- jstring jstr = fPThreadEnv->NewStringUTF(state.toStyledString().c_str());
+void SkiaAndroidApp::setUIState(const char* state) const {
+ jstring jstr = fPThreadEnv->NewStringUTF(state);
fPThreadEnv->CallVoidMethod(fAndroidApp, fSetStateMethodID, jstr);
fPThreadEnv->DeleteLocalRef(jstr);
}
diff --git a/tools/viewer/sk_app/android/surface_glue_android.h b/tools/sk_app/android/surface_glue_android.h
similarity index 96%
rename from tools/viewer/sk_app/android/surface_glue_android.h
rename to tools/sk_app/android/surface_glue_android.h
index 3bbf3af..1dd1f28 100644
--- a/tools/viewer/sk_app/android/surface_glue_android.h
+++ b/tools/sk_app/android/surface_glue_android.h
@@ -57,7 +57,7 @@
// These must be called in SkiaAndroidApp's own pthread because the JNIEnv is thread sensitive
void setTitle(const char* title) const;
- void setUIState(const Json::Value& state) const;
+ void setUIState(const char* state) const;
private:
pthread_t fThread;
diff --git a/tools/viewer/sk_app/ios/GLWindowContext_ios.cpp b/tools/sk_app/ios/GLWindowContext_ios.cpp
similarity index 100%
rename from tools/viewer/sk_app/ios/GLWindowContext_ios.cpp
rename to tools/sk_app/ios/GLWindowContext_ios.cpp
diff --git a/tools/viewer/sk_app/ios/RasterWindowContext_ios.cpp b/tools/sk_app/ios/RasterWindowContext_ios.cpp
similarity index 100%
rename from tools/viewer/sk_app/ios/RasterWindowContext_ios.cpp
rename to tools/sk_app/ios/RasterWindowContext_ios.cpp
diff --git a/tools/viewer/sk_app/ios/WindowContextFactory_ios.h b/tools/sk_app/ios/WindowContextFactory_ios.h
similarity index 100%
rename from tools/viewer/sk_app/ios/WindowContextFactory_ios.h
rename to tools/sk_app/ios/WindowContextFactory_ios.h
diff --git a/tools/viewer/sk_app/ios/Window_ios.cpp b/tools/sk_app/ios/Window_ios.cpp
similarity index 100%
rename from tools/viewer/sk_app/ios/Window_ios.cpp
rename to tools/sk_app/ios/Window_ios.cpp
diff --git a/tools/viewer/sk_app/ios/Window_ios.h b/tools/sk_app/ios/Window_ios.h
similarity index 100%
rename from tools/viewer/sk_app/ios/Window_ios.h
rename to tools/sk_app/ios/Window_ios.h
diff --git a/tools/viewer/sk_app/ios/main_ios.cpp b/tools/sk_app/ios/main_ios.cpp
similarity index 100%
rename from tools/viewer/sk_app/ios/main_ios.cpp
rename to tools/sk_app/ios/main_ios.cpp
diff --git a/tools/viewer/sk_app/mac/GLWindowContext_mac.cpp b/tools/sk_app/mac/GLWindowContext_mac.cpp
similarity index 100%
rename from tools/viewer/sk_app/mac/GLWindowContext_mac.cpp
rename to tools/sk_app/mac/GLWindowContext_mac.cpp
diff --git a/tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp b/tools/sk_app/mac/RasterWindowContext_mac.cpp
similarity index 100%
rename from tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp
rename to tools/sk_app/mac/RasterWindowContext_mac.cpp
diff --git a/tools/viewer/sk_app/mac/WindowContextFactory_mac.h b/tools/sk_app/mac/WindowContextFactory_mac.h
similarity index 100%
rename from tools/viewer/sk_app/mac/WindowContextFactory_mac.h
rename to tools/sk_app/mac/WindowContextFactory_mac.h
diff --git a/tools/viewer/sk_app/mac/Window_mac.cpp b/tools/sk_app/mac/Window_mac.cpp
similarity index 100%
rename from tools/viewer/sk_app/mac/Window_mac.cpp
rename to tools/sk_app/mac/Window_mac.cpp
diff --git a/tools/viewer/sk_app/mac/Window_mac.h b/tools/sk_app/mac/Window_mac.h
similarity index 100%
rename from tools/viewer/sk_app/mac/Window_mac.h
rename to tools/sk_app/mac/Window_mac.h
diff --git a/tools/viewer/sk_app/mac/main_mac.cpp b/tools/sk_app/mac/main_mac.cpp
similarity index 100%
rename from tools/viewer/sk_app/mac/main_mac.cpp
rename to tools/sk_app/mac/main_mac.cpp
diff --git a/tools/viewer/sk_app/unix/GLWindowContext_unix.cpp b/tools/sk_app/unix/GLWindowContext_unix.cpp
similarity index 100%
rename from tools/viewer/sk_app/unix/GLWindowContext_unix.cpp
rename to tools/sk_app/unix/GLWindowContext_unix.cpp
diff --git a/tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp b/tools/sk_app/unix/RasterWindowContext_unix.cpp
similarity index 100%
rename from tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp
rename to tools/sk_app/unix/RasterWindowContext_unix.cpp
diff --git a/tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp b/tools/sk_app/unix/VulkanWindowContext_unix.cpp
similarity index 100%
rename from tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp
rename to tools/sk_app/unix/VulkanWindowContext_unix.cpp
diff --git a/tools/viewer/sk_app/unix/WindowContextFactory_unix.h b/tools/sk_app/unix/WindowContextFactory_unix.h
similarity index 100%
rename from tools/viewer/sk_app/unix/WindowContextFactory_unix.h
rename to tools/sk_app/unix/WindowContextFactory_unix.h
diff --git a/tools/viewer/sk_app/unix/Window_unix.cpp b/tools/sk_app/unix/Window_unix.cpp
similarity index 100%
rename from tools/viewer/sk_app/unix/Window_unix.cpp
rename to tools/sk_app/unix/Window_unix.cpp
diff --git a/tools/viewer/sk_app/unix/Window_unix.h b/tools/sk_app/unix/Window_unix.h
similarity index 100%
rename from tools/viewer/sk_app/unix/Window_unix.h
rename to tools/sk_app/unix/Window_unix.h
diff --git a/tools/viewer/sk_app/unix/main_unix.cpp b/tools/sk_app/unix/main_unix.cpp
similarity index 100%
rename from tools/viewer/sk_app/unix/main_unix.cpp
rename to tools/sk_app/unix/main_unix.cpp
diff --git a/tools/viewer/sk_app/win/ANGLEWindowContext_win.cpp b/tools/sk_app/win/ANGLEWindowContext_win.cpp
similarity index 100%
rename from tools/viewer/sk_app/win/ANGLEWindowContext_win.cpp
rename to tools/sk_app/win/ANGLEWindowContext_win.cpp
diff --git a/tools/viewer/sk_app/win/GLWindowContext_win.cpp b/tools/sk_app/win/GLWindowContext_win.cpp
similarity index 100%
rename from tools/viewer/sk_app/win/GLWindowContext_win.cpp
rename to tools/sk_app/win/GLWindowContext_win.cpp
diff --git a/tools/viewer/sk_app/win/RasterWindowContext_win.cpp b/tools/sk_app/win/RasterWindowContext_win.cpp
similarity index 100%
rename from tools/viewer/sk_app/win/RasterWindowContext_win.cpp
rename to tools/sk_app/win/RasterWindowContext_win.cpp
diff --git a/tools/viewer/sk_app/win/VulkanWindowContext_win.cpp b/tools/sk_app/win/VulkanWindowContext_win.cpp
similarity index 100%
rename from tools/viewer/sk_app/win/VulkanWindowContext_win.cpp
rename to tools/sk_app/win/VulkanWindowContext_win.cpp
diff --git a/tools/viewer/sk_app/win/WindowContextFactory_win.h b/tools/sk_app/win/WindowContextFactory_win.h
similarity index 100%
rename from tools/viewer/sk_app/win/WindowContextFactory_win.h
rename to tools/sk_app/win/WindowContextFactory_win.h
diff --git a/tools/viewer/sk_app/win/Window_win.cpp b/tools/sk_app/win/Window_win.cpp
similarity index 100%
rename from tools/viewer/sk_app/win/Window_win.cpp
rename to tools/sk_app/win/Window_win.cpp
diff --git a/tools/viewer/sk_app/win/Window_win.h b/tools/sk_app/win/Window_win.h
similarity index 100%
rename from tools/viewer/sk_app/win/Window_win.h
rename to tools/sk_app/win/Window_win.h
diff --git a/tools/viewer/sk_app/win/main_win.cpp b/tools/sk_app/win/main_win.cpp
similarity index 100%
rename from tools/viewer/sk_app/win/main_win.cpp
rename to tools/sk_app/win/main_win.cpp
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 2108b09..919fac0 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -1564,7 +1564,7 @@
state.append(softkeyState);
state.append(fpsState);
- fWindow->setUIState(state);
+ fWindow->setUIState(state.toStyledString().c_str());
}
void Viewer::onUIStateChanged(const SkString& stateName, const SkString& stateValue) {
diff --git a/tools/viewer/Viewer.h b/tools/viewer/Viewer.h
index f121c17..24f68b4 100644
--- a/tools/viewer/Viewer.h
+++ b/tools/viewer/Viewer.h
@@ -13,6 +13,7 @@
#include "sk_app/Window.h"
#include "gm.h"
#include "SkAnimTimer.h"
+#include "SkJSONCPP.h"
#include "SkTouchGesture.h"
#include "Slide.h"