aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/viewer
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2018-04-17 11:16:32 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-17 16:10:14 +0000
commita580fb3f9ec5c177e4e8f827f6aa14239f984121 (patch)
tree744abe49ed4ee2590f4ff9cd83d81e7791ecfeae /tools/viewer
parent3101f65d6b415618fc052f30b15b59731ee95e5a (diff)
Add paint flags to viewer GUI.
Overriding bits of the paint was added with keyboard bindings but without being reflected in the GUI. This adds these flags to the GUI. Change-Id: I633801fb776248952afe7cbe8857676ef8b57135 Reviewed-on: https://skia-review.googlesource.com/121796 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'tools/viewer')
-rw-r--r--tools/viewer/Viewer.cpp115
-rw-r--r--tools/viewer/Viewer.h9
2 files changed, 113 insertions, 11 deletions
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 7695aab05a..3172244bf7 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -405,10 +405,6 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
fPaintOverrides.fAntiAlias = SkPaintFields::AntiAliasState::Alias;
fPaintOverrides.fFlags |= SkPaint::kAntiAlias_Flag;
fPaint.setAntiAlias(false);
- fPaintOverrides.fOriginalSkUseAnalyticAA = gSkUseAnalyticAA;
- fPaintOverrides.fOriginalSkForceAnalyticAA = gSkForceAnalyticAA;
- fPaintOverrides.fOriginalSkUseDeltaAA = gSkUseDeltaAA;
- fPaintOverrides.fOriginalSkForceDeltaAA = gSkForceDeltaAA;
gSkUseAnalyticAA = gSkForceAnalyticAA = false;
gSkUseDeltaAA = gSkForceDeltaAA = false;
} else {
@@ -416,24 +412,30 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
switch (fPaintOverrides.fAntiAlias) {
case SkPaintFields::AntiAliasState::Alias:
fPaintOverrides.fAntiAlias = SkPaintFields::AntiAliasState::Normal;
+ gSkUseAnalyticAA = gSkForceAnalyticAA = false;
+ gSkUseDeltaAA = gSkForceDeltaAA = false;
break;
case SkPaintFields::AntiAliasState::Normal:
fPaintOverrides.fAntiAlias = SkPaintFields::AntiAliasState::AnalyticAAEnabled;
- gSkUseDeltaAA = gSkForceDeltaAA = false;
gSkUseAnalyticAA = true;
+ gSkForceAnalyticAA = false;
+ gSkUseDeltaAA = gSkForceDeltaAA = false;
break;
case SkPaintFields::AntiAliasState::AnalyticAAEnabled:
fPaintOverrides.fAntiAlias = SkPaintFields::AntiAliasState::AnalyticAAForced;
- gSkForceAnalyticAA = true;
+ gSkUseAnalyticAA = gSkForceAnalyticAA = true;
+ gSkUseDeltaAA = gSkForceDeltaAA = false;
break;
case SkPaintFields::AntiAliasState::AnalyticAAForced:
fPaintOverrides.fAntiAlias = SkPaintFields::AntiAliasState::DeltaAAEnabled;
gSkUseAnalyticAA = gSkForceAnalyticAA = false;
gSkUseDeltaAA = true;
+ gSkForceDeltaAA = false;
break;
case SkPaintFields::AntiAliasState::DeltaAAEnabled:
fPaintOverrides.fAntiAlias = SkPaintFields::AntiAliasState::DeltaAAForced;
- gSkForceDeltaAA = true;
+ gSkUseAnalyticAA = gSkForceAnalyticAA = false;
+ gSkUseDeltaAA = gSkForceDeltaAA = true;
break;
case SkPaintFields::AntiAliasState::DeltaAAForced:
fPaintOverrides.fAntiAlias = SkPaintFields::AntiAliasState::Alias;
@@ -1344,6 +1346,105 @@ void Viewer::drawImGui() {
ImGui::SetNextTreeNodeOpen(true);
}
+ if (ImGui::CollapsingHeader("Paint")) {
+ int hintingIdx = 0;
+ if (fPaintOverrides.fHinting) {
+ hintingIdx = fPaint.getHinting() + 1;
+ }
+ if (ImGui::Combo("Hinting", &hintingIdx,
+ "Default\0None\0Slight\0Normal\0Full\0\0"))
+ {
+ if (hintingIdx == 0) {
+ fPaintOverrides.fHinting = false;
+ fPaint.setHinting(SkPaint::kNo_Hinting);
+ } else {
+ fPaintOverrides.fHinting = true;
+ SkPaint::Hinting hinting = SkTo<SkPaint::Hinting>(hintingIdx - 1);
+ fPaint.setHinting(hinting);
+ }
+ paramsChanged = true;
+ }
+
+ int aliasIdx = 0;
+ if (fPaintOverrides.fFlags & SkPaint::kAntiAlias_Flag) {
+ aliasIdx = SkTo<int>(fPaintOverrides.fAntiAlias) + 1;
+ }
+ if (ImGui::Combo("Anti-Alias", &aliasIdx,
+ "Default\0Alias\0Normal\0AnalyticAAEnabled\0AnalyticAAForced\0"
+ "DeltaAAEnabled\0DeltaAAForced\0\0"))
+ {
+ gSkUseAnalyticAA = fPaintOverrides.fOriginalSkUseAnalyticAA;
+ gSkForceAnalyticAA = fPaintOverrides.fOriginalSkForceAnalyticAA;
+ gSkUseDeltaAA = fPaintOverrides.fOriginalSkUseDeltaAA;
+ gSkForceDeltaAA = fPaintOverrides.fOriginalSkForceDeltaAA;
+ if (aliasIdx == 0) {
+ fPaintOverrides.fAntiAlias = SkPaintFields::AntiAliasState::Alias;
+ fPaintOverrides.fFlags &= ~SkPaint::kAntiAlias_Flag;
+ } else {
+ fPaintOverrides.fFlags |= SkPaint::kAntiAlias_Flag;
+ fPaintOverrides.fAntiAlias =SkTo<SkPaintFields::AntiAliasState>(aliasIdx-1);
+ fPaint.setAntiAlias(aliasIdx > 1);
+ switch (fPaintOverrides.fAntiAlias) {
+ case SkPaintFields::AntiAliasState::Alias:
+ break;
+ case SkPaintFields::AntiAliasState::Normal:
+ break;
+ case SkPaintFields::AntiAliasState::AnalyticAAEnabled:
+ gSkUseAnalyticAA = true;
+ gSkForceAnalyticAA = false;
+ gSkUseDeltaAA = gSkForceDeltaAA = false;
+ break;
+ case SkPaintFields::AntiAliasState::AnalyticAAForced:
+ gSkUseAnalyticAA = gSkForceAnalyticAA = true;
+ gSkUseDeltaAA = gSkForceDeltaAA = false;
+ break;
+ case SkPaintFields::AntiAliasState::DeltaAAEnabled:
+ gSkUseAnalyticAA = gSkForceAnalyticAA = false;
+ gSkUseDeltaAA = true;
+ gSkForceDeltaAA = false;
+ break;
+ case SkPaintFields::AntiAliasState::DeltaAAForced:
+ gSkUseAnalyticAA = gSkForceAnalyticAA = false;
+ gSkUseDeltaAA = gSkForceDeltaAA = true;
+ break;
+ }
+ }
+ paramsChanged = true;
+ }
+
+ int subpixelAAIdx = 0;
+ if (fPaintOverrides.fFlags & SkPaint::kLCDRenderText_Flag) {
+ subpixelAAIdx = fPaint.isLCDRenderText() ? 2 : 1;
+ }
+ if (ImGui::Combo("Subpixel Anti-Alias", &subpixelAAIdx,
+ "Default\0lcd\0LCD\0\0"))
+ {
+ if (subpixelAAIdx == 0) {
+ fPaintOverrides.fFlags &= ~SkPaint::kLCDRenderText_Flag;
+ } else {
+ fPaintOverrides.fFlags |= SkPaint::kLCDRenderText_Flag;
+ fPaint.setLCDRenderText(subpixelAAIdx == 2);
+ }
+ paramsChanged = true;
+ }
+
+ int subpixelPositionIdx = 0;
+ if (fPaintOverrides.fFlags & SkPaint::kSubpixelText_Flag) {
+ subpixelPositionIdx = fPaint.isSubpixelText() ? 2 : 1;
+ }
+ if (ImGui::Combo("Subpixel Position Glyphs", &subpixelPositionIdx,
+ "Default\0Pixel Glyphs\0Subpixel Glyphs\0\0"))
+ {
+ if (subpixelPositionIdx == 0) {
+ fPaintOverrides.fFlags &= ~SkPaint::kSubpixelText_Flag;
+ } else {
+ fPaintOverrides.fFlags |= SkPaint::kSubpixelText_Flag;
+ fPaint.setSubpixelText(subpixelPositionIdx == 2);
+ }
+ paramsChanged = true;
+ }
+ }
+
if (ImGui::CollapsingHeader("Slide")) {
static ImGuiTextFilter filter;
static ImVector<const char*> filteredSlideNames;
diff --git a/tools/viewer/Viewer.h b/tools/viewer/Viewer.h
index 2a8f12b466..760e3b8520 100644
--- a/tools/viewer/Viewer.h
+++ b/tools/viewer/Viewer.h
@@ -16,6 +16,7 @@
#include "SkAnimTimer.h"
#include "SkExecutor.h"
#include "SkJSONCPP.h"
+#include "SkScan.h"
#include "SkTouchGesture.h"
#include "Slide.h"
#include "StatsLayer.h"
@@ -63,10 +64,10 @@ public:
DeltaAAEnabled,
DeltaAAForced,
} fAntiAlias = AntiAliasState::Alias;
- bool fOriginalSkUseAnalyticAA = false;
- bool fOriginalSkForceAnalyticAA = false;
- bool fOriginalSkUseDeltaAA = false;
- bool fOriginalSkForceDeltaAA = false;
+ const bool fOriginalSkUseAnalyticAA = gSkUseAnalyticAA;
+ const bool fOriginalSkForceAnalyticAA = gSkForceAnalyticAA;
+ const bool fOriginalSkUseDeltaAA = gSkUseDeltaAA;
+ const bool fOriginalSkForceDeltaAA = gSkForceDeltaAA;
bool fTextAlign = false;
bool fCapType = false;