Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(900)

Unified Diff: src/utils/debugger/SkDebugCanvas.cpp

Issue 27716003: Add texture filtering override to debugger (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Cleaned up Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils/debugger/SkDebugCanvas.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
}
« no previous file with comments | « src/utils/debugger/SkDebugCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698