aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-22 08:10:17 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-22 08:10:17 -0700
commit4c9776b046dd5e9e46e2d1ce35154855c8fcb381 (patch)
tree3cdcc394a99b0483921eb86a8f5cc118f20d6433 /src/effects
parent1eb81db650d31f50be67b12d60c4f9e7dd08432f (diff)
Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.org/1822623002/ )"
Fixed legacy withColorFilter to call new(er) make method This reverts commit 1eb81db650d31f50be67b12d60c4f9e7dd08432f. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1825073002 TBR= Review URL: https://codereview.chromium.org/1825073002
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkBlurDrawLooper.cpp4
-rw-r--r--src/effects/SkColorCubeFilter.cpp18
-rw-r--r--src/effects/SkColorFilterImageFilter.cpp18
-rw-r--r--src/effects/SkColorMatrixFilter.cpp4
-rw-r--r--src/effects/SkDropShadowImageFilter.cpp4
-rw-r--r--src/effects/SkLayerDrawLooper.cpp2
-rw-r--r--src/effects/SkLumaColorFilter.cpp4
-rw-r--r--src/effects/SkTableColorFilter.cpp24
8 files changed, 36 insertions, 42 deletions
diff --git a/src/effects/SkBlurDrawLooper.cpp b/src/effects/SkBlurDrawLooper.cpp
index d8127eba4e..c8e20e1265 100644
--- a/src/effects/SkBlurDrawLooper.cpp
+++ b/src/effects/SkBlurDrawLooper.cpp
@@ -44,8 +44,7 @@ void SkBlurDrawLooper::initEffects() {
// be baked into the blurred mask.
SkColor opaqueColor = SkColorSetA(fBlurColor, 255);
//The SrcIn xfer mode will multiply 'color' by the incoming alpha
- fColorFilter = SkColorFilter::CreateModeFilter(opaqueColor,
- SkXfermode::kSrcIn_Mode);
+ fColorFilter = SkColorFilter::MakeModeFilter(opaqueColor, SkXfermode::kSrcIn_Mode);
} else {
fColorFilter = nullptr;
}
@@ -81,7 +80,6 @@ void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const {
SkBlurDrawLooper::~SkBlurDrawLooper() {
SkSafeUnref(fBlur);
- SkSafeUnref(fColorFilter);
}
bool SkBlurDrawLooper::asABlurShadow(BlurShadowRec* rec) const {
diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp
index d59f123a80..d80a02fef2 100644
--- a/src/effects/SkColorCubeFilter.cpp
+++ b/src/effects/SkColorCubeFilter.cpp
@@ -48,19 +48,19 @@ static bool is_valid_3D_lut(SkData* cubeData, int cubeDimension) {
(nullptr != cubeData) && (cubeData->size() >= minMemorySize);
}
-SkColorFilter* SkColorCubeFilter::Create(SkData* cubeData, int cubeDimension) {
- if (!is_valid_3D_lut(cubeData, cubeDimension)) {
+sk_sp<SkColorFilter> SkColorCubeFilter::Make(sk_sp<SkData> cubeData, int cubeDimension) {
+ if (!is_valid_3D_lut(cubeData.get(), cubeDimension)) {
return nullptr;
}
- return new SkColorCubeFilter(cubeData, cubeDimension);
+ return sk_sp<SkColorFilter>(new SkColorCubeFilter(std::move(cubeData), cubeDimension));
}
-SkColorCubeFilter::SkColorCubeFilter(SkData* cubeData, int cubeDimension)
- : fCubeData(SkRef(cubeData))
- , fUniqueID(SkNextColorCubeUniqueID())
- , fCache(cubeDimension) {
-}
+SkColorCubeFilter::SkColorCubeFilter(sk_sp<SkData> cubeData, int cubeDimension)
+ : fCubeData(std::move(cubeData))
+ , fUniqueID(SkNextColorCubeUniqueID())
+ , fCache(cubeDimension)
+{}
uint32_t SkColorCubeFilter::getFlags() const {
return this->INHERITED::getFlags() | kAlphaUnchanged_Flag;
@@ -142,7 +142,7 @@ SkFlattenable* SkColorCubeFilter::CreateProc(SkReadBuffer& buffer) {
if (!buffer.validate(is_valid_3D_lut(cubeData.get(), cubeDimension))) {
return nullptr;
}
- return Create(cubeData.get(), cubeDimension);
+ return Make(std::move(cubeData), cubeDimension).release();
}
void SkColorCubeFilter::flatten(SkWriteBuffer& buffer) const {
diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp
index 96ce5d9690..6eb66533d9 100644
--- a/src/effects/SkColorFilterImageFilter.cpp
+++ b/src/effects/SkColorFilterImageFilter.cpp
@@ -25,10 +25,10 @@ SkImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf, SkImageFilter
if (input && input->isColorFilterNode(&inputCF)) {
// This is an optimization, as it collapses the hierarchy by just combining the two
// colorfilters into a single one, which the new imagefilter will wrap.
- SkAutoUnref autoUnref(inputCF);
- SkAutoTUnref<SkColorFilter> newCF(SkColorFilter::CreateComposeFilter(cf, inputCF));
+ sk_sp<SkColorFilter> newCF(SkColorFilter::MakeComposeFilter(sk_ref_sp(cf),
+ sk_sp<SkColorFilter>(inputCF)));
if (newCF) {
- return new SkColorFilterImageFilter(newCF, input->getInput(0), cropRect);
+ return new SkColorFilterImageFilter(newCF.get(), input->getInput(0), cropRect);
}
}
@@ -42,17 +42,13 @@ SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf,
SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
- SkAutoTUnref<SkColorFilter> cf(buffer.readColorFilter());
- return Create(cf, common.getInput(0), &common.cropRect());
+ sk_sp<SkColorFilter> cf(buffer.readColorFilter());
+ return Create(cf.get(), common.getInput(0), &common.cropRect());
}
void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
- buffer.writeFlattenable(fColorFilter);
-}
-
-SkColorFilterImageFilter::~SkColorFilterImageFilter() {
- fColorFilter->unref();
+ buffer.writeFlattenable(fColorFilter.get());
}
bool SkColorFilterImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitmap& source,
@@ -94,7 +90,7 @@ bool SkColorFilterImageFilter::onIsColorFilterNode(SkColorFilter** filter) const
SkASSERT(1 == this->countInputs());
if (!this->cropRectIsSet()) {
if (filter) {
- *filter = SkRef(fColorFilter);
+ *filter = SkRef(fColorFilter.get());
}
return true;
}
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index e122b6ac8e..82bd45b73d 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -16,7 +16,7 @@ static SkScalar byte_to_scale(U8CPU byte) {
}
}
-SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor add) {
+sk_sp<SkColorFilter> SkColorMatrixFilter::MakeLightingFilter(SkColor mul, SkColor add) {
SkColorMatrix matrix;
matrix.setScale(byte_to_scale(SkColorGetR(mul)),
byte_to_scale(SkColorGetG(mul)),
@@ -26,5 +26,5 @@ SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor ad
SkIntToScalar(SkColorGetG(add)),
SkIntToScalar(SkColorGetB(add)),
0);
- return SkColorMatrixFilter::Create(matrix);
+ return SkColorFilter::MakeMatrixFilterRowMajor255(matrix.fMat);
}
diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp
index deece35b38..e32b89ee6d 100644
--- a/src/effects/SkDropShadowImageFilter.cpp
+++ b/src/effects/SkDropShadowImageFilter.cpp
@@ -79,11 +79,9 @@ bool SkDropShadowImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitm
sigma.fX = SkMaxScalar(0, sigma.fX);
sigma.fY = SkMaxScalar(0, sigma.fY);
SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(sigma.fX, sigma.fY));
- SkAutoTUnref<SkColorFilter> colorFilter(
- SkColorFilter::CreateModeFilter(fColor, SkXfermode::kSrcIn_Mode));
SkPaint paint;
paint.setImageFilter(blurFilter.get());
- paint.setColorFilter(colorFilter.get());
+ paint.setColorFilter(SkColorFilter::MakeModeFilter(fColor, SkXfermode::kSrcIn_Mode));
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
SkVector offsetVec = SkVector::Make(fDx, fDy);
ctx.ctm().mapVectors(&offsetVec, 1);
diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp
index ae31482ae7..8510767801 100644
--- a/src/effects/SkLayerDrawLooper.cpp
+++ b/src/effects/SkLayerDrawLooper.cpp
@@ -102,7 +102,7 @@ void SkLayerDrawLooper::LayerDrawLooperContext::ApplyInfo(
dst->setShader(src.getShader());
}
if (bits & kColorFilter_Bit) {
- dst->setColorFilter(src.getColorFilter());
+ dst->setColorFilter(sk_ref_sp(src.getColorFilter()));
}
if (bits & kXfermode_Bit) {
dst->setXfermode(src.getXfermode());
diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp
index 0ca6342d56..18b2485a30 100644
--- a/src/effects/SkLumaColorFilter.cpp
+++ b/src/effects/SkLumaColorFilter.cpp
@@ -37,7 +37,9 @@ void SkLumaColorFilter::filterSpan(const SkPMColor src[], int count,
}
}
-SkColorFilter* SkLumaColorFilter::Create() { return new SkLumaColorFilter; }
+sk_sp<SkColorFilter> SkLumaColorFilter::Make() {
+ return sk_sp<SkColorFilter>(new SkLumaColorFilter);
+}
SkLumaColorFilter::SkLumaColorFilter() : INHERITED() {}
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 5ae175ffca..4ce0b4bb0e 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -46,7 +46,7 @@ public:
virtual ~SkTable_ColorFilter() { delete fBitmap; }
bool asComponentTable(SkBitmap* table) const override;
- SkColorFilter* newComposed(const SkColorFilter* inner) const override;
+ sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter> inner) const override;
#if SK_SUPPORT_GPU
const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
@@ -251,7 +251,7 @@ SkFlattenable* SkTable_ColorFilter::CreateProc(SkReadBuffer& buffer) {
b = ptr;
ptr += 256;
}
- return SkTableColorFilter::CreateARGB(a, r, g, b);
+ return SkTableColorFilter::MakeARGB(a, r, g, b).release();
}
bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const {
@@ -287,7 +287,7 @@ static void combine_tables(uint8_t res[256], const uint8_t outer[256], const uin
}
}
-SkColorFilter* SkTable_ColorFilter::newComposed(const SkColorFilter* innerFilter) const {
+sk_sp<SkColorFilter> SkTable_ColorFilter::makeComposed(sk_sp<SkColorFilter> innerFilter) const {
SkBitmap innerBM;
if (!innerFilter->asComponentTable(&innerBM)) {
return nullptr;
@@ -326,7 +326,7 @@ SkColorFilter* SkTable_ColorFilter::newComposed(const SkColorFilter* innerFilter
combine_tables(concatG, tableG, innerBM.getAddr8(0, 2));
combine_tables(concatB, tableB, innerBM.getAddr8(0, 3));
- return SkTableColorFilter::CreateARGB(concatA, concatR, concatG, concatB);
+ return SkTableColorFilter::MakeARGB(concatA, concatR, concatG, concatB);
}
#if SK_SUPPORT_GPU
@@ -554,7 +554,7 @@ const GrFragmentProcessor* ColorTableEffect::TestCreate(GrProcessorTestData* d)
}
}
}
- SkAutoTUnref<SkColorFilter> filter(SkTableColorFilter::CreateARGB(
+ auto filter(SkTableColorFilter::MakeARGB(
(flags & (1 << 0)) ? luts[0] : nullptr,
(flags & (1 << 1)) ? luts[1] : nullptr,
(flags & (1 << 2)) ? luts[2] : nullptr,
@@ -587,15 +587,15 @@ const GrFragmentProcessor* SkTable_ColorFilter::asFragmentProcessor(GrContext* c
///////////////////////////////////////////////////////////////////////////////
-SkColorFilter* SkTableColorFilter::Create(const uint8_t table[256]) {
- return new SkTable_ColorFilter(table, table, table, table);
+sk_sp<SkColorFilter> SkTableColorFilter::Make(const uint8_t table[256]) {
+ return sk_make_sp<SkTable_ColorFilter>(table, table, table, table);
}
-SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256],
- const uint8_t tableR[256],
- const uint8_t tableG[256],
- const uint8_t tableB[256]) {
- return new SkTable_ColorFilter(tableA, tableR, tableG, tableB);
+sk_sp<SkColorFilter> SkTableColorFilter::MakeARGB(const uint8_t tableA[256],
+ const uint8_t tableR[256],
+ const uint8_t tableG[256],
+ const uint8_t tableB[256]) {
+ return sk_make_sp<SkTable_ColorFilter>(tableA, tableR, tableG, tableB);
}
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter)