Subpixel in Viewer from -1 to 1.

Change the Subpixel positioning in Viewer from 0 to 1 to -1 to 1, with
the origin at the center of the drag area. This allows for observing
what happens when rolling over integer boundaries. Since it is no longer
simple to reset to the origin, closing the collapsing header resets the
drag point to the origin.

Change-Id: I88d4fd489c3bfb914fb843fa261d4097fef3671a
Reviewed-on: https://skia-review.googlesource.com/146643
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2018-08-09 15:18:46 -04:00 committed by Skia Commit-Bot
parent 7cd011ab44
commit 897dfa2530

View File

@ -189,7 +189,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
, fColorSpaceTransferFn(g2Dot2_TransferFn) , fColorSpaceTransferFn(g2Dot2_TransferFn)
, fZoomLevel(0.0f) , fZoomLevel(0.0f)
, fRotation(0.0f) , fRotation(0.0f)
, fOffset{0.0f, 0.0f} , fOffset{0.5f, 0.5f}
, fGestureDevice(GestureDevice::kNone) , fGestureDevice(GestureDevice::kNone)
, fPerspectiveMode(kPerspective_Off) , fPerspectiveMode(kPerspective_Off)
{ {
@ -911,7 +911,7 @@ SkMatrix Viewer::computePreTouchMatrix() {
SkMatrix m = fDefaultMatrix; SkMatrix m = fDefaultMatrix;
SkScalar zoomScale = (fZoomLevel < 0) ? SK_Scalar1 / (SK_Scalar1 - fZoomLevel) SkScalar zoomScale = (fZoomLevel < 0) ? SK_Scalar1 / (SK_Scalar1 - fZoomLevel)
: SK_Scalar1 + fZoomLevel; : SK_Scalar1 + fZoomLevel;
m.preTranslate(fOffset.x(), fOffset.y()); m.preTranslate((fOffset.x() - 0.5f) * 2.0f, (fOffset.y() - 0.5f) * 2.0f);
m.preScale(zoomScale, zoomScale); m.preScale(zoomScale, zoomScale);
const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions(); const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions();
@ -1525,6 +1525,10 @@ void Viewer::drawImGui() {
this->preTouchMatrixChanged(); this->preTouchMatrixChanged();
paramsChanged = true; paramsChanged = true;
} }
} else if (fOffset != SkVector{0.5f, 0.5f}) {
this->preTouchMatrixChanged();
paramsChanged = true;
fOffset = {0.5f, 0.5f};
} }
int perspectiveMode = static_cast<int>(fPerspectiveMode); int perspectiveMode = static_cast<int>(fPerspectiveMode);
if (ImGui::Combo("Perspective", &perspectiveMode, "Off\0Real\0Fake\0\0")) { if (ImGui::Combo("Perspective", &perspectiveMode, "Off\0Real\0Fake\0\0")) {