aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkLiteDL.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-09-02 11:24:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-02 11:24:30 -0700
commit0764efe6a9ae65ad83992f614f57ca9db5b1f191 (patch)
tree0093acd4cd619336ccd5f6b06748e9928af438ef /src/core/SkLiteDL.cpp
parent005327b9ddbf0bb2890c7d563b3d9a8ea8a284f6 (diff)
Add option to skip rects to drawImageLattice()
HWUI skips transparent rects when drawing. When skia draws using bilerp, we will blend transparent rects with neighboring rects and might draw a bit of a smudge. This CL adds the option to skip rects, allowing us to have compatible behavior with the framework. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2305433002 Review-Url: https://codereview.chromium.org/2305433002
Diffstat (limited to 'src/core/SkLiteDL.cpp')
-rw-r--r--src/core/SkLiteDL.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/core/SkLiteDL.cpp b/src/core/SkLiteDL.cpp
index eaa5a79626..8c8abb1cc3 100644
--- a/src/core/SkLiteDL.cpp
+++ b/src/core/SkLiteDL.cpp
@@ -352,19 +352,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);
}
};
@@ -665,11 +667,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) {
@@ -686,10 +690,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,