aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkCanvas.cpp
diff options
context:
space:
mode:
authorGravatar piotaixr <piotaixr@chromium.org>2014-09-23 14:10:50 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-23 14:10:50 -0700
commit432789972c1e1f8a66165c75a250dba1853efa08 (patch)
tree587fd2e2ae72baa63af8fcad67d2471980894dbe /src/core/SkCanvas.cpp
parent271a030f5d0d3c59715fbeffb31c761279f3f8ca (diff)
SkCanvas::drawImage is the new way for drawing a SkImage to a Canvas
BUG=skia:2947 R=junov@chromium.org, reed@google.com, bsalomon@google.com Author: piotaixr@chromium.org Review URL: https://codereview.chromium.org/583453002
Diffstat (limited to 'src/core/SkCanvas.cpp')
-rw-r--r--src/core/SkCanvas.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index dcc7047dbc..afd7fbef88 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -12,6 +12,7 @@
#include "SkDraw.h"
#include "SkDrawFilter.h"
#include "SkDrawLooper.h"
+#include "SkImage.h"
#include "SkMetaData.h"
#include "SkPathOps.h"
#include "SkPatchUtils.h"
@@ -183,7 +184,7 @@ public:
fFilter = NULL;
fLayer = NULL;
fTopLayer = NULL;
-
+
// don't bother initializing fNext
inc_rec();
}
@@ -192,7 +193,7 @@ public:
fFilter = SkSafeRef(prev.fFilter);
fLayer = NULL;
fTopLayer = prev.fTopLayer;
-
+
// don't bother initializing fNext
inc_rec();
}
@@ -292,7 +293,7 @@ public:
// can we be marked as simple?
fIsSimple = !fFilter && !fDoClearImageFilter;
}
-
+
uint32_t oldFlags = paint.getFlags();
fNewPaintFlags = filter_paint_flags(props, oldFlags);
if (fIsSimple && (fNewPaintFlags != oldFlags)) {
@@ -457,7 +458,7 @@ public:
SkNoPixelsBitmapDevice(int width, int height) : INHERITED(make_nopixels(width, height)) {}
private:
-
+
typedef SkBitmapDevice INHERITED;
};
@@ -466,7 +467,7 @@ SkCanvas::SkCanvas(int width, int height)
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
{
inc_canvas();
-
+
this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), kDefault_InitFlags)->unref();
}
@@ -475,7 +476,7 @@ SkCanvas::SkCanvas(int width, int height, InitFlags flags)
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
{
inc_canvas();
-
+
this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (width, height)), flags)->unref();
}
@@ -484,7 +485,7 @@ SkCanvas::SkCanvas(SkBaseDevice* device, const SkSurfaceProps* props, InitFlags
, fProps(SkSurfacePropsCopyOrDefault(props))
{
inc_canvas();
-
+
this->init(device, flags);
}
@@ -493,7 +494,7 @@ SkCanvas::SkCanvas(SkBaseDevice* device)
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
{
inc_canvas();
-
+
this->init(device, kDefault_InitFlags);
}
@@ -502,7 +503,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)
, fProps(props)
{
inc_canvas();
-
+
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
this->init(device, kDefault_InitFlags);
}
@@ -512,7 +513,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap)
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
{
inc_canvas();
-
+
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
this->init(device, kDefault_InitFlags);
}
@@ -1885,6 +1886,17 @@ void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
LOOPER_END
}
+void SkCanvas::drawImage(const SkImage* image, SkScalar left, SkScalar top,
+ const SkPaint* paint) {
+ image->draw(this, left, top, paint);
+}
+
+void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src,
+ const SkRect& dst,
+ const SkPaint* paint) {
+ image->draw(this, src, dst, paint);
+}
+
void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
const SkPaint* paint) {
SkDEBUGCODE(bitmap.validate();)