aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/viewer/Viewer.cpp
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2018-01-22 13:39:30 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-22 19:24:47 +0000
commit0848fb0b3e3f465ec0de01ed7e0028cda32aa948 (patch)
tree7e1b05d254ff10af72a26f10cd38459e205ffe4c /tools/viewer/Viewer.cpp
parent4c11945a971f18177aa494b773b24d88a942bba6 (diff)
Fix startup for SampleSlide
When we start up Viewer with a SampleSlide as the first slide, nothing gets rendered because SampleSlide depends on the backend being initialized before setting its dimensions. This pushes the first slide's initialization after the backend creation. Change-Id: I8f83fe7b3973c40234104f1a83c0a60750694311 Reviewed-on: https://skia-review.googlesource.com/98161 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'tools/viewer/Viewer.cpp')
-rw-r--r--tools/viewer/Viewer.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 8db541c8fd..198f9baab6 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -380,7 +380,6 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
// set up slides
this->initSlides();
- this->setCurrentSlide(this->startupSlide());
if (FLAGS_list) {
this->listNames();
}
@@ -395,6 +394,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
fImGuiGamutPaint.setFilterQuality(kLow_SkFilterQuality);
fWindow->attach(backend_type_for_window(fBackendType));
+ this->setCurrentSlide(this->startupSlide());
}
void Viewer::initSlides() {
@@ -616,30 +616,32 @@ void Viewer::setCurrentSlide(int slide) {
}
void Viewer::setupCurrentSlide() {
- // prepare dimensions for image slides
- fGesture.resetTouchState();
- fDefaultMatrix.reset();
-
- const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions();
- const SkRect slideBounds = SkRect::MakeIWH(slideSize.width(), slideSize.height());
- const SkRect windowRect = SkRect::MakeIWH(fWindow->width(), fWindow->height());
-
- // Start with a matrix that scales the slide to the available screen space
- if (fWindow->scaleContentToFit()) {
- if (windowRect.width() > 0 && windowRect.height() > 0) {
- fDefaultMatrix.setRectToRect(slideBounds, windowRect, SkMatrix::kStart_ScaleToFit);
+ if (fCurrentSlide >= 0) {
+ // prepare dimensions for image slides
+ fGesture.resetTouchState();
+ fDefaultMatrix.reset();
+
+ const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions();
+ const SkRect slideBounds = SkRect::MakeIWH(slideSize.width(), slideSize.height());
+ const SkRect windowRect = SkRect::MakeIWH(fWindow->width(), fWindow->height());
+
+ // Start with a matrix that scales the slide to the available screen space
+ if (fWindow->scaleContentToFit()) {
+ if (windowRect.width() > 0 && windowRect.height() > 0) {
+ fDefaultMatrix.setRectToRect(slideBounds, windowRect, SkMatrix::kStart_ScaleToFit);
+ }
}
- }
- // Prevent the user from dragging content so far outside the window they can't find it again
- fGesture.setTransLimit(slideBounds, windowRect, fDefaultMatrix);
+ // Prevent the user from dragging content so far outside the window they can't find it again
+ fGesture.setTransLimit(slideBounds, windowRect, fDefaultMatrix);
- this->updateTitle();
- this->updateUIState();
+ this->updateTitle();
+ this->updateUIState();
- fStatsLayer.resetMeasurements();
+ fStatsLayer.resetMeasurements();
- fWindow->inval();
+ fWindow->inval();
+ }
}
#define MAX_ZOOM_LEVEL 8