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

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: Clean 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
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 // After the change, please call updateUIState no notify the frontend (e.g., Android app).
scroggo 2016/06/02 18:25:16 to* notify? Also, who is this comment for? The ca
liyuqian 2016/06/02 18:47:13 This comment is for those who will add more featur
440 // For slide change, updateUIState is called inside setupCurrentSlide.
438 if (stateName.equals(kSlideStateName)) { 441 if (stateName.equals(kSlideStateName)) {
439 int previousSlide = fCurrentSlide; 442 int previousSlide = fCurrentSlide;
440 fCurrentSlide = 0; 443 fCurrentSlide = 0;
441 for(auto slide : fSlides) { 444 for(auto slide : fSlides) {
442 if (slide->getName().equals(stateValue)) { 445 if (slide->getName().equals(stateValue)) {
443 setupCurrentSlide(previousSlide); 446 setupCurrentSlide(previousSlide);
444 break; 447 break;
445 } 448 }
446 fCurrentSlide++; 449 fCurrentSlide++;
447 } 450 }
448 if (fCurrentSlide >= fSlides.count()) { 451 if (fCurrentSlide >= fSlides.count()) {
449 fCurrentSlide = previousSlide; 452 fCurrentSlide = previousSlide;
450 SkDebugf("Slide not found: %s", stateValue.c_str()); 453 SkDebugf("Slide not found: %s", stateValue.c_str());
451 } 454 }
455 } else if (stateName.equals(kBackendStateName)) {
456 for(int i=0; i<sk_app::Window::kBackendTypeCount; i++) {
scroggo 2016/06/02 18:25:16 nit: Typically we put spaces around operators: fo
liyuqian 2016/06/02 18:47:13 Done.
457 if (stateValue.equals(kBackendTypeStrings[i])) {
458 if (fBackendType != i) {
459 fBackendType = (sk_app::Window::BackendType)i;
460 fWindow->detach();
461 fWindow->attach(fBackendType, DisplayParams());
462 fWindow->inval();
463 updateTitle();
464 updateUIState();
465 }
466 break;
467 }
468 }
452 } else { 469 } else {
453 SkDebugf("Unknown stateName: %s", stateName.c_str()); 470 SkDebugf("Unknown stateName: %s", stateName.c_str());
454 } 471 }
455 } 472 }
OLDNEW
« no previous file with comments | « no previous file | tools/viewer/sk_app/GLWindowContext.h » ('j') | tools/viewer/sk_app/android/GLWindowContext_android.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698