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

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

Issue 2382893002: Add a src rect to drawImageLattice() API (Closed)
Patch Set: Fix win Created 4 years, 2 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 "SkDrawFilter.h" 10 #include "SkDrawFilter.h"
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 SkRect src, dst; 346 SkRect src, dst;
347 SkPaint paint; 347 SkPaint paint;
348 SkCanvas::SrcRectConstraint constraint; 348 SkCanvas::SrcRectConstraint constraint;
349 void draw(SkCanvas* c, const SkMatrix&) { 349 void draw(SkCanvas* c, const SkMatrix&) {
350 c->drawImageRect(image.get(), src, dst, &paint, constraint); 350 c->drawImageRect(image.get(), src, dst, &paint, constraint);
351 } 351 }
352 }; 352 };
353 struct DrawImageLattice final : Op { 353 struct DrawImageLattice final : Op {
354 static const auto kType = Type::DrawImageLattice; 354 static const auto kType = Type::DrawImageLattice;
355 DrawImageLattice(sk_sp<const SkImage>&& image, int xs, int ys, int fs, 355 DrawImageLattice(sk_sp<const SkImage>&& image, int xs, int ys, int fs,
356 const SkRect& dst, const SkPaint* paint) 356 const SkIRect& src, const SkRect& dst, const SkPaint* p aint)
357 : image(std::move(image)), xs(xs), ys(ys), fs(fs), dst(dst) { 357 : image(std::move(image)), xs(xs), ys(ys), fs(fs), src(src), dst(dst ) {
358 if (paint) { this->paint = *paint; } 358 if (paint) { this->paint = *paint; }
359 } 359 }
360 sk_sp<const SkImage> image; 360 sk_sp<const SkImage> image;
361 int xs, ys, fs; 361 int xs, ys, fs;
362 SkIRect src;
362 SkRect dst; 363 SkRect dst;
363 SkPaint paint; 364 SkPaint paint;
364 void draw(SkCanvas* c, const SkMatrix&) { 365 void draw(SkCanvas* c, const SkMatrix&) {
365 auto xdivs = pod<int>(this, 0), 366 auto xdivs = pod<int>(this, 0),
366 ydivs = pod<int>(this, xs*sizeof(int)); 367 ydivs = pod<int>(this, xs*sizeof(int));
367 auto flags = (0 == fs) ? nullptr : 368 auto flags = (0 == fs) ? nullptr :
368 pod<SkCanvas::Lattice::Flags>(this, (xs+ys) *sizeof(int)); 369 pod<SkCanvas::Lattice::Flags>(this, (xs+ys) *sizeof(int));
369 c->drawImageLattice(image.get(), {xdivs, ydivs, flags, xs, ys}, dst, &paint); 370 c->drawImageLattice(image.get(), {xdivs, ydivs, flags, xs, ys, src}, dst, &paint);
370 } 371 }
371 }; 372 };
372 373
373 struct DrawText final : Op { 374 struct DrawText final : Op {
374 static const auto kType = Type::DrawText; 375 static const auto kType = Type::DrawText;
375 DrawText(size_t bytes, SkScalar x, SkScalar y, const SkPaint& paint) 376 DrawText(size_t bytes, SkScalar x, SkScalar y, const SkPaint& paint)
376 : bytes(bytes), x(x), y(y), paint(paint) {} 377 : bytes(bytes), x(x), y(y), paint(paint) {}
377 size_t bytes; 378 size_t bytes;
378 SkScalar x,y; 379 SkScalar x,y;
379 SkPaint paint; 380 SkPaint paint;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 } 663 }
663 void SkLiteDL::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRec t& dst, 664 void SkLiteDL::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRec t& dst,
664 const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) { 665 const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) {
665 this->push<DrawImageRect>(0, SkImage::MakeFromBitmap(bm), src, dst, paint, c onstraint); 666 this->push<DrawImageRect>(0, SkImage::MakeFromBitmap(bm), src, dst, paint, c onstraint);
666 } 667 }
667 void SkLiteDL::drawBitmapLattice(const SkBitmap& bm, const SkCanvas::Lattice& la ttice, 668 void SkLiteDL::drawBitmapLattice(const SkBitmap& bm, const SkCanvas::Lattice& la ttice,
668 const SkRect& dst, const SkPaint* paint) { 669 const SkRect& dst, const SkPaint* paint) {
669 int xs = lattice.fXCount, ys = lattice.fYCount; 670 int xs = lattice.fXCount, ys = lattice.fYCount;
670 int fs = lattice.fFlags ? (xs + 1) * (ys + 1) : 0; 671 int fs = lattice.fFlags ? (xs + 1) * (ys + 1) : 0;
671 size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::Flag s); 672 size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::Flag s);
672 void* pod = this->push<DrawImageLattice>(bytes, SkImage::MakeFromBitmap(bm), xs, ys, fs, dst, 673 void* pod = this->push<DrawImageLattice>(bytes, SkImage::MakeFromBitmap(bm), xs, ys, fs,
673 paint); 674 lattice.fBounds, dst, paint);
674 copy_v(pod, lattice.fXDivs, xs, 675 copy_v(pod, lattice.fXDivs, xs,
675 lattice.fYDivs, ys, 676 lattice.fYDivs, ys,
676 lattice.fFlags, fs); 677 lattice.fFlags, fs);
677 } 678 }
678 679
679 void SkLiteDL::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP aint* paint) { 680 void SkLiteDL::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP aint* paint) {
680 this->push<DrawImage>(0, sk_ref_sp(image), x,y, paint); 681 this->push<DrawImage>(0, sk_ref_sp(image), x,y, paint);
681 } 682 }
682 void SkLiteDL::drawImageNine(const SkImage* image, const SkIRect& center, 683 void SkLiteDL::drawImageNine(const SkImage* image, const SkIRect& center,
683 const SkRect& dst, const SkPaint* paint) { 684 const SkRect& dst, const SkPaint* paint) {
684 this->push<DrawImageNine>(0, sk_ref_sp(image), center, dst, paint); 685 this->push<DrawImageNine>(0, sk_ref_sp(image), center, dst, paint);
685 } 686 }
686 void SkLiteDL::drawImageRect(const SkImage* image, const SkRect* src, const SkRe ct& dst, 687 void SkLiteDL::drawImageRect(const SkImage* image, const SkRect* src, const SkRe ct& dst,
687 const SkPaint* paint, SkCanvas::SrcRectConstraint c onstraint) { 688 const SkPaint* paint, SkCanvas::SrcRectConstraint c onstraint) {
688 this->push<DrawImageRect>(0, sk_ref_sp(image), src, dst, paint, constraint); 689 this->push<DrawImageRect>(0, sk_ref_sp(image), src, dst, paint, constraint);
689 } 690 }
690 void SkLiteDL::drawImageLattice(const SkImage* image, const SkCanvas::Lattice& l attice, 691 void SkLiteDL::drawImageLattice(const SkImage* image, const SkCanvas::Lattice& l attice,
691 const SkRect& dst, const SkPaint* paint) { 692 const SkRect& dst, const SkPaint* paint) {
692 int xs = lattice.fXCount, ys = lattice.fYCount; 693 int xs = lattice.fXCount, ys = lattice.fYCount;
693 int fs = lattice.fFlags ? (xs + 1) * (ys + 1) : 0; 694 int fs = lattice.fFlags ? (xs + 1) * (ys + 1) : 0;
694 size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::Flag s); 695 size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::Flag s);
695 void* pod = this->push<DrawImageLattice>(bytes, sk_ref_sp(image), xs, ys, fs , dst, paint); 696 void* pod = this->push<DrawImageLattice>(bytes, sk_ref_sp(image), xs, ys, fs , lattice.fBounds,
697 dst, paint);
696 copy_v(pod, lattice.fXDivs, xs, 698 copy_v(pod, lattice.fXDivs, xs,
697 lattice.fYDivs, ys, 699 lattice.fYDivs, ys,
698 lattice.fFlags, fs); 700 lattice.fFlags, fs);
699 } 701 }
700 702
701 void SkLiteDL::drawText(const void* text, size_t bytes, 703 void SkLiteDL::drawText(const void* text, size_t bytes,
702 SkScalar x, SkScalar y, const SkPaint& paint) { 704 SkScalar x, SkScalar y, const SkPaint& paint) {
703 void* pod = this->push<DrawText>(bytes, bytes, x, y, paint); 705 void* pod = this->push<DrawText>(bytes, bytes, x, y, paint);
704 copy_v(pod, (const char*)text,bytes); 706 copy_v(pod, (const char*)text,bytes);
705 } 707 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 }; 828 };
827 829
828 // TODO: single-draw specializations 830 // TODO: single-draw specializations
829 831
830 return fallback_plan(); 832 return fallback_plan();
831 } 833 }
832 834
833 void SkLiteDL::setBounds(const SkRect& bounds) { 835 void SkLiteDL::setBounds(const SkRect& bounds) {
834 fBounds = bounds; 836 fBounds = bounds;
835 } 837 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698