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