aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pipe
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/pipe
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/pipe')
-rw-r--r--src/pipe/SkGPipePriv.h2
-rw-r--r--src/pipe/SkGPipeRead.cpp11
-rw-r--r--src/pipe/SkGPipeWrite.cpp18
3 files changed, 19 insertions, 12 deletions
diff --git a/src/pipe/SkGPipePriv.h b/src/pipe/SkGPipePriv.h
index 614853dd92..c86e6fb304 100644
--- a/src/pipe/SkGPipePriv.h
+++ b/src/pipe/SkGPipePriv.h
@@ -42,7 +42,7 @@ enum DrawOps {
kDrawAtlas_DrawOp,
kDrawBitmap_DrawOp,
kDrawBitmapNine_DrawOp,
- kDrawBitmapRectToRect_DrawOp,
+ kDrawBitmapRect_DrawOp,
kDrawDRRect_DrawOp,
kDrawImage_DrawOp,
kDrawImageRect_DrawOp,
diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp
index 48e0c0641b..ef1eeb303b 100644
--- a/src/pipe/SkGPipeRead.cpp
+++ b/src/pipe/SkGPipeRead.cpp
@@ -643,15 +643,14 @@ static void drawBitmapRect_rp(SkCanvas* canvas, SkReader32* reader,
} 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);
}
}
@@ -689,9 +688,11 @@ static void drawImageRect_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32
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);
}
}
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 4dbb5b536c..60a63b090a 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -276,10 +276,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 onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
@@ -791,7 +791,10 @@ void SkGPipeCanvas::onDrawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top
}
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;
@@ -802,11 +805,11 @@ void SkGPipeCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src, cons
} 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);
}
@@ -869,8 +872,10 @@ void SkGPipeCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y,
}
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) {
@@ -882,6 +887,7 @@ void SkGPipeCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, con
fWriter.writeRect(*src);
}
fWriter.writeRect(dst);
+ fWriter.writeInt(constraint);
}
}