aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/debugger
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-04 13:42:46 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-04 13:42:46 +0000
commit1735d6696e9a941925e6ca352849307d698ef139 (patch)
tree4568e32d4a4f19447f38231d9a617dc83b565f82 /src/utils/debugger
parent6e515d67d2365ecd05fb80762eeb76c55e81368c (diff)
Fix incremental visibility filter handling.
When drawing incrementally, SkDebugCanvas can end up applying the visibility overlay multiple times (resulting in a fade-to-white effect). The CL also includes a minor/unrelated SkDebugCanvas cleanup. R=robertphillips@google.com Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/103083004 git-svn-id: http://skia.googlecode.com/svn/trunk@12478 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/debugger')
-rw-r--r--src/utils/debugger/SkDebugCanvas.cpp28
-rw-r--r--src/utils/debugger/SkDebugCanvas.h12
2 files changed, 12 insertions, 28 deletions
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index d1a9f0c925..e491f3b8a7 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -22,18 +22,15 @@ static SkBitmap make_noconfig_bm(int width, int height) {
SkDebugCanvas::SkDebugCanvas(int width, int height)
: INHERITED(make_noconfig_bm(width, height))
+ , fWidth(width)
+ , fHeight(height)
+ , fFilter(false)
+ , fIndex(0)
, fOverdrawViz(false)
, fOverdrawFilter(NULL)
, fOverrideTexFiltering(false)
, fTexOverrideFilter(NULL)
, fOutstandingSaveCount(0) {
- // TODO(chudy): Free up memory from all draw commands in destructor.
- fWidth = width;
- fHeight = height;
- // do we need fBm anywhere?
- fBm.setConfig(SkBitmap::kNo_Config, fWidth, fHeight);
- fFilter = false;
- fIndex = 0;
fUserMatrix.reset();
// SkPicturePlayback uses the base-class' quickReject calls to cull clipped
@@ -58,6 +55,7 @@ SkDebugCanvas::SkDebugCanvas(int width, int height)
SkDebugCanvas::~SkDebugCanvas() {
fCommandVector.deleteAll();
SkSafeUnref(fOverdrawFilter);
+ SkSafeUnref(fTexOverrideFilter);
}
void SkDebugCanvas::addDrawCommand(SkDrawCommand* command) {
@@ -65,14 +63,9 @@ void SkDebugCanvas::addDrawCommand(SkDrawCommand* command) {
}
void SkDebugCanvas::draw(SkCanvas* canvas) {
- if(!fCommandVector.isEmpty()) {
- for (int i = 0; i < fCommandVector.count(); i++) {
- if (fCommandVector[i]->isVisible()) {
- fCommandVector[i]->execute(canvas);
- }
- }
+ if (!fCommandVector.isEmpty()) {
+ drawTo(canvas, fCommandVector.count() - 1);
}
- fIndex = fCommandVector.count() - 1;
}
void SkDebugCanvas::applyUserTransform(SkCanvas* canvas) {
@@ -177,18 +170,19 @@ private:
void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
SkASSERT(!fCommandVector.isEmpty());
SkASSERT(index < fCommandVector.count());
- int i;
+ int i = 0;
// This only works assuming the canvas and device are the same ones that
// were previously drawn into because they need to preserve all saves
// and restores.
- if (fIndex < index) {
+ // The visibility filter also requires a full re-draw - otherwise we can
+ // end up drawing the filter repeatedly.
+ if (fIndex < index && !fFilter) {
i = fIndex + 1;
} else {
for (int j = 0; j < fOutstandingSaveCount; j++) {
canvas->restore();
}
- i = 0;
canvas->clear(SK_ColorTRANSPARENT);
canvas->resetMatrix();
SkRect rect = SkRect::MakeWH(SkIntToScalar(fWidth),
diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h
index 3df31513b4..262619e7f1 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -42,15 +42,6 @@ public:
void draw(SkCanvas* canvas);
/**
- Executes the draw calls in the specified range.
- @param canvas The canvas being drawn to
- @param i The beginning of the range
- @param j The end of the range
- TODO(chudy): Implement
- */
- void drawRange(SkCanvas* canvas, int i, int j);
-
- /**
Executes the draw calls up to the specified index.
@param canvas The canvas being drawn to
@param index The index of the final command being executed
@@ -244,9 +235,8 @@ public:
private:
SkTDArray<SkDrawCommand*> fCommandVector;
- int fHeight;
int fWidth;
- SkBitmap fBm;
+ int fHeight;
bool fFilter;
int fIndex;
SkMatrix fUserMatrix;