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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/core/SkLiteDL.cpp
diff --git a/src/core/SkLiteDL.cpp b/src/core/SkLiteDL.cpp
index fee6de385c7e84cbcd6716e0c4688fc34981dafd..b65e50be2d0b3e70766cfa13aa8b9a4bdd203a7d 100644
--- a/src/core/SkLiteDL.cpp
+++ b/src/core/SkLiteDL.cpp
@@ -338,19 +338,21 @@ namespace {
};
struct DrawImageLattice final : Op {
static const auto kType = Type::DrawImageLattice;
- DrawImageLattice(sk_sp<const SkImage>&& image, int xs, int ys,
+ DrawImageLattice(sk_sp<const SkImage>&& image, int xs, int ys, int fs,
const SkRect& dst, const SkPaint* paint)
- : image(std::move(image)), xs(xs), ys(ys), dst(dst) {
+ : image(std::move(image)), xs(xs), ys(ys), fs(fs), dst(dst) {
if (paint) { this->paint = *paint; }
}
sk_sp<const SkImage> image;
- int xs, ys;
+ int xs, ys, fs;
SkRect dst;
SkPaint paint;
void draw(SkCanvas* c, const SkMatrix&) {
auto xdivs = pod<int>(this, 0),
ydivs = pod<int>(this, xs*sizeof(int));
- c->drawImageLattice(image.get(), {xdivs, xs, ydivs, ys}, dst, &paint);
+ auto flags = (0 == fs) ? nullptr :
+ pod<SkCanvas::Lattice::Flags>(this, (xs+ys)*sizeof(int));
+ c->drawImageLattice(image.get(), {xdivs, xs, ydivs, ys, flags, fs}, dst, &paint);
}
};
@@ -644,12 +646,13 @@ void SkLiteDL::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRec
}
void SkLiteDL::drawBitmapLattice(const SkBitmap& bm, const SkCanvas::Lattice& lattice,
const SkRect& dst, const SkPaint* paint) {
- int xs = lattice.fXCount, ys = lattice.fYCount;
- size_t bytes = (xs + ys) * sizeof(int);
- void* pod = this->push<DrawImageLattice>(bytes, SkImage::MakeFromBitmap(bm), xs, ys, dst,
+ int xs = lattice.fXCount, ys = lattice.fYCount, fs = lattice.fFlagCount;
+ size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::Flags);
+ void* pod = this->push<DrawImageLattice>(bytes, SkImage::MakeFromBitmap(bm), xs, ys, fs, dst,
paint);
copy_v(pod, lattice.fXDivs, xs,
- lattice.fYDivs, ys);
+ lattice.fYDivs, ys,
+ lattice.fFlags, fs);
}
void SkLiteDL::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint* paint) {
@@ -665,11 +668,12 @@ void SkLiteDL::drawImageRect(const SkImage* image, const SkRect* src, const SkRe
}
void SkLiteDL::drawImageLattice(const SkImage* image, const SkCanvas::Lattice& lattice,
const SkRect& dst, const SkPaint* paint) {
- int xs = lattice.fXCount, ys = lattice.fYCount;
- size_t bytes = (xs + ys) * sizeof(int);
- void* pod = this->push<DrawImageLattice>(bytes, sk_ref_sp(image), xs, ys, dst, paint);
+ int xs = lattice.fXCount, ys = lattice.fYCount, fs = lattice.fFlagCount;
+ size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::Flags);
+ void* pod = this->push<DrawImageLattice>(bytes, sk_ref_sp(image), xs, ys, fs, dst, paint);
copy_v(pod, lattice.fXDivs, xs,
- lattice.fYDivs, ys);
+ lattice.fYDivs, ys,
+ lattice.fFlags, fs);
}
void SkLiteDL::drawText(const void* text, size_t bytes,

Powered by Google App Engine
This is Rietveld 408576698