| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 sk_sp<const SkImage> image; | 331 sk_sp<const SkImage> image; |
| 332 SkRect src, dst; | 332 SkRect src, dst; |
| 333 SkPaint paint; | 333 SkPaint paint; |
| 334 SkCanvas::SrcRectConstraint constraint; | 334 SkCanvas::SrcRectConstraint constraint; |
| 335 void draw(SkCanvas* c, const SkMatrix&) { | 335 void draw(SkCanvas* c, const SkMatrix&) { |
| 336 c->drawImageRect(image.get(), src, dst, &paint, constraint); | 336 c->drawImageRect(image.get(), src, dst, &paint, constraint); |
| 337 } | 337 } |
| 338 }; | 338 }; |
| 339 struct DrawImageLattice final : Op { | 339 struct DrawImageLattice final : Op { |
| 340 static const auto kType = Type::DrawImageLattice; | 340 static const auto kType = Type::DrawImageLattice; |
| 341 DrawImageLattice(sk_sp<const SkImage>&& image, int xs, int ys, | 341 DrawImageLattice(sk_sp<const SkImage>&& image, int xs, int ys, int fs, |
| 342 const SkRect& dst, const SkPaint* paint) | 342 const SkRect& dst, const SkPaint* paint) |
| 343 : image(std::move(image)), xs(xs), ys(ys), dst(dst) { | 343 : image(std::move(image)), xs(xs), ys(ys), fs(fs), dst(dst) { |
| 344 if (paint) { this->paint = *paint; } | 344 if (paint) { this->paint = *paint; } |
| 345 } | 345 } |
| 346 sk_sp<const SkImage> image; | 346 sk_sp<const SkImage> image; |
| 347 int xs, ys; | 347 int xs, ys, fs; |
| 348 SkRect dst; | 348 SkRect dst; |
| 349 SkPaint paint; | 349 SkPaint paint; |
| 350 void draw(SkCanvas* c, const SkMatrix&) { | 350 void draw(SkCanvas* c, const SkMatrix&) { |
| 351 auto xdivs = pod<int>(this, 0), | 351 auto xdivs = pod<int>(this, 0), |
| 352 ydivs = pod<int>(this, xs*sizeof(int)); | 352 ydivs = pod<int>(this, xs*sizeof(int)); |
| 353 c->drawImageLattice(image.get(), {xdivs, xs, ydivs, ys}, dst, &paint
); | 353 auto flags = (0 == fs) ? nullptr : |
| 354 pod<SkCanvas::Lattice::Flags>(this, (xs+ys)
*sizeof(int)); |
| 355 c->drawImageLattice(image.get(), {xdivs, ydivs, flags, xs, ys}, dst,
&paint); |
| 354 } | 356 } |
| 355 }; | 357 }; |
| 356 | 358 |
| 357 struct DrawText final : Op { | 359 struct DrawText final : Op { |
| 358 static const auto kType = Type::DrawText; | 360 static const auto kType = Type::DrawText; |
| 359 DrawText(size_t bytes, SkScalar x, SkScalar y, const SkPaint& paint) | 361 DrawText(size_t bytes, SkScalar x, SkScalar y, const SkPaint& paint) |
| 360 : bytes(bytes), x(x), y(y), paint(paint) {} | 362 : bytes(bytes), x(x), y(y), paint(paint) {} |
| 361 size_t bytes; | 363 size_t bytes; |
| 362 SkScalar x,y; | 364 SkScalar x,y; |
| 363 SkPaint paint; | 365 SkPaint paint; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 const SkRect& dst, const SkPaint* paint) { | 640 const SkRect& dst, const SkPaint* paint) { |
| 639 this->push<DrawImageNine>(0, SkImage::MakeFromBitmap(bm), center, dst, paint
); | 641 this->push<DrawImageNine>(0, SkImage::MakeFromBitmap(bm), center, dst, paint
); |
| 640 } | 642 } |
| 641 void SkLiteDL::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRec
t& dst, | 643 void SkLiteDL::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRec
t& dst, |
| 642 const SkPaint* paint, SkCanvas::SrcRectConstraint
constraint) { | 644 const SkPaint* paint, SkCanvas::SrcRectConstraint
constraint) { |
| 643 this->push<DrawImageRect>(0, SkImage::MakeFromBitmap(bm), src, dst, paint, c
onstraint); | 645 this->push<DrawImageRect>(0, SkImage::MakeFromBitmap(bm), src, dst, paint, c
onstraint); |
| 644 } | 646 } |
| 645 void SkLiteDL::drawBitmapLattice(const SkBitmap& bm, const SkCanvas::Lattice& la
ttice, | 647 void SkLiteDL::drawBitmapLattice(const SkBitmap& bm, const SkCanvas::Lattice& la
ttice, |
| 646 const SkRect& dst, const SkPaint* paint) { | 648 const SkRect& dst, const SkPaint* paint) { |
| 647 int xs = lattice.fXCount, ys = lattice.fYCount; | 649 int xs = lattice.fXCount, ys = lattice.fYCount; |
| 648 size_t bytes = (xs + ys) * sizeof(int); | 650 int fs = lattice.fFlags ? (xs + 1) * (ys + 1) : 0; |
| 649 void* pod = this->push<DrawImageLattice>(bytes, SkImage::MakeFromBitmap(bm),
xs, ys, dst, | 651 size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::Flag
s); |
| 652 void* pod = this->push<DrawImageLattice>(bytes, SkImage::MakeFromBitmap(bm),
xs, ys, fs, dst, |
| 650 paint); | 653 paint); |
| 651 copy_v(pod, lattice.fXDivs, xs, | 654 copy_v(pod, lattice.fXDivs, xs, |
| 652 lattice.fYDivs, ys); | 655 lattice.fYDivs, ys, |
| 656 lattice.fFlags, fs); |
| 653 } | 657 } |
| 654 | 658 |
| 655 void SkLiteDL::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP
aint* paint) { | 659 void SkLiteDL::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP
aint* paint) { |
| 656 this->push<DrawImage>(0, sk_ref_sp(image), x,y, paint); | 660 this->push<DrawImage>(0, sk_ref_sp(image), x,y, paint); |
| 657 } | 661 } |
| 658 void SkLiteDL::drawImageNine(const SkImage* image, const SkIRect& center, | 662 void SkLiteDL::drawImageNine(const SkImage* image, const SkIRect& center, |
| 659 const SkRect& dst, const SkPaint* paint) { | 663 const SkRect& dst, const SkPaint* paint) { |
| 660 this->push<DrawImageNine>(0, sk_ref_sp(image), center, dst, paint); | 664 this->push<DrawImageNine>(0, sk_ref_sp(image), center, dst, paint); |
| 661 } | 665 } |
| 662 void SkLiteDL::drawImageRect(const SkImage* image, const SkRect* src, const SkRe
ct& dst, | 666 void SkLiteDL::drawImageRect(const SkImage* image, const SkRect* src, const SkRe
ct& dst, |
| 663 const SkPaint* paint, SkCanvas::SrcRectConstraint c
onstraint) { | 667 const SkPaint* paint, SkCanvas::SrcRectConstraint c
onstraint) { |
| 664 this->push<DrawImageRect>(0, sk_ref_sp(image), src, dst, paint, constraint); | 668 this->push<DrawImageRect>(0, sk_ref_sp(image), src, dst, paint, constraint); |
| 665 } | 669 } |
| 666 void SkLiteDL::drawImageLattice(const SkImage* image, const SkCanvas::Lattice& l
attice, | 670 void SkLiteDL::drawImageLattice(const SkImage* image, const SkCanvas::Lattice& l
attice, |
| 667 const SkRect& dst, const SkPaint* paint) { | 671 const SkRect& dst, const SkPaint* paint) { |
| 668 int xs = lattice.fXCount, ys = lattice.fYCount; | 672 int xs = lattice.fXCount, ys = lattice.fYCount; |
| 669 size_t bytes = (xs + ys) * sizeof(int); | 673 int fs = lattice.fFlags ? (xs + 1) * (ys + 1) : 0; |
| 670 void* pod = this->push<DrawImageLattice>(bytes, sk_ref_sp(image), xs, ys, ds
t, paint); | 674 size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::Flag
s); |
| 675 void* pod = this->push<DrawImageLattice>(bytes, sk_ref_sp(image), xs, ys, fs
, dst, paint); |
| 671 copy_v(pod, lattice.fXDivs, xs, | 676 copy_v(pod, lattice.fXDivs, xs, |
| 672 lattice.fYDivs, ys); | 677 lattice.fYDivs, ys, |
| 678 lattice.fFlags, fs); |
| 673 } | 679 } |
| 674 | 680 |
| 675 void SkLiteDL::drawText(const void* text, size_t bytes, | 681 void SkLiteDL::drawText(const void* text, size_t bytes, |
| 676 SkScalar x, SkScalar y, const SkPaint& paint) { | 682 SkScalar x, SkScalar y, const SkPaint& paint) { |
| 677 void* pod = this->push<DrawText>(bytes, bytes, x, y, paint); | 683 void* pod = this->push<DrawText>(bytes, bytes, x, y, paint); |
| 678 copy_v(pod, (const char*)text,bytes); | 684 copy_v(pod, (const char*)text,bytes); |
| 679 } | 685 } |
| 680 void SkLiteDL::drawPosText(const void* text, size_t bytes, | 686 void SkLiteDL::drawPosText(const void* text, size_t bytes, |
| 681 const SkPoint pos[], const SkPaint& paint) { | 687 const SkPoint pos[], const SkPaint& paint) { |
| 682 int n = paint.countText(text, bytes); | 688 int n = paint.countText(text, bytes); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 } | 789 } |
| 784 | 790 |
| 785 void SkLiteDL::reset(SkRect bounds) { | 791 void SkLiteDL::reset(SkRect bounds) { |
| 786 SkASSERT(this->unique()); | 792 SkASSERT(this->unique()); |
| 787 this->map(dtor_fns); | 793 this->map(dtor_fns); |
| 788 | 794 |
| 789 // Leave fBytes and fReserved alone. | 795 // Leave fBytes and fReserved alone. |
| 790 fUsed = 0; | 796 fUsed = 0; |
| 791 fBounds = bounds; | 797 fBounds = bounds; |
| 792 } | 798 } |
| OLD | NEW |