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

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

Issue 2032623002: Implement OpenGL backend in Android viewer app (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Comments 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 | « no previous file | tools/viewer/sk_app/GLWindowContext.h » ('j') | 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"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 Json::Value allSlideNames(Json::arrayValue); 415 Json::Value allSlideNames(Json::arrayValue);
416 for(auto slide : fSlides) { 416 for(auto slide : fSlides) {
417 allSlideNames.append(Json::Value(slide->getName().c_str())); 417 allSlideNames.append(Json::Value(slide->getName().c_str()));
418 } 418 }
419 slideState[kOptions] = allSlideNames; 419 slideState[kOptions] = allSlideNames;
420 420
421 // This state is currently a demo for the one without options. 421 // This state is currently a demo for the one without options.
422 // We will be able to change the backend too. 422 // We will be able to change the backend too.
423 Json::Value backendState(Json::objectValue); 423 Json::Value backendState(Json::objectValue);
424 backendState[kName] = kBackendStateName; 424 backendState[kName] = kBackendStateName;
425 backendState[kValue] = fBackendType == sk_app::Window::kVulkan_BackendType ? 425 backendState[kValue] = kBackendTypeStrings[fBackendType];
426 "Vulkan" : "Other than Vulkan";
427 backendState[kOptions] = Json::Value(Json::arrayValue); 426 backendState[kOptions] = Json::Value(Json::arrayValue);
427 for(auto str : kBackendTypeStrings) {
428 backendState[kOptions].append(Json::Value(str));
429 }
428 430
429 Json::Value state(Json::arrayValue); 431 Json::Value state(Json::arrayValue);
430 state.append(slideState); 432 state.append(slideState);
431 state.append(backendState); 433 state.append(backendState);
432 434
433 fWindow->setUIState(state); 435 fWindow->setUIState(state);
434 } 436 }
435 437
436 void Viewer::onUIStateChanged(const SkString& stateName, const SkString& stateVa lue) { 438 void Viewer::onUIStateChanged(const SkString& stateName, const SkString& stateVa lue) {
437 // Currently, we only recognize the Slide state 439 // For those who will add more features to handle the state change in this f unction:
440 // After the change, please call updateUIState no notify the frontend (e.g., Android app).
441 // For example, after slide change, updateUIState is called inside setupCurr entSlide;
442 // after backend change, updateUIState is called in this function.
438 if (stateName.equals(kSlideStateName)) { 443 if (stateName.equals(kSlideStateName)) {
439 int previousSlide = fCurrentSlide; 444 int previousSlide = fCurrentSlide;
440 fCurrentSlide = 0; 445 fCurrentSlide = 0;
441 for(auto slide : fSlides) { 446 for(auto slide : fSlides) {
442 if (slide->getName().equals(stateValue)) { 447 if (slide->getName().equals(stateValue)) {
443 setupCurrentSlide(previousSlide); 448 setupCurrentSlide(previousSlide);
444 break; 449 break;
445 } 450 }
446 fCurrentSlide++; 451 fCurrentSlide++;
447 } 452 }
448 if (fCurrentSlide >= fSlides.count()) { 453 if (fCurrentSlide >= fSlides.count()) {
449 fCurrentSlide = previousSlide; 454 fCurrentSlide = previousSlide;
450 SkDebugf("Slide not found: %s", stateValue.c_str()); 455 SkDebugf("Slide not found: %s", stateValue.c_str());
451 } 456 }
457 } else if (stateName.equals(kBackendStateName)) {
458 for (int i = 0; i < sk_app::Window::kBackendTypeCount; i++) {
459 if (stateValue.equals(kBackendTypeStrings[i])) {
460 if (fBackendType != i) {
461 fBackendType = (sk_app::Window::BackendType)i;
462 fWindow->detach();
463 fWindow->attach(fBackendType, DisplayParams());
464 fWindow->inval();
465 updateTitle();
scroggo 2016/06/02 18:58:37 nit: this->updateTitle(); this->updateUIState();
466 updateUIState();
467 }
468 break;
469 }
470 }
452 } else { 471 } else {
453 SkDebugf("Unknown stateName: %s", stateName.c_str()); 472 SkDebugf("Unknown stateName: %s", stateName.c_str());
454 } 473 }
455 } 474 }
OLDNEW
« no previous file with comments | « no previous file | tools/viewer/sk_app/GLWindowContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698