| OLD | NEW |
| 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 "SampleSlide.h" | |
| 12 #include "SKPSlide.h" | 11 #include "SKPSlide.h" |
| 13 | 12 |
| 14 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
| 15 #include "SkCommonFlags.h" | 14 #include "SkCommonFlags.h" |
| 16 #include "SkOSFile.h" | 15 #include "SkOSFile.h" |
| 17 #include "SkRandom.h" | 16 #include "SkRandom.h" |
| 18 #include "SkStream.h" | 17 #include "SkStream.h" |
| 19 | 18 |
| 20 using namespace sk_app; | 19 using namespace sk_app; |
| 21 | 20 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 return viewer->onTouch(owner, state, x, y); | 35 return viewer->onTouch(owner, state, x, y); |
| 37 } | 36 } |
| 38 | 37 |
| 39 static void on_ui_state_changed_handler(const SkString& stateName, const SkStrin
g& stateValue, void* userData) { | 38 static void on_ui_state_changed_handler(const SkString& stateName, const SkStrin
g& stateValue, void* userData) { |
| 40 Viewer* viewer = reinterpret_cast<Viewer*>(userData); | 39 Viewer* viewer = reinterpret_cast<Viewer*>(userData); |
| 41 | 40 |
| 42 return viewer->onUIStateChanged(stateName, stateValue); | 41 return viewer->onUIStateChanged(stateName, stateValue); |
| 43 } | 42 } |
| 44 | 43 |
| 45 DEFINE_bool2(fullscreen, f, true, "Run fullscreen."); | 44 DEFINE_bool2(fullscreen, f, true, "Run fullscreen."); |
| 45 DEFINE_string(key, "", "Space-separated key/value pairs to add to JSON identifyi
ng this builder."); |
| 46 DEFINE_string2(match, m, nullptr, | 46 DEFINE_string2(match, m, nullptr, |
| 47 "[~][^]substring[$] [...] of bench name to run.\n" | 47 "[~][^]substring[$] [...] of bench name to run.\n" |
| 48 "Multiple matches may be separated by spaces.\n" | 48 "Multiple matches may be separated by spaces.\n" |
| 49 "~ causes a matching bench to always be skipped\n" | 49 "~ causes a matching bench to always be skipped\n" |
| 50 "^ requires the start of the bench to match\n" | 50 "^ requires the start of the bench to match\n" |
| 51 "$ requires the end of the bench to match\n" | 51 "$ requires the end of the bench to match\n" |
| 52 "^ and $ requires an exact match\n" | 52 "^ and $ requires an exact match\n" |
| 53 "If a bench does not match any list entry,\n" | 53 "If a bench does not match any list entry,\n" |
| 54 "it is skipped unless some list entry starts with ~"); | 54 "it is skipped unless some list entry starts with ~"); |
| 55 DEFINE_string(skps, "skps", "Directory to read skps from."); | 55 DEFINE_string(skps, "skps", "Directory to read skps from."); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 gms = gms->next(); | 189 gms = gms->next(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 // reverse array | 192 // reverse array |
| 193 for (int i = 0; i < fSlides.count()/2; ++i) { | 193 for (int i = 0; i < fSlides.count()/2; ++i) { |
| 194 sk_sp<Slide> temp = fSlides[i]; | 194 sk_sp<Slide> temp = fSlides[i]; |
| 195 fSlides[i] = fSlides[fSlides.count() - i - 1]; | 195 fSlides[i] = fSlides[fSlides.count() - i - 1]; |
| 196 fSlides[fSlides.count() - i - 1] = temp; | 196 fSlides[fSlides.count() - i - 1] = temp; |
| 197 } | 197 } |
| 198 | 198 |
| 199 // samples | |
| 200 const SkViewRegister* reg = SkViewRegister::Head(); | |
| 201 while (reg) { | |
| 202 sk_sp<Slide> slide(new SampleSlide(reg->factory())); | |
| 203 fSlides.push_back(slide); | |
| 204 reg = reg->next(); | |
| 205 } | |
| 206 | |
| 207 // SKPs | 199 // SKPs |
| 208 for (int i = 0; i < FLAGS_skps.count(); i++) { | 200 for (int i = 0; i < FLAGS_skps.count(); i++) { |
| 209 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { | 201 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { |
| 210 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, FLAGS_skps[i])) { | 202 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, FLAGS_skps[i])) { |
| 211 continue; | 203 continue; |
| 212 } | 204 } |
| 213 | 205 |
| 214 SkString path(FLAGS_skps[i]); | 206 SkString path(FLAGS_skps[i]); |
| 215 sk_sp<SKPSlide> slide(new SKPSlide(SkOSPath::Basename(path.c_str()),
path)); | 207 sk_sp<SKPSlide> slide(new SKPSlide(SkOSPath::Basename(path.c_str()),
path)); |
| 216 if (slide) { | 208 if (slide) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions(); | 265 const SkISize slideSize = fSlides[fCurrentSlide]->getDimensions(); |
| 274 SkRect windowRect = fWindow->getContentRect(); | 266 SkRect windowRect = fWindow->getContentRect(); |
| 275 fDefaultMatrixInv.mapRect(&windowRect); | 267 fDefaultMatrixInv.mapRect(&windowRect); |
| 276 fGesture.setTransLimit(SkRect::MakeWH(SkIntToScalar(slideSize.width()), | 268 fGesture.setTransLimit(SkRect::MakeWH(SkIntToScalar(slideSize.width()), |
| 277 SkIntToScalar(slideSize.height()))
, | 269 SkIntToScalar(slideSize.height()))
, |
| 278 windowRect); | 270 windowRect); |
| 279 } | 271 } |
| 280 | 272 |
| 281 this->updateTitle(); | 273 this->updateTitle(); |
| 282 this->updateUIState(); | 274 this->updateUIState(); |
| 283 fSlides[fCurrentSlide]->load(SkIntToScalar(fWindow->width()), SkIntToScalar(
fWindow->height())); | 275 fSlides[fCurrentSlide]->load(); |
| 284 if (previousSlide >= 0) { | 276 if (previousSlide >= 0) { |
| 285 fSlides[previousSlide]->unload(); | 277 fSlides[previousSlide]->unload(); |
| 286 } | 278 } |
| 287 fWindow->inval(); | 279 fWindow->inval(); |
| 288 } | 280 } |
| 289 | 281 |
| 290 #define MAX_ZOOM_LEVEL 8 | 282 #define MAX_ZOOM_LEVEL 8 |
| 291 #define MIN_ZOOM_LEVEL -8 | 283 #define MIN_ZOOM_LEVEL -8 |
| 292 | 284 |
| 293 void Viewer::changeZoomLevel(float delta) { | 285 void Viewer::changeZoomLevel(float delta) { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 } | 505 } |
| 514 } else if (stateName.equals(kSoftkeyStateName)) { | 506 } else if (stateName.equals(kSoftkeyStateName)) { |
| 515 if (!stateValue.equals(kSoftkeyHint)) { | 507 if (!stateValue.equals(kSoftkeyHint)) { |
| 516 fCommands.onSoftkey(stateValue); | 508 fCommands.onSoftkey(stateValue); |
| 517 updateUIState(); // This is still needed to reset the value to kSoft
keyHint | 509 updateUIState(); // This is still needed to reset the value to kSoft
keyHint |
| 518 } | 510 } |
| 519 } else { | 511 } else { |
| 520 SkDebugf("Unknown stateName: %s", stateName.c_str()); | 512 SkDebugf("Unknown stateName: %s", stateName.c_str()); |
| 521 } | 513 } |
| 522 } | 514 } |
| OLD | NEW |