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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkImagePriv.h" 8 #include "SkImagePriv.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPicture.h" 10 #include "SkPicture.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 canvas->saveLayer(&bounds, paint); 134 canvas->saveLayer(&bounds, paint);
135 canvas->translate(x, y); 135 canvas->translate(x, y);
136 } else if (x || y) { 136 } else if (x || y) {
137 canvas->save(); 137 canvas->save();
138 canvas->translate(x, y); 138 canvas->translate(x, y);
139 } 139 }
140 140
141 canvas->drawPicture(*picture); 141 canvas->drawPicture(*picture);
142 canvas->restoreToCount(saveCount); 142 canvas->restoreToCount(saveCount);
143 } 143 }
144
145 void SkImagePrivDrawPicture(SkCanvas* canvas, SkPicture* picture,
146 const SkRect* src, const SkRect& dst, const SkPaint * paint) {
147 int saveCount = canvas->getSaveCount();
148
149 SkMatrix matrix;
150 SkRect tmpSrc;
151
152 if (NULL != src) {
153 tmpSrc = *src;
154 } else {
155 tmpSrc.set(0, 0,
156 SkIntToScalar(picture->width()),
157 SkIntToScalar(picture->height()));
158 }
159
160 matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
161 if (paint && needs_layer(*paint)) {
162 canvas->saveLayer(&dst, paint);
163 } else {
164 canvas->save();
165 }
166 canvas->concat(matrix);
167 if (!paint || !needs_layer(*paint)) {
168 canvas->clipRect(tmpSrc);
169 }
170
171 canvas->drawPicture(*picture);
172 canvas->restoreToCount(saveCount);
173 }
OLDNEW
« 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