SkRect bound3 = SkRect::MakeXYWH(320, 320,
SkIntToScalar(kBitmapSize),
SkIntToScalar(kBitmapSize));
- canvas->drawBitmapRectToRect(fGreenBitmap, &bound2, bound3);
+ canvas->drawBitmapRect(fGreenBitmap, &bound2, bound3, NULL,
+ SkCanvas::kStrict_SrcRectConstraint);
canvas->restore();
}
}
canvas->drawBitmap(bitmap, 0, 0, &paint);
if (!fUseIRect) {
- canvas->drawBitmapRectToRect(bitmap, &srcR, dstR, &paint);
+ canvas->drawBitmapRect(bitmap, &srcR, dstR, &paint,
+ SkCanvas::kStrict_SrcRectConstraint);
} else {
canvas->drawBitmapRect(bitmap, &src[i], dstR, &paint);
}
}
}
-// This GM attempts to make visible any issues drawBitmapRectToRect may have
+// This GM attempts to make visible any issues drawBitmapRect may have
// with partial source rects. In this case the eight pixels on the border
// should be half the width/height of the central pixel, i.e.:
// __|____|__
SkScalar scale = 0.472560018f;
canvas->save();
canvas->scale(scale, scale);
- canvas->drawBitmapRectToRect(bm, NULL, SkRect::MakeXYWH(100, 100, 128, 128), NULL);
+ canvas->drawBitmapRect(bm, SkRect::MakeXYWH(100, 100, 128, 128));
canvas->restore();
canvas->scale(-1, 1);
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
+#include "SkImage.h"
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextOptions.h"
#endif
+static void draw_bitmap_rect(SkCanvas* canvas, const SkBitmap& bitmap, const SkImage*,
+ 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 SkPaint* paint, SkCanvas::SrcRectConstraint constraint) {
+ canvas->drawImageRect(image, src, dst, paint, constraint);
+}
+
+enum BleedTest {
+ kUseBitmap_BleedTest,
+ kUseImage_BleedTest,
+};
+
+const struct {
+ const char* fName;
+ void (*fDraw)(SkCanvas*, const SkBitmap&, const SkImage*, const SkRect*, const SkRect&,
+ const SkPaint*, SkCanvas::SrcRectConstraint);
+} gBleedRec[] = {
+ { "bleed", draw_bitmap_rect },
+ { "bleed_image", draw_image_rect },
+};
+
// Create a black&white checked texture with 2 1-pixel rings
// around the outside edge. The inner ring is red and the outer ring is blue.
static void make_ringed_bitmap(SkBitmap* result, int width, int height) {
result->setImmutable();
}
-// This GM exercises the drawBitmapRectToRect "bleed" flag
+// This GM exercises the drawBitmapRect constraints
class BleedGM : public skiagm::GM {
public:
- BleedGM() {}
+ BleedGM(BleedTest bt) : fBT(bt) {}
protected:
SkString onShortName() override {
- return SkString("bleed");
+ return SkString(gBleedRec[fBT].fName);
}
SkISize onISize() override {
void onOnceBeforeDraw() override {
make_ringed_bitmap(&fBitmapSmall, kSmallTextureSize, kSmallTextureSize);
+ fImageSmall.reset(SkImage::NewFromBitmap(fBitmapSmall));
// To exercise the GPU's tiling path we need a texture
// too big for the GPU to handle in one go
make_ringed_bitmap(&fBitmapBig, 2*kMaxTextureSize, 2*kMaxTextureSize);
+ fImageBig.reset(SkImage::NewFromBitmap(fBitmapBig));
}
// Draw only the center of the small bitmap
void drawCase1(SkCanvas* canvas, int transX, int transY,
- SkCanvas::DrawBitmapRectFlags flags, SkFilterQuality filter) {
+ SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) {
SkRect src = SkRect::MakeXYWH(2, 2,
SkIntToScalar(kSmallTextureSize-4),
SkIntToScalar(kSmallTextureSize-4));
- SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
+ SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY),
+ SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
SkPaint paint;
paint.setFilterQuality(filter);
- canvas->save();
- canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY));
- canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, flags);
- canvas->restore();
+ gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, &src, dst, &paint, constraint);
}
// Draw almost all of the large bitmap
void drawCase2(SkCanvas* canvas, int transX, int transY,
- SkCanvas::DrawBitmapRectFlags flags, SkFilterQuality filter) {
+ SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) {
SkRect src = SkRect::MakeXYWH(2, 2,
SkIntToScalar(fBitmapBig.width()-4),
SkIntToScalar(fBitmapBig.height()-4));
- SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
+ SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY),
+ SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
SkPaint paint;
paint.setFilterQuality(filter);
- canvas->save();
- canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY));
- canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint, flags);
- canvas->restore();
+ gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, &src, dst, &paint, constraint);
}
// Draw ~1/4 of the large bitmap
void drawCase3(SkCanvas* canvas, int transX, int transY,
- SkCanvas::DrawBitmapRectFlags flags, SkFilterQuality filter) {
+ SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) {
SkRect src = SkRect::MakeXYWH(2, 2,
SkIntToScalar(fBitmapBig.width()/2-2),
SkIntToScalar(fBitmapBig.height()/2-2));
- SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
+ SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY),
+ SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
SkPaint paint;
paint.setFilterQuality(filter);
- canvas->save();
- canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY));
- canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint, flags);
- canvas->restore();
+ gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, &src, dst, &paint, constraint);
}
// Draw the center of the small bitmap with a mask filter
void drawCase4(SkCanvas* canvas, int transX, int transY,
- SkCanvas::DrawBitmapRectFlags flags, SkFilterQuality filter) {
+ SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) {
SkRect src = SkRect::MakeXYWH(2, 2,
SkIntToScalar(kSmallTextureSize-4),
SkIntToScalar(kSmallTextureSize-4));
- SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
+ SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY),
+ SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
SkPaint paint;
paint.setFilterQuality(filter);
SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
- SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)));
+ SkBlurMask::ConvertRadiusToSigma(3));
paint.setMaskFilter(mf)->unref();
- canvas->save();
- canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY));
- canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, flags);
- canvas->restore();
+ gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, &src, dst, &paint, constraint);
}
void onDraw(SkCanvas* canvas) override {
}
// First draw a column with no bleeding and no filtering
- this->drawCase1(canvas, kCol0X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
- this->drawCase2(canvas, kCol0X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
- this->drawCase3(canvas, kCol0X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
- this->drawCase4(canvas, kCol0X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
+ this->drawCase1(canvas, kCol0X, kRow0Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
+ this->drawCase2(canvas, kCol0X, kRow1Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
+ this->drawCase3(canvas, kCol0X, kRow2Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
+ this->drawCase4(canvas, kCol0X, kRow3Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
// Then draw a column with no bleeding and low filtering
- this->drawCase1(canvas, kCol1X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase2(canvas, kCol1X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase3(canvas, kCol1X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase4(canvas, kCol1X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
+ this->drawCase1(canvas, kCol1X, kRow0Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
+ this->drawCase2(canvas, kCol1X, kRow1Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
+ this->drawCase3(canvas, kCol1X, kRow2Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
+ this->drawCase4(canvas, kCol1X, kRow3Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
// Then draw a column with no bleeding and high filtering
- this->drawCase1(canvas, kCol2X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase2(canvas, kCol2X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase3(canvas, kCol2X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase4(canvas, kCol2X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
+ this->drawCase1(canvas, kCol2X, kRow0Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
+ this->drawCase2(canvas, kCol2X, kRow1Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
+ this->drawCase3(canvas, kCol2X, kRow2Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
+ this->drawCase4(canvas, kCol2X, kRow3Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
// Then draw a column with bleeding and no filtering (bleed should have no effect w/out blur)
- this->drawCase1(canvas, kCol3X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
- this->drawCase2(canvas, kCol3X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
- this->drawCase3(canvas, kCol3X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
- this->drawCase4(canvas, kCol3X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
+ this->drawCase1(canvas, kCol3X, kRow0Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
+ this->drawCase2(canvas, kCol3X, kRow1Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
+ this->drawCase3(canvas, kCol3X, kRow2Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
+ this->drawCase4(canvas, kCol3X, kRow3Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
// Then draw a column with bleeding and low filtering
- this->drawCase1(canvas, kCol4X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase2(canvas, kCol4X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase3(canvas, kCol4X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
- this->drawCase4(canvas, kCol4X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
+ this->drawCase1(canvas, kCol4X, kRow0Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
+ this->drawCase2(canvas, kCol4X, kRow1Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
+ this->drawCase3(canvas, kCol4X, kRow2Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
+ this->drawCase4(canvas, kCol4X, kRow3Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
// Finally draw a column with bleeding and high filtering
- this->drawCase1(canvas, kCol5X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase2(canvas, kCol5X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase3(canvas, kCol5X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
- this->drawCase4(canvas, kCol5X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
+ this->drawCase1(canvas, kCol5X, kRow0Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
+ this->drawCase2(canvas, kCol5X, kRow1Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
+ this->drawCase3(canvas, kCol5X, kRow2Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
+ this->drawCase4(canvas, kCol5X, kRow3Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
canvas->restore();
}
SkBitmap fBitmapSmall;
SkBitmap fBitmapBig;
+ SkAutoTUnref<SkImage> fImageSmall;
+ SkAutoTUnref<SkImage> fImageBig;
+ const BleedTest fBT;
typedef GM INHERITED;
};
-DEF_GM( return new BleedGM(); )
+DEF_GM( return new BleedGM(kUseBitmap_BleedTest); )
+DEF_GM( return new BleedGM(kUseImage_BleedTest); )
SkPaint bgPaint;
bgPaint.setAlpha(0x15);
SkISize size = canvas->getDeviceSize();
- SkRect dstRect = SkRect::MakeWH(SkIntToScalar(size.fWidth),
- SkIntToScalar(size.fHeight));
- canvas->drawBitmapRectToRect(fBmp, NULL, dstRect, &bgPaint);
+ canvas->drawBitmapRect(fBmp, SkRect::MakeIWH(size.fWidth, size.fHeight), &bgPaint);
static const char kTxt[] = "Clip Me!";
SkPaint txtPaint;
* The default impl. will create a bitmap-shader from the bitmap,
* and call drawRect with it.
*/
- virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
- const SkRect* srcOrNull, const SkRect& dst,
- const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags) override;
+ void drawBitmapRect(const SkDraw&, const SkBitmap&, const SkRect*, const SkRect&,
+ const SkPaint&, SK_VIRTUAL_CONSTRAINT_TYPE) override;
/**
* Does not handle text decoration.
class GrContext;
class GrRenderTarget;
+//#define SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
+
class SkCanvasState;
+#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
+ #define SK_VIRTUAL_CONSTRAINT_TYPE SkCanvas::DrawBitmapRectFlags
+ #define SRC_RECT_CONSTRAINT_PARAM(param)
+ #define SRC_RECT_CONSTRAINT_ARG(arg)
+ #define SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(var) SkCanvas::SrcRectConstraint var = SkCanvas::kStrict_SrcRectConstraint;
+#else
+ #define SK_VIRTUAL_CONSTRAINT_TYPE SkCanvas::SrcRectConstraint
+ #define SRC_RECT_CONSTRAINT_PARAM(param) , SrcRectConstraint param
+ #define SRC_RECT_CONSTRAINT_ARG(arg) , arg
+ #define SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(var)
+#endif
+
/** \class SkCanvas
A Canvas encapsulates all of the state about drawing into a device (bitmap).
@param paint The paint used to draw the image, or NULL
*/
void drawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint = NULL);
- /** Draw the specified image, with the specified matrix applied (before the
- canvas' matrix is applied).
- @param image The image to be drawn
- @param src Optional: specify the subset of the image to be drawn
- @param dst The destination rectangle where the scaled/translated
- image will be drawn
- @param paint The paint used to draw the image, or NULL
- */
+ /**
+ * Controls the behavior at the edge of the src-rect, when specified in drawImageRect,
+ * trading off speed for exactness.
+ *
+ * When filtering is enabled (in the Paint), skia may need to sample in a neighborhood around
+ * the pixels in the image. If there is a src-rect specified, it is intended to restrict the
+ * pixels that will be read. However, for performance reasons, some implementations may slow
+ * down if they cannot read 1-pixel past the src-rect boundary at times.
+ *
+ * This enum allows the caller to specify if such a 1-pixel "slop" will be visually acceptable.
+ * If it is, the caller should pass kFast, and it may result in a faster draw. If the src-rect
+ * must be strictly respected, the caller should pass kStrict.
+ */
+ enum SrcRectConstraint {
+ /**
+ * If kStrict is specified, the implementation must respect the src-rect
+ * (if specified) strictly, and will never sample outside of those bounds during sampling
+ * even when filtering. This may be slower than kFast.
+ */
+ kStrict_SrcRectConstraint,
+
+ /**
+ * If kFast is specified, the implementation may sample outside of the src-rect
+ * (if specified) by at most 1 pixel when filtering. This allows greater flexibility
+ * to the implementation and can make the draw much faster.
+ */
+ kFast_SrcRectConstraint,
+ };
+
+ /** Draw the specified image, scaling and translating so that it fills the specified
+ * dst rect. If the src rect is non-null, only that subset of the image is transformed
+ * and drawn.
+ *
+ * @param image The image to be drawn
+ * @param src Optional: specify the subset of the image to be drawn
+ * @param dst The destination rectangle where the scaled/translated
+ * image will be drawn
+ * @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 = NULL);
+ const SkPaint* paint, SrcRectConstraint);
+
+ void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
+ const SkPaint* paint = NULL) {
+ this->drawImageRect(image, src, dst, paint, 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);
+ }
/**
* Draw the image stretched differentially to fit into dst.
void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
const SkPaint* paint = NULL);
+ /** Draw the specified bitmap, scaling and translating so that it fills the specified
+ * dst rect. If the src rect is non-null, only that subset of the bitmap is transformed
+ * and drawn.
+ *
+ * @param bitmap The bitmap to be drawn
+ * @param src Optional: specify the subset of the bitmap to be drawn
+ * @param dst The destination rectangle where the scaled/translated
+ * bitmap will be drawn
+ * @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,
+ const SkPaint* paint, SrcRectConstraint);
+
+ void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint = NULL) {
+ this->drawBitmapRect(bitmap, NULL, dst, paint, kStrict_SrcRectConstraint);
+ }
+
+ // IMPORTANT that thse be value-equal with SrcRectConstraint (during transition period)
enum DrawBitmapRectFlags {
kNone_DrawBitmapRectFlag = 0x0,
/**
const SkPaint* paint = NULL,
DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag);
- void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst,
- const SkPaint* paint = NULL) {
- this->drawBitmapRectToRect(bitmap, NULL, dst, paint, kNone_DrawBitmapRectFlag);
- }
-
void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc,
const SkRect& dst, const SkPaint* paint = NULL,
DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) {
int count, SkXfermode::Mode, const SkRect* cull, const SkPaint*);
virtual void onDrawPath(const SkPath&, const SkPaint&);
virtual void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*);
- virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*);
+ virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*
+ SRC_RECT_CONSTRAINT_PARAM(constraint));
virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
const SkPaint*);
virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*);
virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
- DrawBitmapRectFlags);
+ SK_VIRTUAL_CONSTRAINT_TYPE);
virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*);
virtual void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*);
void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* paint);
void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
- DrawBitmapRectFlags flags);
+ SrcRectConstraint);
void internalDrawPaint(const SkPaint& paint);
void internalSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags, SaveLayerStrategy);
void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*, bool isBitmapDevice);
virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags) = 0;
+ SK_VIRTUAL_CONSTRAINT_TYPE) = 0;
virtual void drawBitmapNine(const SkDraw&, const SkBitmap&, const SkIRect& center,
const SkRect& dst, const SkPaint&);
virtual void drawImage(const SkDraw&, const SkImage*, SkScalar x, SkScalar y, const SkPaint&);
virtual void drawImageRect(const SkDraw&, const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint&);
+ const SkPaint&, SkCanvas::SrcRectConstraint);
virtual void drawImageNine(const SkDraw&, const SkImage*, const SkIRect& center,
const SkRect& dst, const SkPaint&);
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
- DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint*) override;
+ const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
- DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint*) override;
+ const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
- DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint*) override;
+ const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
- DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint*) override;
+ const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
- DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint*) override;
+ const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
const SkRect* src, const SkRect& dst,
- const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags) {
+ const SkPaint& paint, SK_VIRTUAL_CONSTRAINT_TYPE) {
SkMatrix matrix;
SkRect bitmapBounds, tmpSrc, tmpDst;
SkBitmap tmpBitmap;
}
void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint) {
+ const SkPaint* paint, SrcRectConstraint constraint) {
if (dst.isEmpty()) {
return;
}
- this->onDrawImageRect(image, src, dst, paint);
+ this->onDrawImageRect(image, src, dst, paint SRC_RECT_CONSTRAINT_ARG(constraint));
}
void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
if (bitmap.drawsNothing() || dst.isEmpty()) {
return;
}
- this->onDrawBitmapRect(bitmap, src, dst, paint, flags);
+ this->onDrawBitmapRect(bitmap, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_TYPE)flags);
+}
+
+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, (SK_VIRTUAL_CONSTRAINT_TYPE)constraint);
}
void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
return;
}
if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) {
- this->drawBitmapRectToRect(bitmap, NULL, dst, paint);
+ this->drawBitmapRect(bitmap, dst, paint);
}
this->onDrawBitmapNine(bitmap, center, dst, paint);
}
}
void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint) {
+ const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()");
+ SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(constraint)
SkRect storage;
const SkRect* bounds = &dst;
if (NULL == paint || paint->canComputeFastBounds()) {
LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, bounds)
while (iter.next()) {
- iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint());
+ iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint(), constraint);
}
LOOPER_END
// this one is non-virtual, so it can be called safely by other canvas apis
void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
- DrawBitmapRectFlags flags) {
+ SrcRectConstraint constraint) {
if (bitmap.drawsNothing() || dst.isEmpty()) {
return;
}
LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, bounds)
while (iter.next()) {
- iter.fDevice->drawBitmapRect(iter, bitmap, src, dst, looper.paint(), flags);
+ iter.fDevice->drawBitmapRect(iter, bitmap, src, dst, looper.paint(),
+ (SK_VIRTUAL_CONSTRAINT_TYPE)constraint);
}
LOOPER_END
}
void SkCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, DrawBitmapRectFlags flags) {
+ const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapRectToRect()");
SkDEBUGCODE(bitmap.validate();)
- this->internalDrawBitmapRect(bitmap, src, dst, paint, flags);
+ this->internalDrawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
}
void SkCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
}
void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
- const SkRect& dst, const SkPaint& paint) {
+ const SkRect& dst, const SkPaint& paint,
+ SkCanvas::SrcRectConstraint constraint) {
// Default impl : turns everything into raster bitmap
SkBitmap bm;
if (as_IB(image)->getROPixels(&bm)) {
- this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitmapRectFlag);
+ this->drawBitmapRect(draw, bm, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_TYPE)constraint);
}
}
SkRect srcR, dstR;
while (iter.next(&srcR, &dstR)) {
- this->drawImageRect(draw, image, &srcR, dstR, paint);
+ this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
}
}
SkRect srcR, dstR;
while (iter.next(&srcR, &dstR)) {
- this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kNone_DrawBitmapRectFlag);
+ this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint,
+ (SK_VIRTUAL_CONSTRAINT_TYPE)SkCanvas::kStrict_SrcRectConstraint);
}
}
new (fBuffer.get()) Type(__VA_ARGS__); \
return true
-bool SkMiniRecorder::drawBitmapRectToRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
- const SkPaint* p, SkCanvas::DrawBitmapRectFlags flags) {
+bool SkMiniRecorder::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
+ const SkPaint* p, SkCanvas::SrcRectConstraint constraint) {
SkRect bounds;
if (!src) {
bm.getBounds(&bounds);
if (!p) {
p = defaultPaint.init();
}
- TRY_TO_STORE(DrawBitmapRectToRectFixedSize, *p, bm, *src, dst, flags);
+ TRY_TO_STORE(DrawBitmapRectFixedSize, *p, bm, *src, dst, constraint);
}
bool SkMiniRecorder::drawRect(const SkRect& rect, const SkPaint& paint) {
switch (fState) {
case State::kEmpty: return SkRef(gEmptyPicture.get());
- CASE(DrawBitmapRectToRectFixedSize);
+ CASE(DrawBitmapRectFixedSize);
CASE(DrawPath);
CASE(DrawRect);
CASE(DrawTextBlob);
switch (fState) {
case State::kEmpty: return;
- CASE(DrawBitmapRectToRectFixedSize);
+ CASE(DrawBitmapRectFixedSize);
CASE(DrawPath);
CASE(DrawRect);
CASE(DrawTextBlob);
~SkMiniRecorder();
// Try to record an op. Returns false on failure.
- bool drawBitmapRectToRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
- const SkPaint*, SkCanvas::DrawBitmapRectFlags);
+ bool drawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
+ const SkPaint*, SkCanvas::SrcRectConstraint);
bool drawPath(const SkPath&, const SkPaint&);
bool drawRect(const SkRect&, const SkPaint&);
bool drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint&);
private:
enum class State {
kEmpty,
- kDrawBitmapRectToRectFixedSize,
+ kDrawBitmapRectFixedSize,
kDrawPath,
kDrawRect,
kDrawTextBlob,
struct Max { static const size_t val = A > B ? A : B; };
static const size_t kInlineStorage =
- Max<sizeof(SkRecords::DrawBitmapRectToRectFixedSize),
+ Max<sizeof(SkRecords::DrawBitmapRectFixedSize),
Max<sizeof(SkRecords::DrawPath),
Max<sizeof(SkRecords::DrawRect),
sizeof(SkRecords::DrawTextBlob)>::val>::val>::val;
DRAW_BITMAP,
DRAW_BITMAP_MATRIX, // deprecated, M41 was last Chromium version to write this to an .skp
DRAW_BITMAP_NINE,
- DRAW_BITMAP_RECT_TO_RECT,
+ DRAW_BITMAP_RECT,
DRAW_CLEAR,
DRAW_DATA,
DRAW_OVAL,
DRAW_PICTURE_MATRIX_PAINT,
DRAW_TEXT_BLOB,
DRAW_IMAGE,
- DRAW_IMAGE_RECT,
+ DRAW_IMAGE_RECT_STRICT, // deprecated (M45)
DRAW_ATLAS,
DRAW_IMAGE_NINE,
+ DRAW_IMAGE_RECT,
- LAST_DRAWTYPE_ENUM = DRAW_IMAGE_NINE
+ LAST_DRAWTYPE_ENUM = DRAW_IMAGE_RECT
};
// In the 'match' method, this constant will match any flavor of DRAW_BITMAP*
const SkPoint& loc = reader->skipT<SkPoint>();
canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint);
} break;
- case DRAW_BITMAP_RECT_TO_RECT: {
+ case DRAW_BITMAP_RECT: {
const SkPaint* paint = fPictureData->getPaint(reader);
const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader));
const SkRect* src = get_rect_ptr(reader); // may be null
const SkRect& dst = reader->skipT<SkRect>(); // required
- SkCanvas::DrawBitmapRectFlags flags;
- flags = (SkCanvas::DrawBitmapRectFlags) reader->readInt();
- canvas->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
+ SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
+ canvas->drawBitmapRect(bitmap, src, dst, paint, constraint);
} break;
case DRAW_BITMAP_MATRIX: {
const SkPaint* paint = fPictureData->getPaint(reader);
const SkRect& dst = reader->skipT<SkRect>();
canvas->drawImageNine(image, center, dst, paint);
} break;
+ case DRAW_IMAGE_RECT_STRICT:
case DRAW_IMAGE_RECT: {
const SkPaint* paint = fPictureData->getPaint(reader);
const SkImage* image = fPictureData->getImage(reader);
const SkRect* src = get_rect_ptr(reader); // may be null
const SkRect& dst = reader->skipT<SkRect>(); // required
- canvas->drawImageRect(image, src, dst, paint);
+ // DRAW_IMAGE_RECT_STRICT assumes this constraint, and doesn't store it
+ SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint;
+ if (DRAW_IMAGE_RECT == op) {
+ // newer op-code stores the constraint explicitly
+ constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
+ }
+ canvas->drawImageRect(image, src, dst, paint, constraint);
} break;
case DRAW_OVAL: {
const SkPaint& paint = *fPictureData->getPaint(reader);
1, // DRAW_BITMAP - 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
+ 1, // DRAW_BITMAP_RECT - right after op code
0, // DRAW_CLEAR - no paint
0, // DRAW_DATA - no paint
1, // DRAW_OVAL - right after op code
1, // DRAW_PICTURE_MATRIX_PAINT - right after op code
1, // DRAW_TEXT_BLOB- right after op code
1, // DRAW_IMAGE - right after op code
- 1, // DRAW_IMAGE_RECT - right after op code
+ 1, // DRAW_IMAGE_RECT_STRICT - right after op code
1, // DRAW_ATLAS - right after op code
1, // DRAW_IMAGE_NINE - right after op code
+ 1, // DRAW_IMAGE_RECT - right after op code
};
SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1,
}
void SkPictureRecord::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, DrawBitmapRectFlags flags) {
+ const SkPaint* paint,
+ SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
// id + paint index + bitmap index + bool for 'src' + flags
size_t size = 5 * kUInt32Size;
if (src) {
}
size += sizeof(dst); // + rect
- size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_RECT_TO_RECT, size)
- == fWriter.bytesWritten());
+ size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT, &size);
+ SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_RECT, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
this->addBitmap(bitmap);
this->addRectPtr(src); // may be null
this->addRect(dst);
- this->addInt(flags);
+ this->addInt(constraint);
this->validate(initialOffset, size);
}
}
void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint) {
- // id + paint_index + image_index + bool_for_src
- size_t size = 4 * kUInt32Size;
+ const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
+ SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(constraint)
+ // id + paint_index + image_index + bool_for_src + constraint
+ size_t size = 5 * kUInt32Size;
if (src) {
size += sizeof(*src); // + rect
}
this->addImage(image);
this->addRectPtr(src); // may be null
this->addRect(dst);
+ this->addInt(constraint);
this->validate(initialOffset, size);
}
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
- DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint*) override;
+ const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
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(DrawBitmapRectToRect,
- drawBitmapRectToRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
- SkCanvas::kNone_DrawBitmapRectFlag));
-DRAW(DrawBitmapRectToRectBleed,
- drawBitmapRectToRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
- SkCanvas::kBleed_DrawBitmapRectFlag));
-DRAW(DrawBitmapRectToRectFixedSize,
- drawBitmapRectToRect(r.bitmap.shallowCopy(), &r.src, r.dst, &r.paint, r.flags));
+DRAW(DrawBitmapRect,
+ 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,
+ SkCanvas::kFast_SrcRectConstraint));
+DRAW(DrawBitmapRectFixedSize,
+ 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));
Bounds bounds(const DrawImageNine& op) const {
return this->adjustAndMap(op.dst, op.paint);
}
- Bounds bounds(const DrawBitmapRectToRect& op) const {
+ Bounds bounds(const DrawBitmapRect& op) const {
return this->adjustAndMap(op.dst, op.paint);
}
- Bounds bounds(const DrawBitmapRectToRectBleed& op) const {
+ Bounds bounds(const DrawBitmapRectFast& op) const {
return this->adjustAndMap(op.dst, op.paint);
}
- Bounds bounds(const DrawBitmapRectToRectFixedSize& op) const {
+ Bounds bounds(const DrawBitmapRectFixedSize& op) const {
return this->adjustAndMap(op.dst, &op.paint);
}
Bounds bounds(const DrawBitmapNine& op) const {
const SkRect* src,
const SkRect& dst,
const SkPaint* paint,
- DrawBitmapRectFlags flags) {
+ SK_VIRTUAL_CONSTRAINT_TYPE legacyConstraint) {
+ SrcRectConstraint constraint = (SrcRectConstraint)legacyConstraint;
+
#ifdef WRAP_BITMAP_AS_IMAGE
// TODO: need a way to support the flags for images...
SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap));
this->onDrawImageRect(image, src, dst, paint);
}
#else
- TRY_MINIRECORDER(drawBitmapRectToRect, bitmap, src, dst, paint, flags);
- if (kBleed_DrawBitmapRectFlag == flags) {
- APPEND(DrawBitmapRectToRectBleed,
- this->copy(paint), bitmap, this->copy(src), dst);
+ TRY_MINIRECORDER(drawBitmapRect, bitmap, src, dst, paint, constraint);
+ if (kFast_SrcRectConstraint == constraint) {
+ APPEND(DrawBitmapRectFast, this->copy(paint), bitmap, this->copy(src), dst);
return;
}
- SkASSERT(kNone_DrawBitmapRectFlag == flags);
- APPEND(DrawBitmapRectToRect,
- this->copy(paint), bitmap, this->copy(src), dst);
+ SkASSERT(kStrict_SrcRectConstraint == constraint);
+ APPEND(DrawBitmapRect, this->copy(paint), bitmap, this->copy(src), dst);
#endif
}
void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src,
const SkRect& dst,
- const SkPaint* paint) {
- APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst);
+ const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
+#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
+ SrcRectConstraint constraint = kStrict_SrcRectConstraint;
+#endif
+ APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst, constraint);
}
void SkRecorder::onDrawImageNine(const SkImage* image, const SkIRect& center,
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
- DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint*) override;
+ const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
M(ClipRegion) \
M(DrawBitmap) \
M(DrawBitmapNine) \
- M(DrawBitmapRectToRect) \
- M(DrawBitmapRectToRectBleed) \
- M(DrawBitmapRectToRectFixedSize) \
+ M(DrawBitmapRect) \
+ M(DrawBitmapRectFast) \
+ M(DrawBitmapRectFixedSize) \
M(DrawDrawable) \
M(DrawImage) \
M(DrawImageRect) \
ImmutableBitmap, bitmap,
SkIRect, center,
SkRect, dst);
-RECORD4(DrawBitmapRectToRect, Optional<SkPaint>, paint,
- ImmutableBitmap, bitmap,
- Optional<SkRect>, src,
- SkRect, dst);
-RECORD4(DrawBitmapRectToRectBleed, Optional<SkPaint>, paint,
- ImmutableBitmap, bitmap,
- Optional<SkRect>, src,
- SkRect, dst);
-RECORD5(DrawBitmapRectToRectFixedSize, SkPaint, paint,
- ImmutableBitmap, bitmap,
- SkRect, src,
- SkRect, dst,
- SkCanvas::DrawBitmapRectFlags, flags);
+RECORD4(DrawBitmapRect, Optional<SkPaint>, paint,
+ ImmutableBitmap, bitmap,
+ Optional<SkRect>, src,
+ SkRect, dst);
+RECORD4(DrawBitmapRectFast, Optional<SkPaint>, paint,
+ ImmutableBitmap, bitmap,
+ Optional<SkRect>, src,
+ SkRect, dst);
+RECORD5(DrawBitmapRectFixedSize, SkPaint, paint,
+ ImmutableBitmap, bitmap,
+ SkRect, src,
+ SkRect, dst,
+ SkCanvas::SrcRectConstraint, constraint);
RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner);
RECORD3(DrawDrawable, Optional<SkMatrix>, matrix, SkRect, worstCaseBounds, int32_t, index);
RECORD4(DrawImage, Optional<SkPaint>, paint,
RefBox<const SkImage>, image,
SkScalar, left,
SkScalar, top);
-RECORD4(DrawImageRect, Optional<SkPaint>, paint,
+RECORD5(DrawImageRect, Optional<SkPaint>, paint,
RefBox<const SkImage>, image,
Optional<SkRect>, src,
- SkRect, dst);
+ SkRect, dst,
+ SkCanvas::SrcRectConstraint, constraint);
RECORD4(DrawImageNine, Optional<SkPaint>, paint,
RefBox<const SkImage>, image,
SkIRect, center,
// Subtract off the integer component of the translation (will be applied in loc, below).
dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop));
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- // FIXME: this probably shouldn't be necessary, but drawBitmapRectToRect asserts
+ // FIXME: this probably shouldn't be necessary, but drawBitmapRect asserts
// None filtering when it's translate-only
paint.setFilterQuality(
fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.height() ?
kNone_SkFilterQuality : fFilterQuality);
- canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint);
+ canvas.drawBitmapRect(fBitmap, &fSrcRect, dstRect, &paint, SkCanvas::kStrict_SrcRectConstraint);
*result = device.get()->accessBitmap(false);
offset->fX = dstIRect.fLeft;
canvas->save();
canvas->setMatrix(SkMatrix::I());
- canvas->drawBitmapRectToRect(bm, &src, dst, layer->paint());
+ canvas->drawBitmapRect(bm, &src, dst, layer->paint(), SkCanvas::kStrict_SrcRectConstraint);
canvas->restore();
} else {
canvas->drawSprite(bm,
concat.setConcat(*draw->fMatrix, m);
draw.writable()->fMatrix = &concat;
}
- this->drawBitmapCommon(*draw, bitmap, NULL, NULL, paint, SkCanvas::kNone_DrawBitmapRectFlag);
+ this->drawBitmapCommon(*draw, bitmap, NULL, NULL, paint, SkCanvas::kStrict_SrcRectConstraint);
}
// This method outsets 'iRect' by 'outset' all around and then clamps its extents to
const SkRect* srcRectPtr,
const SkSize* dstSizePtr,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags) {
+ SkCanvas::SrcRectConstraint constraint) {
CHECK_SHOULD_DRAW(draw);
SkRect srcRect;
int height = tex ? tex->height() : bitmap.height();
if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
srcRect.fRight >= width && srcRect.fBottom >= height) {
- flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_DrawBitmapRectFlag);
+ constraint = SkCanvas::kFast_SrcRectConstraint;
}
// If the render target is not msaa and draw is antialiased, we call
// already accounted for in 'm' and 'srcRect'. In clamp mode we need to chop out
// the desired portion of the bitmap and then update 'm' and 'srcRect' to
// compensate.
- if (!(SkCanvas::kBleed_DrawBitmapRectFlag & flags)) {
+ if (SkCanvas::kStrict_SrcRectConstraint == constraint) {
SkIRect iSrc;
srcRect.roundOut(&iSrc);
SkIRect clippedSrcRect;
if (this->shouldTileBitmap(bitmap, viewM, params, srcRectPtr, maxTileSize, &tileSize,
&clippedSrcRect)) {
- this->drawTiledBitmap(bitmap, viewM, srcRect, clippedSrcRect, params, paint, flags,
+ this->drawTiledBitmap(bitmap, viewM, srcRect, clippedSrcRect, params, paint, constraint,
tileSize, doBicubic);
} else {
// take the simple case
srcRect,
params,
paint,
- flags,
+ constraint,
doBicubic,
needsTextureDomain);
}
const SkIRect& clippedSrcIRect,
const GrTextureParams& params,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags,
+ SkCanvas::SrcRectConstraint constraint,
int tileSize,
bool bicubic) {
// The following pixel lock is technically redundant, but it is desirable
if (GrTextureParams::kNone_FilterMode != params.filterMode() || bicubic) {
SkIRect iClampRect;
- if (SkCanvas::kBleed_DrawBitmapRectFlag & flags) {
+ if (SkCanvas::kFast_SrcRectConstraint == constraint) {
// In bleed mode we want to always expand the tile on all edges
// but stay within the bitmap bounds
iClampRect = SkIRect::MakeWH(bitmap.width(), bitmap.height());
tileR,
paramsTemp,
paint,
- flags,
+ constraint,
bicubic,
needsTextureDomain);
}
const SkRect& srcRect,
const GrTextureParams& params,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags,
+ SkCanvas::SrcRectConstraint constraint,
bool bicubic,
bool needsTextureDomain) {
SkASSERT(bitmap.width() <= fContext->caps()->maxTextureSize() &&
GrPaint grPaint;
SkAutoTUnref<GrFragmentProcessor> fp;
- if (needsTextureDomain && !(flags & SkCanvas::kBleed_DrawBitmapRectFlag)) {
+ if (needsTextureDomain && (SkCanvas::kStrict_SrcRectConstraint == constraint)) {
// Use a constrained texture domain to avoid color bleeding
SkScalar left, top, right, bottom;
if (srcRect.width() > SK_Scalar1) {
void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap,
const SkRect* src, const SkRect& dst,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags) {
+ SK_VIRTUAL_CONSTRAINT_TYPE legacyConstraint) {
+ SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)legacyConstraint;
+
SkMatrix matrix;
SkRect bitmapBounds, tmpSrc;
dstSize.fWidth = tmpDst.width();
dstSize.fHeight = tmpDst.height();
- this->drawBitmapCommon(*draw, bitmap, &tmpSrc, &dstSize, paint, flags);
+ this->drawBitmapCommon(*draw, bitmap, &tmpSrc, &dstSize, paint, constraint);
}
void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
}
void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
- const SkRect& dst, const SkPaint& paint) {
+ const SkRect& dst, const SkPaint& paint,
+ SkCanvas::SrcRectConstraint constraint) {
SkBitmap bm;
if (wrap_as_bm(image, &bm)) {
- this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitmapRectFlag);
+ this->drawBitmapRect(draw, bm, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_TYPE)constraint);
}
}
virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) override;
virtual void drawText(const SkDraw&, const void* text, size_t len,
const SkPaint&) override;
void drawImage(const SkDraw&, const SkImage*, SkScalar x, SkScalar y, const SkPaint&) override;
void drawImageRect(const SkDraw&, const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint&) override;
+ const SkPaint&, SkCanvas::SrcRectConstraint) override;
void flush() override;
const SkRect* srcRectPtr,
const SkSize* dstSizePtr, // ignored iff srcRectPtr == NULL
const SkPaint&,
- SkCanvas::DrawBitmapRectFlags flags);
+ SkCanvas::SrcRectConstraint);
/**
* Helper functions called by drawBitmapCommon. By the time these are called the SkDraw's
const SkRect&,
const GrTextureParams& params,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags,
+ SkCanvas::SrcRectConstraint,
bool bicubic,
bool needsTextureDomain);
void drawTiledBitmap(const SkBitmap& bitmap,
const SkIRect& clippedSrcRect,
const GrTextureParams& params,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags,
+ SkCanvas::SrcRectConstraint,
int tileSize,
bool bicubic);
void SkPDFDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
const SkRect* src, const SkRect& dst,
const SkPaint& srcPaint,
- SkCanvas::DrawBitmapRectFlags flags) {
+ SK_VIRTUAL_CONSTRAINT_TYPE) {
SkPaint paint = srcPaint;
if (bitmap.isOpaque()) {
replace_srcmode_on_opaque_paint(&paint);
void drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
const SkRect* src, const SkRect& dst,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
const SkMatrix& matrix, const SkPaint&) override;
void drawSprite(const SkDraw&, const SkBitmap& bitmap, int x, int y,
kDrawAtlas_DrawOp,
kDrawBitmap_DrawOp,
kDrawBitmapNine_DrawOp,
- kDrawBitmapRectToRect_DrawOp,
+ kDrawBitmapRect_DrawOp,
kDrawDRRect_DrawOp,
kDrawImage_DrawOp,
kDrawImageRect_DrawOp,
} else {
src = NULL;
}
- SkCanvas::DrawBitmapRectFlags dbmrFlags = SkCanvas::kNone_DrawBitmapRectFlag;
+ SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint;
if (flags & kDrawBitmap_Bleed_DrawOpFlag) {
- dbmrFlags = (SkCanvas::DrawBitmapRectFlags)(dbmrFlags|SkCanvas::kBleed_DrawBitmapRectFlag);
+ constraint = SkCanvas::kFast_SrcRectConstraint;
}
const SkRect* dst = skip<SkRect>(reader);
const SkBitmap* bitmap = holder.getBitmap();
if (state->shouldDraw()) {
- canvas->drawBitmapRectToRect(*bitmap, src, *dst,
- hasPaint ? &state->paint() : NULL, dbmrFlags);
+ canvas->drawBitmapRect(*bitmap, src, *dst, hasPaint ? &state->paint() : NULL, constraint);
}
}
src = skip<SkRect>(reader);
}
const SkRect* dst = skip<SkRect>(reader);
+ SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
+
const SkImage* image = state->getImage(slot);
if (state->shouldDraw()) {
- canvas->drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NULL);
+ canvas->drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NULL, constraint);
}
}
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
- DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint*) override;
+ const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
}
void SkGPipeCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, DrawBitmapRectFlags dbmrFlags) {
+ const SkPaint* paint,
+ SK_VIRTUAL_CONSTRAINT_TYPE legacyConstraint) {
+ SrcRectConstraint constraint = (SrcRectConstraint)legacyConstraint;
+
NOTIFY_SETUP(this);
size_t opBytesNeeded = sizeof(SkRect);
bool hasSrc = src != NULL;
} else {
flags = 0;
}
- if (dbmrFlags & kBleed_DrawBitmapRectFlag) {
+ if (kFast_SrcRectConstraint == constraint) {
flags |= kDrawBitmap_Bleed_DrawOpFlag;
}
- if (this->commonDrawBitmap(bm, kDrawBitmapRectToRect_DrawOp, flags, opBytesNeeded, paint)) {
+ if (this->commonDrawBitmap(bm, kDrawBitmapRect_DrawOp, flags, opBytesNeeded, paint)) {
if (hasSrc) {
fWriter.writeRect(*src);
}
}
void SkGPipeCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint) {
+ const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
NOTIFY_SETUP(this);
+
+ SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(constraint)
unsigned flags = 0;
size_t opBytesNeeded = sizeof(SkRect); // dst
if (src) {
fWriter.writeRect(*src);
}
fWriter.writeRect(dst);
+ fWriter.writeInt(constraint);
}
}
void SkSVGDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bm, const SkRect* srcOrNull,
const SkRect& dst, const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags) {
+ SK_VIRTUAL_CONSTRAINT_TYPE) {
SkMatrix adjustedMatrix;
adjustedMatrix.setRectToRect(srcOrNull ? *srcOrNull : SkRect::Make(bm.bounds()),
dst,
void drawBitmapRect(const SkDraw&, const SkBitmap&,
const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void drawText(const SkDraw&, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint& paint) override;
{SkASSERT(0);}
void drawBitmapRect(const SkDraw&, const SkBitmap&, const SkRect*,
const SkRect&, const SkPaint&,
- SkCanvas::DrawBitmapRectFlags) override
+ SK_VIRTUAL_CONSTRAINT_TYPE) override
{SkASSERT(0);}
void drawSprite(const SkDraw&, const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) override
void drawImage(const SkDraw&, const SkImage*, SkScalar, SkScalar, const SkPaint&) override
{SkASSERT(0);}
void drawImageRect(const SkDraw&, const SkImage*, const SkRect*, const SkRect&,
- const SkPaint&) override
+ const SkPaint&, SkCanvas::SrcRectConstraint) override
{SkASSERT(0);}
void drawImageNine(const SkDraw&, const SkImage*, const SkIRect&, const SkRect&,
const SkPaint&) override
}
void SkDeferredCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
- const SkRect& dst,
- const SkPaint* paint, DrawBitmapRectFlags flags) {
+ const SkRect& dst, const SkPaint* paint,
+ SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
if (fDeferredDrawing &&
this->isFullFrame(&dst, paint) &&
isPaintOpaque(paint, &bitmap)) {
}
AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
- this->drawingCanvas()->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
+ this->drawingCanvas()->drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
this->recordedDrawCommand();
}
this->recordedDrawCommand();
}
void SkDeferredCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint) {
+ const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
if (fDeferredDrawing &&
this->isFullFrame(&dst, paint) &&
isPaintOpaque(paint, image)) {
}
AutoImmediateDrawIfNeeded autoDraw(*this, image, paint);
- this->drawingCanvas()->drawImageRect(image, src, dst, paint);
+ this->drawingCanvas()->drawImageRect(image, src, dst, paint
+ SRC_RECT_CONSTRAINT_ARG(constraint));
this->recordedDrawCommand();
}
}
void SkDumpCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, DrawBitmapRectFlags flags) {
+ const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE) {
SkString bs, rs;
bitmap.toString(&bs);
toString(dst, &rs);
rs.prependf("%s ", ss.c_str());
}
- this->dump(kDrawBitmap_Verb, paint, "drawBitmapRectToRect(%s %s)",
- bs.c_str(), rs.c_str());
+ this->dump(kDrawBitmap_Verb, paint, "drawBitmapRect(%s %s)", bs.c_str(), rs.c_str());
}
void SkDumpCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
}
void SkDumpCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint) {
+ const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
SkString bs, rs;
image->toString(&bs);
toString(dst, &rs);
}
void SkLuaCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, DrawBitmapRectFlags flags) {
+ const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE) {
AUTO_LUA("drawBitmapRect");
if (paint) {
lua.pushPaint(*paint, "paint");
}
void SkLuaCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint) {
+ const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
AUTO_LUA("drawImageRect");
if (paint) {
lua.pushPaint(*paint, "paint");
}
}
-void SkNWayCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
- const SkPaint& paint) {
+void SkNWayCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawDRRect(outer, inner, paint);
}
void SkNWayCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, DrawBitmapRectFlags flags) {
+ const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
Iter iter(fList);
while (iter.next()) {
- iter->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
+ iter->drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
}
}
}
void SkNWayCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint) {
+ const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
Iter iter(fList);
while (iter.next()) {
- iter->drawImageRect(image, src, dst, paint);
+ iter->drawImageRect(image, src, dst, paint SRC_RECT_CONSTRAINT_ARG(constraint));
}
}
}
void SkPaintFilterCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, DrawBitmapRectFlags flags) {
+ const SkPaint* paint,
+ SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
AutoPaintFilter apf(this, kBitmap_Type, paint);
- this->INHERITED::onDrawBitmapRect(bm, src, dst, apf.paint(), flags);
+ this->INHERITED::onDrawBitmapRect(bm, src, dst, apf.paint(), constraint);
}
void SkPaintFilterCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
}
void SkPaintFilterCanvas::onDrawImageRect(const SkImage* image, const SkRect* src,
- const SkRect& dst, const SkPaint* paint) {
+ const SkRect& dst, const SkPaint* paint
+ SRC_RECT_CONSTRAINT_PARAM(constraint)) {
AutoPaintFilter apf(this, kBitmap_Type, paint);
- this->INHERITED::onDrawImageRect(image, src, dst, apf.paint());
+ this->INHERITED::onDrawImageRect(image, src, dst, apf.paint()
+ SRC_RECT_CONSTRAINT_ARG(constraint));
}
void SkPaintFilterCanvas::onDrawBitmapNine(const SkBitmap& bm, const SkIRect& center,
const SkRect* src,
const SkRect& dst,
const SkPaint* paint,
- DrawBitmapRectFlags flags) {
+ SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
FILTER_PTR(paint);
- fProxyTarget->drawBitmapRectToRect(bitmap, src, dst, filteredPaint, flags);
+ fProxyTarget->drawBitmapRect(bitmap, src, dst, filteredPaint,
+ (SrcRectConstraint)constraint);
}
void SkAndroidSDKCanvas::onDrawBitmapNine(const SkBitmap& bitmap,
const SkIRect& center,
void onDrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
const SkPaint* paint) override;
void onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, DrawBitmapRectFlags flags) override;
+ const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE) override;
void onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint) override;
void onDrawSprite(const SkBitmap& bitmap, int left, int top,
}
void SkDebugCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, DrawBitmapRectFlags flags) {
- this->addDrawCommand(new SkDrawBitmapRectCommand(bitmap, src, dst, paint, flags));
+ const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
+ this->addDrawCommand(new SkDrawBitmapRectCommand(bitmap, src, dst, paint,
+ (SrcRectConstraint)constraint));
}
void SkDebugCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
}
void SkDebugCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint) {
+ const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
SkDebugf("SkDebugCanvas::onDrawImageRect unimplemented\n");
}
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
- DrawBitmapRectFlags flags) override;
+ SK_VIRTUAL_CONSTRAINT_TYPE) override;
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint*) override;
+ const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
- SkCanvas::DrawBitmapRectFlags flags)
+ SkCanvas::SrcRectConstraint constraint)
: INHERITED(kDrawBitmapRect_OpType) {
fBitmap = bitmap;
if (src) {
} else {
fPaintPtr = NULL;
}
- fFlags = flags;
+ fConstraint = constraint;
fInfo.push(SkObjectParser::BitmapToString(bitmap));
if (src) {
if (paint) {
fInfo.push(SkObjectParser::PaintToString(*paint));
}
- fInfo.push(SkObjectParser::IntToString(fFlags, "Flags: "));
+ fInfo.push(SkObjectParser::IntToString(fConstraint, "Constraint: "));
}
void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const {
- canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFlags);
+ canvas->drawBitmapRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fConstraint);
}
bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const {
public:
SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
- SkCanvas::DrawBitmapRectFlags flags);
+ SkCanvas::SrcRectConstraint);
void execute(SkCanvas* canvas) const override;
bool render(SkCanvas* canvas) const override;
const SkRect& dstRect() const { return fDst; }
void setDstRect(const SkRect& dst) { fDst = dst; }
- SkCanvas::DrawBitmapRectFlags flags() const { return fFlags; }
- void setFlags(SkCanvas::DrawBitmapRectFlags flags) { fFlags = flags; }
+ SkCanvas::SrcRectConstraint constraint() const { return fConstraint; }
+ void setConstraint(SkCanvas::SrcRectConstraint constraint) { fConstraint = constraint; }
private:
SkBitmap fBitmap;
SkRect fDst;
SkPaint fPaint;
SkPaint* fPaintPtr;
- SkCanvas::DrawBitmapRectFlags fFlags;
+ SkCanvas::SrcRectConstraint fConstraint;
typedef SkDrawCommand INHERITED;
};
}
void onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint) override {
+ const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) override {
fDrawImageRectCalled = true;
}