aboutsummaryrefslogtreecommitdiffhomepage
path: root/debugger
diff options
context:
space:
mode:
authorGravatar kkinnunen <kkinnunen@nvidia.com>2015-01-13 22:49:02 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-13 22:49:02 -0800
commitcfdc0e3fee69694e0f6b083d8455665b2a810589 (patch)
tree62bd3c1b6d98337bf05c5d9a7d8c3f801e746298 /debugger
parent63121f0db6ebbefb17f47ec4ec108d77d619fad5 (diff)
debugger: SW rasterize the picture only when it changes
Rasterize the picture only when it changes, not every time raster widget paints itself. Removes include SkForceLinking.h while organizing the SkDebuggerGUI.cpp includes. This is part of the work trying to remove bugs that come from SkDebugCanvas stateful draw. Part of the state comes from some optimization that this tries to reproduce in a different way. Review URL: https://codereview.chromium.org/839743003
Diffstat (limited to 'debugger')
-rw-r--r--debugger/QT/SkCanvasWidget.cpp9
-rw-r--r--debugger/QT/SkDebuggerGUI.cpp49
-rw-r--r--debugger/QT/SkDebuggerGUI.h3
-rw-r--r--debugger/QT/SkDrawCommandGeometryWidget.cpp5
-rw-r--r--debugger/QT/SkGLWidget.cpp1
-rw-r--r--debugger/QT/SkGLWidget.h2
-rw-r--r--debugger/QT/SkRasterWidget.cpp79
-rw-r--r--debugger/QT/SkRasterWidget.h21
8 files changed, 87 insertions, 82 deletions
diff --git a/debugger/QT/SkCanvasWidget.cpp b/debugger/QT/SkCanvasWidget.cpp
index 73de8c21ca..9d691cd35a 100644
--- a/debugger/QT/SkCanvasWidget.cpp
+++ b/debugger/QT/SkCanvasWidget.cpp
@@ -8,6 +8,7 @@
#include "SkCanvasWidget.h"
+#include <QtGui>
SkCanvasWidget::SkCanvasWidget(QWidget* parent,
SkDebugger* debugger) : QWidget(parent)
@@ -40,17 +41,17 @@ SkCanvasWidget::SkCanvasWidget(QWidget* parent,
#if SK_SUPPORT_GPU
setWidgetVisibility(kGPU_WidgetType, true);
#endif
- connect(&fRasterWidget, SIGNAL(drawComplete()),
- this->parentWidget(), SLOT(drawComplete()));
+ connect(&fRasterWidget, SIGNAL(drawComplete()), this->parentWidget(), SLOT(drawComplete()));
+ connect(&fGLWidget, SIGNAL(drawComplete()), this->parentWidget(), SLOT(drawComplete()));
}
SkCanvasWidget::~SkCanvasWidget() {}
void SkCanvasWidget::drawTo(int index) {
fDebugger->setIndex(index);
- fRasterWidget.draw();
+ fRasterWidget.updateImage();
#if SK_SUPPORT_GPU
- fGLWidget.draw();
+ fGLWidget.updateImage();
#endif
emit commandChanged(fDebugger->index());
}
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index dade56768d..9e212981a7 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -6,12 +6,12 @@
*/
#include "SkDebuggerGUI.h"
-#include "SkForceLinking.h"
-#include <QListWidgetItem>
#include "PictureRenderer.h"
+#include "SkPictureData.h"
#include "SkPicturePlayback.h"
#include "SkPictureRecord.h"
-#include "SkPictureData.h"
+#include <QListWidgetItem>
+#include <QtGui>
#if defined(SK_BUILD_FOR_WIN32)
#include "SysTimer_windows.h"
@@ -217,11 +217,7 @@ void SkDebuggerGUI::actionClearDeletes() {
fDebugger.setCommandVisible(row, true);
fSkipCommands[row] = false;
}
- if (this->isPaused()) {
- fCanvasWidget.drawTo(fPausedRow);
- } else {
- fCanvasWidget.drawTo(fListWidget.currentRow());
- }
+ this->updateImage();
}
void SkDebuggerGUI::actionClose() {
@@ -248,13 +244,7 @@ void SkDebuggerGUI::actionDelete() {
}
}
- int currentRow = fListWidget.currentRow();
-
- if (this->isPaused()) {
- fCanvasWidget.drawTo(fPausedRow);
- } else {
- fCanvasWidget.drawTo(currentRow);
- }
+ this->updateImage();
}
#if SK_SUPPORT_GPU
@@ -291,14 +281,14 @@ void SkDebuggerGUI::actionRasterSettingsChanged() {
fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType,
!fSettingsWidget.isRasterEnabled());
fDebugger.setOverdrawViz(fSettingsWidget.isOverdrawVizEnabled());
- fCanvasWidget.update();
+ this->updateImage();
}
void SkDebuggerGUI::actionVisualizationsChanged() {
fDebugger.setMegaViz(fSettingsWidget.isMegaVizEnabled());
fDebugger.setPathOps(fSettingsWidget.isPathOpsEnabled());
fDebugger.highlightCurrentCommand(fSettingsWidget.isVisibilityFilterEnabled());
- fCanvasWidget.drawTo(fListWidget.currentRow());
+ this->updateImage();
}
void SkDebuggerGUI::actionTextureFilter() {
@@ -357,6 +347,10 @@ void SkDebuggerGUI::actionStepForward() {
}
void SkDebuggerGUI::drawComplete() {
+ SkString clipStack;
+ fDebugger.getClipStackText(&clipStack);
+ fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_TabType);
+
fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix());
fInspectorWidget.setClip(fDebugger.getCurrentClip());
}
@@ -398,9 +392,7 @@ void SkDebuggerGUI::openFile(const QString &filename) {
void SkDebuggerGUI::pauseDrawing(bool isPaused) {
fPausedRow = fListWidget.currentRow();
- if (!fLoading) {
- fCanvasWidget.drawTo(fPausedRow);
- }
+ this->updateDrawCommandInfo();
}
void SkDebuggerGUI::updateDrawCommandInfo() {
@@ -414,9 +406,8 @@ void SkDebuggerGUI::updateDrawCommandInfo() {
fCurrentCommandBox.setText("");
fDrawCommandGeometryWidget.setDrawCommandIndex(-1);
} else {
- if (!this->isPaused()) {
- fCanvasWidget.drawTo(currentRow);
- }
+ this->updateImage();
+
const SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(currentRow);
/* TODO(chudy): Add command type before parameters. Rename v
@@ -431,10 +422,6 @@ void SkDebuggerGUI::updateDrawCommandInfo() {
fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType);
}
- SkString clipStack;
- fDebugger.getClipStackText(&clipStack);
- fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_TabType);
-
fCurrentCommandBox.setText(QString::number(currentRow));
fDrawCommandGeometryWidget.setDrawCommandIndex(currentRow);
@@ -862,6 +849,14 @@ void SkDebuggerGUI::setupComboBox() {
firstItem->setSelectable(false);
}
+void SkDebuggerGUI::updateImage() {
+ if (this->isPaused()) {
+ fCanvasWidget.drawTo(fPausedRow);
+ } else {
+ fCanvasWidget.drawTo(fListWidget.currentRow());
+ }
+}
+
void SkDebuggerGUI::updateHit(int newHit) {
fCommandHitBox.setText(QString::number(newHit));
}
diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h
index 8c6865b8ca..d6c3f49073 100644
--- a/debugger/QT/SkDebuggerGUI.h
+++ b/debugger/QT/SkDebuggerGUI.h
@@ -19,6 +19,7 @@
#include "SkRasterWidget.h"
#include "SkDrawCommandGeometryWidget.h"
#include "SkSettingsWidget.h"
+#include <QtCore/QSignalMapper>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
@@ -233,6 +234,8 @@ private slots:
void toggleFilter(QString string);
void updateHit(int newHit);
+
+ void updateImage();
private:
QSplitter fCentralSplitter;
QStatusBar fStatusBar;
diff --git a/debugger/QT/SkDrawCommandGeometryWidget.cpp b/debugger/QT/SkDrawCommandGeometryWidget.cpp
index 03572cfdd1..9f19785667 100644
--- a/debugger/QT/SkDrawCommandGeometryWidget.cpp
+++ b/debugger/QT/SkDrawCommandGeometryWidget.cpp
@@ -42,8 +42,8 @@ void SkDrawCommandGeometryWidget::paintEvent(QPaintEvent* event) {
painter.setRenderHint(QPainter::Antialiasing);
SkImageInfo info;
- size_t rowPixels;
- if (const void* pixels = fSurface->peekPixels(&info, &rowPixels)) {
+ size_t rowBytes;
+ if (const void* pixels = fSurface->peekPixels(&info, &rowBytes)) {
SkASSERT(info.width() > 0);
SkASSERT(info.height() > 0);
@@ -61,6 +61,7 @@ void SkDrawCommandGeometryWidget::paintEvent(QPaintEvent* event) {
QImage image(reinterpret_cast<const uchar*>(pixels),
info.width(),
info.height(),
+ rowBytes,
QImage::Format_ARGB32_Premultiplied);
painter.drawImage(resultRect, image);
}
diff --git a/debugger/QT/SkGLWidget.cpp b/debugger/QT/SkGLWidget.cpp
index a1f82e1a54..1c524aad58 100644
--- a/debugger/QT/SkGLWidget.cpp
+++ b/debugger/QT/SkGLWidget.cpp
@@ -72,7 +72,6 @@ void SkGLWidget::createRenderTarget() {
void SkGLWidget::resizeGL(int w, int h) {
SkASSERT(w == this->width() && h == this->height());
this->createRenderTarget();
- draw();
}
void SkGLWidget::paintGL() {
diff --git a/debugger/QT/SkGLWidget.h b/debugger/QT/SkGLWidget.h
index d78ff979fa..baef126138 100644
--- a/debugger/QT/SkGLWidget.h
+++ b/debugger/QT/SkGLWidget.h
@@ -30,7 +30,7 @@ public:
~SkGLWidget();
- void draw() {
+ void updateImage() {
this->updateGL();
}
void setSampleCount(int sampleCount);
diff --git a/debugger/QT/SkRasterWidget.cpp b/debugger/QT/SkRasterWidget.cpp
index 5363d4ad5f..72a742f7aa 100644
--- a/debugger/QT/SkRasterWidget.cpp
+++ b/debugger/QT/SkRasterWidget.cpp
@@ -7,50 +7,67 @@
*/
#include "SkRasterWidget.h"
+#include "SkDebugger.h"
+#include <QtGui>
-SkRasterWidget::SkRasterWidget(SkDebugger *debugger) : QWidget() {
- fBitmap.allocN32Pixels(800, 800);
- fBitmap.eraseColor(SK_ColorTRANSPARENT);
- fDevice = new SkBitmapDevice(fBitmap);
- fDebugger = debugger;
- fCanvas = new SkCanvas(fDevice);
+SkRasterWidget::SkRasterWidget(SkDebugger *debugger)
+ : QWidget()
+ , fDebugger(debugger)
+ , fNeedImageUpdate(false) {
this->setStyleSheet("QWidget {background-color: black; border: 1px solid #cccccc;}");
}
-SkRasterWidget::~SkRasterWidget() {
- SkSafeUnref(fCanvas);
- SkSafeUnref(fDevice);
-}
-
void SkRasterWidget::resizeEvent(QResizeEvent* event) {
- fBitmap.allocN32Pixels(event->size().width(), event->size().height());
- fBitmap.eraseColor(SK_ColorTRANSPARENT);
- SkSafeUnref(fCanvas);
- SkSafeUnref(fDevice);
- fDevice = new SkBitmapDevice(fBitmap);
- fCanvas = new SkCanvas(fDevice);
- this->update();
+ this->QWidget::resizeEvent(event);
+
+ QRect r = this->contentsRect();
+ if (r.width() == 0 || r.height() == 0) {
+ fSurface.reset(NULL);
+ } else {
+ SkImageInfo info = SkImageInfo::MakeN32Premul(r.width(), r.height());
+ fSurface.reset(SkSurface::NewRaster(info));
+ }
+ this->updateImage();
}
void SkRasterWidget::paintEvent(QPaintEvent* event) {
- if (!this->isHidden()) {
- fDebugger->draw(fCanvas);
- QPainter painter(this);
- QStyleOption opt;
- opt.init(this);
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ QStyleOption opt;
+ opt.init(this);
+ style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
- style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
+ if (!fSurface) {
+ return;
+ }
- QPoint origin(0,0);
- QImage image((uchar *)fBitmap.getPixels(), fBitmap.width(),
- fBitmap.height(), QImage::Format_ARGB32_Premultiplied);
+ if (fNeedImageUpdate) {
+ fDebugger->draw(fSurface->getCanvas());
+ fSurface->getCanvas()->flush();
+ fNeedImageUpdate = false;
+ emit drawComplete();
+ }
+ SkImageInfo info;
+ size_t rowBytes;
+ if (const void* pixels = fSurface->peekPixels(&info, &rowBytes)) {
+ QImage image(reinterpret_cast<const uchar*>(pixels),
+ info.width(),
+ info.height(),
+ rowBytes,
+ QImage::Format_ARGB32_Premultiplied);
#if SK_R32_SHIFT == 0
- painter.drawImage(origin, image.rgbSwapped());
+ painter.drawImage(this->contentsRect(), image.rgbSwapped());
#else
- painter.drawImage(origin, image);
+ painter.drawImage(this->contentsRect(), image);
#endif
- painter.end();
- emit drawComplete();
}
}
+
+void SkRasterWidget::updateImage() {
+ if (!fSurface) {
+ return;
+ }
+ fNeedImageUpdate = true;
+ this->update();
+}
diff --git a/debugger/QT/SkRasterWidget.h b/debugger/QT/SkRasterWidget.h
index afad609c32..09b529c049 100644
--- a/debugger/QT/SkRasterWidget.h
+++ b/debugger/QT/SkRasterWidget.h
@@ -9,15 +9,9 @@
#ifndef SKRASTERWIDGET_H_
#define SKRASTERWIDGET_H_
-#if SK_SUPPORT_GPU
-#include "SkGpuDevice.h"
-#endif
+#include "SkSurface.h"
+class SkDebugger;
-#include "SkBitmapDevice.h"
-#include "SkDebugger.h"
-
-#include <QApplication>
-#include <QtGui>
#include <QWidget>
class SkRasterWidget : public QWidget {
@@ -26,11 +20,7 @@ class SkRasterWidget : public QWidget {
public:
SkRasterWidget(SkDebugger* debugger);
- ~SkRasterWidget();
-
- void draw() {
- this->update();
- }
+ void updateImage();
signals:
void drawComplete();
@@ -41,10 +31,9 @@ protected:
void resizeEvent(QResizeEvent* event);
private:
- SkBitmap fBitmap;
SkDebugger* fDebugger;
- SkCanvas* fCanvas;
- SkBaseDevice* fDevice;
+ SkAutoTUnref<SkSurface> fSurface;
+ bool fNeedImageUpdate;
};
#endif /* SKRASTERWIDGET_H_ */