Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: src/core/SkLiteDL.cpp

Issue 2305433002: Add option to skip rects to drawImageLattice() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: numRectsToDraw() Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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, xs, ydivs, ys, flags, fs}, 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 void SkLiteDL::drawBitmapNine(const SkBitmap& bm, const SkIRect& center, 639 void SkLiteDL::drawBitmapNine(const SkBitmap& bm, const SkIRect& center,
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, fs = lattice.fFlagCount;
648 size_t bytes = (xs + ys) * sizeof(int); 650 size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::Flag s);
649 void* pod = this->push<DrawImageLattice>(bytes, SkImage::MakeFromBitmap(bm), xs, ys, dst, 651 void* pod = this->push<DrawImageLattice>(bytes, SkImage::MakeFromBitmap(bm), xs, ys, fs, dst,
650 paint); 652 paint);
651 copy_v(pod, lattice.fXDivs, xs, 653 copy_v(pod, lattice.fXDivs, xs,
652 lattice.fYDivs, ys); 654 lattice.fYDivs, ys,
655 lattice.fFlags, fs);
653 } 656 }
654 657
655 void SkLiteDL::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP aint* paint) { 658 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); 659 this->push<DrawImage>(0, sk_ref_sp(image), x,y, paint);
657 } 660 }
658 void SkLiteDL::drawImageNine(const SkImage* image, const SkIRect& center, 661 void SkLiteDL::drawImageNine(const SkImage* image, const SkIRect& center,
659 const SkRect& dst, const SkPaint* paint) { 662 const SkRect& dst, const SkPaint* paint) {
660 this->push<DrawImageNine>(0, sk_ref_sp(image), center, dst, paint); 663 this->push<DrawImageNine>(0, sk_ref_sp(image), center, dst, paint);
661 } 664 }
662 void SkLiteDL::drawImageRect(const SkImage* image, const SkRect* src, const SkRe ct& dst, 665 void SkLiteDL::drawImageRect(const SkImage* image, const SkRect* src, const SkRe ct& dst,
663 const SkPaint* paint, SkCanvas::SrcRectConstraint c onstraint) { 666 const SkPaint* paint, SkCanvas::SrcRectConstraint c onstraint) {
664 this->push<DrawImageRect>(0, sk_ref_sp(image), src, dst, paint, constraint); 667 this->push<DrawImageRect>(0, sk_ref_sp(image), src, dst, paint, constraint);
665 } 668 }
666 void SkLiteDL::drawImageLattice(const SkImage* image, const SkCanvas::Lattice& l attice, 669 void SkLiteDL::drawImageLattice(const SkImage* image, const SkCanvas::Lattice& l attice,
667 const SkRect& dst, const SkPaint* paint) { 670 const SkRect& dst, const SkPaint* paint) {
668 int xs = lattice.fXCount, ys = lattice.fYCount; 671 int xs = lattice.fXCount, ys = lattice.fYCount, fs = lattice.fFlagCount;
669 size_t bytes = (xs + ys) * sizeof(int); 672 size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::Flag s);
670 void* pod = this->push<DrawImageLattice>(bytes, sk_ref_sp(image), xs, ys, ds t, paint); 673 void* pod = this->push<DrawImageLattice>(bytes, sk_ref_sp(image), xs, ys, fs , dst, paint);
671 copy_v(pod, lattice.fXDivs, xs, 674 copy_v(pod, lattice.fXDivs, xs,
672 lattice.fYDivs, ys); 675 lattice.fYDivs, ys,
676 lattice.fFlags, fs);
673 } 677 }
674 678
675 void SkLiteDL::drawText(const void* text, size_t bytes, 679 void SkLiteDL::drawText(const void* text, size_t bytes,
676 SkScalar x, SkScalar y, const SkPaint& paint) { 680 SkScalar x, SkScalar y, const SkPaint& paint) {
677 void* pod = this->push<DrawText>(bytes, bytes, x, y, paint); 681 void* pod = this->push<DrawText>(bytes, bytes, x, y, paint);
678 copy_v(pod, (const char*)text,bytes); 682 copy_v(pod, (const char*)text,bytes);
679 } 683 }
680 void SkLiteDL::drawPosText(const void* text, size_t bytes, 684 void SkLiteDL::drawPosText(const void* text, size_t bytes,
681 const SkPoint pos[], const SkPaint& paint) { 685 const SkPoint pos[], const SkPaint& paint) {
682 int n = paint.countText(text, bytes); 686 int n = paint.countText(text, bytes);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 } 787 }
784 788
785 void SkLiteDL::reset(SkRect bounds) { 789 void SkLiteDL::reset(SkRect bounds) {
786 SkASSERT(this->unique()); 790 SkASSERT(this->unique());
787 this->map(dtor_fns); 791 this->map(dtor_fns);
788 792
789 // Leave fBytes and fReserved alone. 793 // Leave fBytes and fReserved alone.
790 fUsed = 0; 794 fUsed = 0;
791 fBounds = bounds; 795 fBounds = bounds;
792 } 796 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698