reverting r3268 because of test failures

git-svn-id: http://skia.googlecode.com/svn/trunk@3270 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
junov@chromium.org 2012-02-28 15:27:59 +00:00
parent 1c70074ffa
commit 5e5a095a94
2 changed files with 44 additions and 46 deletions

View File

@ -289,12 +289,11 @@ protected:
virtual SkCanvas* canvasForDrawIter();
private:
SkCanvas* drawingCanvas() const;
bool isFullFrame(const SkRect*, const SkPaint*) const;
void validate() const;
void init();
SkCanvas* fDrawingCanvas; // This points to the recording or immediate
// canvas, based on fDeferredDrawing
bool fDeferredDrawing;
bool fDeferredDrawing;
typedef SkCanvas INHERITED;
};

View File

@ -95,14 +95,19 @@ SkDeferredCanvas::SkDeferredCanvas(SkDevice* device,
}
void SkDeferredCanvas::init() {
fDeferredDrawing = true;
fDrawingCanvas = NULL;
fDeferredDrawing = true; // On by default
}
void SkDeferredCanvas::validate() const {
SkASSERT(getDevice());
}
SkCanvas* SkDeferredCanvas::drawingCanvas() const {
validate();
return fDeferredDrawing ? getDeferredDevice()->recordingCanvas() :
getDeferredDevice()->immediateCanvas();
}
void SkDeferredCanvas::flushIfNeeded(const SkBitmap& bitmap) {
validate();
if (fDeferredDrawing) {
@ -116,16 +121,13 @@ SkDeferredCanvas::DeferredDevice* SkDeferredCanvas::getDeferredDevice() const {
void SkDeferredCanvas::setDeferredDrawing(bool val) {
validate(); // Must set device before calling this method
SkASSERT(fDrawingCanvas->getSaveCount() == 1);
SkASSERT(drawingCanvas()->getSaveCount() == 1);
if (val != fDeferredDrawing) {
if (fDeferredDrawing) {
// Going live.
// Going live.
getDeferredDevice()->flushPending();
}
fDeferredDrawing = val;
fDrawingCanvas = val ?
getDeferredDevice()->recordingCanvas() :
getDeferredDevice()->immediateCanvas();
}
}
@ -134,9 +136,6 @@ SkDeferredCanvas::~SkDeferredCanvas() {
SkDevice* SkDeferredCanvas::setDevice(SkDevice* device) {
INHERITED::setDevice(SkNEW_ARGS(DeferredDevice, (device)))->unref();
fDrawingCanvas = fDeferredDrawing ?
getDeferredDevice()->recordingCanvas() :
getDeferredDevice()->immediateCanvas();
return device;
}
@ -153,7 +152,7 @@ SkDeferredCanvas::DeviceContext* SkDeferredCanvas::setDeviceContext(
bool SkDeferredCanvas::isFullFrame(const SkRect* rect,
const SkPaint* paint) const {
SkCanvas* canvas = fDrawingCanvas;
SkCanvas* canvas = drawingCanvas();
SkISize canvasSize = getDeviceSize();
if (rect) {
if (!canvas->getTotalMatrix().rectStaysRect()) {
@ -207,74 +206,74 @@ bool SkDeferredCanvas::isFullFrame(const SkRect* rect,
}
int SkDeferredCanvas::save(SaveFlags flags) {
fDrawingCanvas->save(flags);
drawingCanvas()->save(flags);
return this->INHERITED::save(flags);
}
int SkDeferredCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
SaveFlags flags) {
fDrawingCanvas->saveLayer(bounds, paint, flags);
drawingCanvas()->saveLayer(bounds, paint, flags);
int count = this->INHERITED::save(flags);
this->clipRectBounds(bounds, flags, NULL);
return count;
}
void SkDeferredCanvas::restore() {
fDrawingCanvas->restore();
drawingCanvas()->restore();
this->INHERITED::restore();
}
bool SkDeferredCanvas::isDrawingToLayer() const {
return fDrawingCanvas->isDrawingToLayer();
return drawingCanvas()->isDrawingToLayer();
}
bool SkDeferredCanvas::translate(SkScalar dx, SkScalar dy) {
fDrawingCanvas->translate(dx, dy);
drawingCanvas()->translate(dx, dy);
return this->INHERITED::translate(dx, dy);
}
bool SkDeferredCanvas::scale(SkScalar sx, SkScalar sy) {
fDrawingCanvas->scale(sx, sy);
drawingCanvas()->scale(sx, sy);
return this->INHERITED::scale(sx, sy);
}
bool SkDeferredCanvas::rotate(SkScalar degrees) {
fDrawingCanvas->rotate(degrees);
drawingCanvas()->rotate(degrees);
return this->INHERITED::rotate(degrees);
}
bool SkDeferredCanvas::skew(SkScalar sx, SkScalar sy) {
fDrawingCanvas->skew(sx, sy);
drawingCanvas()->skew(sx, sy);
return this->INHERITED::skew(sx, sy);
}
bool SkDeferredCanvas::concat(const SkMatrix& matrix) {
fDrawingCanvas->concat(matrix);
drawingCanvas()->concat(matrix);
return this->INHERITED::concat(matrix);
}
void SkDeferredCanvas::setMatrix(const SkMatrix& matrix) {
fDrawingCanvas->setMatrix(matrix);
drawingCanvas()->setMatrix(matrix);
this->INHERITED::setMatrix(matrix);
}
bool SkDeferredCanvas::clipRect(const SkRect& rect,
SkRegion::Op op,
bool doAntiAlias) {
fDrawingCanvas->clipRect(rect, op, doAntiAlias);
drawingCanvas()->clipRect(rect, op, doAntiAlias);
return this->INHERITED::clipRect(rect, op, doAntiAlias);
}
bool SkDeferredCanvas::clipPath(const SkPath& path,
SkRegion::Op op,
bool doAntiAlias) {
fDrawingCanvas->clipPath(path, op, doAntiAlias);
drawingCanvas()->clipPath(path, op, doAntiAlias);
return this->INHERITED::clipPath(path, op, doAntiAlias);
}
bool SkDeferredCanvas::clipRegion(const SkRegion& deviceRgn,
SkRegion::Op op) {
fDrawingCanvas->clipRegion(deviceRgn, op);
drawingCanvas()->clipRegion(deviceRgn, op);
return this->INHERITED::clipRegion(deviceRgn, op);
}
@ -284,7 +283,7 @@ void SkDeferredCanvas::clear(SkColor color) {
getDeferredDevice()->contentsCleared();
}
fDrawingCanvas->clear(color);
drawingCanvas()->clear(color);
}
void SkDeferredCanvas::drawPaint(const SkPaint& paint) {
@ -293,12 +292,12 @@ void SkDeferredCanvas::drawPaint(const SkPaint& paint) {
getDeferredDevice()->contentsCleared();
}
fDrawingCanvas->drawPaint(paint);
drawingCanvas()->drawPaint(paint);
}
void SkDeferredCanvas::drawPoints(PointMode mode, size_t count,
const SkPoint pts[], const SkPaint& paint) {
fDrawingCanvas->drawPoints(mode, count, pts, paint);
drawingCanvas()->drawPoints(mode, count, pts, paint);
}
void SkDeferredCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
@ -307,11 +306,11 @@ void SkDeferredCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
getDeferredDevice()->contentsCleared();
}
fDrawingCanvas->drawRect(rect, paint);
drawingCanvas()->drawRect(rect, paint);
}
void SkDeferredCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
fDrawingCanvas->drawPath(path, paint);
drawingCanvas()->drawPath(path, paint);
}
void SkDeferredCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar left,
@ -324,7 +323,7 @@ void SkDeferredCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar left,
getDeferredDevice()->contentsCleared();
}
fDrawingCanvas->drawBitmap(bitmap, left, top, paint);
drawingCanvas()->drawBitmap(bitmap, left, top, paint);
flushIfNeeded(bitmap);
}
@ -338,7 +337,7 @@ void SkDeferredCanvas::drawBitmapRect(const SkBitmap& bitmap,
getDeferredDevice()->contentsCleared();
}
fDrawingCanvas->drawBitmapRect(bitmap, src,
drawingCanvas()->drawBitmapRect(bitmap, src,
dst, paint);
flushIfNeeded(bitmap);
}
@ -349,7 +348,7 @@ void SkDeferredCanvas::drawBitmapMatrix(const SkBitmap& bitmap,
const SkPaint* paint) {
// TODO: reset recording canvas if paint+bitmap is opaque and clip rect
// covers canvas entirely and transformed bitmap covers canvas entirely
fDrawingCanvas->drawBitmapMatrix(bitmap, m, paint);
drawingCanvas()->drawBitmapMatrix(bitmap, m, paint);
flushIfNeeded(bitmap);
}
@ -358,7 +357,7 @@ void SkDeferredCanvas::drawBitmapNine(const SkBitmap& bitmap,
const SkPaint* paint) {
// TODO: reset recording canvas if paint+bitmap is opaque and clip rect
// covers canvas entirely and dst covers canvas entirely
fDrawingCanvas->drawBitmapNine(bitmap, center,
drawingCanvas()->drawBitmapNine(bitmap, center,
dst, paint);
flushIfNeeded(bitmap);
}
@ -376,38 +375,38 @@ void SkDeferredCanvas::drawSprite(const SkBitmap& bitmap, int left, int top,
getDeferredDevice()->contentsCleared();
}
fDrawingCanvas->drawSprite(bitmap, left, top,
drawingCanvas()->drawSprite(bitmap, left, top,
paint);
flushIfNeeded(bitmap);
}
void SkDeferredCanvas::drawText(const void* text, size_t byteLength,
SkScalar x, SkScalar y, const SkPaint& paint) {
fDrawingCanvas->drawText(text, byteLength, x, y, paint);
drawingCanvas()->drawText(text, byteLength, x, y, paint);
}
void SkDeferredCanvas::drawPosText(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint) {
fDrawingCanvas->drawPosText(text, byteLength, pos, paint);
drawingCanvas()->drawPosText(text, byteLength, pos, paint);
}
void SkDeferredCanvas::drawPosTextH(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY,
const SkPaint& paint) {
fDrawingCanvas->drawPosTextH(text, byteLength, xpos, constY, paint);
drawingCanvas()->drawPosTextH(text, byteLength, xpos, constY, paint);
}
void SkDeferredCanvas::drawTextOnPath(const void* text, size_t byteLength,
const SkPath& path,
const SkMatrix* matrix,
const SkPaint& paint) {
fDrawingCanvas->drawTextOnPath(text, byteLength,
drawingCanvas()->drawTextOnPath(text, byteLength,
path, matrix,
paint);
}
void SkDeferredCanvas::drawPicture(SkPicture& picture) {
fDrawingCanvas->drawPicture(picture);
drawingCanvas()->drawPicture(picture);
}
void SkDeferredCanvas::drawVertices(VertexMode vmode, int vertexCount,
@ -416,7 +415,7 @@ void SkDeferredCanvas::drawVertices(VertexMode vmode, int vertexCount,
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) {
fDrawingCanvas->drawVertices(vmode, vertexCount,
drawingCanvas()->drawVertices(vmode, vertexCount,
vertices, texs,
colors, xmode,
indices, indexCount,
@ -424,17 +423,17 @@ void SkDeferredCanvas::drawVertices(VertexMode vmode, int vertexCount,
}
SkBounder* SkDeferredCanvas::setBounder(SkBounder* bounder) {
fDrawingCanvas->setBounder(bounder);
drawingCanvas()->setBounder(bounder);
return INHERITED::setBounder(bounder);
}
SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) {
fDrawingCanvas->setDrawFilter(filter);
drawingCanvas()->setDrawFilter(filter);
return INHERITED::setDrawFilter(filter);
}
SkCanvas* SkDeferredCanvas::canvasForDrawIter() {
return fDrawingCanvas;
return drawingCanvas();
}
// SkDeferredCanvas::DeferredDevice