Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: tools/viewer/Viewer.cpp

Issue 2056343004: Add samples to Viewer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add samples.gypi Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/viewer/Slide.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Viewer.h" 8 #include "Viewer.h"
9 9
10 #include "GMSlide.h" 10 #include "GMSlide.h"
11 #include "ImageSlide.h" 11 #include "ImageSlide.h"
12 #include "SampleSlide.h"
12 #include "SKPSlide.h" 13 #include "SKPSlide.h"
13 14
14 #include "SkCanvas.h" 15 #include "SkCanvas.h"
15 #include "SkCommonFlags.h" 16 #include "SkCommonFlags.h"
16 #include "SkMetaData.h" 17 #include "SkMetaData.h"
17 #include "SkOSFile.h" 18 #include "SkOSFile.h"
18 #include "SkRandom.h" 19 #include "SkRandom.h"
19 #include "SkStream.h" 20 #include "SkStream.h"
20 21
21 using namespace sk_app; 22 using namespace sk_app;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 gms = gms->next(); 199 gms = gms->next();
199 } 200 }
200 201
201 // reverse array 202 // reverse array
202 for (int i = 0; i < fSlides.count()/2; ++i) { 203 for (int i = 0; i < fSlides.count()/2; ++i) {
203 sk_sp<Slide> temp = fSlides[i]; 204 sk_sp<Slide> temp = fSlides[i];
204 fSlides[i] = fSlides[fSlides.count() - i - 1]; 205 fSlides[i] = fSlides[fSlides.count() - i - 1];
205 fSlides[fSlides.count() - i - 1] = temp; 206 fSlides[fSlides.count() - i - 1] = temp;
206 } 207 }
207 208
209 // samples
210 const SkViewRegister* reg = SkViewRegister::Head();
211 while (reg) {
212 sk_sp<Slide> slide(new SampleSlide(reg->factory()));
213 fSlides.push_back(slide);
214 reg = reg->next();
215 }
216
208 // SKPs 217 // SKPs
209 for (int i = 0; i < FLAGS_skps.count(); i++) { 218 for (int i = 0; i < FLAGS_skps.count(); i++) {
210 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { 219 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) {
211 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, FLAGS_skps[i])) { 220 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, FLAGS_skps[i])) {
212 continue; 221 continue;
213 } 222 }
214 223
215 SkString path(FLAGS_skps[i]); 224 SkString path(FLAGS_skps[i]);
216 sk_sp<SKPSlide> slide(new SKPSlide(SkOSPath::Basename(path.c_str()), path)); 225 sk_sp<SKPSlide> slide(new SKPSlide(SkOSPath::Basename(path.c_str()), path));
217 if (slide) { 226 if (slide) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 title.append(kBackendTypeStrings[fBackendType]); 272 title.append(kBackendTypeStrings[fBackendType]);
264 fWindow->setTitle(title.c_str()); 273 fWindow->setTitle(title.c_str());
265 } 274 }
266 275
267 void Viewer::setupCurrentSlide(int previousSlide) { 276 void Viewer::setupCurrentSlide(int previousSlide) {
268 if (fCurrentSlide == previousSlide) { 277 if (fCurrentSlide == previousSlide) {
269 return; // no change; do nothing 278 return; // no change; do nothing
270 } 279 }
271 280
272 // prepare dimensions for image slides 281 // prepare dimensions for image slides
273 fSlides[fCurrentSlide]->load(); 282 fSlides[fCurrentSlide]->load(SkIntToScalar(fWindow->width()), SkIntToScalar( fWindow->height()));
274 283
275 fGesture.reset(); 284 fGesture.reset();
276 fDefaultMatrix.reset(); 285 fDefaultMatrix.reset();
277 fDefaultMatrixInv.reset(); 286 fDefaultMatrixInv.reset();
278 287
279 if (fWindow->supportsContentRect() && fWindow->scaleContentToFit()) { 288 if (fWindow->supportsContentRect() && fWindow->scaleContentToFit()) {
280 const SkRect contentRect = fWindow->getContentRect(); 289 const SkRect contentRect = fWindow->getContentRect();
281 const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions(); 290 const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions();
282 const SkRect slideBounds = SkRect::MakeIWH(slideSize.width(), slideSize. height()); 291 const SkRect slideBounds = SkRect::MakeIWH(slideSize.width(), slideSize. height());
283 if (contentRect.width() > 0 && contentRect.height() > 0) { 292 if (contentRect.width() > 0 && contentRect.height() > 0) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 bool newSplitScreen = stateValue.equals(kON); 568 bool newSplitScreen = stateValue.equals(kON);
560 if (newSplitScreen != fSplitScreen) { 569 if (newSplitScreen != fSplitScreen) {
561 fSplitScreen = newSplitScreen; 570 fSplitScreen = newSplitScreen;
562 fWindow->inval(); 571 fWindow->inval();
563 updateUIState(); 572 updateUIState();
564 } 573 }
565 } else { 574 } else {
566 SkDebugf("Unknown stateName: %s", stateName.c_str()); 575 SkDebugf("Unknown stateName: %s", stateName.c_str());
567 } 576 }
568 } 577 }
OLDNEW
« no previous file with comments | « tools/viewer/Slide.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698