OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkData.h" | 9 #include "SkData.h" |
10 #include "SkImageFilter.h" | 10 #include "SkImageFilter.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 SkMatrix matrix = SkMatrix::I(); | 263 SkMatrix matrix = SkMatrix::I(); |
264 SkPaint paint; | 264 SkPaint paint; |
265 bool has_paint = false; // TODO: why is a default pai
nt not the same? | 265 bool has_paint = false; // TODO: why is a default pai
nt not the same? |
266 void draw(SkCanvas* c, const SkMatrix&) { | 266 void draw(SkCanvas* c, const SkMatrix&) { |
267 c->drawPicture(picture.get(), &matrix, has_paint ? &paint : nullptr)
; | 267 c->drawPicture(picture.get(), &matrix, has_paint ? &paint : nullptr)
; |
268 } | 268 } |
269 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } | 269 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } |
270 }; | 270 }; |
271 struct DrawShadowedPicture final : Op { | 271 struct DrawShadowedPicture final : Op { |
272 static const auto kType = Type::DrawShadowedPicture; | 272 static const auto kType = Type::DrawShadowedPicture; |
273 DrawShadowedPicture(const SkPicture* picture, const SkMatrix* matrix, co
nst SkPaint* paint) | 273 DrawShadowedPicture(const SkPicture* picture, const SkMatrix* matrix, |
| 274 const SkPaint* paint, const SkShadowParams& params) |
274 : picture(sk_ref_sp(picture)) { | 275 : picture(sk_ref_sp(picture)) { |
275 if (matrix) { this->matrix = *matrix; } | 276 if (matrix) { this->matrix = *matrix; } |
276 if (paint) { this->paint = *paint; } | 277 if (paint) { this->paint = *paint; } |
| 278 this->params = params; |
277 } | 279 } |
278 sk_sp<const SkPicture> picture; | 280 sk_sp<const SkPicture> picture; |
279 SkMatrix matrix = SkMatrix::I(); | 281 SkMatrix matrix = SkMatrix::I(); |
280 SkPaint paint; | 282 SkPaint paint; |
| 283 SkShadowParams params; |
281 void draw(SkCanvas* c, const SkMatrix&) { | 284 void draw(SkCanvas* c, const SkMatrix&) { |
282 #ifdef SK_EXPERIMENTAL_SHADOWING | 285 #ifdef SK_EXPERIMENTAL_SHADOWING |
283 c->drawShadowedPicture(picture.get(), &matrix, &paint); | 286 c->drawShadowedPicture(picture.get(), &matrix, &paint, params); |
284 #endif | 287 #endif |
285 } | 288 } |
286 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } | 289 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } |
287 }; | 290 }; |
288 | 291 |
289 struct DrawImage final : Op { | 292 struct DrawImage final : Op { |
290 static const auto kType = Type::DrawImage; | 293 static const auto kType = Type::DrawImage; |
291 DrawImage(sk_sp<const SkImage>&& image, SkScalar x, SkScalar y, const Sk
Paint* paint) | 294 DrawImage(sk_sp<const SkImage>&& image, SkScalar x, SkScalar y, const Sk
Paint* paint) |
292 : image(std::move(image)), x(x), y(y) { | 295 : image(std::move(image)), x(x), y(y) { |
293 if (paint) { this->paint = *paint; } | 296 if (paint) { this->paint = *paint; } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 void* pod = this->push<DrawAnnotation>(bytes, rect, value); | 611 void* pod = this->push<DrawAnnotation>(bytes, rect, value); |
609 copy_v(pod, key,bytes); | 612 copy_v(pod, key,bytes); |
610 } | 613 } |
611 void SkLiteDL::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix) { | 614 void SkLiteDL::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix) { |
612 this->push<DrawDrawable>(0, drawable, matrix); | 615 this->push<DrawDrawable>(0, drawable, matrix); |
613 } | 616 } |
614 void SkLiteDL::drawPicture(const SkPicture* picture, | 617 void SkLiteDL::drawPicture(const SkPicture* picture, |
615 const SkMatrix* matrix, const SkPaint* paint) { | 618 const SkMatrix* matrix, const SkPaint* paint) { |
616 this->push<DrawPicture>(0, picture, matrix, paint); | 619 this->push<DrawPicture>(0, picture, matrix, paint); |
617 } | 620 } |
618 void SkLiteDL::drawShadowedPicture(const SkPicture* picture, | 621 void SkLiteDL::drawShadowedPicture(const SkPicture* picture, const SkMatrix* mat
rix, |
619 const SkMatrix* matrix, const SkPaint* paint)
{ | 622 const SkPaint* paint, const SkShadowParams& p
arams) { |
620 this->push<DrawShadowedPicture>(0, picture, matrix, paint); | 623 push<DrawShadowedPicture>(0, picture, matrix, paint, params); |
621 } | 624 } |
622 | 625 |
623 void SkLiteDL::drawBitmap(const SkBitmap& bm, SkScalar x, SkScalar y, const SkPa
int* paint) { | 626 void SkLiteDL::drawBitmap(const SkBitmap& bm, SkScalar x, SkScalar y, const SkPa
int* paint) { |
624 this->push<DrawImage>(0, SkImage::MakeFromBitmap(bm), x,y, paint); | 627 this->push<DrawImage>(0, SkImage::MakeFromBitmap(bm), x,y, paint); |
625 } | 628 } |
626 void SkLiteDL::drawBitmapNine(const SkBitmap& bm, const SkIRect& center, | 629 void SkLiteDL::drawBitmapNine(const SkBitmap& bm, const SkIRect& center, |
627 const SkRect& dst, const SkPaint* paint) { | 630 const SkRect& dst, const SkPaint* paint) { |
628 this->push<DrawImageNine>(0, SkImage::MakeFromBitmap(bm), center, dst, paint
); | 631 this->push<DrawImageNine>(0, SkImage::MakeFromBitmap(bm), center, dst, paint
); |
629 } | 632 } |
630 void SkLiteDL::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRec
t& dst, | 633 void SkLiteDL::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRec
t& dst, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 } | 775 } |
773 | 776 |
774 void SkLiteDL::reset(SkRect bounds) { | 777 void SkLiteDL::reset(SkRect bounds) { |
775 SkASSERT(this->unique()); | 778 SkASSERT(this->unique()); |
776 this->map(dtor_fns); | 779 this->map(dtor_fns); |
777 | 780 |
778 // Leave fBytes and fReserved alone. | 781 // Leave fBytes and fReserved alone. |
779 fUsed = 0; | 782 fUsed = 0; |
780 fBounds = bounds; | 783 fBounds = bounds; |
781 } | 784 } |
OLD | NEW |