| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkDebuggerGUI.h" | 8 #include "SkDebuggerGUI.h" |
| 9 #include "SkForceLinking.h" | |
| 10 #include <QListWidgetItem> | |
| 11 #include "PictureRenderer.h" | 9 #include "PictureRenderer.h" |
| 10 #include "SkPictureData.h" |
| 12 #include "SkPicturePlayback.h" | 11 #include "SkPicturePlayback.h" |
| 13 #include "SkPictureRecord.h" | 12 #include "SkPictureRecord.h" |
| 14 #include "SkPictureData.h" | 13 #include <QListWidgetItem> |
| 14 #include <QtGui> |
| 15 | 15 |
| 16 #if defined(SK_BUILD_FOR_WIN32) | 16 #if defined(SK_BUILD_FOR_WIN32) |
| 17 #include "SysTimer_windows.h" | 17 #include "SysTimer_windows.h" |
| 18 #elif defined(SK_BUILD_FOR_MAC) | 18 #elif defined(SK_BUILD_FOR_MAC) |
| 19 #include "SysTimer_mach.h" | 19 #include "SysTimer_mach.h" |
| 20 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) | 20 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) |
| 21 #include "SysTimer_posix.h" | 21 #include "SysTimer_posix.h" |
| 22 #else | 22 #else |
| 23 #include "SysTimer_c.h" | 23 #include "SysTimer_c.h" |
| 24 #endif | 24 #endif |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 | 212 |
| 213 void SkDebuggerGUI::actionClearDeletes() { | 213 void SkDebuggerGUI::actionClearDeletes() { |
| 214 for (int row = 0; row < fListWidget.count(); row++) { | 214 for (int row = 0; row < fListWidget.count(); row++) { |
| 215 QListWidgetItem* item = fListWidget.item(row); | 215 QListWidgetItem* item = fListWidget.item(row); |
| 216 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); | 216 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); |
| 217 fDebugger.setCommandVisible(row, true); | 217 fDebugger.setCommandVisible(row, true); |
| 218 fSkipCommands[row] = false; | 218 fSkipCommands[row] = false; |
| 219 } | 219 } |
| 220 if (this->isPaused()) { | 220 this->updateImage(); |
| 221 fCanvasWidget.drawTo(fPausedRow); | |
| 222 } else { | |
| 223 fCanvasWidget.drawTo(fListWidget.currentRow()); | |
| 224 } | |
| 225 } | 221 } |
| 226 | 222 |
| 227 void SkDebuggerGUI::actionClose() { | 223 void SkDebuggerGUI::actionClose() { |
| 228 this->close(); | 224 this->close(); |
| 229 } | 225 } |
| 230 | 226 |
| 231 void SkDebuggerGUI::actionDelete() { | 227 void SkDebuggerGUI::actionDelete() { |
| 232 | 228 |
| 233 for (int row = 0; row < fListWidget.count(); ++row) { | 229 for (int row = 0; row < fListWidget.count(); ++row) { |
| 234 QListWidgetItem* item = fListWidget.item(row); | 230 QListWidgetItem* item = fListWidget.item(row); |
| 235 | 231 |
| 236 if (!item->isSelected()) { | 232 if (!item->isSelected()) { |
| 237 continue; | 233 continue; |
| 238 } | 234 } |
| 239 | 235 |
| 240 if (fDebugger.isCommandVisible(row)) { | 236 if (fDebugger.isCommandVisible(row)) { |
| 241 item->setData(Qt::UserRole + 2, QPixmap(":/delete.png")); | 237 item->setData(Qt::UserRole + 2, QPixmap(":/delete.png")); |
| 242 fDebugger.setCommandVisible(row, false); | 238 fDebugger.setCommandVisible(row, false); |
| 243 fSkipCommands[row] = true; | 239 fSkipCommands[row] = true; |
| 244 } else { | 240 } else { |
| 245 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); | 241 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); |
| 246 fDebugger.setCommandVisible(row, true); | 242 fDebugger.setCommandVisible(row, true); |
| 247 fSkipCommands[row] = false; | 243 fSkipCommands[row] = false; |
| 248 } | 244 } |
| 249 } | 245 } |
| 250 | 246 |
| 251 int currentRow = fListWidget.currentRow(); | 247 this->updateImage(); |
| 252 | |
| 253 if (this->isPaused()) { | |
| 254 fCanvasWidget.drawTo(fPausedRow); | |
| 255 } else { | |
| 256 fCanvasWidget.drawTo(currentRow); | |
| 257 } | |
| 258 } | 248 } |
| 259 | 249 |
| 260 #if SK_SUPPORT_GPU | 250 #if SK_SUPPORT_GPU |
| 261 void SkDebuggerGUI::actionGLSettingsChanged() { | 251 void SkDebuggerGUI::actionGLSettingsChanged() { |
| 262 bool isToggled = fSettingsWidget.isGLActive(); | 252 bool isToggled = fSettingsWidget.isGLActive(); |
| 263 if (isToggled) { | 253 if (isToggled) { |
| 264 fCanvasWidget.setGLSampleCount(fSettingsWidget.getGLSampleCount()); | 254 fCanvasWidget.setGLSampleCount(fSettingsWidget.getGLSampleCount()); |
| 265 } | 255 } |
| 266 fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggle
d); | 256 fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggle
d); |
| 267 } | 257 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 284 return; | 274 return; |
| 285 } | 275 } |
| 286 } | 276 } |
| 287 fListWidget.setCurrentRow(fListWidget.count() - 1); | 277 fListWidget.setCurrentRow(fListWidget.count() - 1); |
| 288 } | 278 } |
| 289 | 279 |
| 290 void SkDebuggerGUI::actionRasterSettingsChanged() { | 280 void SkDebuggerGUI::actionRasterSettingsChanged() { |
| 291 fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType, | 281 fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType, |
| 292 !fSettingsWidget.isRasterEnabled()); | 282 !fSettingsWidget.isRasterEnabled()); |
| 293 fDebugger.setOverdrawViz(fSettingsWidget.isOverdrawVizEnabled()); | 283 fDebugger.setOverdrawViz(fSettingsWidget.isOverdrawVizEnabled()); |
| 294 fCanvasWidget.update(); | 284 this->updateImage(); |
| 295 } | 285 } |
| 296 | 286 |
| 297 void SkDebuggerGUI::actionVisualizationsChanged() { | 287 void SkDebuggerGUI::actionVisualizationsChanged() { |
| 298 fDebugger.setMegaViz(fSettingsWidget.isMegaVizEnabled()); | 288 fDebugger.setMegaViz(fSettingsWidget.isMegaVizEnabled()); |
| 299 fDebugger.setPathOps(fSettingsWidget.isPathOpsEnabled()); | 289 fDebugger.setPathOps(fSettingsWidget.isPathOpsEnabled()); |
| 300 fDebugger.highlightCurrentCommand(fSettingsWidget.isVisibilityFilterEnabled(
)); | 290 fDebugger.highlightCurrentCommand(fSettingsWidget.isVisibilityFilterEnabled(
)); |
| 301 fCanvasWidget.drawTo(fListWidget.currentRow()); | 291 this->updateImage(); |
| 302 } | 292 } |
| 303 | 293 |
| 304 void SkDebuggerGUI::actionTextureFilter() { | 294 void SkDebuggerGUI::actionTextureFilter() { |
| 305 SkPaint::FilterLevel level; | 295 SkPaint::FilterLevel level; |
| 306 bool enabled = fSettingsWidget.getFilterOverride(&level); | 296 bool enabled = fSettingsWidget.getFilterOverride(&level); |
| 307 fDebugger.setTexFilterOverride(enabled, level); | 297 fDebugger.setTexFilterOverride(enabled, level); |
| 308 fCanvasWidget.update(); | 298 fCanvasWidget.update(); |
| 309 } | 299 } |
| 310 | 300 |
| 311 void SkDebuggerGUI::actionRewind() { | 301 void SkDebuggerGUI::actionRewind() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 void SkDebuggerGUI::actionStepForward() { | 340 void SkDebuggerGUI::actionStepForward() { |
| 351 int currentRow = fListWidget.currentRow(); | 341 int currentRow = fListWidget.currentRow(); |
| 352 QString curRow = QString::number(currentRow); | 342 QString curRow = QString::number(currentRow); |
| 353 QString curCount = QString::number(fListWidget.count()); | 343 QString curCount = QString::number(fListWidget.count()); |
| 354 if (currentRow < fListWidget.count() - 1) { | 344 if (currentRow < fListWidget.count() - 1) { |
| 355 fListWidget.setCurrentRow(currentRow + 1); | 345 fListWidget.setCurrentRow(currentRow + 1); |
| 356 } | 346 } |
| 357 } | 347 } |
| 358 | 348 |
| 359 void SkDebuggerGUI::drawComplete() { | 349 void SkDebuggerGUI::drawComplete() { |
| 350 SkString clipStack; |
| 351 fDebugger.getClipStackText(&clipStack); |
| 352 fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_Ta
bType); |
| 353 |
| 360 fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix()); | 354 fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix()); |
| 361 fInspectorWidget.setClip(fDebugger.getCurrentClip()); | 355 fInspectorWidget.setClip(fDebugger.getCurrentClip()); |
| 362 } | 356 } |
| 363 | 357 |
| 364 void SkDebuggerGUI::saveToFile(const SkString& filename) { | 358 void SkDebuggerGUI::saveToFile(const SkString& filename) { |
| 365 SkFILEWStream file(filename.c_str()); | 359 SkFILEWStream file(filename.c_str()); |
| 366 SkAutoTUnref<SkPicture> copy(fDebugger.copyPicture()); | 360 SkAutoTUnref<SkPicture> copy(fDebugger.copyPicture()); |
| 367 | 361 |
| 368 copy->serialize(&file); | 362 copy->serialize(&file); |
| 369 } | 363 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 391 if (!filename.isEmpty()) { | 385 if (!filename.isEmpty()) { |
| 392 QFileInfo pathInfo(filename); | 386 QFileInfo pathInfo(filename); |
| 393 loadPicture(SkString(filename.toAscii().data())); | 387 loadPicture(SkString(filename.toAscii().data())); |
| 394 setupDirectoryWidget(pathInfo.path()); | 388 setupDirectoryWidget(pathInfo.path()); |
| 395 } | 389 } |
| 396 fDirectoryWidgetActive = true; | 390 fDirectoryWidgetActive = true; |
| 397 } | 391 } |
| 398 | 392 |
| 399 void SkDebuggerGUI::pauseDrawing(bool isPaused) { | 393 void SkDebuggerGUI::pauseDrawing(bool isPaused) { |
| 400 fPausedRow = fListWidget.currentRow(); | 394 fPausedRow = fListWidget.currentRow(); |
| 401 if (!fLoading) { | 395 this->updateDrawCommandInfo(); |
| 402 fCanvasWidget.drawTo(fPausedRow); | |
| 403 } | |
| 404 } | 396 } |
| 405 | 397 |
| 406 void SkDebuggerGUI::updateDrawCommandInfo() { | 398 void SkDebuggerGUI::updateDrawCommandInfo() { |
| 407 int currentRow = -1; | 399 int currentRow = -1; |
| 408 if (!fLoading) { | 400 if (!fLoading) { |
| 409 currentRow = fListWidget.currentRow(); | 401 currentRow = fListWidget.currentRow(); |
| 410 } | 402 } |
| 411 if (currentRow == -1) { | 403 if (currentRow == -1) { |
| 412 fInspectorWidget.setText("", SkInspectorWidget::kDetail_TabType); | 404 fInspectorWidget.setText("", SkInspectorWidget::kDetail_TabType); |
| 413 fInspectorWidget.setText("", SkInspectorWidget::kClipStack_TabType); | 405 fInspectorWidget.setText("", SkInspectorWidget::kClipStack_TabType); |
| 414 fCurrentCommandBox.setText(""); | 406 fCurrentCommandBox.setText(""); |
| 415 fDrawCommandGeometryWidget.setDrawCommandIndex(-1); | 407 fDrawCommandGeometryWidget.setDrawCommandIndex(-1); |
| 416 } else { | 408 } else { |
| 417 if (!this->isPaused()) { | 409 this->updateImage(); |
| 418 fCanvasWidget.drawTo(currentRow); | 410 |
| 419 } | |
| 420 const SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(currentR
ow); | 411 const SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(currentR
ow); |
| 421 | 412 |
| 422 /* TODO(chudy): Add command type before parameters. Rename v | 413 /* TODO(chudy): Add command type before parameters. Rename v |
| 423 * to something more informative. */ | 414 * to something more informative. */ |
| 424 if (currInfo) { | 415 if (currInfo) { |
| 425 QString info; | 416 QString info; |
| 426 info.append("<b>Parameters: </b><br/>"); | 417 info.append("<b>Parameters: </b><br/>"); |
| 427 for (int i = 0; i < currInfo->count(); i++) { | 418 for (int i = 0; i < currInfo->count(); i++) { |
| 428 info.append(QString((*currInfo)[i]->c_str())); | 419 info.append(QString((*currInfo)[i]->c_str())); |
| 429 info.append("<br/>"); | 420 info.append("<br/>"); |
| 430 } | 421 } |
| 431 fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType); | 422 fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType); |
| 432 } | 423 } |
| 433 | 424 |
| 434 SkString clipStack; | |
| 435 fDebugger.getClipStackText(&clipStack); | |
| 436 fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStac
k_TabType); | |
| 437 | |
| 438 fCurrentCommandBox.setText(QString::number(currentRow)); | 425 fCurrentCommandBox.setText(QString::number(currentRow)); |
| 439 | 426 |
| 440 fDrawCommandGeometryWidget.setDrawCommandIndex(currentRow); | 427 fDrawCommandGeometryWidget.setDrawCommandIndex(currentRow); |
| 441 | 428 |
| 442 fInspectorWidget.setDisabled(false); | 429 fInspectorWidget.setDisabled(false); |
| 443 fViewStateFrame.setDisabled(false); | 430 fViewStateFrame.setDisabled(false); |
| 444 } | 431 } |
| 445 } | 432 } |
| 446 | 433 |
| 447 void SkDebuggerGUI::selectCommand(int command) { | 434 void SkDebuggerGUI::selectCommand(int command) { |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 | 842 |
| 856 // NOTE(chudy): Makes first item unselectable. | 843 // NOTE(chudy): Makes first item unselectable. |
| 857 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( | 844 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( |
| 858 fFilter.model()); | 845 fFilter.model()); |
| 859 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), | 846 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), |
| 860 fFilter.rootModelIndex()); | 847 fFilter.rootModelIndex()); |
| 861 QStandardItem* firstItem = model->itemFromIndex(firstIndex); | 848 QStandardItem* firstItem = model->itemFromIndex(firstIndex); |
| 862 firstItem->setSelectable(false); | 849 firstItem->setSelectable(false); |
| 863 } | 850 } |
| 864 | 851 |
| 852 void SkDebuggerGUI::updateImage() { |
| 853 if (this->isPaused()) { |
| 854 fCanvasWidget.drawTo(fPausedRow); |
| 855 } else { |
| 856 fCanvasWidget.drawTo(fListWidget.currentRow()); |
| 857 } |
| 858 } |
| 859 |
| 865 void SkDebuggerGUI::updateHit(int newHit) { | 860 void SkDebuggerGUI::updateHit(int newHit) { |
| 866 fCommandHitBox.setText(QString::number(newHit)); | 861 fCommandHitBox.setText(QString::number(newHit)); |
| 867 } | 862 } |
| 868 | 863 |
| OLD | NEW |