aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar piotaixr <piotaixr@chromium.org>2014-10-16 11:58:39 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-16 11:58:39 -0700
commit65151754b9fdb6a968d7307764c20655d1b680a0 (patch)
tree497bb3e2990cd595755e896d1eb7b8ca164b508b /src
parent687732fe046c9cfec940f2d7f661cd97651d10a8 (diff)
Override SkCanvas::drawImage() in SkRecorder.
Diffstat (limited to 'src')
-rw-r--r--src/core/SkRecordDraw.cpp10
-rw-r--r--src/core/SkRecorder.cpp11
-rw-r--r--src/core/SkRecorder.h5
-rw-r--r--src/core/SkRecords.h10
-rw-r--r--src/image/SkImagePriv.h2
-rw-r--r--src/image/SkImage_Raster.cpp4
6 files changed, 39 insertions, 3 deletions
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index 577ffa125e..0c3347ec55 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -93,6 +93,8 @@ DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.p
DRAW(DrawBitmapRectToRect,
drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, r.flags));
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));
DRAW(DrawOval, drawOval(r.oval, r.paint));
DRAW(DrawPaint, drawPaint(r.paint));
DRAW(DrawPath, drawPath(r.path, r.paint));
@@ -359,7 +361,15 @@ private:
Bounds bounds(const DrawDRRect& op) const {
return this->adjustAndMap(op.outer.rect(), &op.paint);
}
+ Bounds bounds(const DrawImage& op) const {
+ const SkImage* image = op.image;
+ SkRect rect = SkRect::MakeXYWH(op.left, op.top, image->width(), image->height());
+ return this->adjustAndMap(rect, op.paint);
+ }
+ Bounds bounds(const DrawImageRect& op) const {
+ return this->adjustAndMap(op.dst, op.paint);
+ }
Bounds bounds(const DrawBitmapRectToRect& op) const {
return this->adjustAndMap(op.dst, op.paint);
}
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index f6c16d1c30..8dfce7e7dd 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -155,6 +155,17 @@ void SkRecorder::drawBitmapNine(const SkBitmap& bitmap,
APPEND(DrawBitmapNine, this->copy(paint), delay_copy(bitmap), center, dst);
}
+void SkRecorder::drawImage(const SkImage* image, SkScalar left, SkScalar top,
+ const SkPaint* paint) {
+ APPEND(DrawImage, this->copy(paint), image, left, top);
+}
+
+void SkRecorder::drawImageRect(const SkImage* image, const SkRect* src,
+ const SkRect& dst,
+ const SkPaint* paint) {
+ APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst);
+}
+
void SkRecorder::drawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint) {
APPEND(DrawSprite, this->copy(paint), delay_copy(bitmap), left, top);
}
diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h
index 9eb68319cb..6ac8a56475 100644
--- a/src/core/SkRecorder.h
+++ b/src/core/SkRecorder.h
@@ -49,6 +49,11 @@ public:
const SkIRect& center,
const SkRect& dst,
const SkPaint* paint = NULL) SK_OVERRIDE;
+ virtual void drawImage(const SkImage* image, SkScalar left, SkScalar top,
+ const SkPaint* paint = NULL) SK_OVERRIDE;
+ virtual void drawImageRect(const SkImage* image, const SkRect* src,
+ const SkRect& dst,
+ const SkPaint* paint = NULL) SK_OVERRIDE;
void drawSprite(const SkBitmap& bitmap,
int left,
int top,
diff --git a/src/core/SkRecords.h b/src/core/SkRecords.h
index c06d276cfa..f6292d419b 100644
--- a/src/core/SkRecords.h
+++ b/src/core/SkRecords.h
@@ -44,6 +44,8 @@ namespace SkRecords {
M(DrawBitmapMatrix) \
M(DrawBitmapNine) \
M(DrawBitmapRectToRect) \
+ M(DrawImage) \
+ M(DrawImageRect) \
M(DrawDRRect) \
M(DrawOval) \
M(DrawPaint) \
@@ -234,6 +236,14 @@ RECORD5(DrawBitmapRectToRect, Optional<SkPaint>, paint,
SkRect, dst,
SkCanvas::DrawBitmapRectFlags, flags);
RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner);
+RECORD4(DrawImage, Optional<SkPaint>, paint,
+ RefBox<const SkImage>, image,
+ SkScalar, left,
+ SkScalar, top);
+RECORD4(DrawImageRect, Optional<SkPaint>, paint,
+ RefBox<const SkImage>, image,
+ Optional<SkRect>, src,
+ SkRect, dst);
RECORD2(DrawOval, SkPaint, paint, SkRect, oval);
RECORD1(DrawPaint, SkPaint, paint);
RECORD2(DrawPath, SkPaint, paint, SkPath, path);
diff --git a/src/image/SkImagePriv.h b/src/image/SkImagePriv.h
index 89900766b4..e9d1d83899 100644
--- a/src/image/SkImagePriv.h
+++ b/src/image/SkImagePriv.h
@@ -33,7 +33,7 @@ static inline size_t SkImageMinRowBytes(const SkImageInfo& info) {
// Given an image created from SkNewImageFromBitmap, return its pixelref. This
// may be called to see if the surface and the image share the same pixelref,
// in which case the surface may need to perform a copy-on-write.
-extern SkPixelRef* SkBitmapImageGetPixelRef(SkImage* rasterImage);
+extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage);
// Given an image created with NewTexture, return its GrTexture. This
// may be called to see if the surface and the image share the same GrTexture,
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index d13141c3c6..18d6a8cabb 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -217,8 +217,8 @@ SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes));
}
-SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) {
- return ((SkImage_Raster*)image)->getPixelRef();
+const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) {
+ return ((const SkImage_Raster*)image)->getPixelRef();
}
bool SkImage_Raster::isOpaque() const {