Support MSAA in the picture debugger

Add radio buttons for setting the GL sample count to 0 ("off"), 4 or
16.

Change the default mode of the GL widget to MSAA4. Previous behavior
corresponded to "off".

BUG=1459
R=robertphillips@google.com

Author: kkinnunen@nvidia.com

Review URL: https://chromiumcodereview.appspot.com/21752002

git-svn-id: http://skia.googlecode.com/svn/trunk@10509 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2013-08-02 13:59:50 +00:00
parent bd74add1dc
commit fde1e7ccb4
8 changed files with 74 additions and 7 deletions

View File

@ -129,6 +129,13 @@ void SkCanvasWidget::setWidgetVisibility(WidgetType type, bool isHidden) {
#endif
}
#if SK_SUPPORT_GPU
void SkCanvasWidget::setGLSampleCount(int sampleCount)
{
fGLWidget.setSampleCount(sampleCount);
}
#endif
void SkCanvasWidget::zoom(float scale, int px, int py) {
fUserMatrix.postScale(scale, scale, px, py);
emit scaleFactorChanged(fUserMatrix.getScaleX());

View File

@ -36,6 +36,10 @@ public:
void setWidgetVisibility(WidgetType type, bool isHidden);
#if SK_SUPPORT_GPU
void setGLSampleCount(int sampleCount);
#endif
/** Zooms the canvas by scale with the transformation centered at the widget point (px, py). */
void zoom(float scale, int px, int py);

View File

@ -92,7 +92,7 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this, SLOT(actionCommandFilter()));
#if SK_SUPPORT_GPU
connect(fSettingsWidget.getGLCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionGLWidget(bool)));
connect(&fSettingsWidget, SIGNAL(glSettingsChanged()), this, SLOT(actionGLWidget()));
#endif
connect(fSettingsWidget.getRasterCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionRasterWidget(bool)));
connect(fSettingsWidget.getOverdrawVizCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionOverdrawVizWidget(bool)));
@ -360,8 +360,9 @@ void SkDebuggerGUI::actionProfile() {
renderer = SkNEW(sk_tools::SimplePictureRenderer);
#if SK_SUPPORT_GPU
if (Qt::Checked == fSettingsWidget.getGLCheckBox()->checkState()) {
if (fSettingsWidget.isGLActive()) {
renderer->setDeviceType(sk_tools::PictureRenderer::kGPU_DeviceType);
renderer->setSampleCount(fSettingsWidget.getGLSampleCount());
}
#endif
@ -459,7 +460,11 @@ void SkDebuggerGUI::actionDelete() {
}
#if SK_SUPPORT_GPU
void SkDebuggerGUI::actionGLWidget(bool isToggled) {
void SkDebuggerGUI::actionGLWidget() {
bool isToggled = fSettingsWidget.isGLActive();
if (isToggled) {
fCanvasWidget.setGLSampleCount(fSettingsWidget.getGLSampleCount());
}
fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggled);
}
#endif

View File

@ -114,9 +114,9 @@ private slots:
#if SK_SUPPORT_GPU
/**
Toggles the visibility of the GL canvas widget.
Updates the visibility of the GL canvas widget and sample count of the GL surface.
*/
void actionGLWidget(bool isToggled);
void actionGLWidget();
#endif
/**

View File

@ -27,6 +27,14 @@ SkGLWidget::~SkGLWidget() {
SkSafeUnref(fCanvas);
}
void SkGLWidget::setSampleCount(int sampleCount)
{
QGLFormat currentFormat = format();
currentFormat.setSampleBuffers(sampleCount > 0);
currentFormat.setSamples(sampleCount);
setFormat(currentFormat);
}
void SkGLWidget::initializeGL() {
fCurIntf = GrGLCreateNativeInterface();
if (!fCurIntf) {

View File

@ -33,6 +33,7 @@ public:
void draw() {
this->updateGL();
}
void setSampleCount(int sampleCount);
signals:
void drawComplete();

View File

@ -67,6 +67,28 @@ SkSettingsWidget::SkSettingsWidget() : QWidget()
fGLLabel.setText("OpenGL: ");
fGLLabel.setMinimumWidth(178);
fGLLabel.setMaximumWidth(178);
fGLMSAAButtonGroup.setTitle("MSAA");
fGLMSAAButtonGroup.setMinimumWidth(178);
fGLMSAAButtonGroup.setMaximumWidth(178);
fGLMSAAButtonGroup.setEnabled(fGLCheckBox.isChecked());
fGLMSAAOff.setText("Off");
fGLMSAA4On.setText("4");
fGLMSAA4On.setChecked(true);
fGLMSAA16On.setText("16");
fGLMSAALayout.addWidget(&fGLMSAAOff);
fGLMSAALayout.addWidget(&fGLMSAA4On);
fGLMSAALayout.addWidget(&fGLMSAA16On);
fGLMSAAButtonGroup.setLayout(&fGLMSAALayout);
connect(&fGLCheckBox, SIGNAL(toggled(bool)), &fGLMSAAButtonGroup, SLOT(setEnabled(bool)));
connect(&fGLCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged()));
connect(&fGLMSAAOff, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged()));
connect(&fGLMSAA4On, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged()));
connect(&fGLMSAA16On, SIGNAL(toggled(bool)), this, SIGNAL(glSettingsChanged()));
#endif
fRasterLayout.addWidget(&fRasterLabel);
@ -86,6 +108,7 @@ SkSettingsWidget::SkSettingsWidget() : QWidget()
fCanvasLayout.addLayout(&fOverdrawVizLayout);
#if SK_SUPPORT_GPU
fCanvasLayout.addLayout(&fGLLayout);
fCanvasLayout.addWidget(&fGLMSAAButtonGroup);
#endif
// Command Toggle

View File

@ -14,6 +14,7 @@
#include <QHBoxLayout>
#include <QTextEdit>
#include <QFrame>
#include <QGroupBox>
#include <QLabel>
#include <QRadioButton>
#include <QCheckBox>
@ -40,9 +41,19 @@ public:
QRadioButton* getVisibilityButton();
#if SK_SUPPORT_GPU
QCheckBox* getGLCheckBox() {
return &fGLCheckBox;
bool isGLActive() {
return fGLCheckBox.isChecked();
}
int getGLSampleCount() {
if (fGLMSAA4On.isChecked()) {
return 4;
} else if (fGLMSAA16On.isChecked()) {
return 16;
}
return 0;
}
#endif
QCheckBox* getRasterCheckBox() {
@ -61,6 +72,9 @@ signals:
void scrollingPreferences(bool isStickyActivate);
void showStyle(bool isSingleCommand);
void visibilityFilter(bool isEnabled);
#if SK_SUPPORT_GPU
void glSettingsChanged();
#endif
private:
QVBoxLayout mainFrameLayout;
@ -101,6 +115,11 @@ private:
QHBoxLayout fGLLayout;
QLabel fGLLabel;
QCheckBox fGLCheckBox;
QGroupBox fGLMSAAButtonGroup;
QVBoxLayout fGLMSAALayout;
QRadioButton fGLMSAAOff;
QRadioButton fGLMSAA4On;
QRadioButton fGLMSAA16On;
#endif
QFrame fZoomFrame;