#include "SkDevice.h"
#include "SkXfermode.h"
-static SkBitmap make_noconfig_bm(int width, int height) {
- SkBitmap bm;
- bm.setConfig(SkBitmap::kNo_Config, width, height);
- return bm;
-}
-
SkDebugCanvas::SkDebugCanvas(int width, int height)
- : INHERITED(make_noconfig_bm(width, height))
+ : INHERITED(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
+ // operations. This can lead to problems in the debugger which expects all
+ // the operations in the captured skp to appear in the debug canvas. To
+ // circumvent this we create a wide open clip here (an empty clip rect
+ // is not sufficient).
+ // Internally, the SkRect passed to clipRect is converted to an SkIRect and
+ // rounded out. The following code creates a nearly maximal rect that will
+ // not get collapsed by the coming conversions (Due to precision loss the
+ // inset has to be surprisingly large).
+ SkIRect largeIRect = SkIRect::MakeLargest();
+ largeIRect.inset(1024, 1024);
+ SkRect large = SkRect::Make(largeIRect);
+#ifdef SK_DEBUG
+ large.roundOut(&largeIRect);
+ SkASSERT(!largeIRect.isEmpty());
+#endif
+ INHERITED::clipRect(large, SkRegion::kReplace_Op, false);
}
SkDebugCanvas::~SkDebugCanvas() {
fCommandVector.deleteAll();
SkSafeUnref(fOverdrawFilter);
+ SkSafeUnref(fTexOverrideFilter);
}
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) {
int SkDebugCanvas::getCommandAtPoint(int x, int y, int index) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
- bitmap.allocPixels();
+ bitmap.allocPixels(SkImageInfo::MakeN32Premul(1, 1));
SkCanvas canvas(bitmap);
canvas.translate(SkIntToScalar(-x), SkIntToScalar(-y));
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),