aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkLiteDL.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-09-30 12:41:42 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-30 12:41:42 -0700
commit71df2d7bc1bbc83ad4cf005f9027df4cb3b88a9b (patch)
tree9113c13e0d2285f1204e0a4bee8d89eb644d16ed /src/core/SkLiteDL.cpp
parent9c8a32ff4507481aadf1a190637ee8d55c8dc217 (diff)
Add a src rect to drawImageLattice() API
This will allow us to draw ninepatches directly from an asset texture without having to upload them individually. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2382893002 Review-Url: https://codereview.chromium.org/2382893002
Diffstat (limited to 'src/core/SkLiteDL.cpp')
-rw-r--r--src/core/SkLiteDL.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/core/SkLiteDL.cpp b/src/core/SkLiteDL.cpp
index 8e64ae0a7d..701e9bd38f 100644
--- a/src/core/SkLiteDL.cpp
+++ b/src/core/SkLiteDL.cpp
@@ -353,12 +353,13 @@ namespace {
struct DrawImageLattice final : Op {
static const auto kType = Type::DrawImageLattice;
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), fs(fs), dst(dst) {
+ const SkIRect& src, const SkRect& dst, const SkPaint* paint)
+ : image(std::move(image)), xs(xs), ys(ys), fs(fs), src(src), dst(dst) {
if (paint) { this->paint = *paint; }
}
sk_sp<const SkImage> image;
int xs, ys, fs;
+ SkIRect src;
SkRect dst;
SkPaint paint;
void draw(SkCanvas* c, const SkMatrix&) {
@@ -366,7 +367,7 @@ namespace {
ydivs = pod<int>(this, xs*sizeof(int));
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);
+ c->drawImageLattice(image.get(), {xdivs, ydivs, flags, xs, ys, &src}, dst, &paint);
}
};
@@ -669,8 +670,9 @@ void SkLiteDL::drawBitmapLattice(const SkBitmap& bm, const SkCanvas::Lattice& la
int xs = lattice.fXCount, ys = lattice.fYCount;
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);
+ SkASSERT(lattice.fBounds);
+ void* pod = this->push<DrawImageLattice>(bytes, SkImage::MakeFromBitmap(bm), xs, ys, fs,
+ *lattice.fBounds, dst, paint);
copy_v(pod, lattice.fXDivs, xs,
lattice.fYDivs, ys,
lattice.fFlags, fs);
@@ -692,7 +694,9 @@ void SkLiteDL::drawImageLattice(const SkImage* image, const SkCanvas::Lattice& l
int xs = lattice.fXCount, ys = lattice.fYCount;
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);
+ SkASSERT(lattice.fBounds);
+ void* pod = this->push<DrawImageLattice>(bytes, sk_ref_sp(image), xs, ys, fs, *lattice.fBounds,
+ dst, paint);
copy_v(pod, lattice.fXDivs, xs,
lattice.fYDivs, ys,
lattice.fFlags, fs);