refFoo variant for getters that naturally have a sk_sp
BUG=skia: Change-Id: I13afa1b81e8a72d93e45fb4d37228be196b0f388 Reviewed-on: https://skia-review.googlesource.com/6923 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
a005acc036
commit
693fdbd6b8
@ -95,7 +95,7 @@ void ColorCodecBench::onDelayedSetup() {
|
||||
|
||||
if (FLAGS_xform_only) {
|
||||
fSrc.reset(fSrcInfo.getSafeSize(fSrcInfo.minRowBytes()));
|
||||
fSrcSpace = sk_ref_sp(codec->getInfo().colorSpace());
|
||||
fSrcSpace = codec->getInfo().refColorSpace();
|
||||
codec->getPixels(fSrcInfo, fSrc.get(), fSrcInfo.minRowBytes());
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ protected:
|
||||
for (int makeBlur = 0; makeBlur < 2; makeBlur++) {
|
||||
for (int makeGray = 0; makeGray < 2; makeGray++) {
|
||||
SkPaint shaderPaint;
|
||||
shaderPaint.setTypeface(sk_ref_sp(paint.getTypeface()));
|
||||
shaderPaint.setTypeface(paint.refTypeface());
|
||||
if (SkToBool(makeLinear)) {
|
||||
shaderPaint.setShader(MakeLinear());
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ protected:
|
||||
GrContext* ctx = inputCanvas->getGrContext();
|
||||
SkISize size = onISize();
|
||||
SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType,
|
||||
sk_ref_sp(inputCanvas->imageInfo().colorSpace()));
|
||||
inputCanvas->imageInfo().refColorSpace());
|
||||
SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
|
||||
SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props));
|
||||
|
@ -88,7 +88,7 @@ static sk_sp<SkSurface> make_color_matching_surface(SkCanvas* canvas, int width,
|
||||
SkAlphaType alphaType) {
|
||||
|
||||
SkColorType ct = canvas->imageInfo().colorType();
|
||||
sk_sp<SkColorSpace> cs(sk_ref_sp(canvas->imageInfo().colorSpace()));
|
||||
sk_sp<SkColorSpace> cs(canvas->imageInfo().refColorSpace());
|
||||
|
||||
if (kUnknown_SkColorType == ct) {
|
||||
// For backends that aren't yet color-space aware we just fallback to N32.
|
||||
|
@ -158,8 +158,7 @@ protected:
|
||||
p.getAlpha() != 255 ? &p : nullptr,
|
||||
SkImage::BitDepth::kU8, srgbColorSpace));
|
||||
|
||||
SkImageInfo bmInfo = gen->getInfo().makeColorSpace(
|
||||
sk_ref_sp(canvas->imageInfo().colorSpace()));
|
||||
SkImageInfo bmInfo = gen->getInfo().makeColorSpace(canvas->imageInfo().refColorSpace());
|
||||
|
||||
SkBitmap bm;
|
||||
SkAssertResult(gen->tryGenerateBitmap(&bm, bmInfo, nullptr));
|
||||
|
@ -39,11 +39,8 @@ static void install_detector_color_filter(SkPaint* drawPaint) {
|
||||
|
||||
// This detector detects that image filter phase of the pixel pipeline receives the correct value.
|
||||
static void install_detector_image_filter(SkPaint* drawPaint) {
|
||||
sk_sp<SkColorFilter> colorFilter(make_detector_color_filter());
|
||||
sk_sp<SkImageFilter> imageFilter(
|
||||
SkColorFilterImageFilter::Make(std::move(colorFilter),
|
||||
sk_ref_sp(drawPaint->getImageFilter())));
|
||||
drawPaint->setImageFilter(std::move(imageFilter));
|
||||
drawPaint->setImageFilter(SkColorFilterImageFilter::Make(make_detector_color_filter(),
|
||||
drawPaint->refImageFilter()));
|
||||
}
|
||||
|
||||
static void no_detector_install(SkPaint*) {
|
||||
|
@ -103,7 +103,7 @@ protected:
|
||||
// Create a new Canvas to enable DFT
|
||||
GrContext* ctx = inputCanvas->getGrContext();
|
||||
SkISize size = onISize();
|
||||
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(inputCanvas->imageInfo().colorSpace());
|
||||
sk_sp<SkColorSpace> colorSpace = inputCanvas->imageInfo().refColorSpace();
|
||||
SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(),
|
||||
kPremul_SkAlphaType, colorSpace);
|
||||
SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
|
||||
|
@ -99,7 +99,7 @@ protected:
|
||||
|
||||
SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, canvas->imageInfo().colorType(),
|
||||
kPremul_SkAlphaType,
|
||||
sk_ref_sp(canvas->imageInfo().colorSpace()));
|
||||
canvas->imageInfo().refColorSpace());
|
||||
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
|
||||
auto surface(canvas->makeSurface(info, &props));
|
||||
if (surface) {
|
||||
|
@ -126,7 +126,7 @@ private:
|
||||
GrContext* context = baseCanvas->getGrContext();
|
||||
SkImageInfo baseInfo = baseCanvas->imageInfo();
|
||||
SkImageInfo info = SkImageInfo::Make(w, h, baseInfo.colorType(), baseInfo.alphaType(),
|
||||
sk_ref_sp(baseInfo.colorSpace()));
|
||||
baseInfo.refColorSpace());
|
||||
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
baseCanvas->getProps(&canvasProps);
|
||||
return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, &canvasProps);
|
||||
|
@ -234,6 +234,7 @@ public:
|
||||
SkColorType colorType() const { return fColorType; }
|
||||
SkAlphaType alphaType() const { return fAlphaType; }
|
||||
SkColorSpace* colorSpace() const { return fColorSpace.get(); }
|
||||
sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
|
||||
|
||||
bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; }
|
||||
|
||||
|
@ -481,6 +481,7 @@ public:
|
||||
@return the paint's shader (or NULL)
|
||||
*/
|
||||
SkShader* getShader() const { return fShader.get(); }
|
||||
sk_sp<SkShader> refShader() const;
|
||||
|
||||
/** Set or clear the shader object.
|
||||
* Shaders specify the source color(s) for what is being drawn. If a paint
|
||||
@ -509,6 +510,7 @@ public:
|
||||
@return the paint's colorfilter (or NULL)
|
||||
*/
|
||||
SkColorFilter* getColorFilter() const { return fColorFilter.get(); }
|
||||
sk_sp<SkColorFilter> refColorFilter() const;
|
||||
|
||||
/** Set or clear the paint's colorfilter.
|
||||
<p />
|
||||
@ -528,6 +530,7 @@ public:
|
||||
@return the paint's patheffect (or NULL)
|
||||
*/
|
||||
SkPathEffect* getPathEffect() const { return fPathEffect.get(); }
|
||||
sk_sp<SkPathEffect> refPathEffect() const;
|
||||
|
||||
/** Set or clear the patheffect object.
|
||||
<p />
|
||||
@ -547,6 +550,7 @@ public:
|
||||
@return the paint's maskfilter (or NULL)
|
||||
*/
|
||||
SkMaskFilter* getMaskFilter() const { return fMaskFilter.get(); }
|
||||
sk_sp<SkMaskFilter> refMaskFilter() const;
|
||||
|
||||
/** Set or clear the maskfilter object.
|
||||
<p />
|
||||
@ -569,6 +573,7 @@ public:
|
||||
@return the paint's typeface (or NULL)
|
||||
*/
|
||||
SkTypeface* getTypeface() const { return fTypeface.get(); }
|
||||
sk_sp<SkTypeface> refTypeface() const;
|
||||
|
||||
/** Set or clear the typeface object.
|
||||
<p />
|
||||
@ -588,6 +593,7 @@ public:
|
||||
@return the paint's rasterizer (or NULL)
|
||||
*/
|
||||
SkRasterizer* getRasterizer() const { return fRasterizer.get(); }
|
||||
sk_sp<SkRasterizer> refRasterizer() const;
|
||||
|
||||
/** Set or clear the rasterizer object.
|
||||
<p />
|
||||
@ -603,6 +609,7 @@ public:
|
||||
void setRasterizer(sk_sp<SkRasterizer>);
|
||||
|
||||
SkImageFilter* getImageFilter() const { return fImageFilter.get(); }
|
||||
sk_sp<SkImageFilter> refImageFilter() const;
|
||||
void setImageFilter(sk_sp<SkImageFilter>);
|
||||
|
||||
/**
|
||||
@ -610,6 +617,8 @@ public:
|
||||
* reference count.
|
||||
*/
|
||||
SkDrawLooper* getDrawLooper() const { return fDrawLooper.get(); }
|
||||
sk_sp<SkDrawLooper> refDrawLooper() const;
|
||||
|
||||
SkDrawLooper* getLooper() const { return fDrawLooper.get(); }
|
||||
/**
|
||||
* Set or clear the looper object.
|
||||
|
@ -233,11 +233,11 @@ void SkDrawPaint::setupPaint(SkPaint* paint) const {
|
||||
if (pathEffect == nullptr)
|
||||
paint->setPathEffect(nullptr);
|
||||
else if (pathEffect != (SkDrawPathEffect*) -1)
|
||||
paint->setPathEffect(sk_ref_sp(pathEffect->getPathEffect()));
|
||||
paint->setPathEffect(pathEffect->refPathEffect());
|
||||
if (shader == nullptr)
|
||||
paint->setShader(nullptr);
|
||||
else if (shader != (SkDrawShader*) -1)
|
||||
paint->setShader(sk_ref_sp(shader->getShader()));
|
||||
paint->setShader(shader->refShader());
|
||||
if (strikeThru != -1)
|
||||
paint->setStrikeThruText(SkToBool(strikeThru));
|
||||
if (strokeCap != -1)
|
||||
|
@ -485,7 +485,7 @@ public:
|
||||
* draw onto the previous layer using the xfermode from the original paint.
|
||||
*/
|
||||
SkPaint tmp;
|
||||
tmp.setImageFilter(sk_ref_sp(fPaint->getImageFilter()));
|
||||
tmp.setImageFilter(fPaint->refImageFilter());
|
||||
tmp.setBlendMode(fPaint->getBlendMode());
|
||||
SkRect storage;
|
||||
if (rawBounds) {
|
||||
@ -1180,7 +1180,7 @@ static SkImageInfo make_layer_info(const SkImageInfo& prev, int w, int h, bool i
|
||||
return SkImageInfo::MakeN32(w, h, alphaType);
|
||||
} else {
|
||||
// keep the same characteristics as the prev
|
||||
return SkImageInfo::Make(w, h, prev.colorType(), alphaType, sk_ref_sp(prev.colorSpace()));
|
||||
return SkImageInfo::Make(w, h, prev.colorType(), alphaType, prev.refColorSpace());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1648,7 +1648,7 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
|
||||
|
||||
// Now restore the original settings, so we "draw" with whatever style/stroking.
|
||||
paint.setStyle(origPaint.getStyle());
|
||||
paint.setPathEffect(sk_ref_sp(origPaint.getPathEffect()));
|
||||
paint.setPathEffect(origPaint.refPathEffect());
|
||||
|
||||
while (text < stop) {
|
||||
const SkGlyph& glyph = glyphCacheProc(cache.get(), &text);
|
||||
|
@ -184,6 +184,17 @@ bool operator==(const SkPaint& a, const SkPaint& b) {
|
||||
#undef EQUAL
|
||||
}
|
||||
|
||||
#define DEFINE_REF_FOO(type) sk_sp<Sk##type> SkPaint::ref##type() const { return f##type; }
|
||||
DEFINE_REF_FOO(ColorFilter)
|
||||
DEFINE_REF_FOO(DrawLooper)
|
||||
DEFINE_REF_FOO(ImageFilter)
|
||||
DEFINE_REF_FOO(MaskFilter)
|
||||
DEFINE_REF_FOO(PathEffect)
|
||||
DEFINE_REF_FOO(Rasterizer)
|
||||
DEFINE_REF_FOO(Shader)
|
||||
DEFINE_REF_FOO(Typeface)
|
||||
#undef DEFINE_REF_FOO
|
||||
|
||||
void SkPaint::reset() {
|
||||
SkPaint init;
|
||||
*this = init;
|
||||
@ -2244,12 +2255,12 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
|
||||
sk_sp<SkPathEffect> pe;
|
||||
|
||||
if (!applyStrokeAndPathEffects) {
|
||||
style = paint.getStyle(); // restore
|
||||
pe = sk_ref_sp(paint.getPathEffect()); // restore
|
||||
style = paint.getStyle(); // restore
|
||||
pe = paint.refPathEffect(); // restore
|
||||
}
|
||||
fPaint.setStyle(style);
|
||||
fPaint.setPathEffect(pe);
|
||||
fPaint.setMaskFilter(sk_ref_sp(paint.getMaskFilter())); // restore
|
||||
fPaint.setMaskFilter(paint.refMaskFilter()); // restore
|
||||
|
||||
// now compute fXOffset if needed
|
||||
|
||||
|
@ -92,16 +92,16 @@ void SkLayerDrawLooper::LayerDrawLooperContext::ApplyInfo(
|
||||
}
|
||||
|
||||
if (bits & kPathEffect_Bit) {
|
||||
dst->setPathEffect(sk_ref_sp(src.getPathEffect()));
|
||||
dst->setPathEffect(src.refPathEffect());
|
||||
}
|
||||
if (bits & kMaskFilter_Bit) {
|
||||
dst->setMaskFilter(sk_ref_sp(src.getMaskFilter()));
|
||||
dst->setMaskFilter(src.refMaskFilter());
|
||||
}
|
||||
if (bits & kShader_Bit) {
|
||||
dst->setShader(sk_ref_sp(src.getShader()));
|
||||
dst->setShader(src.refShader());
|
||||
}
|
||||
if (bits & kColorFilter_Bit) {
|
||||
dst->setColorFilter(sk_ref_sp(src.getColorFilter()));
|
||||
dst->setColorFilter(src.refColorFilter());
|
||||
}
|
||||
if (bits & kXfermode_Bit) {
|
||||
dst->setBlendMode(src.getBlendMode());
|
||||
|
@ -524,7 +524,7 @@ void GrTextUtils::DrawPosTextAsPath(GrContext* context,
|
||||
|
||||
// Now restore the original settings, so we "draw" with whatever style/stroking.
|
||||
paint.setStyle(origPaint.getStyle());
|
||||
paint.setPathEffect(sk_ref_sp(origPaint.getPathEffect()));
|
||||
paint.setPathEffect(origPaint.refPathEffect());
|
||||
|
||||
while (text < stop) {
|
||||
const SkGlyph& glyph = glyphCacheProc(cache, &text);
|
||||
|
@ -535,8 +535,7 @@ void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) {
|
||||
|
||||
SkString familyName;
|
||||
SkTHashSet<SkString> familySet;
|
||||
sk_sp<const SkTypeface> tface(paint.getTypeface() ?
|
||||
sk_ref_sp(paint.getTypeface()) : SkTypeface::MakeDefault());
|
||||
sk_sp<SkTypeface> tface(paint.getTypeface() ? paint.refTypeface() : SkTypeface::MakeDefault());
|
||||
|
||||
SkASSERT(tface);
|
||||
SkTypeface::Style style = tface->style();
|
||||
|
@ -87,8 +87,8 @@ DEF_TEST(FontHostStream, reporter) {
|
||||
drawBG(&origCanvas);
|
||||
origCanvas.drawText("A", 1, point.fX, point.fY, paint);
|
||||
|
||||
sk_sp<SkTypeface> typeface(SkToBool(paint.getTypeface()) ? sk_ref_sp(paint.getTypeface())
|
||||
: SkTypeface::MakeDefault());
|
||||
sk_sp<SkTypeface> typeface(paint.getTypeface() ? paint.refTypeface()
|
||||
: SkTypeface::MakeDefault());
|
||||
int ttcIndex;
|
||||
std::unique_ptr<SkStreamAsset> fontData(typeface->openStream(&ttcIndex));
|
||||
sk_sp<SkTypeface> streamTypeface(SkTypeface::MakeFromStream(fontData.release()));
|
||||
|
Loading…
Reference in New Issue
Block a user