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

Side by Side Diff: tools/VisualBench/VisualDebugModule.cpp

Issue 2018603003: Remove VisualBench and its Android implementation. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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/VisualBench/VisualDebugModule.h ('k') | tools/VisualBench/VisualFlags.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "VisualDebugModule.h"
9
10 #include "SkCanvas.h"
11
12 VisualDebugModule::VisualDebugModule(VisualBench* owner)
13 : fState(kInit_State)
14 , fIndex(0)
15 , fOwner(owner) {
16 // VisualDebugModule only really makes sense for SKPs
17 fBenchmarkStream.reset(new VisualBenchmarkStream(owner->getSurfaceProps(), t rue));
18 }
19
20 bool VisualDebugModule::advanceIfNecessary(SkCanvas* canvas) {
21 Benchmark* benchmark = fBenchmarkStream->current();
22 switch (fState) {
23 case kInit_State: {
24 // setup new benchmark
25 benchmark->delayedSetup();
26 fOwner->clear(canvas, SK_ColorWHITE, 3);
27 benchmark->preTimingHooks(canvas);
28
29 // reset debug canvas
30 SkIPoint size = benchmark->getSize();
31 fDebugCanvas.reset(new SkDebugCanvas(size.fX, size.fY));
32
33 // pour benchmark into canvas
34 benchmark->draw(1, fDebugCanvas);
35 fIndex = fDebugCanvas->getSize() - 1;
36 fState = kPlay_State;
37 break;
38 }
39 case kPlay_State: break;
40 case kNext_State:
41 // cleanup after the last SKP
42 benchmark->postTimingHooks(canvas);
43 fOwner->reset();
44 if (!fBenchmarkStream->next()) {
45 SkDebugf("Exiting VisualBench successfully\n");
46 fOwner->closeWindow();
47 return false;
48 }
49 fState = kInit_State;
50 break;
51 }
52 return true;
53 }
54
55 void VisualDebugModule::draw(SkCanvas* canvas) {
56 if (!fBenchmarkStream->current() || !this->advanceIfNecessary(canvas)) {
57 return;
58 }
59
60 fDebugCanvas->drawTo(canvas, fIndex);
61 canvas->flush();
62 fOwner->present();
63 }
64
65 bool VisualDebugModule::onHandleChar(SkUnichar c) {
66 switch (c) {
67 case ' ': fState = kNext_State; break;
68 case 'a': fIndex = (fIndex + 1) % (fDebugCanvas->getSize() - 1); break;
69 case 's': fIndex = fIndex <= 0 ? fDebugCanvas->getSize() - 1 : fIndex - 1; break;
70 default: break;
71 }
72
73 return true;
74 }
OLDNEW
« no previous file with comments | « tools/VisualBench/VisualDebugModule.h ('k') | tools/VisualBench/VisualFlags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698