SkPerlinNoiseShader2::~SkPerlinNoiseShader2() {
}
-SkFlattenable* SkPerlinNoiseShader2::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkPerlinNoiseShader2::CreateProc(SkReadBuffer& buffer) {
Type type = (Type)buffer.readInt();
SkScalar freqX = buffer.readScalar();
SkScalar freqY = buffer.readScalar();
switch (type) {
case kFractalNoise_Type:
- return SkPerlinNoiseShader2::MakeFractalNoise(freqX, freqY, octaves, seed,
- &tileSize).release();
+ return SkPerlinNoiseShader2::MakeFractalNoise(freqX, freqY, octaves, seed, &tileSize);
case kTurbulence_Type:
- return SkPerlinNoiseShader2::MakeTubulence(freqX, freqY, octaves, seed,
- &tileSize).release();
+ return SkPerlinNoiseShader2::MakeTubulence(freqX, freqY, octaves, seed, &tileSize);
case kImprovedNoise_Type:
- return SkPerlinNoiseShader2::MakeImprovedNoise(freqX, freqY, octaves, seed).release();
+ return SkPerlinNoiseShader2::MakeImprovedNoise(freqX, freqY, octaves, seed);
default:
return nullptr;
}
const SkMatrix fDeviceMatrix;
};
-SkFlattenable* DCShader::CreateProc(SkReadBuffer& buf) {
+sk_sp<SkFlattenable> DCShader::CreateProc(SkReadBuffer& buf) {
SkMatrix matrix;
buf.readMatrix(&matrix);
- return new DCShader(matrix);
+ return sk_make_sp<DCShader>(matrix);
}
class DCFP : public GrFragmentProcessor {
static FailImageFilter::Registrar gReg0;
-SkFlattenable* FailImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> FailImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
- return FailImageFilter::Create();
+ return sk_sp<SkFlattenable>(FailImageFilter::Create());
}
#ifndef SK_IGNORE_TO_STRING
static IdentityImageFilter::Registrar gReg1;
-SkFlattenable* IdentityImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> IdentityImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
- return IdentityImageFilter::Create(common.getInput(0).get());
+ return sk_sp<SkFlattenable>(IdentityImageFilter::Create(common.getInput(0).get()));
}
#ifndef SK_IGNORE_TO_STRING
static SimpleOffsetFilter::Registrar gReg;
-SkFlattenable* SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkScalar dx = buffer.readScalar();
SkScalar dy = buffer.readScalar();
- return Create(dx, dy, common.getInput(0).get());
+ return sk_sp<SkFlattenable>(Create(dx, dy, common.getInput(0).get()));
}
#ifndef SK_IGNORE_TO_STRING
#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
private: \
- static SkFlattenable* CreateProc(SkReadBuffer&); \
+ static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
friend class SkFlattenable::PrivateInitializer; \
public: \
Factory getFactory() const override { return CreateProc; }
kSkXfermode_Type,
};
- typedef SkFlattenable* (*Factory)(SkReadBuffer&);
+ typedef sk_sp<SkFlattenable> (*Factory)(SkReadBuffer&);
SkFlattenable() {}
SK_TO_STRING_OVERRIDE()
Factory getFactory() const override { return CreateProc; }
- static SkFlattenable* CreateProc(SkReadBuffer& buffer);
+ static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer);
protected:
SkLayerDrawLooper();
typedef Sk2DPathEffect INHERITED;
};
-SkFlattenable* Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) {
SkMatrix matrix;
buffer.readMatrix(&matrix);
- return new Dot2DPathEffect(buffer.readScalar(), matrix, nullptr);
+ return sk_make_sp<Dot2DPathEffect>(buffer.readScalar(), matrix, nullptr);
}
class InverseFillPE : public SkPathEffect {
typedef SkPathEffect INHERITED;
};
-SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) { return new InverseFillPE; }
+sk_sp<SkFlattenable> InverseFillPE::CreateProc(SkReadBuffer& buffer) {
+ return sk_make_sp<InverseFillPE>();
+}
static sk_sp<SkPathEffect> makepe(float interp, SkTDArray<SkPoint>* pts) {
SkMatrix lattice;
return true;
}
-SkFlattenable* SkBitmapProcShader::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkBitmapProcShader::CreateProc(SkReadBuffer& buffer) {
SkMatrix lm;
buffer.readMatrix(&lm);
SkBitmap bm;
bm.setImmutable();
TileMode mx = (TileMode)buffer.readUInt();
TileMode my = (TileMode)buffer.readUInt();
- return SkShader::MakeBitmapShader(bm, mx, my, &lm).release();
+ return SkShader::MakeBitmapShader(bm, mx, my, &lm);
}
void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const {
typedef SkShader INHERITED;
};
-SkFlattenable* Sk3DShader::CreateProc(SkReadBuffer& buffer) {
- return new Sk3DShader(buffer.readShader());
+sk_sp<SkFlattenable> Sk3DShader::CreateProc(SkReadBuffer& buffer) {
+ return sk_make_sp<Sk3DShader>(buffer.readShader());
}
class Sk3DBlitter : public SkBlitter {
fProxy->blitH(x, y, width);
}
- virtual void blitAntiH(int x, int y, const SkAlpha antialias[],
- const int16_t runs[]) override {
+ void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override {
fProxy->blitAntiH(x, y, antialias, runs);
}
typedef SkColorFilter INHERITED;
};
-SkFlattenable* SkComposeColorFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkComposeColorFilter::CreateProc(SkReadBuffer& buffer) {
sk_sp<SkColorFilter> outer(buffer.readColorFilter());
sk_sp<SkColorFilter> inner(buffer.readColorFilter());
- return MakeComposeFilter(std::move(outer), std::move(inner)).release();
+ return MakeComposeFilter(std::move(outer), std::move(inner));
}
///////////////////////////////////////////////////////////////////////////////////////////////////
SkASSERT(fFilter);
}
-SkFlattenable* SkColorFilterShader::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkColorFilterShader::CreateProc(SkReadBuffer& buffer) {
auto shader = buffer.readShader();
auto filter = buffer.readColorFilter();
if (!shader || !filter) {
return nullptr;
}
- return new SkColorFilterShader(shader, filter);
+ return sk_make_sp<SkColorFilterShader>(shader, filter);
}
void SkColorFilterShader::flatten(SkWriteBuffer& buffer) const {
buffer.writeScalarArray(fMatrix, 20);
}
-SkFlattenable* SkColorMatrixFilterRowMajor255::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkColorMatrixFilterRowMajor255::CreateProc(SkReadBuffer& buffer) {
SkScalar matrix[20];
if (buffer.readScalarArray(matrix, 20)) {
- return new SkColorMatrixFilterRowMajor255(matrix);
+ return sk_make_sp<SkColorMatrixFilterRowMajor255>(matrix);
}
return nullptr;
}
};
#define SkAutoAlphaRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoAlphaRestore)
-SkFlattenable* SkComposeShader::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkComposeShader::CreateProc(SkReadBuffer& buffer) {
sk_sp<SkShader> shaderA(buffer.readShader());
sk_sp<SkShader> shaderB(buffer.readShader());
sk_sp<SkXfermode> mode(buffer.readXfermode());
if (!shaderA || !shaderB) {
return nullptr;
}
- return new SkComposeShader(std::move(shaderA), std::move(shaderB), std::move(mode));
+ return sk_make_sp<SkComposeShader>(std::move(shaderA), std::move(shaderB), std::move(mode));
}
void SkComposeShader::flatten(SkWriteBuffer& buffer) const {
}
#endif
-SkFlattenable* SkLightingShaderImpl::CreateProc(SkReadBuffer& buf) {
+sk_sp<SkFlattenable> SkLightingShaderImpl::CreateProc(SkReadBuffer& buf) {
SkMatrix diffLocalM;
bool hasDiffLocalM = buf.readBool();
if (hasDiffLocalM) {
SkAutoTUnref<const SkLightingShader::Lights> lights(builder.finish());
- return new SkLightingShaderImpl(diffuse, normal, lights, SkVector::Make(1.0f, 0.0f),
- &diffLocalM, &normLocalM);
+ return sk_make_sp<SkLightingShaderImpl>(diffuse, normal, lights, SkVector::Make(1.0f, 0.0f),
+ &diffLocalM, &normLocalM);
}
void SkLightingShaderImpl::flatten(SkWriteBuffer& buf) const {
, fLocalM(localM) {
}
-SkFlattenable* SkLocalMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkLocalMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkMatrix lm;
buffer.readMatrix(&lm);
- return SkLocalMatrixImageFilter::Make(lm, common.getInput(0)).release();
+ return SkLocalMatrixImageFilter::Make(lm, common.getInput(0));
}
void SkLocalMatrixImageFilter::flatten(SkWriteBuffer& buffer) const {
#include "SkLocalMatrixShader.h"
-SkFlattenable* SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) {
SkMatrix lm;
buffer.readMatrix(&lm);
auto baseShader(buffer.readShader());
if (!baseShader) {
return nullptr;
}
- return baseShader->makeWithLocalMatrix(lm).release();
+ return baseShader->makeWithLocalMatrix(lm);
}
void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const {
return new SkMatrixImageFilter(transform, filterQuality, input);
}
-SkFlattenable* SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkMatrix matrix;
buffer.readMatrix(&matrix);
SkFilterQuality quality = static_cast<SkFilterQuality>(buffer.readInt());
- return Create(matrix, quality, common.getInput(0).get());
+ return sk_sp<SkImageFilter>(Create(matrix, quality, common.getInput(0).get()));
}
void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const {
fProc = SkXfermode::GetProc(fMode);
}
-SkFlattenable* SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
SkColor color = buffer.readColor();
SkXfermode::Mode mode = (SkXfermode::Mode)buffer.readUInt();
- return SkColorFilter::MakeModeFilter(color, mode).release();
+ return SkColorFilter::MakeModeFilter(color, mode);
}
///////////////////////////////////////////////////////////////////////////////
this->setPathEffect(buffer.readPathEffect());
this->setShader(buffer.readShader());
this->setXfermode(buffer.readXfermode());
- SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter()));
+ this->setMaskFilter(buffer.readMaskFilter());
this->setColorFilter(buffer.readColorFilter());
this->setRasterizer(buffer.readRasterizer());
this->setLooper(buffer.readDrawLooper());
- SkSafeUnref(this->setImageFilter(buffer.readImageFilter()));
+ this->setImageFilter(buffer.readImageFilter());
if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version)) {
// We used to store annotations here (string+skdata) if this bool was true
///////////////////////////////////////////////////////////////////////////////
-SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
- return SkComposePathEffect::Make(std::move(pe0), std::move(pe1)).release();
+ return SkComposePathEffect::Make(std::move(pe0), std::move(pe1));
}
bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
///////////////////////////////////////////////////////////////////////////////
-SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
- return SkSumPathEffect::Make(pe0, pe1).release();
+ return SkSumPathEffect::Make(pe0, pe1);
}
bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
return sk_sp<SkShader>(new SkPictureShader(std::move(picture), tmx, tmy, localMatrix, tile));
}
-SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkPictureShader::CreateProc(SkReadBuffer& buffer) {
SkMatrix lm;
buffer.readMatrix(&lm);
TileMode mx = (TileMode)buffer.read32();
picture = SkPicture::MakeFromBuffer(buffer);
}
}
- return SkPictureShader::Make(picture, mx, my, &lm, &tile).release();
+ return SkPictureShader::Make(picture, mx, my, &lm, &tile);
}
void SkPictureShader::flatten(SkWriteBuffer& buffer) const {
// if we get here, factory may still be null, but if that is the case, the
// failure was ours, not the writer.
- SkFlattenable* obj = nullptr;
+ sk_sp<SkFlattenable> obj;
uint32_t sizeRecorded = fReader.readU32();
if (factory) {
size_t offset = fReader.offset();
// we must skip the remaining data
fReader.skip(sizeRecorded);
}
- return obj;
+ return obj.release();
}
/**
void readPaint(SkPaint* paint) { paint->unflatten(*this); }
virtual SkFlattenable* readFlattenable(SkFlattenable::Type);
- template <typename T> T* readFlattenable() {
- return (T*) this->readFlattenable(T::GetFlattenableType());
- }
- sk_sp<SkColorFilter> readColorFilter() {
- return sk_sp<SkColorFilter>(this->readFlattenable<SkColorFilter>());
- }
- sk_sp<SkDrawLooper> readDrawLooper() {
- return sk_sp<SkDrawLooper>(this->readFlattenable<SkDrawLooper>());
- }
- SkImageFilter* readImageFilter() { return this->readFlattenable<SkImageFilter>(); }
- SkMaskFilter* readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); }
- sk_sp<SkPathEffect> readPathEffect() {
- return sk_sp<SkPathEffect>(this->readFlattenable<SkPathEffect>());
- }
- sk_sp<SkRasterizer> readRasterizer() {
- return sk_sp<SkRasterizer>(this->readFlattenable<SkRasterizer>());
- }
- sk_sp<SkShader> readShader() { return sk_sp<SkShader>(this->readFlattenable<SkShader>()); }
- sk_sp<SkXfermode> readXfermode() {
- return sk_sp<SkXfermode>(this->readFlattenable<SkXfermode>());
+ template <typename T> sk_sp<T> readFlattenable() {
+ return sk_sp<T>((T*)this->readFlattenable(T::GetFlattenableType()));
}
+ sk_sp<SkColorFilter> readColorFilter() { return this->readFlattenable<SkColorFilter>(); }
+ sk_sp<SkDrawLooper> readDrawLooper() { return this->readFlattenable<SkDrawLooper>(); }
+ sk_sp<SkImageFilter> readImageFilter() { return this->readFlattenable<SkImageFilter>(); }
+ sk_sp<SkMaskFilter> readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); }
+ sk_sp<SkPathEffect> readPathEffect() { return this->readFlattenable<SkPathEffect>(); }
+ sk_sp<SkRasterizer> readRasterizer() { return this->readFlattenable<SkRasterizer>(); }
+ sk_sp<SkShader> readShader() { return this->readFlattenable<SkShader>(); }
+ sk_sp<SkXfermode> readXfermode() { return this->readFlattenable<SkXfermode>(); }
/**
* Like readFlattenable() but explicitly just skips the data that was written for the
return SkColorGetA(fColor) == 255;
}
-SkFlattenable* SkColorShader::CreateProc(SkReadBuffer& buffer) {
- return new SkColorShader(buffer.readColor());
+sk_sp<SkFlattenable> SkColorShader::CreateProc(SkReadBuffer& buffer) {
+ return sk_make_sp<SkColorShader>(buffer.readColor());
}
void SkColorShader::flatten(SkWriteBuffer& buffer) const {
///////////////////////////////////////////////////////////////////////////////
-SkFlattenable* SkEmptyShader::CreateProc(SkReadBuffer&) {
- return SkShader::MakeEmptyShader().release();
+sk_sp<SkFlattenable> SkEmptyShader::CreateProc(SkReadBuffer&) {
+ return SkShader::MakeEmptyShader();
}
#ifndef SK_IGNORE_TO_STRING
// if we get here, factory may still be null, but if that is the case, the
// failure was ours, not the writer.
- SkFlattenable* obj = nullptr;
+ sk_sp<SkFlattenable> obj;
uint32_t sizeRecorded = this->readUInt();
if (factory) {
size_t offset = fReader.offset();
size_t sizeRead = fReader.offset() - offset;
this->validate(sizeRecorded == sizeRead);
if (fError) {
- // we could try to fix up the offset...
- SkSafeUnref(obj);
obj = nullptr;
}
} else {
this->skip(sizeRecorded);
SkASSERT(false);
}
- return obj;
+ return obj.release();
}
void SkValidatingReadBuffer::skipFlattenable() {
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-SkFlattenable* SkProcCoeffXfermode::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkProcCoeffXfermode::CreateProc(SkReadBuffer& buffer) {
uint32_t mode32 = buffer.read32();
if (!buffer.validate(mode32 < SK_ARRAY_COUNT(gProcCoeffs))) {
return nullptr;
}
- return SkXfermode::Make((SkXfermode::Mode)mode32).release();
+ return SkXfermode::Make((SkXfermode::Mode)mode32);
}
void SkProcCoeffXfermode::flatten(SkWriteBuffer& buffer) const {
return fInitialOffset;
}
-SkFlattenable* SkPath1DPathEffect::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkPath1DPathEffect::CreateProc(SkReadBuffer& buffer) {
SkScalar advance = buffer.readScalar();
if (advance > 0) {
SkPath path;
buffer.readPath(&path);
SkScalar phase = buffer.readScalar();
Style style = (Style)buffer.readUInt();
- return SkPath1DPathEffect::Make(path, advance, phase, style).release();
+ return SkPath1DPathEffect::Make(path, advance, phase, style);
}
return nullptr;
}
}
}
-SkFlattenable* SkLine2DPathEffect::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkLine2DPathEffect::CreateProc(SkReadBuffer& buffer) {
SkMatrix matrix;
buffer.readMatrix(&matrix);
SkScalar width = buffer.readScalar();
- return SkLine2DPathEffect::Make(width, matrix).release();
+ return SkLine2DPathEffect::Make(width, matrix);
}
void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const {
: INHERITED(m), fPath(p) {
}
-SkFlattenable* SkPath2DPathEffect::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkPath2DPathEffect::CreateProc(SkReadBuffer& buffer) {
SkMatrix matrix;
buffer.readMatrix(&matrix);
SkPath path;
buffer.readPath(&path);
- return SkPath2DPathEffect::Make(matrix, path).release();
+ return SkPath2DPathEffect::Make(matrix, path);
}
void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const {
#endif
-SkFlattenable* SkAlphaThresholdFilterImpl::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkAlphaThresholdFilterImpl::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkScalar inner = buffer.readScalar();
SkScalar outer = buffer.readScalar();
SkRegion rgn;
buffer.readRegion(&rgn);
- return SkAlphaThresholdFilter::Make(rgn, inner, outer, common.getInput(0)).release();
+ return SkAlphaThresholdFilter::Make(rgn, inner, outer, common.getInput(0));
}
SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region,
return true;
}
-SkFlattenable* SkArcToPathEffect::CreateProc(SkReadBuffer& buffer) {
- return SkArcToPathEffect::Make(buffer.readScalar()).release();
+sk_sp<SkFlattenable> SkArcToPathEffect::CreateProc(SkReadBuffer& buffer) {
+ return SkArcToPathEffect::Make(buffer.readScalar());
}
void SkArcToPathEffect::flatten(SkWriteBuffer& buffer) const {
typedef SkXfermode INHERITED;
};
-SkFlattenable* SkArithmeticMode_scalar::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkArithmeticMode_scalar::CreateProc(SkReadBuffer& buffer) {
const SkScalar k1 = buffer.readScalar();
const SkScalar k2 = buffer.readScalar();
const SkScalar k3 = buffer.readScalar();
const SkScalar k4 = buffer.readScalar();
const bool enforcePMColor = buffer.readBool();
- return SkArithmeticMode::Make(k1, k2, k3, k4, enforcePMColor).release();
+ return SkArithmeticMode::Make(k1, k2, k3, k4, enforcePMColor);
}
static int pinToByte(int value) {
fMode = mode;
}
-SkFlattenable* SkAvoidXfermode::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkAvoidXfermode::CreateProc(SkReadBuffer& buffer) {
const SkColor color = buffer.readColor();
const unsigned tolerance = buffer.readUInt();
const unsigned mode = buffer.readUInt();
- return Make(color, tolerance, (Mode)mode).release();
+ return Make(color, tolerance, (Mode)mode);
}
void SkAvoidXfermode::flatten(SkWriteBuffer& buffer) const {
this->initEffects();
}
-SkFlattenable* SkBlurDrawLooper::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkBlurDrawLooper::CreateProc(SkReadBuffer& buffer) {
const SkColor color = buffer.readColor();
const SkScalar sigma = buffer.readScalar();
const SkScalar dx = buffer.readScalar();
const SkScalar dy = buffer.readScalar();
const uint32_t flags = buffer.read32();
- return Make(color, sigma, dx, dy, flags).release();
+ return Make(color, sigma, dx, dy, flags);
}
void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const {
: INHERITED(1, &input, cropRect), fSigma(SkSize::Make(sigmaX, sigmaY)) {
}
-SkFlattenable* SkBlurImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkBlurImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkScalar sigmaX = buffer.readScalar();
SkScalar sigmaY = buffer.readScalar();
- return Create(sigmaX, sigmaY, common.getInput(0).get(), &common.cropRect());
+ return sk_sp<SkFlattenable>(Create(sigmaX, sigmaY, common.getInput(0).get(),
+ &common.cropRect()));
}
void SkBlurImageFilter::flatten(SkWriteBuffer& buffer) const {
src.fRight + pad, src.fBottom + pad);
}
-SkFlattenable* SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
const SkScalar sigma = buffer.readScalar();
const unsigned style = buffer.readUInt();
const unsigned flags = buffer.readUInt();
if (style <= kLastEnum_SkBlurStyle) {
- return SkBlurMaskFilter::Create((SkBlurStyle)style, sigma, flags);
+ return sk_sp<SkFlattenable>(SkBlurMaskFilter::Create((SkBlurStyle)style, sigma, flags));
}
return nullptr;
}
(const SkColor*)fCubeData->data());
}
-SkFlattenable* SkColorCubeFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkColorCubeFilter::CreateProc(SkReadBuffer& buffer) {
int cubeDimension = buffer.readInt();
auto cubeData(buffer.readByteArrayAsData());
if (!buffer.validate(is_valid_3D_lut(cubeData.get(), cubeDimension))) {
return nullptr;
}
- return Make(std::move(cubeData), cubeDimension).release();
+ return Make(std::move(cubeData), cubeDimension);
}
void SkColorCubeFilter::flatten(SkWriteBuffer& buffer) const {
, fColorFilter(SkRef(cf)) {
}
-SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
sk_sp<SkColorFilter> cf(buffer.readColorFilter());
- return Create(cf.get(), common.getInput(0).get(), &common.cropRect());
+ return sk_sp<SkFlattenable>(Create(cf.get(), common.getInput(0).get(), &common.cropRect()));
}
void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const {
return outer->filterBounds(inner->filterBounds(src, ctm, direction), ctm, direction);
}
-SkFlattenable* SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2);
- return SkComposeImageFilter::Make(common.getInput(0), common.getInput(1)).release();
+ return SkComposeImageFilter::Make(common.getInput(0), common.getInput(1));
}
#ifndef SK_IGNORE_TO_STRING
return true;
}
-SkFlattenable* SkCornerPathEffect::CreateProc(SkReadBuffer& buffer) {
- return SkCornerPathEffect::Make(buffer.readScalar()).release();
+sk_sp<SkFlattenable> SkCornerPathEffect::CreateProc(SkReadBuffer& buffer) {
+ return SkCornerPathEffect::Make(buffer.readScalar());
}
void SkCornerPathEffect::flatten(SkWriteBuffer& buffer) const {
buffer.writeScalarArray(fIntervals, fCount);
}
-SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkDashPathEffect::CreateProc(SkReadBuffer& buffer) {
const SkScalar phase = buffer.readScalar();
uint32_t count = buffer.getArrayCount();
SkAutoSTArray<32, SkScalar> intervals(count);
if (buffer.readScalarArray(intervals.get(), count)) {
- return Make(intervals.get(), SkToInt(count), phase).release();
+ return Make(intervals.get(), SkToInt(count), phase);
}
return nullptr;
}
return true;
}
-SkFlattenable* SkDiscretePathEffect::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkDiscretePathEffect::CreateProc(SkReadBuffer& buffer) {
SkScalar segLength = buffer.readScalar();
SkScalar perterb = buffer.readScalar();
uint32_t seed = buffer.readUInt();
- return Make(segLength, perterb, seed).release();
+ return Make(segLength, perterb, seed);
}
void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const {
SkDisplacementMapEffect::~SkDisplacementMapEffect() {
}
-SkFlattenable* SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2);
ChannelSelectorType xsel = (ChannelSelectorType)buffer.readInt();
ChannelSelectorType ysel = (ChannelSelectorType)buffer.readInt();
SkScalar scale = buffer.readScalar();
- return Create(xsel, ysel, scale,
- common.getInput(0).get(), common.getInput(1).get(), &common.cropRect());
+ return sk_sp<SkFlattenable>(Create(xsel, ysel, scale, common.getInput(0).get(),
+ common.getInput(1).get(), &common.cropRect()));
}
void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const {
, fShadowMode(shadowMode) {
}
-SkFlattenable* SkDropShadowImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkDropShadowImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkScalar dx = buffer.readScalar();
SkScalar dy = buffer.readScalar();
ShadowMode shadowMode = buffer.isVersionLT(SkReadBuffer::kDropShadowMode_Version) ?
kDrawShadowAndForeground_ShadowMode :
static_cast<ShadowMode>(buffer.readInt());
- return Create(dx, dy, sigmaX, sigmaY, color, shadowMode, common.getInput(0).get(),
- &common.cropRect());
+ return sk_sp<SkFlattenable>(Create(dx, dy, sigmaX, sigmaY, color, shadowMode,
+ common.getInput(0).get(), &common.cropRect()));
}
void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const {
return true;
}
-SkFlattenable* SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) {
Light light;
if (buffer.readByteArray(&light, sizeof(Light))) {
light.fPad = 0; // for the font-cache lookup to be clean
const SkScalar sigma = buffer.readScalar();
- return Create(sigma, light);
+ return sk_sp<SkFlattenable>(Create(sigma, light));
}
return nullptr;
}
, fFilterQuality(filterQuality) {
}
-SkFlattenable* SkImageSource::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkImageSource::CreateProc(SkReadBuffer& buffer) {
SkFilterQuality filterQuality = (SkFilterQuality)buffer.readInt();
SkRect src, dst;
return nullptr;
}
- return SkImageSource::Make(std::move(image), src, dst, filterQuality).release();
+ return SkImageSource::Make(std::move(image), src, dst, filterQuality);
}
void SkImageSource::flatten(SkWriteBuffer& buffer) const {
}
}
-SkFlattenable* SkLayerDrawLooper::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkLayerDrawLooper::CreateProc(SkReadBuffer& buffer) {
int count = buffer.readInt();
Builder builder;
info.fPostTranslate = buffer.readBool();
buffer.readPaint(builder.addLayerOnTop(info));
}
- return builder.detach().release();
+ return builder.detach();
}
#ifndef SK_IGNORE_TO_STRING
return true;
}
-SkFlattenable* SkLayerRasterizer::CreateProc(SkReadBuffer& buffer) {
- return new SkLayerRasterizer(ReadLayers(buffer));
+sk_sp<SkFlattenable> SkLayerRasterizer::CreateProc(SkReadBuffer& buffer) {
+ return sk_sp<SkFlattenable>(new SkLayerRasterizer(ReadLayers(buffer)));
}
SkDeque* SkLayerRasterizer::ReadLayers(SkReadBuffer& buffer) {
{
}
-SkFlattenable* SkDiffuseLightingImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkDiffuseLightingImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkAutoTUnref<SkImageFilterLight> light(SkImageFilterLight::UnflattenLight(buffer));
SkScalar surfaceScale = buffer.readScalar();
SkScalar kd = buffer.readScalar();
- return Create(light, surfaceScale, kd, common.getInput(0).get(), &common.cropRect());
+ return sk_sp<SkFlattenable>(Create(light, surfaceScale, kd, common.getInput(0).get(),
+ &common.cropRect()));
}
void SkDiffuseLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
{
}
-SkFlattenable* SkSpecularLightingImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkSpecularLightingImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkAutoTUnref<SkImageFilterLight> light(SkImageFilterLight::UnflattenLight(buffer));
SkScalar surfaceScale = buffer.readScalar();
SkScalar ks = buffer.readScalar();
SkScalar shine = buffer.readScalar();
- return Create(light, surfaceScale, ks, shine, common.getInput(0).get(), &common.cropRect());
+ return sk_sp<SkFlattenable>(Create(light, surfaceScale, ks, shine, common.getInput(0).get(),
+ &common.cropRect()));
}
void SkSpecularLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
SkLumaColorFilter::SkLumaColorFilter() : INHERITED() {}
-SkFlattenable* SkLumaColorFilter::CreateProc(SkReadBuffer&) { return new SkLumaColorFilter; }
+sk_sp<SkFlattenable> SkLumaColorFilter::CreateProc(SkReadBuffer&) {
+ return Make();
+}
void SkLumaColorFilter::flatten(SkWriteBuffer&) const {}
}
#endif
-SkFlattenable* SkMagnifierImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkMagnifierImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkRect src;
buffer.readRect(&src);
- return Create(src, buffer.readScalar(), common.getInput(0).get());
+ return sk_sp<SkFlattenable>(Create(src, buffer.readScalar(), common.getInput(0).get()));
}
void SkMagnifierImageFilter::flatten(SkWriteBuffer& buffer) const {
tileMode, convolveAlpha, input, cropRect);
}
-SkFlattenable* SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkISize kernelSize;
kernelSize.fWidth = buffer.readInt();
kernelOffset.fY = buffer.readInt();
TileMode tileMode = (TileMode)buffer.readInt();
bool convolveAlpha = buffer.readBool();
- return Create(kernelSize, kernel.get(), gain, bias, kernelOffset, tileMode, convolveAlpha,
- common.getInput(0).get(), &common.cropRect());
+ return sk_sp<SkFlattenable>(Create(kernelSize, kernel.get(), gain, bias, kernelOffset, tileMode,
+ convolveAlpha, common.getInput(0).get(), &common.cropRect()));
}
void SkMatrixConvolutionImageFilter::flatten(SkWriteBuffer& buffer) const {
return surf->makeImageSnapshot();
}
-SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) {
Common common;
if (!common.unflatten(buffer, -1)) {
return nullptr;
if (!buffer.isValid()) {
return nullptr;
}
- return Make(common.inputs(), count, modes.get(), &common.cropRect()).release();
+ return Make(common.inputs(), count, modes.get(), &common.cropRect());
}
- return Make(common.inputs(), count, nullptr, &common.cropRect()).release();
+ return Make(common.inputs(), count, nullptr, &common.cropRect());
}
void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const {
return src.makeOutset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y()));
}
-SkFlattenable* SkErodeImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkErodeImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
const int width = buffer.readInt();
const int height = buffer.readInt();
- return Create(width, height, common.getInput(0).get(), &common.cropRect());
+ return sk_sp<SkFlattenable>(Create(width, height, common.getInput(0).get(),
+ &common.cropRect()));
}
-SkFlattenable* SkDilateImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkDilateImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
const int width = buffer.readInt();
const int height = buffer.readInt();
- return Create(width, height, common.getInput(0).get(), &common.cropRect());
+ return sk_sp<SkFlattenable>(Create(width, height, common.getInput(0).get(),
+ &common.cropRect()));
}
#ifndef SK_IGNORE_TO_STRING
return src.makeOffset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY));
}
-SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkPoint offset;
buffer.readPoint(&offset);
- return Make(offset.x(), offset.y(), common.getInput(0), &common.cropRect()).release();
+ return Make(offset.x(), offset.y(), common.getInput(0), &common.cropRect());
}
void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const {
, fPaint(paint) {
}
-SkFlattenable* SkPaintImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkPaintImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
SkPaint paint;
buffer.readPaint(&paint);
- return SkPaintImageFilter::Make(paint, &common.cropRect()).release();
+ return SkPaintImageFilter::Make(paint, &common.cropRect());
}
void SkPaintImageFilter::flatten(SkWriteBuffer& buffer) const {
SkPerlinNoiseShader::~SkPerlinNoiseShader() {
}
-SkFlattenable* SkPerlinNoiseShader::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkPerlinNoiseShader::CreateProc(SkReadBuffer& buffer) {
Type type = (Type)buffer.readInt();
SkScalar freqX = buffer.readScalar();
SkScalar freqY = buffer.readScalar();
switch (type) {
case kFractalNoise_Type:
return SkPerlinNoiseShader::MakeFractalNoise(freqX, freqY, octaves, seed,
- &tileSize).release();
+ &tileSize);
case kTurbulence_Type:
return SkPerlinNoiseShader::MakeTurbulence(freqX, freqY, octaves, seed,
- &tileSize).release();
+ &tileSize);
default:
return nullptr;
}
, fFilterQuality(filterQuality) {
}
-SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
sk_sp<SkPicture> picture;
SkRect cropRect;
} else {
filterQuality = (SkFilterQuality)buffer.readInt();
}
- return MakeForLocalSpace(picture, cropRect, filterQuality).release();
+ return MakeForLocalSpace(picture, cropRect, filterQuality);
}
- return Make(picture, cropRect).release();
+ return Make(picture, cropRect);
}
void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
SkGetPackedB32(fOpColor)));
}
-SkFlattenable* SkPixelXorXfermode::CreateProc(SkReadBuffer& buffer) {
- return Make(buffer.readColor()).release();
+sk_sp<SkFlattenable> SkPixelXorXfermode::CreateProc(SkReadBuffer& buffer) {
+ return Make(buffer.readColor());
}
#ifndef SK_IGNORE_TO_STRING
buffer.writeByteArray(storage, size);
}
-SkFlattenable* SkTable_ColorFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkTable_ColorFilter::CreateProc(SkReadBuffer& buffer) {
const int flags = buffer.read32();
const size_t count = gCountNibBits[flags & 0xF];
SkASSERT(count <= 4);
b = ptr;
ptr += 256;
}
- return SkTableColorFilter::MakeARGB(a, r, g, b).release();
+ return SkTableColorFilter::MakeARGB(a, r, g, b);
}
bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const {
wb.writeByteArray(fTable, 256);
}
-SkFlattenable* SkTableMaskFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkTableMaskFilter::CreateProc(SkReadBuffer& buffer) {
uint8_t table[256];
if (!buffer.readByteArray(table, 256)) {
return nullptr;
}
- return Create(table);
+ return sk_sp<SkFlattenable>(Create(table));
}
///////////////////////////////////////////////////////////////////////////////
return true;
}
-SkFlattenable* SkDownSampleImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkDownSampleImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
- return Create(buffer.readScalar(), common.getInput(0).get());
+ return sk_sp<SkFlattenable>(Create(buffer.readScalar(), common.getInput(0).get()));
}
void SkDownSampleImageFilter::flatten(SkWriteBuffer& buffer) const {
return fDstRect;
}
-SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkTileImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkRect src, dst;
buffer.readRect(&src);
buffer.readRect(&dst);
- return Create(src, dst, common.getInput(0).get());
+ return sk_sp<SkFlattenable>(Create(src, dst, common.getInput(0).get()));
}
void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const {
, fMode(std::move(mode))
{}
-SkFlattenable* SkXfermodeImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkXfermodeImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2);
sk_sp<SkXfermode> mode(buffer.readXfermode());
- return Make(std::move(mode), common.getInput(0).get(),
- common.getInput(1).get(), &common.cropRect()).release();
+ return Make(std::move(mode), common.getInput(0).get(), common.getInput(1).get(),
+ &common.cropRect());
}
void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const {
, fEnd(pts[1]) {
}
-SkFlattenable* SkLinearGradient::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkLinearGradient::CreateProc(SkReadBuffer& buffer) {
DescriptorScope desc;
if (!desc.unflatten(buffer)) {
return nullptr;
pts[0] = buffer.readPoint();
pts[1] = buffer.readPoint();
return SkGradientShader::MakeLinear(pts, desc.fColors, desc.fPos, desc.fCount, desc.fTileMode,
- desc.fGradFlags, desc.fLocalMatrix).release();
+ desc.fGradFlags, desc.fLocalMatrix);
}
void SkLinearGradient::flatten(SkWriteBuffer& buffer) const {
return kRadial_GradientType;
}
-SkFlattenable* SkRadialGradient::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkRadialGradient::CreateProc(SkReadBuffer& buffer) {
DescriptorScope desc;
if (!desc.unflatten(buffer)) {
return nullptr;
const SkPoint center = buffer.readPoint();
const SkScalar radius = buffer.readScalar();
return SkGradientShader::MakeRadial(center, radius, desc.fColors, desc.fPos, desc.fCount,
- desc.fTileMode, desc.fGradFlags,
- desc.fLocalMatrix).release();
+ desc.fTileMode, desc.fGradFlags, desc.fLocalMatrix);
}
void SkRadialGradient::flatten(SkWriteBuffer& buffer) const {
return kSweep_GradientType;
}
-SkFlattenable* SkSweepGradient::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkSweepGradient::CreateProc(SkReadBuffer& buffer) {
DescriptorScope desc;
if (!desc.unflatten(buffer)) {
return nullptr;
}
const SkPoint center = buffer.readPoint();
return SkGradientShader::MakeSweep(center.x(), center.y(), desc.fColors, desc.fPos,
- desc.fCount, desc.fGradFlags, desc.fLocalMatrix).release();
+ desc.fCount, desc.fGradFlags, desc.fLocalMatrix);
}
void SkSweepGradient::flatten(SkWriteBuffer& buffer) const {
return kConical_GradientType;
}
-SkFlattenable* SkTwoPointConicalGradient::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkTwoPointConicalGradient::CreateProc(SkReadBuffer& buffer) {
DescriptorScope desc;
if (!desc.unflatten(buffer)) {
return nullptr;
return SkGradientShader::MakeTwoPointConical(c1, r1, c2, r2, desc.fColors, desc.fPos,
desc.fCount, desc.fTileMode, desc.fGradFlags,
- desc.fLocalMatrix).release();
+ desc.fLocalMatrix);
}
void SkTwoPointConicalGradient::flatten(SkWriteBuffer& buffer) const {
, fTileModeY(tmy)
{}
-SkFlattenable* SkImageShader::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkImageShader::CreateProc(SkReadBuffer& buffer) {
const TileMode tx = (TileMode)buffer.readUInt();
const TileMode ty = (TileMode)buffer.readUInt();
SkMatrix matrix;
if (!img) {
return nullptr;
}
- return SkImageShader::Make(img, tx, ty, &matrix).release();
+ return SkImageShader::Make(img, tx, ty, &matrix);
}
void SkImageShader::flatten(SkWriteBuffer& buffer) const {
#include "SkImageSource.h"
#include "SkReadBuffer.h"
-SkFlattenable* SkBitmapSourceDeserializer::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkBitmapSourceDeserializer::CreateProc(SkReadBuffer& buffer) {
SkFilterQuality filterQuality;
if (buffer.isVersionLT(SkReadBuffer::kBitmapSourceFilterQuality_Version)) {
filterQuality = kHigh_SkFilterQuality;
}
bitmap.setImmutable();
- return SkImageSource::Make(SkImage::MakeFromBitmap(bitmap), src, dst, filterQuality).release();
+ return SkImageSource::Make(SkImage::MakeFromBitmap(bitmap), src, dst, filterQuality);
}
}
-SkFlattenable* MatrixTestImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> MatrixTestImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
skiatest::Reporter* reporter = (skiatest::Reporter*)buffer.readFunctionPtr();
SkMatrix matrix;
buffer.readMatrix(&matrix);
- return new MatrixTestImageFilter(reporter, matrix);
+ return sk_make_sp<MatrixTestImageFilter>(reporter, matrix);
}
#ifndef SK_IGNORE_TO_STRING
int DummyRasterizer::gCount;
-SkFlattenable* DummyRasterizer::CreateProc(SkReadBuffer&) { return new DummyRasterizer; }
+sk_sp<SkFlattenable> DummyRasterizer::CreateProc(SkReadBuffer&) {
+ return sk_make_sp<DummyRasterizer>();
+}
// Check to make sure that the SkPaint in the layer has its destructor called.
DEF_TEST(LayerRasterizer_destructor, reporter) {
mutable bool fVisited;
};
-SkFlattenable* DummyImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> DummyImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
bool visited = buffer.readBool();
- return new DummyImageFilter(visited);
+ return sk_make_sp<DummyImageFilter>(visited);
}
#ifndef SK_IGNORE_TO_STRING
};
};
-SkFlattenable* TestLooper::CreateProc(SkReadBuffer&) { return new TestLooper; }
+sk_sp<SkFlattenable> TestLooper::CreateProc(SkReadBuffer&) { return sk_make_sp<TestLooper>(); }
static void test_drawBitmap(skiatest::Reporter* reporter) {
SkBitmap src;
const void* data;
int size = decode_data(jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA], urlDataManager, &data);
SkValidatingReadBuffer buffer(data, size);
- SkFlattenable* result = factory(buffer);
+ sk_sp<SkFlattenable> result = factory(buffer);
if (!buffer.isValid()) {
SkDebugf("invalid buffer loading flattenable\n");
return nullptr;
}
- return result;
+ return result.release();
}
static SkColorType colortype_from_name(const char* name) {
typedef SkXfermode INHERITED;
};
-SkFlattenable* SkOverdrawXfermode::CreateProc(SkReadBuffer& buffer) {
- return Create();
+sk_sp<SkFlattenable> SkOverdrawXfermode::CreateProc(SkReadBuffer& buffer) {
+ return sk_sp<SkFlattenable>(Create());
}
sk_sp<SkXfermode> SkOverdrawMode::Make() { return sk_make_sp<SkOverdrawXfermode>(); }