Index: src/utils/debugger/SkDebugCanvas.cpp |
=================================================================== |
--- src/utils/debugger/SkDebugCanvas.cpp (revision 11819) |
+++ src/utils/debugger/SkDebugCanvas.cpp (working copy) |
@@ -24,6 +24,8 @@ |
: INHERITED(make_noconfig_bm(width, height)) |
, fOverdrawViz(false) |
, fOverdrawFilter(NULL) |
+ , fOverrideTexFiltering(false) |
+ , fTexOverrideFilter(NULL) |
, fOutstandingSaveCount(0) { |
// TODO(chudy): Free up memory from all draw commands in destructor. |
fWidth = width; |
@@ -109,13 +111,13 @@ |
// The OverdrawFilter modifies every paint to use an SkProcXfermode which |
// in turn invokes OverdrawXferModeProc |
-class OverdrawFilter : public SkDrawFilter { |
+class SkOverdrawFilter : public SkDrawFilter { |
public: |
- OverdrawFilter() { |
+ SkOverdrawFilter() { |
fXferMode = new SkProcXfermode(OverdrawXferModeProc); |
} |
- virtual ~OverdrawFilter() { |
+ virtual ~SkOverdrawFilter() { |
delete fXferMode; |
} |
@@ -131,6 +133,29 @@ |
typedef SkDrawFilter INHERITED; |
}; |
+// SkTexOverrideFilter modifies every paint to use the specified |
+// texture filtering mode |
+class SkTexOverrideFilter : public SkDrawFilter { |
+public: |
+ SkTexOverrideFilter() : fFilterLevel(SkPaint::kNone_FilterLevel) { |
+ } |
+ |
+ void setFilterLevel(SkPaint::FilterLevel filterLevel) { |
+ fFilterLevel = filterLevel; |
+ } |
+ |
+ virtual bool filter(SkPaint* p, Type) SK_OVERRIDE { |
+ p->setFilterLevel(fFilterLevel); |
+ return true; |
+ } |
+ |
+protected: |
+ SkPaint::FilterLevel fFilterLevel; |
+ |
+private: |
+ typedef SkDrawFilter INHERITED; |
+}; |
+ |
void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) { |
SkASSERT(!fCommandVector.isEmpty()); |
SkASSERT(index < fCommandVector.count()); |
@@ -161,12 +186,20 @@ |
// call setDrawFilter on anything but the root layer odd things happen. |
if (fOverdrawViz) { |
if (NULL == fOverdrawFilter) { |
- fOverdrawFilter = new OverdrawFilter; |
+ fOverdrawFilter = new SkOverdrawFilter; |
} |
if (fOverdrawFilter != canvas->getDrawFilter()) { |
canvas->setDrawFilter(fOverdrawFilter); |
} |
+ } else if (fOverrideTexFiltering) { |
+ if (NULL == fTexOverrideFilter) { |
+ fTexOverrideFilter = new SkTexOverrideFilter; |
+ } |
+ |
+ if (fTexOverrideFilter != canvas->getDrawFilter()) { |
+ canvas->setDrawFilter(fTexOverrideFilter); |
+ } |
} else { |
canvas->setDrawFilter(NULL); |
} |
@@ -246,6 +279,15 @@ |
fFilter = toggle; |
} |
+void SkDebugCanvas::overrideTexFiltering(bool overrideTexFiltering, SkPaint::FilterLevel level) { |
+ if (NULL == fTexOverrideFilter) { |
+ fTexOverrideFilter = new SkTexOverrideFilter; |
+ } |
+ |
+ fOverrideTexFiltering = overrideTexFiltering; |
+ fTexOverrideFilter->setFilterLevel(level); |
+} |
+ |
void SkDebugCanvas::clear(SkColor color) { |
addDrawCommand(new SkClearCommand(color)); |
} |