OLD | NEW |
---|---|
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 Loading... | |
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 } | |
OLD | NEW |