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

Unified Diff: src/core/SkDraw.cpp

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/SkComposeShader.cpp ('k') | src/core/SkLocalMatrixShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDraw.cpp
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index c47922136975afa634274bc5b7008d2aeec06d63..409b652e93254a9aebfb0f14e596222a2521e11c 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -81,10 +81,10 @@ public:
SkAutoBitmapShaderInstall(const SkBitmap& src, const SkPaint& paint,
const SkMatrix* localMatrix = nullptr)
: fPaint(paint) /* makes a copy of the paint */ {
- fPaint.setShader(SkCreateBitmapShader(src, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode,
- localMatrix, &fAllocator));
+ fPaint.setShader(SkMakeBitmapShader(src, SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode, localMatrix, &fAllocator));
// we deliberately left the shader with an owner-count of 2
+ fPaint.getShader()->ref();
SkASSERT(2 == fPaint.getShader()->getRefCnt());
}
@@ -1880,7 +1880,7 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
Thus for texture drawing, we need both texture[] and a shader.
*/
- SkTriColorShader triShader; // must be above declaration of p
+ auto triShader = sk_make_sp<SkTriColorShader>();
SkPaint p(paint);
SkShader* shader = p.getShader();
@@ -1894,11 +1894,12 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
}
// setup the custom shader (if needed)
- SkAutoTUnref<SkComposeShader> composeShader;
+ sk_sp<SkShader> composeShader;
if (colors) {
if (nullptr == textures) {
// just colors (no texture)
- shader = p.setShader(&triShader);
+ p.setShader(triShader);
+ shader = p.getShader();
} else {
// colors * texture
SkASSERT(shader);
@@ -1907,7 +1908,7 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
xmode = SkXfermode::Create(SkXfermode::kModulate_Mode);
releaseMode = true;
}
- composeShader.reset(new SkComposeShader(&triShader, shader, xmode));
+ composeShader = sk_make_sp<SkComposeShader>(triShader, sk_ref_sp(shader), xmode);
p.setShader(composeShader);
if (releaseMode) {
xmode->unref();
@@ -1940,14 +1941,14 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
}
}
if (colors) {
- triShader.bindSetupData(&verticesSetup);
+ triShader->bindSetupData(&verticesSetup);
}
SkPoint tmp[] = {
devVerts[state.f0], devVerts[state.f1], devVerts[state.f2]
};
SkScan::FillTriangle(tmp, *fRC, blitter.get());
- triShader.bindSetupData(NULL);
+ triShader->bindSetupData(NULL);
}
} else {
// no colors[] and no texture, stroke hairlines with paint's color.
« no previous file with comments | « src/core/SkComposeShader.cpp ('k') | src/core/SkLocalMatrixShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698