flag to use const& instead of const* for src-rect

BUG=skia:

Review URL: https://codereview.chromium.org/1272713005
This commit is contained in:
reed 2015-08-06 10:02:53 -07:00 committed by Commit bot
parent fb1141ae1d
commit e47829b6b1
31 changed files with 173 additions and 88 deletions

View File

@ -96,7 +96,7 @@ protected:
paint.setAlpha(fAlpha);
for (int i = 0; i < loops; i++) {
canvas->drawBitmapRect(fBitmap, &fSrcR, fDstR, &paint,
canvas->drawBitmapRect(fBitmap, fSrcR, fDstR, &paint,
SkCanvas::kStrict_SrcRectConstraint);
}
}

View File

@ -84,7 +84,7 @@ protected:
SkRect bound3 = SkRect::MakeXYWH(320, 320,
SkIntToScalar(kBitmapSize),
SkIntToScalar(kBitmapSize));
canvas->drawBitmapRect(fGreenBitmap, &bound2, bound3, NULL,
canvas->drawBitmapRect(fGreenBitmap, bound2, bound3, nullptr,
SkCanvas::kStrict_SrcRectConstraint);
canvas->restore();
}

View File

@ -70,7 +70,7 @@ protected:
canvas->drawBitmap(bitmap, 0, 0, &paint);
if (!fUseIRect) {
canvas->drawBitmapRect(bitmap, &srcR, dstR, &paint,
canvas->drawBitmapRect(bitmap, srcR, dstR, &paint,
SkCanvas::kStrict_SrcRectConstraint);
} else {
canvas->drawBitmapRect(bitmap, src[i], dstR, &paint);
@ -143,7 +143,7 @@ protected:
SkRect srcR = { 0.5f, 0.5f, 2.5f, 2.5f };
SkRect dstR = { 100, 100, 300, 200 };
canvas->drawBitmapRect(bitmap, &srcR, dstR, NULL, SkCanvas::kStrict_SrcRectConstraint);
canvas->drawBitmapRect(bitmap, srcR, dstR, nullptr, SkCanvas::kStrict_SrcRectConstraint);
}
private:
@ -213,9 +213,9 @@ protected:
SkRect dstR2 = { 10, 410, 30, 430 };
if (!fUseIRect) {
canvas->drawBitmapRect(fBigBitmap, &srcR1, dstR1, &paint,
canvas->drawBitmapRect(fBigBitmap, srcR1, dstR1, &paint,
SkCanvas::kStrict_SrcRectConstraint);
canvas->drawBitmapRect(fBigBitmap, &srcR2, dstR2, &paint,
canvas->drawBitmapRect(fBigBitmap, srcR2, dstR2, &paint,
SkCanvas::kStrict_SrcRectConstraint);
} else {
canvas->drawBitmapRect(fBigBitmap, srcR1.roundOut(), dstR1, &paint);
@ -263,7 +263,7 @@ protected:
// the drawRect shows the same problem as clipRect(r) followed by drawcolor(red)
canvas->drawRect(r, paint);
canvas->drawBitmapRect(fBM, NULL, r, NULL);
canvas->drawBitmapRect(fBM, r, nullptr);
}
private:

View File

@ -43,7 +43,7 @@ static void test_bitmaprect(SkCanvas* canvas) {
SkScalar scale = 0.472560018f;
canvas->save();
canvas->scale(scale, scale);
canvas->drawBitmapRect(bm, SkRect::MakeXYWH(100, 100, 128, 128));
canvas->drawBitmapRect(bm, SkRect::MakeXYWH(100, 100, 128, 128), nullptr);
canvas->restore();
canvas->scale(-1, 1);

View File

@ -17,13 +17,13 @@
#endif
static void draw_bitmap_rect(SkCanvas* canvas, const SkBitmap& bitmap, const SkImage*,
const SkRect* src, const SkRect& dst,
const SkRect& src, const SkRect& dst,
const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) {
canvas->drawBitmapRect(bitmap, src, dst, paint, constraint);
}
static void draw_image_rect(SkCanvas* canvas, const SkBitmap&, const SkImage* image,
const SkRect* src, const SkRect& dst,
const SkRect& src, const SkRect& dst,
const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) {
canvas->drawImageRect(image, src, dst, paint, constraint);
}
@ -35,7 +35,7 @@ enum BleedTest {
const struct {
const char* fName;
void (*fDraw)(SkCanvas*, const SkBitmap&, const SkImage*, const SkRect*, const SkRect&,
void (*fDraw)(SkCanvas*, const SkBitmap&, const SkImage*, const SkRect&, const SkRect&,
const SkPaint*, SkCanvas::SrcRectConstraint);
} gBleedRec[] = {
{ "bleed", draw_bitmap_rect },
@ -144,7 +144,7 @@ protected:
SkPaint paint;
paint.setFilterQuality(filter);
gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, &src, dst, &paint, constraint);
gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, src, dst, &paint, constraint);
}
// Draw almost all of the large bitmap
@ -159,7 +159,7 @@ protected:
SkPaint paint;
paint.setFilterQuality(filter);
gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, &src, dst, &paint, constraint);
gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, src, dst, &paint, constraint);
}
// Draw ~1/4 of the large bitmap
@ -174,7 +174,7 @@ protected:
SkPaint paint;
paint.setFilterQuality(filter);
gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, &src, dst, &paint, constraint);
gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, src, dst, &paint, constraint);
}
// Draw the center of the small bitmap with a mask filter
@ -192,7 +192,7 @@ protected:
SkBlurMask::ConvertRadiusToSigma(3));
paint.setMaskFilter(mf)->unref();
gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, &src, dst, &paint, constraint);
gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, src, dst, &paint, constraint);
}
void onDraw(SkCanvas* canvas) override {

View File

@ -152,10 +152,7 @@ protected:
static const int kPadY = 40;
SkPaint paint;
paint.setAlpha(0x20);
canvas->drawBitmapRect(fLargeBitmap, NULL,
SkRect::MakeWH(gSize * SK_Scalar1,
gSize * SK_Scalar1),
&paint);
canvas->drawBitmapRect(fLargeBitmap, SkRect::MakeIWH(gSize, gSize), &paint);
canvas->translate(SK_Scalar1 * kPadX / 2,
SK_Scalar1 * kPadY / 2);
SkPaint blackPaint;

View File

@ -92,10 +92,10 @@ static void test_surface(SkCanvas* canvas, SkSurface* surf, bool usePaint) {
dst3.set(0, 400, 65, 465);
dst4.set(0, 480, 65, 545);
canvas->drawImageRect(imgR, &src1, dst1, usePaint ? &paint : NULL);
canvas->drawImageRect(imgG, &src2, dst2, usePaint ? &paint : NULL);
canvas->drawImageRect(imgR, &src3, dst3, usePaint ? &paint : NULL);
canvas->drawImageRect(imgG, NULL, dst4, usePaint ? &paint : NULL);
canvas->drawImageRect(imgR, src1, dst1, usePaint ? &paint : NULL);
canvas->drawImageRect(imgG, src2, dst2, usePaint ? &paint : NULL);
canvas->drawImageRect(imgR, src3, dst3, usePaint ? &paint : NULL);
canvas->drawImageRect(imgG, dst4, usePaint ? &paint : NULL);
imgG->unref();
imgR->unref();
@ -241,7 +241,7 @@ protected:
if (subset) {
srcR.set(*subset);
}
canvas->drawImageRect(image, subset ? &srcR : NULL, dstR, &paint);
canvas->legacy_drawImageRect(image, subset ? &srcR : NULL, dstR, &paint);
canvas->translate(newW + 20.0f, 0);
// image method

View File

@ -42,7 +42,7 @@ static void test_mip(SkCanvas* canvas) {
canvas->translate(20, 20);
for (int i = 0; i < 4; ++i) {
paint.setFilterQuality(SkFilterQuality(i));
canvas->drawImageRect(img, NULL, dst, &paint);
canvas->drawImageRect(img, dst, &paint);
canvas->translate(0, 20);
}
canvas->drawImage(img, 20, 20, NULL);

View File

@ -50,7 +50,7 @@ static void show_bm(SkCanvas* canvas, int width, int height, SkColor colors[2])
r.offset(SkIntToScalar(150), 0);
// exercises bitmapshader
canvas->drawBitmapRect(bm, NULL, r, NULL);
canvas->drawBitmapRect(bm, r, nullptr);
canvas->drawRect(r, paint);
}

View File

@ -17,6 +17,7 @@
# Needed until we fix skbug.com/2440.
'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
'SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS',
'SK_SUPPORT_LEGACY_SRCPTR_DRAWIMAGERECT',
],
},
}

View File

@ -37,6 +37,9 @@ class SkSurface;
class SkSurface_Base;
class SkTextBlob;
//#define SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT
//#define SK_SUPPORT_LEGACY_SRCPTR_DRAWIMAGERECT
/** \class SkCanvas
A Canvas encapsulates all of the state about drawing into a device (bitmap).
@ -819,20 +822,28 @@ public:
* @param paint The paint used to draw the image, or NULL
* @param constraint Control the tradeoff between speed and exactness w.r.t. the src-rect.
*/
void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
// variant that takes src SkIRect
void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
// variant that assumes src == image-bounds
#ifdef SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT
void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint = NULL);
#else
void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint = kStrict_SrcRectConstraint);
#endif
#ifdef SK_SUPPORT_LEGACY_SRCPTR_DRAWIMAGERECT
void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst) {
this->drawImageRect(image, src, dst, NULL, kStrict_SrcRectConstraint);
}
void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint = NULL) {
// With no src-rect, the constraint value is ignored, so we just use the default.
this->drawImageRect(image, NULL, dst, paint, kStrict_SrcRectConstraint);
}
void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
#endif
/**
* Draw the image stretched differentially to fit into dst.
@ -881,15 +892,22 @@ public:
* @param paint The paint used to draw the bitmap, or NULL
* @param constraint Control the tradeoff between speed and exactness w.r.t. the src-rect.
*/
void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint = NULL) {
this->drawBitmapRect(bitmap, NULL, dst, paint, kStrict_SrcRectConstraint);
}
// variant where src is SkIRect
void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
#ifdef SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint = NULL);
#else
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint = kStrict_SrcRectConstraint);
#endif
#ifdef SK_SUPPORT_LEGACY_SRCPTR_DRAWIMAGERECT
void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
#endif
/**
* Draw the bitmap stretched differentially to fit into dst.
@ -1209,6 +1227,14 @@ public:
static void Internal_Private_SetTreatSpriteAsBitmap(bool);
static bool Internal_Private_GetTreatSpriteAsBitmap();
// TEMP helpers until we switch virtual over to const& for src-rect
void legacy_drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
void legacy_drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
protected:
// default impl defers to getDevice()->newSurface(info)
virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&);

View File

@ -33,7 +33,7 @@ static void draw_atlas_sim(SkCanvas* canvas, SkImage* atlas, const SkRSXform xfo
canvas->save();
canvas->concat(matrix);
canvas->drawImageRect(atlas, &tex[i], tex[i].makeOffset(-tex[i].x(), -tex[i].y()), paint,
canvas->drawImageRect(atlas, tex[i], tex[i].makeOffset(-tex[i].x(), -tex[i].y()), paint,
SkCanvas::kFast_SrcRectConstraint);
canvas->restore();
}

View File

@ -131,7 +131,7 @@ protected:
for (int i = 0; i < 2; ++i) {
paint.setFilterQuality(1 == i ? kLow_SkFilterQuality : kNone_SkFilterQuality);
canvas->drawBitmapRect(bitmap, &srcR, fDstR[i], &paint,
canvas->drawBitmapRect(bitmap, srcR, fDstR[i], &paint,
SkCanvas::kStrict_SrcRectConstraint);
canvas->drawRect(fDstR[i], paint);
}
@ -226,7 +226,7 @@ protected:
for (int i = 0; i < 2; ++i) {
paint.setFilterQuality(1 == i ? kLow_SkFilterQuality : kNone_SkFilterQuality);
canvas->drawBitmapRect(fBitmap, &fSrcR, fDstR[i], &paint,
canvas->drawBitmapRect(fBitmap, fSrcR, fDstR[i], &paint,
SkCanvas::kStrict_SrcRectConstraint);
canvas->drawRect(fDstR[i], paint);
}

View File

@ -53,7 +53,7 @@ protected:
// the constrained texture domain.
srcRect.setXYWH(1, 1, 3, 3);
dstRect.setXYWH(5, 5, 305, 305);
canvas->drawBitmapRect(fBM, &srcRect, dstRect, &paint, SkCanvas::kStrict_SrcRectConstraint);
canvas->drawBitmapRect(fBM, srcRect, dstRect, &paint, SkCanvas::kStrict_SrcRectConstraint);
// Test that bitmap draws across separate devices also respect
// the constrainted texture domain.
@ -64,14 +64,14 @@ protected:
srcRect.setXYWH(1, 1, 3, 3);
dstRect.setXYWH(1, 1, 3, 3);
surface->getCanvas()->drawBitmapRect(fBM, &srcRect, dstRect, &paint,
surface->getCanvas()->drawBitmapRect(fBM, srcRect, dstRect, &paint,
SkCanvas::kStrict_SrcRectConstraint);
SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
srcRect.setXYWH(1, 1, 3, 3);
dstRect.setXYWH(405, 5, 305, 305);
canvas->drawImageRect(image, &srcRect, dstRect, &paint);
canvas->drawImageRect(image, srcRect, dstRect, &paint);
// Test that bitmap blurring using a subrect
// renders correctly
@ -83,7 +83,7 @@ protected:
SkBlurMaskFilter::kHighQuality_BlurFlag |
SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
paint.setMaskFilter(mf)->unref();
canvas->drawImageRect(image, &srcRect, dstRect, &paint);
canvas->drawImageRect(image, srcRect, dstRect, &paint);
// Blur and a rotation + NULL src rect
// This should not trigger the texture domain code

View File

@ -162,10 +162,6 @@ static const SkRect& AsRect(const sk_rect_t& crect) {
return reinterpret_cast<const SkRect&>(crect);
}
static const SkRect* AsRect(const sk_rect_t* crect) {
return reinterpret_cast<const SkRect*>(crect);
}
static const SkPath& AsPath(const sk_path_t& cpath) {
return reinterpret_cast<const SkPath&>(cpath);
}
@ -399,7 +395,16 @@ void sk_canvas_draw_image(sk_canvas_t* ccanvas, const sk_image_t* cimage, float
void sk_canvas_draw_image_rect(sk_canvas_t* ccanvas, const sk_image_t* cimage,
const sk_rect_t* csrcR, const sk_rect_t* cdstR,
const sk_paint_t* cpaint) {
AsCanvas(ccanvas)->drawImageRect(AsImage(cimage), AsRect(csrcR), AsRect(*cdstR), AsPaint(cpaint));
SkCanvas* canvas = AsCanvas(ccanvas);
const SkImage* image = AsImage(cimage);
const SkRect& dst = AsRect(*cdstR);
const SkPaint* paint = AsPaint(cpaint);
if (csrcR) {
canvas->drawImageRect(image, AsRect(*csrcR), dst, paint);
} else {
canvas->drawImageRect(image, dst, paint);
}
}
void sk_canvas_draw_picture(sk_canvas_t* ccanvas, const sk_picture_t* cpicture,

View File

@ -1846,6 +1846,7 @@ void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP
this->onDrawImage(image, x, y, paint);
}
#ifdef SK_SUPPORT_LEGACY_SRCPTR_DRAWIMAGERECT
void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
if (dst.isEmpty()) {
@ -1853,20 +1854,47 @@ void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRe
}
this->onDrawImageRect(image, src, dst, paint, constraint);
}
void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
if (bitmap.drawsNothing() || dst.isEmpty()) {
return;
}
this->onDrawBitmapRect(bitmap, src, dst, paint, constraint);
}
#endif
void SkCanvas::drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
if (dst.isEmpty() || src.isEmpty()) {
return;
}
this->onDrawImageRect(image, &src, dst, paint, constraint);
}
void SkCanvas::drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
SkRect src = SkRect::Make(isrc);
this->drawImageRect(image, &src, dst, paint, constraint);
this->drawImageRect(image, SkRect::Make(isrc), dst, paint, constraint);
}
#ifdef SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT
void SkCanvas::drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint) {
this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst, paint);
}
#else
void SkCanvas::drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint) {
this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst, paint,
constraint);
}
#endif
void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
const SkPaint* paint) {
if (dst.isEmpty()) {
return;
}
if (!SkNinePatchIter::Valid(image->width(), image->height(), center)) {
this->drawImageRect(image, NULL, dst, paint);
this->drawImageRect(image, dst, paint);
}
this->onDrawImageNine(image, center, dst, paint);
}
@ -1878,20 +1906,31 @@ void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons
this->onDrawBitmap(bitmap, dx, dy, paint);
}
void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
if (bitmap.drawsNothing() || dst.isEmpty()) {
if (bitmap.drawsNothing() || dst.isEmpty() || src.isEmpty()) {
return;
}
this->onDrawBitmapRect(bitmap, src, dst, paint, constraint);
this->onDrawBitmapRect(bitmap, &src, dst, paint, constraint);
}
void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
SkRect src = SkRect::Make(isrc);
this->drawBitmapRect(bitmap, &src, dst, paint, constraint);
this->drawBitmapRect(bitmap, SkRect::Make(isrc), dst, paint, constraint);
}
#ifdef SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT
void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint) {
this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.height()), dst, paint);
}
#else
void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint) {
this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.height()), dst, paint,
constraint);
}
#endif
void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
const SkPaint* paint) {
if (bitmap.drawsNothing() || dst.isEmpty()) {
@ -1922,6 +1961,25 @@ void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk
this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint);
}
void SkCanvas::legacy_drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
if (src) {
this->drawImageRect(image, *src, dst, paint, constraint);
} else {
this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()),
dst, paint, constraint);
}
}
void SkCanvas::legacy_drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
if (src) {
this->drawBitmapRect(bitmap, *src, dst, paint, constraint);
} else {
this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.height()),
dst, paint, constraint);
}
}
//////////////////////////////////////////////////////////////////////////////
// These are the virtual drawing methods
//////////////////////////////////////////////////////////////////////////////

View File

@ -188,7 +188,7 @@ void SkPicturePlayback::handleOp(SkReader32* reader,
const SkRect* src = get_rect_ptr(reader); // may be null
const SkRect& dst = reader->skipT<SkRect>(); // required
SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
canvas->drawBitmapRect(bitmap, src, dst, paint, constraint);
canvas->legacy_drawBitmapRect(bitmap, src, dst, paint, constraint);
} break;
case DRAW_BITMAP_MATRIX: {
const SkPaint* paint = fPictureData->getPaint(reader);
@ -260,7 +260,7 @@ void SkPicturePlayback::handleOp(SkReader32* reader,
// newer op-code stores the constraint explicitly
constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
}
canvas->drawImageRect(image, src, dst, paint, constraint);
canvas->legacy_drawImageRect(image, src, dst, paint, constraint);
} break;
case DRAW_OVAL: {
const SkPaint& paint = *fPictureData->getPaint(reader);

View File

@ -89,16 +89,16 @@ DRAW(ClipRegion, clipRegion(r.region, r.op));
DRAW(DrawBitmap, drawBitmap(r.bitmap.shallowCopy(), r.left, r.top, r.paint));
DRAW(DrawBitmapNine, drawBitmapNine(r.bitmap.shallowCopy(), r.center, r.dst, r.paint));
DRAW(DrawBitmapRect,
drawBitmapRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
legacy_drawBitmapRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
SkCanvas::kStrict_SrcRectConstraint));
DRAW(DrawBitmapRectFast,
drawBitmapRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
legacy_drawBitmapRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
SkCanvas::kFast_SrcRectConstraint));
DRAW(DrawBitmapRectFixedSize,
drawBitmapRect(r.bitmap.shallowCopy(), &r.src, r.dst, &r.paint, r.constraint));
legacy_drawBitmapRect(r.bitmap.shallowCopy(), &r.src, r.dst, &r.paint, r.constraint));
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint));
DRAW(DrawImageRect, drawImageRect(r.image, r.src, r.dst, r.paint, r.constraint));
DRAW(DrawImageRect, legacy_drawImageRect(r.image, r.src, r.dst, r.paint, r.constraint));
DRAW(DrawImageNine, drawImageNine(r.image, r.center, r.dst, r.paint));
DRAW(DrawOval, drawOval(r.oval, r.paint));
DRAW(DrawPaint, drawPaint(r.paint));

View File

@ -84,7 +84,7 @@ bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context&
paint.setFilterQuality(
fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.height() ?
kNone_SkFilterQuality : fFilterQuality);
canvas.drawBitmapRect(fBitmap, &fSrcRect, dstRect, &paint, SkCanvas::kStrict_SrcRectConstraint);
canvas.drawBitmapRect(fBitmap, fSrcRect, dstRect, &paint, SkCanvas::kStrict_SrcRectConstraint);
*result = device.get()->accessBitmap(false);
offset->fX = dstIRect.fLeft;

View File

@ -69,9 +69,7 @@ bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
}
OwnDeviceCanvas canvas(dev);
SkRect r = SkRect::MakeWH(SkIntToScalar(src.width()),
SkIntToScalar(src.height()));
canvas.drawBitmapRect(tmp, r);
canvas.drawBitmapRect(tmp, SkRect::MakeIWH(src.width(), src.height()), nullptr);
*result = dev->accessBitmap(false);
}
return true;

View File

@ -43,7 +43,7 @@ static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canva
canvas->save();
canvas->setMatrix(SkMatrix::I());
canvas->drawBitmapRect(bm, &src, dst, layer->paint(), SkCanvas::kStrict_SrcRectConstraint);
canvas->drawBitmapRect(bm, src, dst, layer->paint(), SkCanvas::kStrict_SrcRectConstraint);
canvas->restore();
} else {
canvas->drawSprite(bm,

View File

@ -650,7 +650,7 @@ static void drawBitmapRect_rp(SkCanvas* canvas, SkReader32* reader,
const SkRect* dst = skip<SkRect>(reader);
const SkBitmap* bitmap = holder.getBitmap();
if (state->shouldDraw()) {
canvas->drawBitmapRect(*bitmap, src, *dst, hasPaint ? &state->paint() : NULL, constraint);
canvas->legacy_drawBitmapRect(*bitmap, src, *dst, hasPaint ? &state->paint() : NULL, constraint);
}
}
@ -692,7 +692,7 @@ static void drawImageRect_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32
const SkImage* image = state->getImage(slot);
if (state->shouldDraw()) {
canvas->drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NULL, constraint);
canvas->legacy_drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NULL, constraint);
}
}

View File

@ -872,7 +872,7 @@ void SkDeferredCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* sr
}
AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
this->drawingCanvas()->drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
this->drawingCanvas()->legacy_drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
this->recordedDrawCommand();
}
@ -900,7 +900,7 @@ void SkDeferredCanvas::onDrawImageRect(const SkImage* image, const SkRect* src,
}
AutoImmediateDrawIfNeeded autoDraw(*this, image, paint);
this->drawingCanvas()->drawImageRect(image, src, dst, paint, constraint);
this->drawingCanvas()->legacy_drawImageRect(image, src, dst, paint, constraint);
this->recordedDrawCommand();
}

View File

@ -534,7 +534,7 @@ static int lcanvas_drawImageRect(lua_State* L) {
lua2rect(L, 4, &dstR);
SkPaint paint;
canvas->drawImageRect(image, srcRPtr, dstR, lua2OptionalPaint(L, 5, &paint));
canvas->legacy_drawImageRect(image, srcRPtr, dstR, lua2OptionalPaint(L, 5, &paint));
return 0;
}

View File

@ -196,7 +196,7 @@ void SkNWayCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, c
const SkPaint* paint, SrcRectConstraint constraint) {
Iter iter(fList);
while (iter.next()) {
iter->drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
iter->legacy_drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
}
}
@ -220,7 +220,7 @@ void SkNWayCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, cons
const SkPaint* paint, SrcRectConstraint constraint) {
Iter iter(fList);
while (iter.next()) {
iter->drawImageRect(image, src, dst, paint, constraint);
iter->legacy_drawImageRect(image, src, dst, paint, constraint);
}
}

View File

@ -147,7 +147,7 @@ void SkAndroidSDKCanvas::onDrawBitmapRect(const SkBitmap& bitmap,
const SkPaint* paint,
SkCanvas::SrcRectConstraint constraint) {
FILTER_PTR(paint);
fProxyTarget->drawBitmapRect(bitmap, src, dst, filteredPaint, constraint);
fProxyTarget->legacy_drawBitmapRect(bitmap, src, dst, filteredPaint, constraint);
}
void SkAndroidSDKCanvas::onDrawBitmapNine(const SkBitmap& bitmap,
const SkIRect& center,
@ -244,7 +244,7 @@ void SkAndroidSDKCanvas::onDrawImageRect(const SkImage* image,
const SkPaint* paint,
SrcRectConstraint constraint) {
FILTER_PTR(paint);
fProxyTarget->drawImageRect(image, in, out, filteredPaint, constraint);
fProxyTarget->legacy_drawImageRect(image, in, out, filteredPaint, constraint);
}
void SkAndroidSDKCanvas::onDrawPicture(const SkPicture* picture,

View File

@ -131,7 +131,7 @@ void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRec
yScale * input.height());
canvas->clear(0xFFFFFFFF);
canvas->drawBitmapRect(input, dst);
canvas->drawBitmapRect(input, dst, nullptr);
if (srcRect) {
SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1,
@ -352,7 +352,7 @@ SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
}
void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const {
canvas->drawBitmapRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fConstraint);
canvas->legacy_drawBitmapRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fConstraint);
}
bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const {
@ -405,7 +405,7 @@ SkDrawImageRectCommand::SkDrawImageRectCommand(const SkImage* image, const SkRec
}
void SkDrawImageRectCommand::execute(SkCanvas* canvas) const {
canvas->drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(), fConstraint);
canvas->legacy_drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(), fConstraint);
}
bool SkDrawImageRectCommand::render(SkCanvas* canvas) const {

View File

@ -690,7 +690,7 @@ DEF_TEST(PictureRecorder_replay, reporter) {
make_bm(&bm, 10, 10, SK_ColorRED, true);
r.offset(5.0f, 5.0f);
canvas->drawBitmapRect(bm, r);
canvas->drawBitmapRect(bm, r, nullptr);
SkAutoTUnref<SkPicture> final(recorder.endRecording());
REPORTER_ASSERT(reporter, final->willPlayBackBitmaps());
@ -1167,7 +1167,7 @@ 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->drawBitmapRect(bitmap, &rect, rect, &paint, SkCanvas::kStrict_SrcRectConstraint);
canvas->drawBitmapRect(bitmap, rect, rect, &paint, SkCanvas::kStrict_SrcRectConstraint);
canvas->drawBitmapNine(bitmap, irect, rect, &paint);
canvas->drawSprite(bitmap, 1, 1);
}

View File

@ -325,7 +325,7 @@ DEF_TEST(RecordDraw_drawImage, r){
{
SkRecord record;
SkRecorder recorder(&record, 10, 10);
recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10));
recorder.drawImageRect(image, SkRect::MakeWH(10, 10), nullptr);
SkRecordDraw(record, &canvas, NULL, NULL, 0, NULL, 0);
}
REPORTER_ASSERT(r, canvas.fDrawImageRectCalled);

View File

@ -98,7 +98,7 @@ DEF_TEST(Recorder_drawImage_takeReference, reporter) {
SkRecorder recorder(&record, 100, 100);
// DrawImageRect is supposed to take a reference
recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100));
recorder.drawImageRect(image.get(), SkRect::MakeWH(100, 100), nullptr);
REPORTER_ASSERT(reporter, !image->unique());
Tally tally;

View File

@ -705,7 +705,7 @@ static void TestSurfaceCopyOnWrite(skiatest::Reporter* reporter, SurfaceType sur
EXPECT_COPY_ON_WRITE(drawRRect(testRRect, testPaint))
EXPECT_COPY_ON_WRITE(drawPath(testPath, testPaint))
EXPECT_COPY_ON_WRITE(drawBitmap(testBitmap, 0, 0))
EXPECT_COPY_ON_WRITE(drawBitmapRect(testBitmap, testRect))
EXPECT_COPY_ON_WRITE(drawBitmapRect(testBitmap, testRect, nullptr))
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))