OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkPatchUtils.h" | 9 #include "SkPatchUtils.h" |
10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 cull = (const SkRect*)reader->skip(sizeof(SkRect)); | 175 cull = (const SkRect*)reader->skip(sizeof(SkRect)); |
176 } | 176 } |
177 canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, pain
t); | 177 canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, pain
t); |
178 } break; | 178 } break; |
179 case DRAW_BITMAP: { | 179 case DRAW_BITMAP: { |
180 const SkPaint* paint = fPictureData->getPaint(reader); | 180 const SkPaint* paint = fPictureData->getPaint(reader); |
181 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); | 181 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); |
182 const SkPoint& loc = reader->skipT<SkPoint>(); | 182 const SkPoint& loc = reader->skipT<SkPoint>(); |
183 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint); | 183 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint); |
184 } break; | 184 } break; |
185 case DRAW_BITMAP_RECT_TO_RECT: { | 185 case DRAW_BITMAP_RECT: { |
186 const SkPaint* paint = fPictureData->getPaint(reader); | 186 const SkPaint* paint = fPictureData->getPaint(reader); |
187 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); | 187 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); |
188 const SkRect* src = get_rect_ptr(reader); // may be null | 188 const SkRect* src = get_rect_ptr(reader); // may be null |
189 const SkRect& dst = reader->skipT<SkRect>(); // required | 189 const SkRect& dst = reader->skipT<SkRect>(); // required |
190 SkCanvas::DrawBitmapRectFlags flags; | 190 SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstrain
t)reader->readInt(); |
191 flags = (SkCanvas::DrawBitmapRectFlags) reader->readInt(); | 191 canvas->drawBitmapRect(bitmap, src, dst, paint, constraint); |
192 canvas->drawBitmapRectToRect(bitmap, src, dst, paint, flags); | |
193 } break; | 192 } break; |
194 case DRAW_BITMAP_MATRIX: { | 193 case DRAW_BITMAP_MATRIX: { |
195 const SkPaint* paint = fPictureData->getPaint(reader); | 194 const SkPaint* paint = fPictureData->getPaint(reader); |
196 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); | 195 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); |
197 SkMatrix matrix; | 196 SkMatrix matrix; |
198 reader->readMatrix(&matrix); | 197 reader->readMatrix(&matrix); |
199 | 198 |
200 SkAutoCanvasRestore acr(canvas, true); | 199 SkAutoCanvasRestore acr(canvas, true); |
201 canvas->concat(matrix); | 200 canvas->concat(matrix); |
202 canvas->drawBitmap(bitmap, 0, 0, paint); | 201 canvas->drawBitmap(bitmap, 0, 0, paint); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 const SkPoint& loc = reader->skipT<SkPoint>(); | 241 const SkPoint& loc = reader->skipT<SkPoint>(); |
243 canvas->drawImage(image, loc.fX, loc.fY, paint); | 242 canvas->drawImage(image, loc.fX, loc.fY, paint); |
244 } break; | 243 } break; |
245 case DRAW_IMAGE_NINE: { | 244 case DRAW_IMAGE_NINE: { |
246 const SkPaint* paint = fPictureData->getPaint(reader); | 245 const SkPaint* paint = fPictureData->getPaint(reader); |
247 const SkImage* image = fPictureData->getImage(reader); | 246 const SkImage* image = fPictureData->getImage(reader); |
248 const SkIRect& center = reader->skipT<SkIRect>(); | 247 const SkIRect& center = reader->skipT<SkIRect>(); |
249 const SkRect& dst = reader->skipT<SkRect>(); | 248 const SkRect& dst = reader->skipT<SkRect>(); |
250 canvas->drawImageNine(image, center, dst, paint); | 249 canvas->drawImageNine(image, center, dst, paint); |
251 } break; | 250 } break; |
| 251 case DRAW_IMAGE_RECT_STRICT: |
252 case DRAW_IMAGE_RECT: { | 252 case DRAW_IMAGE_RECT: { |
253 const SkPaint* paint = fPictureData->getPaint(reader); | 253 const SkPaint* paint = fPictureData->getPaint(reader); |
254 const SkImage* image = fPictureData->getImage(reader); | 254 const SkImage* image = fPictureData->getImage(reader); |
255 const SkRect* src = get_rect_ptr(reader); // may be null | 255 const SkRect* src = get_rect_ptr(reader); // may be null |
256 const SkRect& dst = reader->skipT<SkRect>(); // required | 256 const SkRect& dst = reader->skipT<SkRect>(); // required |
257 canvas->drawImageRect(image, src, dst, paint); | 257 // DRAW_IMAGE_RECT_STRICT assumes this constraint, and doesn't store
it |
| 258 SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectCo
nstraint; |
| 259 if (DRAW_IMAGE_RECT == op) { |
| 260 // newer op-code stores the constraint explicitly |
| 261 constraint = (SkCanvas::SrcRectConstraint)reader->readInt(); |
| 262 } |
| 263 canvas->drawImageRect(image, src, dst, paint, constraint); |
258 } break; | 264 } break; |
259 case DRAW_OVAL: { | 265 case DRAW_OVAL: { |
260 const SkPaint& paint = *fPictureData->getPaint(reader); | 266 const SkPaint& paint = *fPictureData->getPaint(reader); |
261 canvas->drawOval(reader->skipT<SkRect>(), paint); | 267 canvas->drawOval(reader->skipT<SkRect>(), paint); |
262 } break; | 268 } break; |
263 case DRAW_PAINT: | 269 case DRAW_PAINT: |
264 canvas->drawPaint(*fPictureData->getPaint(reader)); | 270 canvas->drawPaint(*fPictureData->getPaint(reader)); |
265 break; | 271 break; |
266 case DRAW_PATCH: { | 272 case DRAW_PATCH: { |
267 const SkPaint& paint = *fPictureData->getPaint(reader); | 273 const SkPaint& paint = *fPictureData->getPaint(reader); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 case TRANSLATE: { | 479 case TRANSLATE: { |
474 SkScalar dx = reader->readScalar(); | 480 SkScalar dx = reader->readScalar(); |
475 SkScalar dy = reader->readScalar(); | 481 SkScalar dy = reader->readScalar(); |
476 canvas->translate(dx, dy); | 482 canvas->translate(dx, dy); |
477 } break; | 483 } break; |
478 default: | 484 default: |
479 SkASSERTF(false, "Unknown draw type: %d", op); | 485 SkASSERTF(false, "Unknown draw type: %d", op); |
480 } | 486 } |
481 } | 487 } |
482 | 488 |
OLD | NEW |