Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Unified Diff: src/image/SkImagePriv.cpp

Issue 19729007: Add SkImage->draw() call with src and dst rects. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImagePriv.cpp
diff --git a/src/image/SkImagePriv.cpp b/src/image/SkImagePriv.cpp
index c44e439b72c8b29eb82837b6dae19797d4b9569b..4ff1c92bff4c00a646a234f0b1d9b79a5f0bdf10 100644
--- a/src/image/SkImagePriv.cpp
+++ b/src/image/SkImagePriv.cpp
@@ -141,3 +141,33 @@ void SkImagePrivDrawPicture(SkCanvas* canvas, SkPicture* picture,
canvas->drawPicture(*picture);
canvas->restoreToCount(saveCount);
}
+
+void SkImagePrivDrawPicture(SkCanvas* canvas, SkPicture* picture,
+ const SkRect* src, const SkRect& dst, const SkPaint* paint) {
+ int saveCount = canvas->getSaveCount();
+
+ SkMatrix matrix;
+ SkRect tmpSrc;
+
+ if (NULL != src) {
+ tmpSrc = *src;
+ } else {
+ tmpSrc.set(0, 0,
+ SkIntToScalar(picture->width()),
+ SkIntToScalar(picture->height()));
+ }
+
+ matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
+ if (paint && needs_layer(*paint)) {
+ canvas->saveLayer(&dst, paint);
+ } else {
+ canvas->save();
+ }
+ canvas->concat(matrix);
+ if (!paint || !needs_layer(*paint)) {
+ canvas->clipRect(tmpSrc);
+ }
+
+ canvas->drawPicture(*picture);
+ canvas->restoreToCount(saveCount);
+}
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698