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

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: Better detection for zero divs 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
« no previous file with comments | « src/core/SkLatticeIter.cpp ('k') | src/core/SkPicturePlayback.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLiteDL.cpp
diff --git a/src/core/SkLiteDL.cpp b/src/core/SkLiteDL.cpp
index fee6de385c7e84cbcd6716e0c4688fc34981dafd..7d96de23da36794bd432ab4333ad63417a10f824 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, ydivs, flags, xs, ys}, dst, &paint);
}
};
@@ -645,11 +647,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 fs = lattice.fFlags ? (xs + 1) * (ys + 1) : 0;
+ 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) {
@@ -666,10 +670,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 fs = lattice.fFlags ? (xs + 1) * (ys + 1) : 0;
+ 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,
« no previous file with comments | « src/core/SkLatticeIter.cpp ('k') | src/core/SkPicturePlayback.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698