aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-07-14 10:54:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-14 10:54:12 -0700
commita5517e2b190a8083b38964972b031c13e99f1012 (patch)
tree16fc3439de41b3af1e85c360904e96c44a2b8078 /src/utils
parent4abc186d029c3c57a53cec3f483de2fff6d4a954 (diff)
add src-rect-constraint to drawImageRect
Follow-on work - unify around SrcRectConstraint (i.e. drawBitmapRect) - remove silly drawBitmapRectToRect alias - clean-up (possibly remove) alias problems around drawBitmapRect + IRect parameter BUG=skia: Review URL: https://codereview.chromium.org/1228083004
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/SkDeferredCanvas.cpp15
-rw-r--r--src/utils/SkDumpCanvas.cpp7
-rw-r--r--src/utils/SkLuaCanvas.cpp4
-rw-r--r--src/utils/SkNWayCanvas.cpp11
-rw-r--r--src/utils/SkPaintFilterCanvas.cpp11
-rw-r--r--src/utils/android/SkAndroidSDKCanvas.cpp5
-rw-r--r--src/utils/android/SkAndroidSDKCanvas.h2
-rw-r--r--src/utils/debugger/SkDebugCanvas.cpp7
-rw-r--r--src/utils/debugger/SkDebugCanvas.h4
-rw-r--r--src/utils/debugger/SkDrawCommand.cpp8
-rw-r--r--src/utils/debugger/SkDrawCommand.h8
11 files changed, 43 insertions, 39 deletions
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 8e34235848..343d0c45d7 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -219,7 +219,7 @@ protected:
{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
@@ -227,7 +227,7 @@ protected:
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
@@ -865,8 +865,8 @@ void SkDeferredCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar left,
}
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)) {
@@ -874,7 +874,7 @@ void SkDeferredCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* sr
}
AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
- this->drawingCanvas()->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
+ this->drawingCanvas()->drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
this->recordedDrawCommand();
}
@@ -894,7 +894,7 @@ void SkDeferredCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y,
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)) {
@@ -902,7 +902,8 @@ void SkDeferredCanvas::onDrawImageRect(const SkImage* image, const SkRect* src,
}
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();
}
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index 5cbf2f4bcc..e20aea4e02 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -346,7 +346,7 @@ void SkDumpCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
}
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);
@@ -359,8 +359,7 @@ void SkDumpCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, c
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,
@@ -381,7 +380,7 @@ void SkDumpCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, con
}
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);
diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp
index 68094f2ca0..b8921310a6 100644
--- a/src/utils/SkLuaCanvas.cpp
+++ b/src/utils/SkLuaCanvas.cpp
@@ -215,7 +215,7 @@ void SkLuaCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
}
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");
@@ -238,7 +238,7 @@ void SkLuaCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, cons
}
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");
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index 8ae842237f..706c769d7b 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -170,8 +170,7 @@ void SkNWayCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& 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);
@@ -194,10 +193,10 @@ void SkNWayCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
}
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);
}
}
@@ -218,10 +217,10 @@ void SkNWayCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top
}
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));
}
}
diff --git a/src/utils/SkPaintFilterCanvas.cpp b/src/utils/SkPaintFilterCanvas.cpp
index 1abebef8ca..3e589e6146 100644
--- a/src/utils/SkPaintFilterCanvas.cpp
+++ b/src/utils/SkPaintFilterCanvas.cpp
@@ -74,9 +74,10 @@ void SkPaintFilterCanvas::onDrawBitmap(const SkBitmap& bm, SkScalar left, SkScal
}
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,
@@ -86,9 +87,11 @@ void SkPaintFilterCanvas::onDrawImage(const SkImage* image, SkScalar left, SkSca
}
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,
diff --git a/src/utils/android/SkAndroidSDKCanvas.cpp b/src/utils/android/SkAndroidSDKCanvas.cpp
index 26baaf2954..2f988919d8 100644
--- a/src/utils/android/SkAndroidSDKCanvas.cpp
+++ b/src/utils/android/SkAndroidSDKCanvas.cpp
@@ -143,9 +143,10 @@ void SkAndroidSDKCanvas::onDrawBitmapRect(const SkBitmap& bitmap,
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,
diff --git a/src/utils/android/SkAndroidSDKCanvas.h b/src/utils/android/SkAndroidSDKCanvas.h
index a54315d478..d22931d4c9 100644
--- a/src/utils/android/SkAndroidSDKCanvas.h
+++ b/src/utils/android/SkAndroidSDKCanvas.h
@@ -43,7 +43,7 @@ protected:
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,
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index 3c166b73da..00923db405 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -415,8 +415,9 @@ void SkDebugCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar left,
}
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,
@@ -430,7 +431,7 @@ void SkDebugCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar to
}
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");
}
diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h
index ceaaa78413..4f5f226e82 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -198,10 +198,10 @@ protected:
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;
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp
index 7e2af084f2..5f0f74ffc0 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -320,7 +320,7 @@ bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const {
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) {
@@ -336,7 +336,7 @@ SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
} else {
fPaintPtr = NULL;
}
- fFlags = flags;
+ fConstraint = constraint;
fInfo.push(SkObjectParser::BitmapToString(bitmap));
if (src) {
@@ -346,11 +346,11 @@ SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
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 {
diff --git a/src/utils/debugger/SkDrawCommand.h b/src/utils/debugger/SkDrawCommand.h
index 307599fdb7..99e3eea457 100644
--- a/src/utils/debugger/SkDrawCommand.h
+++ b/src/utils/debugger/SkDrawCommand.h
@@ -229,7 +229,7 @@ class SkDrawBitmapRectCommand : public SkDrawCommand {
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;
@@ -250,8 +250,8 @@ public:
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;
@@ -259,7 +259,7 @@ private:
SkRect fDst;
SkPaint fPaint;
SkPaint* fPaintPtr;
- SkCanvas::DrawBitmapRectFlags fFlags;
+ SkCanvas::SrcRectConstraint fConstraint;
typedef SkDrawCommand INHERITED;
};