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

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 2255963002: Batched implementation of drawLattice() for GPU (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Speculative reland Created 4 years, 4 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/gpu/SkGpuDevice.h ('k') | src/gpu/batches/GrNinePatch.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 376d5e1b57669789c47d504126db628f06313761..040833b731d22c359289807e4f9374971425430c 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1409,8 +1409,10 @@ void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc
return;
}
- fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width(),
- producer->height(), center, dst);
+ std::unique_ptr<SkLatticeIter> iter(
+ new SkLatticeIter(producer->width(), producer->height(), center, dst));
+ fDrawContext->drawImageLattice(fClip, grPaint, *draw.fMatrix, producer->width(),
+ producer->height(), std::move(iter), dst);
}
void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image,
@@ -1440,6 +1442,61 @@ void SkGpuDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, con
this->drawProducerNine(draw, &maker, center, dst, paint);
}
+void SkGpuDevice::drawProducerLattice(const SkDraw& draw, GrTextureProducer* producer,
+ const SkCanvas::Lattice& lattice, const SkRect& dst,
+ const SkPaint& paint) {
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawProducerLattice", fContext);
+
+ CHECK_SHOULD_DRAW(draw);
+
+ static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_FilterMode;
+ sk_sp<GrFragmentProcessor> fp(
+ producer->createFragmentProcessor(SkMatrix::I(),
+ SkRect::MakeIWH(producer->width(), producer->height()),
+ GrTextureProducer::kNo_FilterConstraint, true,
+ &kMode, fDrawContext->getColorSpace(),
+ fDrawContext->sourceGammaTreatment()));
+ GrPaint grPaint;
+ if (!SkPaintToGrPaintWithTexture(this->context(), fDrawContext.get(), paint, *draw.fMatrix,
+ std::move(fp), producer->isAlphaOnly(), &grPaint)) {
+ return;
+ }
+
+ std::unique_ptr<SkLatticeIter> iter(
+ new SkLatticeIter(producer->width(), producer->height(), lattice, dst));
+ fDrawContext->drawImageLattice(fClip, grPaint, *draw.fMatrix, producer->width(),
+ producer->height(), std::move(iter), dst);
+}
+
+void SkGpuDevice::drawImageLattice(const SkDraw& draw, const SkImage* image,
+ const SkCanvas::Lattice& lattice, const SkRect& dst,
+ const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ uint32_t pinnedUniqueID;
+ if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) {
+ CHECK_SHOULD_DRAW(draw);
+ GrTextureAdjuster adjuster(tex.get(), image->alphaType(), image->bounds(), pinnedUniqueID,
+ as_IB(image)->onImageInfo().colorSpace());
+ this->drawProducerLattice(draw, &adjuster, lattice, dst, paint);
+ } else {
+ SkBitmap bm;
+ if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) {
+ GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_CachingHint);
+ this->drawProducerLattice(draw, &maker, lattice, dst, paint);
+ } else if (as_IB(image)->getROPixels(&bm)) {
+ this->drawBitmapLattice(draw, bm, lattice, dst, paint);
+ }
+ }
+}
+
+void SkGpuDevice::drawBitmapLattice(const SkDraw& draw, const SkBitmap& bitmap,
+ const SkCanvas::Lattice& lattice, const SkRect& dst,
+ const SkPaint& paint) {
+ ASSERT_SINGLE_OWNER
+ GrBitmapTextureMaker maker(fContext, bitmap);
+ this->drawProducerLattice(draw, &maker, lattice, dst, paint);
+}
+
///////////////////////////////////////////////////////////////////////////////
// must be in SkCanvas::VertexMode order
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/batches/GrNinePatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698