void drawColor(SkColor color,
SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode);
- /** Fill the entire canvas' bitmap (restricted to the current clip) with the
- specified paint.
- @param paint The paint used to fill the canvas
- */
+ /**
+ * This erases the entire drawing surface to the specified color,
+ * irrespective of the clip. It does not blend with the previous pixels,
+ * but always overwrites them.
+ *
+ * It is roughly equivalent to the following:
+ * canvas.save();
+ * canvas.clipRect(hugeRect, kReplace_Op);
+ * paint.setColor(color);
+ * paint.setXfermodeMode(kSrc_Mode);
+ * canvas.drawPaint(paint);
+ * canvas.restore();
+ * though it is almost always much more efficient.
+ */
+ virtual void clear(SkColor);
+
+ /**
+ * Fill the entire canvas' bitmap (restricted to the current clip) with the
+ * specified paint.
+ * @param paint The paint used to fill the canvas
+ */
virtual void drawPaint(const SkPaint& paint);
enum PointMode {
// These are the virtual drawing methods
//////////////////////////////////////////////////////////////////////////////
+void SkCanvas::clear(SkColor color) {
+ SkDrawIter iter(this);
+
+ while (iter.next()) {
+ iter.fDevice->clear(color);
+ }
+}
+
void SkCanvas::drawPaint(const SkPaint& paint) {
LOOPER_BEGIN(paint, SkDrawFilter::kPaint_Type)
DRAW_BITMAP,
DRAW_BITMAP_MATRIX,
DRAW_BITMAP_RECT,
+ DRAW_CLEAR,
DRAW_DATA,
DRAW_PAINT,
DRAW_PATH,
const SkMatrix* matrix = getMatrix();
canvas.drawBitmapMatrix(bitmap, *matrix, paint);
} break;
+ case DRAW_CLEAR:
+ canvas.clear(getInt());
+ break;
case DRAW_DATA: {
size_t length = getInt();
canvas.drawData(fReader.skip(length), length);
return this->INHERITED::clipRegion(region, op);
}
+void SkPictureRecord::clear(SkColor color) {
+ addDraw(DRAW_CLEAR);
+ addInt(color);
+ validate();
+}
+
void SkPictureRecord::drawPaint(const SkPaint& paint) {
addDraw(DRAW_PAINT);
addPaint(paint);
virtual bool clipRect(const SkRect& rect, SkRegion::Op op);
virtual bool clipPath(const SkPath& path, SkRegion::Op op);
virtual bool clipRegion(const SkRegion& region, SkRegion::Op op);
+ virtual void clear(SkColor);
virtual void drawPaint(const SkPaint& paint);
virtual void drawPoints(PointMode, size_t count, const SkPoint pts[],
const SkPaint&);