Remove SkCanvas::drawBitmapMatrix()

R=mtklein@google.com, reed@google.com, robertphillips@google.com

Review URL: https://codereview.chromium.org/789033002
This commit is contained in:
Florin Malita 2014-12-10 12:02:16 -05:00
parent 3d6405b52d
commit c54d8db4d1
38 changed files with 61 additions and 361 deletions

View File

@ -94,7 +94,8 @@ protected:
paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
fInputBitmap.notifyPixelsChanged();
canvas.drawBitmapMatrix( fInputBitmap, fMatrix, &paint );
canvas.concat(fMatrix);
canvas.drawBitmap(fInputBitmap, 0, 0, &paint );
}
private:
typedef BitmapScaleBench INHERITED;

View File

@ -40,8 +40,6 @@ public:
const SkRect& dst,
const SkPaint* paint,
DrawBitmapRectFlags flags) SK_OVERRIDE {}
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint* paint = NULL) SK_OVERRIDE {}
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {}
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,

View File

@ -1,135 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkBitmap.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkColor.h"
#include "SkMatrix.h"
#include "SkPath.h"
#include "SkRect.h"
#include "SkSize.h"
#include "SkString.h"
namespace skiagm {
class DrawBitmapMatrixGM : public GM {
public:
DrawBitmapMatrixGM() {}
protected:
virtual uint32_t onGetFlags() const SK_OVERRIDE {
return kSkipTiled_Flag;
}
virtual SkString onShortName() SK_OVERRIDE {
return SkString("drawbitmapmatrix");
}
virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(1024, 256); }
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkBitmap bm;
this->setupBitmap(&bm);
// Draw normally.
SkMatrix matrix;
matrix.reset();
SkPaint paint;
paint.setAntiAlias(true);
paint.setDither(true);
canvas->drawBitmapMatrix(bm, matrix, &paint);
// Draw stretched horizontally and squished vertically.
canvas->translate(SkIntToScalar(bm.width() + 5), 0);
matrix.setScale(SkIntToScalar(2), SK_ScalarHalf);
canvas->drawBitmapMatrix(bm, matrix, &paint);
// Draw rotated
canvas->translate(SkIntToScalar(bm.width()*2 + 5), 0);
matrix.reset();
matrix.setRotate(SkIntToScalar(45), SkIntToScalar(bm.width() / 2),
SkIntToScalar(bm.height() / 2));
canvas->save();
canvas->translate(0, SkIntToScalar(10));
canvas->drawBitmapMatrix(bm, matrix, &paint);
canvas->restore();
// Draw with perspective
canvas->translate(SkIntToScalar(bm.width() + 15), 0);
matrix.reset();
matrix.setPerspX(SkScalarDiv(SK_Scalar1, SkIntToScalar(1000)));
matrix.setPerspY(SkScalarDiv(SK_Scalar1, SkIntToScalar(1000)));
canvas->drawBitmapMatrix(bm, matrix, &paint);
// Draw with skew
canvas->translate(SkIntToScalar(bm.width() + 5), 0);
matrix.reset();
matrix.setSkew(SkIntToScalar(2), SkIntToScalar(2));
canvas->drawBitmapMatrix(bm, matrix, &paint);
// Draw with sin/cos
canvas->translate(SkIntToScalar(bm.width() * 4), 0);
matrix.reset();
matrix.setSinCos(SK_ScalarHalf, SkIntToScalar(2));
canvas->drawBitmapMatrix(bm, matrix, &paint);
{
// test the following code path:
// SkGpuDevice::drawPath() -> SkGpuDevice::drawWithMaskFilter()
SkPaint paint;
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
SkMaskFilter* mf = SkBlurMaskFilter::Create(
kNormal_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(5),
SkBlurMaskFilter::kHighQuality_BlurFlag |
SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
paint.setMaskFilter(mf)->unref();
canvas->translate(SkIntToScalar(bm.width()*2 + 20), 0);
matrix.reset();
matrix.setRotate(SkIntToScalar(45), SkIntToScalar(bm.width() / 2),
SkIntToScalar(bm.height() / 2));
canvas->save();
canvas->translate(0, SkIntToScalar(20));
canvas->drawBitmapMatrix(bm, matrix, &paint);
canvas->restore();
}
}
private:
void setupBitmap(SkBitmap* bm) {
SkASSERT(bm);
static const int SIZE = 64;
bm->allocN32Pixels(SIZE, SIZE);
SkCanvas canvas(*bm);
SkPaint paint;
paint.setColor(SK_ColorGREEN);
canvas.drawPaint(paint);
paint.setColor(SK_ColorBLUE);
paint.setAntiAlias(true);
SkRect rect = SkRect::MakeWH(SkIntToScalar(SIZE), SkIntToScalar(SIZE));
SkPath path;
path.addOval(rect);
canvas.drawPath(path, paint);
}
};
////////////////////////////////////////////////////////////////////////////////
static GM* MyFactory(void*) { return new DrawBitmapMatrixGM; }
static GMRegistry reg(MyFactory);
}

View File

@ -78,7 +78,8 @@ protected:
canvas->save();
canvas->translate(0, (SkScalar)curY);
canvas->drawBitmapMatrix( fBM, matrix, &paint );
canvas->concat(matrix);
canvas->drawBitmap(fBM, 0, 0, &paint);
canvas->restore();
curHeight = (int) (fBM.height() * curScale + 2);

View File

@ -24,24 +24,22 @@ static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
return SkSize::Make(bounds.width(), bounds.height());
}
static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx) {
static void draw_cell(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx,
SkPaint::FilterLevel lvl) {
SkPaint paint;
paint.setFilterLevel(lvl);
SkAutoCanvasRestore acr(canvas, true);
canvas->drawBitmapMatrix(bm, mat, &paint);
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
canvas->translate(dx, 0);
canvas->drawBitmapMatrix(bm, mat, &paint);
canvas->concat(mat);
canvas->drawBitmap(bm, 0, 0, &paint);
}
paint.setFilterLevel(SkPaint::kMedium_FilterLevel);
canvas->translate(dx, 0);
canvas->drawBitmapMatrix(bm, mat, &paint);
paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
canvas->translate(dx, 0);
canvas->drawBitmapMatrix(bm, mat, &paint);
static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx) {
draw_cell(canvas, bm, mat, 0 * dx, SkPaint::kNone_FilterLevel);
draw_cell(canvas, bm, mat, 1 * dx, SkPaint::kLow_FilterLevel);
draw_cell(canvas, bm, mat, 2 * dx, SkPaint::kMedium_FilterLevel);
draw_cell(canvas, bm, mat, 3 * dx, SkPaint::kHigh_FilterLevel);
}
class FilterBitmapGM : public skiagm::GM {

View File

@ -23,24 +23,23 @@ static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
return SkSize::Make(bounds.width(), bounds.height());
}
static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx) {
static void draw_cell(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx,
SkPaint::FilterLevel lvl) {
SkPaint paint;
paint.setFilterLevel(lvl);
SkAutoCanvasRestore acr(canvas, true);
canvas->drawBitmapMatrix(bm, mat, &paint);
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
canvas->translate(dx, 0);
canvas->drawBitmapMatrix(bm, mat, &paint);
canvas->concat(mat);
canvas->drawBitmap(bm, 0, 0, &paint);
}
paint.setFilterLevel(SkPaint::kMedium_FilterLevel);
canvas->translate(dx, 0);
canvas->drawBitmapMatrix(bm, mat, &paint);
paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
canvas->translate(dx, 0);
canvas->drawBitmapMatrix(bm, mat, &paint);
static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx) {
draw_cell(canvas, bm, mat, 0 * dx, SkPaint::kNone_FilterLevel);
draw_cell(canvas, bm, mat, 1 * dx, SkPaint::kLow_FilterLevel);
draw_cell(canvas, bm, mat, 2 * dx, SkPaint::kMedium_FilterLevel);
draw_cell(canvas, bm, mat, 3 * dx, SkPaint::kHigh_FilterLevel);
}
class FilterIndiaBoxGM : public skiagm::GM {

View File

@ -84,13 +84,17 @@ class XfermodesGM : public GM {
bool restoreNeeded = false;
m.setTranslate(x, y);
canvas->drawBitmapMatrix(fSrcB, m, &p);
canvas->drawBitmap(fSrcB, x, y, &p);
p.setXfermode(mode);
switch (srcType) {
case kSmallTransparentImage_SrcType:
case kSmallTransparentImage_SrcType: {
m.postScale(SK_ScalarHalf, SK_ScalarHalf, x, y);
canvas->drawBitmapMatrix(fTransparent, m, &p);
SkAutoCanvasRestore acr(canvas, true);
canvas->concat(m);
canvas->drawBitmap(fTransparent, 0, 0, &p);
break;
}
case kQuarterClearInLayer_SrcType: {
SkRect bounds = SkRect::MakeXYWH(x, y, SkIntToScalar(W),
SkIntToScalar(H));
@ -135,9 +139,12 @@ class XfermodesGM : public GM {
case kRectangleImageWithAlpha_SrcType:
p.setAlpha(0x88);
// Fall through.
case kRectangleImage_SrcType:
canvas->drawBitmapMatrix(fDstB, m, &p);
case kRectangleImage_SrcType: {
SkAutoCanvasRestore acr(canvas, true);
canvas->concat(m);
canvas->drawBitmap(fDstB, 0, 0, &p);
break;
}
default:
break;
}

View File

@ -25,7 +25,6 @@
'../gm/bigmatrix.cpp',
'../gm/bigtext.cpp',
'../gm/bitmapcopy.cpp',
'../gm/bitmapmatrix.cpp',
'../gm/bitmapfilters.cpp',
'../gm/bitmappremul.cpp',
'../gm/bitmaprect.cpp',

View File

@ -853,9 +853,6 @@ public:
this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint, flags);
}
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint* paint = NULL);
/**
* Draw the bitmap stretched differentially to fit into dst.
* center is a rect within the bitmap, and logically divides the bitmap

View File

@ -160,8 +160,6 @@ public:
const SkRect& dst, const SkPaint* paint,
DrawBitmapRectFlags flags) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint* paint) SK_OVERRIDE;
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint)
SK_OVERRIDE;

View File

@ -87,8 +87,6 @@ public:
virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
DrawBitmapRectFlags flags) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint* paint) SK_OVERRIDE;
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
const SkPaint* paint) SK_OVERRIDE;
virtual void drawVertices(VertexMode vmode, int vertexCount,

View File

@ -32,8 +32,6 @@ public:
virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
DrawBitmapRectFlags flags) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint* paint) SK_OVERRIDE;
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
const SkPaint* paint) SK_OVERRIDE;
virtual void drawVertices(VertexMode vmode, int vertexCount,

View File

@ -40,8 +40,6 @@ public:
virtual void drawImageRect(const SkImage* image, const SkRect* src,
const SkRect& dst,
const SkPaint* paint) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint*) SK_OVERRIDE;
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst,
const SkPaint* paint = NULL) SK_OVERRIDE;

View File

@ -38,8 +38,6 @@ public:
virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
DrawBitmapRectFlags flags) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint* paint = NULL) SK_OVERRIDE;
virtual void drawImage(const SkImage* image, SkScalar left, SkScalar top,
const SkPaint* paint = NULL) SK_OVERRIDE;
virtual void drawImageRect(const SkImage* image, const SkRect* src,

View File

@ -1961,13 +1961,6 @@ void SkCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
this->internalDrawBitmapRect(bitmap, src, dst, paint, flags);
}
void SkCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
const SkPaint* paint) {
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapMatrix()");
SkDEBUGCODE(bitmap.validate();)
this->internalDrawBitmap(bitmap, matrix, paint);
}
void SkCanvas::internalDrawBitmapNine(const SkBitmap& bitmap,
const SkIRect& center, const SkRect& dst,
const SkPaint* paint) {

View File

@ -27,7 +27,7 @@ enum DrawType {
CLIP_RRECT,
CONCAT,
DRAW_BITMAP,
DRAW_BITMAP_MATRIX,
DRAW_BITMAP_MATRIX, // deprecated, M41 was last Chromium version to write this to an .skp
DRAW_BITMAP_NINE,
DRAW_BITMAP_RECT_TO_RECT,
DRAW_CLEAR,

View File

@ -186,7 +186,10 @@ void SkPicturePlayback::handleOp(SkReader32* reader,
const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader));
SkMatrix matrix;
reader->readMatrix(&matrix);
canvas->drawBitmapMatrix(bitmap, matrix, paint);
SkAutoCanvasRestore acr(canvas, true);
canvas->concat(matrix);
canvas->drawBitmap(bitmap, 0, 0, paint);
} break;
case DRAW_BITMAP_NINE: {
const SkPaint* paint = fPictureData->getPaint(reader);

View File

@ -57,7 +57,7 @@ static inline size_t get_paint_offset(DrawType op, size_t opSize) {
0, // CLIP_RRECT - no paint
0, // CONCAT - no paint
1, // DRAW_BITMAP - right after op code
1, // DRAW_BITMAP_MATRIX - right after op code
1, // DRAW_BITMAP_MATRIX - right after op code, deprecated
1, // DRAW_BITMAP_NINE - right after op code
1, // DRAW_BITMAP_RECT_TO_RECT - right after op code
0, // DRAW_CLEAR - no paint
@ -573,18 +573,6 @@ void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect*
this->validate(initialOffset, size);
}
void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
const SkPaint* paint) {
// id + paint index + bitmap index + matrix
size_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL);
size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size);
SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_MATRIX, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
this->addBitmap(bitmap);
this->addMatrix(matrix);
this->validate(initialOffset, size);
}
void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint) {
// op + paint index + bitmap id + center + dst rect

View File

@ -41,8 +41,6 @@ public:
virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
DrawBitmapRectFlags flags) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
const SkPaint*) SK_OVERRIDE;
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint*) SK_OVERRIDE;
virtual void drawSprite(const SkBitmap&, int left, int top,

View File

@ -101,7 +101,6 @@ DRAW(AddComment, addComment(r.key, r.value));
DRAW(EndCommentGroup, endCommentGroup());
DRAW(DrawBitmap, drawBitmap(shallow_copy(r.bitmap), r.left, r.top, r.paint));
DRAW(DrawBitmapMatrix, drawBitmapMatrix(shallow_copy(r.bitmap), r.matrix, r.paint));
DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.paint));
DRAW(DrawBitmapRectToRect,
drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint,
@ -436,11 +435,6 @@ private:
SkRect::MakeXYWH(op.left, op.top, op.bitmap.width(), op.bitmap.height()),
op.paint);
}
Bounds bounds(const DrawBitmapMatrix& op) const {
SkRect dst = SkRect::MakeWH(op.bitmap.width(), op.bitmap.height());
op.matrix.mapRect(&dst);
return this->adjustAndMap(dst, op.paint);
}
Bounds bounds(const DrawPath& op) const {
return op.path.isInverseFillType() ? fCurrentClipBounds

View File

@ -179,12 +179,6 @@ void SkRecorder::drawBitmapRectToRect(const SkBitmap& bitmap,
this->copy(paint), delay_copy(bitmap), this->copy(src), dst);
}
void SkRecorder::drawBitmapMatrix(const SkBitmap& bitmap,
const SkMatrix& matrix,
const SkPaint* paint) {
APPEND(DrawBitmapMatrix, this->copy(paint), delay_copy(bitmap), matrix);
}
void SkRecorder::drawBitmapNine(const SkBitmap& bitmap,
const SkIRect& center,
const SkRect& dst,

View File

@ -63,9 +63,6 @@ public:
const SkRect& dst,
const SkPaint* paint = NULL,
DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) SK_OVERRIDE;
void drawBitmapMatrix(const SkBitmap& bitmap,
const SkMatrix& m,
const SkPaint* paint = NULL) SK_OVERRIDE;
void drawBitmapNine(const SkBitmap& bitmap,
const SkIRect& center,
const SkRect& dst,

View File

@ -42,7 +42,6 @@ namespace SkRecords {
M(AddComment) \
M(EndCommentGroup) \
M(DrawBitmap) \
M(DrawBitmapMatrix) \
M(DrawBitmapNine) \
M(DrawBitmapRectToRect) \
M(DrawBitmapRectToRectBleed) \
@ -246,7 +245,6 @@ RECORD4(DrawBitmap, Optional<SkPaint>, paint,
ImmutableBitmap, bitmap,
SkScalar, left,
SkScalar, top);
RECORD3(DrawBitmapMatrix, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, TypedMatrix, matrix);
RECORD4(DrawBitmapNine, Optional<SkPaint>, paint,
ImmutableBitmap, bitmap,
SkIRect, center,

View File

@ -469,6 +469,12 @@ static SkString sweepCode(const SkShader::GradientInfo& info,
return function;
}
static void drawBitmapMatrix(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& matrix) {
SkAutoCanvasRestore acr(canvas, true);
canvas->concat(matrix);
canvas->drawBitmap(bm, 0, 0);
}
class SkPDFShader::State {
public:
SkShader::GradientType fType;
@ -1015,14 +1021,14 @@ SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) : fState(state) {
SkMatrix xMirror;
xMirror.setScale(-1, 1);
xMirror.postTranslate(2 * width, 0);
canvas.drawBitmapMatrix(*image, xMirror);
drawBitmapMatrix(&canvas, *image, xMirror);
patternBBox.fRight += width;
}
if (tileModes[1] == SkShader::kMirror_TileMode) {
SkMatrix yMirror;
yMirror.setScale(SK_Scalar1, -SK_Scalar1);
yMirror.postTranslate(0, 2 * height);
canvas.drawBitmapMatrix(*image, yMirror);
drawBitmapMatrix(&canvas, *image, yMirror);
patternBBox.fBottom += height;
}
if (tileModes[0] == SkShader::kMirror_TileMode &&
@ -1030,7 +1036,7 @@ SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) : fState(state) {
SkMatrix mirror;
mirror.setScale(-1, -1);
mirror.postTranslate(2 * width, 2 * height);
canvas.drawBitmapMatrix(*image, mirror);
drawBitmapMatrix(&canvas, *image, mirror);
}
// Then handle Clamping, which requires expanding the pattern canvas to
@ -1081,12 +1087,12 @@ SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) : fState(state) {
SkMatrix leftMatrix;
leftMatrix.setScale(-deviceBounds.left(), 1);
leftMatrix.postTranslate(deviceBounds.left(), 0);
canvas.drawBitmapMatrix(left, leftMatrix);
drawBitmapMatrix(&canvas, left, leftMatrix);
if (tileModes[1] == SkShader::kMirror_TileMode) {
leftMatrix.postScale(SK_Scalar1, -SK_Scalar1);
leftMatrix.postTranslate(0, 2 * height);
canvas.drawBitmapMatrix(left, leftMatrix);
drawBitmapMatrix(&canvas, left, leftMatrix);
}
patternBBox.fLeft = 0;
}
@ -1099,12 +1105,12 @@ SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) : fState(state) {
SkMatrix rightMatrix;
rightMatrix.setScale(deviceBounds.right() - width, 1);
rightMatrix.postTranslate(width, 0);
canvas.drawBitmapMatrix(right, rightMatrix);
drawBitmapMatrix(&canvas, right, rightMatrix);
if (tileModes[1] == SkShader::kMirror_TileMode) {
rightMatrix.postScale(SK_Scalar1, -SK_Scalar1);
rightMatrix.postTranslate(0, 2 * height);
canvas.drawBitmapMatrix(right, rightMatrix);
drawBitmapMatrix(&canvas, right, rightMatrix);
}
patternBBox.fRight = deviceBounds.width();
}
@ -1119,12 +1125,12 @@ SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) : fState(state) {
SkMatrix topMatrix;
topMatrix.setScale(SK_Scalar1, -deviceBounds.top());
topMatrix.postTranslate(0, deviceBounds.top());
canvas.drawBitmapMatrix(top, topMatrix);
drawBitmapMatrix(&canvas, top, topMatrix);
if (tileModes[0] == SkShader::kMirror_TileMode) {
topMatrix.postScale(-1, 1);
topMatrix.postTranslate(2 * width, 0);
canvas.drawBitmapMatrix(top, topMatrix);
drawBitmapMatrix(&canvas, top, topMatrix);
}
patternBBox.fTop = 0;
}
@ -1137,12 +1143,12 @@ SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) : fState(state) {
SkMatrix bottomMatrix;
bottomMatrix.setScale(SK_Scalar1, deviceBounds.bottom() - height);
bottomMatrix.postTranslate(0, height);
canvas.drawBitmapMatrix(bottom, bottomMatrix);
drawBitmapMatrix(&canvas, bottom, bottomMatrix);
if (tileModes[0] == SkShader::kMirror_TileMode) {
bottomMatrix.postScale(-1, 1);
bottomMatrix.postTranslate(2 * width, 0);
canvas.drawBitmapMatrix(bottom, bottomMatrix);
drawBitmapMatrix(&canvas, bottom, bottomMatrix);
}
patternBBox.fBottom = deviceBounds.height();
}

View File

@ -40,7 +40,6 @@ enum DrawOps {
kClipRRect_DrawOp,
kConcat_DrawOp,
kDrawBitmap_DrawOp,
kDrawBitmapMatrix_DrawOp,
kDrawBitmapNine_DrawOp,
kDrawBitmapRectToRect_DrawOp,
kDrawClear_DrawOp,

View File

@ -590,19 +590,6 @@ static void drawBitmap_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
}
}
static void drawBitmapMatrix_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
SkGPipeState* state) {
BitmapHolder holder(reader, op32, state);
bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_DrawOpFlag);
SkMatrix matrix;
reader->readMatrix(&matrix);
const SkBitmap* bitmap = holder.getBitmap();
if (state->shouldDraw()) {
canvas->drawBitmapMatrix(*bitmap, matrix,
hasPaint ? &state->paint() : NULL);
}
}
static void drawBitmapNine_rp(SkCanvas* canvas, SkReader32* reader,
uint32_t op32, SkGPipeState* state) {
BitmapHolder holder(reader, op32, state);
@ -825,7 +812,6 @@ static const ReadProc gReadTable[] = {
clipRRect_rp,
concat_rp,
drawBitmap_rp,
drawBitmapMatrix_rp,
drawBitmapNine_rp,
drawBitmapRect_rp,
drawClear_rp,

View File

@ -245,8 +245,6 @@ public:
virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
DrawBitmapRectFlags flags) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
const SkPaint*) SK_OVERRIDE;
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE;
virtual void drawSprite(const SkBitmap&, int left, int top,
@ -820,16 +818,6 @@ void SkGPipeCanvas::drawBitmapRectToRect(const SkBitmap& bm, const SkRect* src,
}
}
void SkGPipeCanvas::drawBitmapMatrix(const SkBitmap& bm, const SkMatrix& matrix,
const SkPaint* paint) {
NOTIFY_SETUP(this);
size_t opBytesNeeded = matrix.writeToMemory(NULL);
if (this->commonDrawBitmap(bm, kDrawBitmapMatrix_DrawOp, 0, opBytesNeeded, paint)) {
fWriter.writeMatrix(matrix);
}
}
void SkGPipeCanvas::drawBitmapNine(const SkBitmap& bm, const SkIRect& center,
const SkRect& dst, const SkPaint* paint) {
NOTIFY_SETUP(this);

View File

@ -829,17 +829,6 @@ void SkDeferredCanvas::drawBitmapRectToRect(const SkBitmap& bitmap,
this->recordedDrawCommand();
}
void SkDeferredCanvas::drawBitmapMatrix(const SkBitmap& bitmap,
const SkMatrix& m,
const SkPaint* paint) {
// TODO: reset recording canvas if paint+bitmap is opaque and clip rect
// covers canvas entirely and transformed bitmap covers canvas entirely
AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
this->drawingCanvas()->drawBitmapMatrix(bitmap, m, paint);
this->recordedDrawCommand();
}
void SkDeferredCanvas::drawBitmapNine(const SkBitmap& bitmap,
const SkIRect& center, const SkRect& dst,
const SkPaint* paint) {

View File

@ -373,15 +373,6 @@ void SkDumpCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* sr
bs.c_str(), rs.c_str());
}
void SkDumpCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint* paint) {
SkString bs, ms;
bitmap.toString(&bs);
m.toString(&ms);
this->dump(kDrawBitmap_Verb, paint, "drawBitmapMatrix(%s %s)",
bs.c_str(), ms.c_str());
}
void SkDumpCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
const SkPaint* paint) {
SkString str;

View File

@ -223,14 +223,6 @@ void SkLuaCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src
}
}
void SkLuaCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint* paint) {
AUTO_LUA("drawBitmapMatrix");
if (paint) {
lua.pushPaint(*paint, "paint");
}
}
void SkLuaCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
const SkPaint* paint) {
AUTO_LUA("drawSprite");

View File

@ -202,14 +202,6 @@ void SkNWayCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* sr
}
}
void SkNWayCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint* paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawBitmapMatrix(bitmap, m, paint);
}
}
void SkNWayCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint) {
Iter iter(fList);

View File

@ -117,11 +117,6 @@ void SkProxyCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* s
fProxy->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
}
void SkProxyCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
const SkPaint* paint) {
fProxy->drawBitmapMatrix(bitmap, m, paint);
}
void SkProxyCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
const SkPaint* paint) {
fProxy->drawSprite(bitmap, x, y, paint);

View File

@ -472,11 +472,6 @@ void SkDebugCanvas::drawBitmapRectToRect(const SkBitmap& bitmap,
this->addDrawCommand(new SkDrawBitmapRectCommand(bitmap, src, dst, paint, flags));
}
void SkDebugCanvas::drawBitmapMatrix(const SkBitmap& bitmap,
const SkMatrix& matrix, const SkPaint* paint) {
this->addDrawCommand(new SkDrawBitmapMatrixCommand(bitmap, matrix, paint));
}
void SkDebugCanvas::drawBitmapNine(const SkBitmap& bitmap,
const SkIRect& center, const SkRect& dst, const SkPaint* paint) {
this->addDrawCommand(new SkDrawBitmapNineCommand(bitmap, center, dst, paint));

View File

@ -165,9 +165,6 @@ public:
const SkRect& dst, const SkPaint* paint,
DrawBitmapRectFlags flags) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
const SkPaint*) SK_OVERRIDE;
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint*) SK_OVERRIDE;

View File

@ -300,35 +300,6 @@ bool SkDrawBitmapCommand::render(SkCanvas* canvas) const {
return true;
}
SkDrawBitmapMatrixCommand::SkDrawBitmapMatrixCommand(const SkBitmap& bitmap,
const SkMatrix& matrix,
const SkPaint* paint)
: INHERITED(DRAW_BITMAP_MATRIX) {
fBitmap = bitmap;
fMatrix = matrix;
if (paint) {
fPaint = *paint;
fPaintPtr = &fPaint;
} else {
fPaintPtr = NULL;
}
fInfo.push(SkObjectParser::BitmapToString(bitmap));
fInfo.push(SkObjectParser::MatrixToString(matrix));
if (paint) {
fInfo.push(SkObjectParser::PaintToString(*paint));
}
}
void SkDrawBitmapMatrixCommand::execute(SkCanvas* canvas) const {
canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr);
}
bool SkDrawBitmapMatrixCommand::render(SkCanvas* canvas) const {
render_bitmap(canvas, fBitmap);
return true;
}
SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint)
: INHERITED(DRAW_BITMAP_NINE) {

View File

@ -189,21 +189,6 @@ private:
typedef SkDrawCommand INHERITED;
};
class SkDrawBitmapMatrixCommand : public SkDrawCommand {
public:
SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, const SkMatrix& matrix,
const SkPaint* paint);
virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
private:
SkBitmap fBitmap;
SkMatrix fMatrix;
SkPaint fPaint;
SkPaint* fPaintPtr;
typedef SkDrawCommand INHERITED;
};
class SkDrawBitmapNineCommand : public SkDrawCommand {
public:
SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,

View File

@ -1779,7 +1779,6 @@ static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) {
// Don't care what these record, as long as they're legal.
canvas->drawBitmap(bitmap, 0.0f, 0.0f, &paint);
canvas->drawBitmapRectToRect(bitmap, &rect, rect, &paint, SkCanvas::kNone_DrawBitmapRectFlag);
canvas->drawBitmapMatrix(bitmap, SkMatrix::I(), &paint);
canvas->drawBitmapNine(bitmap, irect, rect, &paint);
canvas->drawSprite(bitmap, 1, 1);
}

View File

@ -240,10 +240,6 @@ static void TestSurfaceCopyOnWrite(skiatest::Reporter* reporter, SurfaceType sur
const SkRect testRect =
SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
SkIntToScalar(4), SkIntToScalar(5));
SkMatrix testMatrix;
testMatrix.reset();
testMatrix.setScale(SkIntToScalar(2), SkIntToScalar(3));
SkPath testPath;
testPath.addRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
SkIntToScalar(2), SkIntToScalar(1)));
@ -305,7 +301,6 @@ static void TestSurfaceCopyOnWrite(skiatest::Reporter* reporter, SurfaceType sur
EXPECT_COPY_ON_WRITE(drawPath(testPath, testPaint))
EXPECT_COPY_ON_WRITE(drawBitmap(testBitmap, 0, 0))
EXPECT_COPY_ON_WRITE(drawBitmapRect(testBitmap, NULL, testRect))
EXPECT_COPY_ON_WRITE(drawBitmapMatrix(testBitmap, testMatrix, NULL))
EXPECT_COPY_ON_WRITE(drawBitmapNine(testBitmap, testIRect, testRect, NULL))
EXPECT_COPY_ON_WRITE(drawSprite(testBitmap, 0, 0, NULL))
EXPECT_COPY_ON_WRITE(drawText(testText.c_str(), testText.size(), 0, 1, testPaint))