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

Unified Diff: src/core/SkComposeShader.cpp

Issue 1832223002: switch xfermodes over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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
Index: src/core/SkComposeShader.cpp
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index 4d3e4e57ba8f9b60dbda7bd5a212eeb43816c617..f39f20c46cefa7b8fb25107a4d23babe54031696 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -16,19 +16,6 @@
///////////////////////////////////////////////////////////////////////////////
-SkComposeShader::SkComposeShader(sk_sp<SkShader> sA, sk_sp<SkShader> sB, SkXfermode* mode)
- : fShaderA(std::move(sA))
- , fShaderB(std::move(sB))
-{
- // mode may be null
- fMode = mode;
- SkSafeRef(mode);
-}
-
-SkComposeShader::~SkComposeShader() {
- SkSafeUnref(fMode);
-}
-
size_t SkComposeShader::onContextSize(const ContextRec& rec) const {
return sizeof(ComposeShaderContext)
+ fShaderA->contextSize(rec)
@@ -55,17 +42,17 @@ private:
SkFlattenable* SkComposeShader::CreateProc(SkReadBuffer& buffer) {
sk_sp<SkShader> shaderA(buffer.readShader());
sk_sp<SkShader> shaderB(buffer.readShader());
- SkAutoTUnref<SkXfermode> mode(buffer.readXfermode());
+ sk_sp<SkXfermode> mode(buffer.readXfermode());
if (!shaderA || !shaderB) {
return nullptr;
}
- return new SkComposeShader(std::move(shaderA), std::move(shaderB), mode);
+ return new SkComposeShader(std::move(shaderA), std::move(shaderB), std::move(mode));
}
void SkComposeShader::flatten(SkWriteBuffer& buffer) const {
buffer.writeFlattenable(fShaderA.get());
buffer.writeFlattenable(fShaderB.get());
- buffer.writeFlattenable(fMode);
+ buffer.writeFlattenable(fMode.get());
}
template <typename T> void safe_call_destructor(T* obj) {
@@ -120,7 +107,7 @@ bool SkComposeShader::asACompose(ComposeRec* rec) const {
if (rec) {
rec->fShaderA = fShaderA.get();
rec->fShaderB = fShaderB.get();
- rec->fMode = fMode;
+ rec->fMode = fMode.get();
}
return true;
}
@@ -133,7 +120,7 @@ bool SkComposeShader::asACompose(ComposeRec* rec) const {
void SkComposeShader::ComposeShaderContext::shadeSpan(int x, int y, SkPMColor result[], int count) {
SkShader::Context* shaderContextA = fShaderContextA;
SkShader::Context* shaderContextB = fShaderContextB;
- SkXfermode* mode = static_cast<const SkComposeShader&>(fShader).fMode;
+ SkXfermode* mode = static_cast<const SkComposeShader&>(fShader).fMode.get();
unsigned scale = SkAlpha255To256(this->getPaintAlpha());
SkPMColor tmp[TMP_COLOR_COUNT];
@@ -255,15 +242,14 @@ void SkComposeShader::toString(SkString* str) const {
///////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkShader> SkShader::MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader> src,
- SkXfermode* xfer) {
+ sk_sp<SkXfermode> xfer) {
if (!dst || !src) {
return nullptr;
}
- return sk_make_sp<SkComposeShader>(std::move(dst), std::move(src), xfer);
+ return sk_make_sp<SkComposeShader>(std::move(dst), std::move(src), std::move(xfer));
}
sk_sp<SkShader> SkShader::MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader> src,
SkXfermode::Mode mode) {
- SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(mode));
- return MakeComposeShader(std::move(dst), std::move(src), xfer);
+ return MakeComposeShader(std::move(dst), std::move(src), SkXfermode::Make(mode));
}

Powered by Google App Engine
This is Rietveld 408576698