From: commit-bot@chromium.org Date: Fri, 2 Aug 2013 13:59:50 +0000 (+0000) Subject: Support MSAA in the picture debugger X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~11451 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fde1e7ccb4524aa2e0c42872e529ee25d09e7f34;p=platform%2Fupstream%2FlibSkiaSharp.git 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 --- diff --git a/debugger/QT/SkCanvasWidget.cpp b/debugger/QT/SkCanvasWidget.cpp index 3c239d0..73de8c2 100644 --- a/debugger/QT/SkCanvasWidget.cpp +++ b/debugger/QT/SkCanvasWidget.cpp @@ -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()); diff --git a/debugger/QT/SkCanvasWidget.h b/debugger/QT/SkCanvasWidget.h index 0dcb470..3308613 100644 --- a/debugger/QT/SkCanvasWidget.h +++ b/debugger/QT/SkCanvasWidget.h @@ -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); diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp index 0f4299f..d444152 100644 --- a/debugger/QT/SkDebuggerGUI.cpp +++ b/debugger/QT/SkDebuggerGUI.cpp @@ -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 diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h index 3122638..13ec181 100644 --- a/debugger/QT/SkDebuggerGUI.h +++ b/debugger/QT/SkDebuggerGUI.h @@ -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 /** diff --git a/debugger/QT/SkGLWidget.cpp b/debugger/QT/SkGLWidget.cpp index ae3155a..53b6fa4 100644 --- a/debugger/QT/SkGLWidget.cpp +++ b/debugger/QT/SkGLWidget.cpp @@ -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) { diff --git a/debugger/QT/SkGLWidget.h b/debugger/QT/SkGLWidget.h index ccbb1ee..a8e4604 100644 --- a/debugger/QT/SkGLWidget.h +++ b/debugger/QT/SkGLWidget.h @@ -33,6 +33,7 @@ public: void draw() { this->updateGL(); } + void setSampleCount(int sampleCount); signals: void drawComplete(); diff --git a/debugger/QT/SkSettingsWidget.cpp b/debugger/QT/SkSettingsWidget.cpp index 88078ea..fa619ea 100644 --- a/debugger/QT/SkSettingsWidget.cpp +++ b/debugger/QT/SkSettingsWidget.cpp @@ -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 diff --git a/debugger/QT/SkSettingsWidget.h b/debugger/QT/SkSettingsWidget.h index 1a16ed2..e5662ee 100644 --- a/debugger/QT/SkSettingsWidget.h +++ b/debugger/QT/SkSettingsWidget.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -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;