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

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: Test paint = NULL path for SkPicture. 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
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 pictureBounds, tmpSrc;
151
152 pictureBounds.set(0, 0,
reed1 2013/07/19 20:28:52 minor, but might move the initialization of pictur
153 SkIntToScalar(picture->width()),
154 SkIntToScalar(picture->height()));
155 if (NULL != src) {
156 tmpSrc = *src;
157 } else {
158 tmpSrc = pictureBounds;
159 }
160
161 matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
162 if (paint && needs_layer(*paint)) {
163 canvas->saveLayer(&dst, paint);
164 } else {
165 canvas->save();
166 }
167 canvas->concat(matrix);
168 if (!paint || !needs_layer(*paint)) {
169 canvas->clipRect(tmpSrc);
170 }
171
172 canvas->drawPicture(*picture);
173 canvas->restoreToCount(saveCount);
174 }
OLDNEW
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/image/SkImage_Base.h » ('j') | src/image/SkImage_Base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698