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

Side by Side Diff: trunk/debugger/SkDebugger.cpp

Issue 12449006: NaCl Debugger: Implement overview and filters, cleanup (Closed) Base URL: http://skia.googlecode.com/svn/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« trunk/debugger/SkDebugger.h ('K') | « trunk/debugger/SkDebugger.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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkDebugger.h" 9 #include "SkDebugger.h"
10 #include "SkString.h"
11
10 12
11 SkDebugger::SkDebugger() { 13 SkDebugger::SkDebugger() {
12 // Create this some other dynamic way? 14 // Create this some other dynamic way?
13 fDebugCanvas = new SkDebugCanvas(100, 100); 15 fDebugCanvas = new SkDebugCanvas(100, 100);
14 fPicture = NULL; 16 fPicture = NULL;
15 fPictureWidth = 0; 17 fPictureWidth = 0;
16 fPictureHeight = 0; 18 fPictureHeight = 0;
17 fIndex = 0; 19 fIndex = 0;
18 } 20 }
19 21
(...skipping 16 matching lines...) Expand all
36 38
37 SkPicture* SkDebugger::copyPicture() { 39 SkPicture* SkDebugger::copyPicture() {
38 // We can't just call clone here since we want to removed the "deleted" 40 // We can't just call clone here since we want to removed the "deleted"
39 // commands. Playing back will strip those out. 41 // commands. Playing back will strip those out.
40 SkPicture* newPicture = new SkPicture; 42 SkPicture* newPicture = new SkPicture;
41 SkCanvas* canvas = newPicture->beginRecording(fPictureWidth, fPictureHeight) ; 43 SkCanvas* canvas = newPicture->beginRecording(fPictureWidth, fPictureHeight) ;
42 fDebugCanvas->draw(canvas); 44 fDebugCanvas->draw(canvas);
43 newPicture->endRecording(); 45 newPicture->endRecording();
44 return newPicture; 46 return newPicture;
45 } 47 }
48
49 void SkDebugger::getOverviewText(const SkTDArray<double>* typeTimes,
50 double totTime,
robertphillips 2013/03/07 22:19:11 SkString*
borenet 2013/03/08 13:00:26 Done.
51 SkString& overview) {
robertphillips 2013/03/07 22:19:11 this->?
borenet 2013/03/08 13:00:26 Done.
52 const SkTDArray<SkDrawCommand*>& commands = getDrawCommands();
53
borenet 2013/03/07 21:38:08 The below is copy/pasted and minimally modified.
54 SkTDArray<int> counts;
55 counts.setCount(LAST_DRAWTYPE_ENUM+1);
56 for (int i = 0; i < LAST_DRAWTYPE_ENUM+1; ++i) {
57 counts[i] = 0;
58 }
59
60 for (int i = 0; i < commands.count(); i++) {
61 counts[commands[i]->getType()]++;
62 }
63
64 overview.reset();
65 int total = 0;
66 #ifdef SK_DEBUG
67 double totPercent = 0, tempSum = 0;
68 #endif
69 for (int i = 0; i < LAST_DRAWTYPE_ENUM+1; ++i) {
70 if (0 == counts[i]) {
71 // if there were no commands of this type then they should've consum ed no time
72 SkASSERT(NULL == typeTimes || 0.0 == (*typeTimes)[i]);
73 continue;
74 }
75
76 overview.append(SkDrawCommand::GetCommandString((DrawType) i));
77 overview.append(": ");
78 overview.appendScalar(counts[i]);
79 if (NULL != typeTimes) {
80 overview.append(" - ");
81 overview.appendScalar((*typeTimes)[i]);
82 overview.append("ms");
83 overview.append(" - ");
84 double percent = 100.0*(*typeTimes)[i]/totTime;
85 overview.appendScalar(percent);
86 overview.append("%");
87 #ifdef SK_DEBUG
88 totPercent += percent;
89 tempSum += (*typeTimes)[i];
90 #endif
91 }
92 overview.append("<br/>");
93 total += counts[i];
94 }
95 #ifdef SK_DEBUG
96 if (NULL != typeTimes) {
97 SkASSERT(SkScalarNearlyEqual(totPercent, 100.0));
98 SkASSERT(SkScalarNearlyEqual(tempSum, totTime));
99 }
100 #endif
101
102 if (totTime > 0.0) {
103 overview.append("Total Time: ");
104 overview.appendScalar(totTime);
105 overview.append("ms");
106 #ifdef SK_DEBUG
107 overview.append(" ");
108 overview.appendScalar(totPercent);
109 overview.append("% ");
110 #endif
111 overview.append("<br/>");
112 }
113
114 SkString totalStr;
115 totalStr.append("Total Draw Commands: ");
116 totalStr.appendScalar(total);
117 totalStr.append("<br/>");
118 overview.insert(0, totalStr);
119
120 overview.append("<br/>");
121 overview.append("SkPicture Width: ");
robertphillips 2013/03/07 22:19:11 Remove this comment? It doesn't seem to add anythi
borenet 2013/03/08 13:00:26 Done.
122 // NOTE(chudy): This is where we can pull out the SkPictures width.
123 overview.appendScalar(pictureWidth());
124 overview.append("px<br/>");
125 overview.append("SkPicture Height: ");
126 overview.appendScalar(pictureHeight());
127 overview.append("px");
128 }
OLDNEW
« trunk/debugger/SkDebugger.h ('K') | « trunk/debugger/SkDebugger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698