From e8fe4bc3efa8f18f5651c5d005fba1935a741be0 Mon Sep 17 00:00:00 2001 From: "robertphillips@google.com" Date: Wed, 13 Feb 2013 13:26:13 +0000 Subject: [PATCH] Allow debugger to be compiled without Ganesh https://codereview.appspot.com/7311084/ git-svn-id: http://skia.googlecode.com/svn/trunk@7710 2bbb7eff-a529-9590-31e7-b0007b416f81 --- debugger/QT/SkCanvasWidget.cpp | 15 ++++++++++++++- debugger/QT/SkCanvasWidget.h | 4 ++++ debugger/QT/SkDebuggerGUI.cpp | 4 ++++ debugger/QT/SkDebuggerGUI.h | 2 ++ debugger/QT/SkGLWidget.cpp | 4 ++++ debugger/QT/SkGLWidget.h | 5 ++++- debugger/QT/SkRasterWidget.h | 3 +++ debugger/QT/SkSettingsWidget.cpp | 6 ++++++ debugger/QT/SkSettingsWidget.h | 4 ++++ tools/PictureRenderer.h | 4 ++-- 10 files changed, 47 insertions(+), 4 deletions(-) diff --git a/debugger/QT/SkCanvasWidget.cpp b/debugger/QT/SkCanvasWidget.cpp index 63a0e056e9..0350b3d7bc 100644 --- a/debugger/QT/SkCanvasWidget.cpp +++ b/debugger/QT/SkCanvasWidget.cpp @@ -13,7 +13,9 @@ SkCanvasWidget::SkCanvasWidget(QWidget* parent, SkDebugger* debugger) : QWidget(parent) , fHorizontalLayout(this) , fRasterWidget(debugger) +#if SK_SUPPORT_GPU , fGLWidget(debugger) +#endif { fDebugger = debugger; @@ -22,16 +24,22 @@ SkCanvasWidget::SkCanvasWidget(QWidget* parent, fHorizontalLayout.setContentsMargins(0,0,0,0); fRasterWidget.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); +#if SK_SUPPORT_GPU fGLWidget.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); +#endif fHorizontalLayout.addWidget(&fRasterWidget); +#if SK_SUPPORT_GPU fHorizontalLayout.addWidget(&fGLWidget); +#endif fPreviousPoint.set(0,0); fUserMatrix.reset(); +#if SK_SUPPORT_GPU setWidgetVisibility(kGPU_WidgetType, true); +#endif connect(&fRasterWidget, SIGNAL(drawComplete()), this->parentWidget(), SLOT(drawComplete())); } @@ -41,7 +49,9 @@ SkCanvasWidget::~SkCanvasWidget() {} void SkCanvasWidget::drawTo(int index) { fDebugger->setIndex(index); fRasterWidget.draw(); +#if SK_SUPPORT_GPU fGLWidget.draw(); +#endif emit commandChanged(fDebugger->index()); } @@ -111,9 +121,12 @@ void SkCanvasWidget::resetWidgetTransform() { void SkCanvasWidget::setWidgetVisibility(WidgetType type, bool isHidden) { if (type == kRaster_8888_WidgetType) { fRasterWidget.setHidden(isHidden); - } else if (type == kGPU_WidgetType) { + } +#if SK_SUPPORT_GPU + else if (type == kGPU_WidgetType) { fGLWidget.setHidden(isHidden); } +#endif } void SkCanvasWidget::zoom(float scale, int px, int py) { diff --git a/debugger/QT/SkCanvasWidget.h b/debugger/QT/SkCanvasWidget.h index f6bc6186c9..0dcb470405 100644 --- a/debugger/QT/SkCanvasWidget.h +++ b/debugger/QT/SkCanvasWidget.h @@ -27,7 +27,9 @@ public: enum WidgetType { kRaster_8888_WidgetType = 1 << 0, +#if SK_SUPPORT_GPU kGPU_WidgetType = 1 << 1, +#endif }; void drawTo(int index); @@ -58,7 +60,9 @@ signals: private: QHBoxLayout fHorizontalLayout; SkRasterWidget fRasterWidget; +#if SK_SUPPORT_GPU SkGLWidget fGLWidget; +#endif SkDebugger* fDebugger; SkIPoint fPreviousPoint; SkMatrix fUserMatrix; diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp index a823c19f90..fba7a1e42d 100644 --- a/debugger/QT/SkDebuggerGUI.cpp +++ b/debugger/QT/SkDebuggerGUI.cpp @@ -87,7 +87,9 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes())); 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))); +#endif connect(fSettingsWidget.getRasterCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionRasterWidget(bool))); connect(fSettingsWidget.getOverdrawVizCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionOverdrawVizWidget(bool))); connect(&fActionPause, SIGNAL(toggled(bool)), this, SLOT(pauseDrawing(bool))); @@ -487,9 +489,11 @@ void SkDebuggerGUI::actionDelete() { } } +#if SK_SUPPORT_GPU void SkDebuggerGUI::actionGLWidget(bool isToggled) { fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggled); } +#endif void SkDebuggerGUI::actionInspector() { if (fInspectorWidget.isHidden()) { diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h index 4130e962d1..bb3d6ceb49 100644 --- a/debugger/QT/SkDebuggerGUI.h +++ b/debugger/QT/SkDebuggerGUI.h @@ -112,10 +112,12 @@ private slots: */ void actionDelete(); +#if SK_SUPPORT_GPU /** Toggles the visibility of the GL canvas widget. */ void actionGLWidget(bool isToggled); +#endif /** Toggles the visibility of the inspector widget. diff --git a/debugger/QT/SkGLWidget.cpp b/debugger/QT/SkGLWidget.cpp index 6343a8bece..3dc60598ad 100644 --- a/debugger/QT/SkGLWidget.cpp +++ b/debugger/QT/SkGLWidget.cpp @@ -9,6 +9,8 @@ #include "SkGLWidget.h" +#if SK_SUPPORT_GPU + SkGLWidget::SkGLWidget(SkDebugger* debugger) : QGLWidget() { this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}"); fDebugger = debugger; @@ -74,3 +76,5 @@ GrBackendRenderTargetDesc SkGLWidget::getDesc(int w, int h) { return desc; } + +#endif diff --git a/debugger/QT/SkGLWidget.h b/debugger/QT/SkGLWidget.h index 2a60c9ab91..ccbb1eef21 100644 --- a/debugger/QT/SkGLWidget.h +++ b/debugger/QT/SkGLWidget.h @@ -10,12 +10,13 @@ #ifndef SKGLWIDGET_H_ #define SKGLWIDGET_H_ +#if SK_SUPPORT_GPU + #include #include "SkDebugCanvas.h" #include "SkDebugger.h" #include "SkDevice.h" #include "SkGpuDevice.h" - #include "GrContext.h" #include "gl/GrGLInterface.h" #include "gl/GrGLUtil.h" @@ -51,4 +52,6 @@ private: GrBackendRenderTargetDesc getDesc(int w, int h); }; +#endif /* SK_SUPPORT_GPU */ + #endif /* SKGLWIDGET_H_ */ diff --git a/debugger/QT/SkRasterWidget.h b/debugger/QT/SkRasterWidget.h index a0355c1f17..769aa51032 100644 --- a/debugger/QT/SkRasterWidget.h +++ b/debugger/QT/SkRasterWidget.h @@ -9,7 +9,10 @@ #ifndef SKRASTERWIDGET_H_ #define SKRASTERWIDGET_H_ +#if SK_SUPPORT_GPU #include "SkGpuDevice.h" +#endif + #include "SkDevice.h" #include "SkDebugger.h" diff --git a/debugger/QT/SkSettingsWidget.cpp b/debugger/QT/SkSettingsWidget.cpp index 09196fbc5e..88078ea64f 100644 --- a/debugger/QT/SkSettingsWidget.cpp +++ b/debugger/QT/SkSettingsWidget.cpp @@ -63,9 +63,11 @@ SkSettingsWidget::SkSettingsWidget() : QWidget() fOverdrawVizLabel.setMinimumWidth(178); fOverdrawVizLabel.setMaximumWidth(178); +#if SK_SUPPORT_GPU fGLLabel.setText("OpenGL: "); fGLLabel.setMinimumWidth(178); fGLLabel.setMaximumWidth(178); +#endif fRasterLayout.addWidget(&fRasterLabel); fRasterLayout.addWidget(&fRasterCheckBox); @@ -73,14 +75,18 @@ SkSettingsWidget::SkSettingsWidget() : QWidget() fOverdrawVizLayout.addWidget(&fOverdrawVizLabel); fOverdrawVizLayout.addWidget(&fOverdrawVizCheckBox); +#if SK_SUPPORT_GPU fGLLayout.addWidget(&fGLLabel); fGLLayout.addWidget(&fGLCheckBox); +#endif fCanvasLayout.setSpacing(6); fCanvasLayout.setContentsMargins(11,11,11,11); fCanvasLayout.addLayout(&fRasterLayout); fCanvasLayout.addLayout(&fOverdrawVizLayout); +#if SK_SUPPORT_GPU fCanvasLayout.addLayout(&fGLLayout); +#endif // Command Toggle fCommandToggle.setText("Command Scrolling Preferences"); diff --git a/debugger/QT/SkSettingsWidget.h b/debugger/QT/SkSettingsWidget.h index 73cd6e1bc9..1a16ed243f 100644 --- a/debugger/QT/SkSettingsWidget.h +++ b/debugger/QT/SkSettingsWidget.h @@ -39,9 +39,11 @@ public: QRadioButton* getVisibilityButton(); +#if SK_SUPPORT_GPU QCheckBox* getGLCheckBox() { return &fGLCheckBox; } +#endif QCheckBox* getRasterCheckBox() { return &fRasterCheckBox; @@ -95,9 +97,11 @@ private: QLabel fOverdrawVizLabel; QCheckBox fOverdrawVizCheckBox; +#if SK_SUPPORT_GPU QHBoxLayout fGLLayout; QLabel fGLLabel; QCheckBox fGLCheckBox; +#endif QFrame fZoomFrame; QHBoxLayout fZoomLayout; diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h index 0e4134fa93..b054a546fe 100644 --- a/tools/PictureRenderer.h +++ b/tools/PictureRenderer.h @@ -195,8 +195,8 @@ public: } else if (kTileGrid_BBoxHierarchyType == fBBoxHierarchyType) { config.append("_grid"); } - switch (fDeviceType) { #if SK_SUPPORT_GPU + switch (fDeviceType) { case kGPU_DeviceType: config.append("_gpu"); break; @@ -204,12 +204,12 @@ public: case kAngle_DeviceType: config.append("_angle"); break; -#endif #endif default: // Assume that no extra info means bitmap. break; } +#endif config.append(fDrawFiltersConfig.c_str()); return config; }