Enable ClangTidy check readability-redundant-smartptr-get.
To my surprise, this even works with homegrown smart pointers (such as SkTLazy). https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-smartptr-get.html Find and remove redundant calls to smart pointer’s .get() method. Examples: ptr.get()->Foo() ==> ptr->Foo() *ptr.get() ==> *ptr *ptr->get() ==> **ptr if (ptr.get() == nullptr) ... => if (ptr == nullptr) ... Change-Id: I8ff541e0229656b4d8e875c8053a7e6138302547 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310976 Auto-Submit: John Stiles <johnstiles@google.com> Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
c1c3c6d70d
commit
a008b0fa8b
@ -16,6 +16,7 @@ Checks: >
|
||||
performance-unnecessary-copy-initialization,
|
||||
readability-const-return-type,
|
||||
readability-redundant-preprocessor,
|
||||
readability-redundant-smartptr-get,
|
||||
readability-static-accessed-through-instance
|
||||
CheckOptions:
|
||||
- key: llvm-namespace-comment.SpacesBeforeComments
|
||||
|
@ -258,7 +258,7 @@ struct GPUTarget : public Target {
|
||||
SkBudgeted::kNo, info, this->config.samples, &props);
|
||||
this->contextInfo =
|
||||
this->factory->getContextInfo(this->config.ctxType, this->config.ctxOverrides);
|
||||
if (!this->surface.get()) {
|
||||
if (!this->surface) {
|
||||
return false;
|
||||
}
|
||||
if (!this->contextInfo.testContext()->fenceSyncSupport()) {
|
||||
@ -607,7 +607,7 @@ static Target* is_enabled(Benchmark* bench, const Config& config) {
|
||||
static bool valid_brd_bench(sk_sp<SkData> encoded, SkColorType colorType, uint32_t sampleSize,
|
||||
uint32_t minOutputSize, int* width, int* height) {
|
||||
auto brd = android::skia::BitmapRegionDecoder::Make(encoded);
|
||||
if (nullptr == brd.get()) {
|
||||
if (nullptr == brd) {
|
||||
// This is indicates that subset decoding is not supported for a particular image format.
|
||||
return false;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ struct Target {
|
||||
virtual void dumpStats() {}
|
||||
|
||||
SkCanvas* getCanvas() const {
|
||||
if (!surface.get()) {
|
||||
if (!surface) {
|
||||
return nullptr;
|
||||
}
|
||||
return surface->getCanvas();
|
||||
|
@ -683,7 +683,7 @@ static void push_codec_srcs(Path path) {
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(encoded);
|
||||
if (nullptr == codec.get()) {
|
||||
if (nullptr == codec) {
|
||||
info("Couldn't create codec for %s.", path.c_str());
|
||||
return;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ Result BRDSrc::draw(GrDirectContext*, SkCanvas* canvas) const {
|
||||
}
|
||||
|
||||
auto brd = create_brd(fPath);
|
||||
if (nullptr == brd.get()) {
|
||||
if (nullptr == brd) {
|
||||
return Result::Skip("Could not create brd for %s.", fPath.c_str());
|
||||
}
|
||||
|
||||
@ -423,7 +423,7 @@ Result CodecSrc::draw(GrDirectContext*, SkCanvas* canvas) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<SkCodec> codec(SkCodec::MakeFromData(encoded));
|
||||
if (nullptr == codec.get()) {
|
||||
if (nullptr == codec) {
|
||||
return Result::Fatal("Couldn't create codec for %s.", fPath.c_str());
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ struct MatchResult {
|
||||
return SkToBool(fNext);
|
||||
}
|
||||
|
||||
const V& operator* () const { return *fValue.get(); }
|
||||
const V& operator* () const { return *fValue; }
|
||||
const V* operator->() const { return fValue.get(); }
|
||||
|
||||
const char* fNext;
|
||||
|
@ -52,7 +52,7 @@ bool SkSVGNode::onPrepareToRender(SkSVGRenderContext* ctx) const {
|
||||
this->hasChildren() ? 0 : SkSVGRenderContext::kLeaf);
|
||||
|
||||
// visibility:hidden disables rendering
|
||||
const auto visibility = ctx->presentationContext().fInherited.fVisibility.get()->type();
|
||||
const auto visibility = ctx->presentationContext().fInherited.fVisibility->type();
|
||||
return visibility != SkSVGVisibility::Type::kHidden;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ void SkSVGPath::onDraw(SkCanvas* canvas, const SkSVGLengthContext&, const SkPain
|
||||
SkPath SkSVGPath::onAsPath(const SkSVGRenderContext& ctx) const {
|
||||
SkPath path = fPath;
|
||||
// clip-rule can be inherited and needs to be applied at clip time.
|
||||
path.setFillType(ctx.presentationContext().fInherited.fClipRule.get()->asFillType());
|
||||
path.setFillType(ctx.presentationContext().fInherited.fClipRule->asFillType());
|
||||
this->mapToParent(&path);
|
||||
return path;
|
||||
}
|
||||
|
@ -142,10 +142,10 @@ bool SkSVGPattern::onAsPaint(const SkSVGRenderContext& ctx, SkPaint* paint) cons
|
||||
const auto* contentNode = this->resolveHref(ctx, &attrs);
|
||||
|
||||
const auto tile = ctx.lengthContext().resolveRect(
|
||||
attrs.fX.isValid() ? *attrs.fX.get() : SkSVGLength(0),
|
||||
attrs.fY.isValid() ? *attrs.fY.get() : SkSVGLength(0),
|
||||
attrs.fWidth.isValid() ? *attrs.fWidth.get() : SkSVGLength(0),
|
||||
attrs.fHeight.isValid() ? *attrs.fHeight.get() : SkSVGLength(0));
|
||||
attrs.fX.isValid() ? *attrs.fX : SkSVGLength(0),
|
||||
attrs.fY.isValid() ? *attrs.fY : SkSVGLength(0),
|
||||
attrs.fWidth.isValid() ? *attrs.fWidth : SkSVGLength(0),
|
||||
attrs.fHeight.isValid() ? *attrs.fHeight : SkSVGLength(0));
|
||||
|
||||
if (tile.isEmpty()) {
|
||||
return false;
|
||||
|
@ -43,7 +43,7 @@ SkPath SkSVGPoly::onAsPath(const SkSVGRenderContext& ctx) const {
|
||||
SkPath path = fPath;
|
||||
|
||||
// clip-rule can be inherited and needs to be applied at clip time.
|
||||
path.setFillType(ctx.presentationContext().fInherited.fClipRule.get()->asFillType());
|
||||
path.setFillType(ctx.presentationContext().fInherited.fClipRule->asFillType());
|
||||
|
||||
this->mapToParent(&path);
|
||||
return path;
|
||||
|
@ -74,9 +74,9 @@ sk_sp<SkShader> SkSVGRadialGradient::onMakeShader(const SkSVGRenderContext& ctx,
|
||||
lctx.resolve(fCx, SkSVGLengthContext::LengthType::kHorizontal),
|
||||
lctx.resolve(fCy, SkSVGLengthContext::LengthType::kVertical));
|
||||
const auto focal = SkPoint::Make(
|
||||
fFx.isValid() ? lctx.resolve(*fFx.get(), SkSVGLengthContext::LengthType::kHorizontal)
|
||||
fFx.isValid() ? lctx.resolve(*fFx, SkSVGLengthContext::LengthType::kHorizontal)
|
||||
: center.x(),
|
||||
fFy.isValid() ? lctx.resolve(*fFy.get(), SkSVGLengthContext::LengthType::kVertical)
|
||||
fFy.isValid() ? lctx.resolve(*fFy, SkSVGLengthContext::LengthType::kVertical)
|
||||
: center.y());
|
||||
|
||||
return center == focal
|
||||
|
@ -139,7 +139,7 @@ template <>
|
||||
void commitToPaint<SkSVGAttribute::kFill>(const SkSVGPresentationAttributes& attrs,
|
||||
const SkSVGRenderContext& ctx,
|
||||
SkSVGPresentationContext* pctx) {
|
||||
const auto& fill = *attrs.fFill.get();
|
||||
const auto& fill = *attrs.fFill;
|
||||
SkASSERT(fill.type() != SkSVGPaint::Type::kInherit);
|
||||
|
||||
applySvgPaint(ctx, fill, &pctx->fFillPaint);
|
||||
@ -149,7 +149,7 @@ template <>
|
||||
void commitToPaint<SkSVGAttribute::kStroke>(const SkSVGPresentationAttributes& attrs,
|
||||
const SkSVGRenderContext& ctx,
|
||||
SkSVGPresentationContext* pctx) {
|
||||
const auto& stroke = *attrs.fStroke.get();
|
||||
const auto& stroke = *attrs.fStroke;
|
||||
SkASSERT(stroke.type() != SkSVGPaint::Type::kInherit);
|
||||
|
||||
applySvgPaint(ctx, stroke, &pctx->fStrokePaint);
|
||||
@ -159,7 +159,7 @@ template <>
|
||||
void commitToPaint<SkSVGAttribute::kFillOpacity>(const SkSVGPresentationAttributes& attrs,
|
||||
const SkSVGRenderContext&,
|
||||
SkSVGPresentationContext* pctx) {
|
||||
pctx->fFillPaint.setAlpha(opacity_to_alpha(*attrs.fFillOpacity.get()));
|
||||
pctx->fFillPaint.setAlpha(opacity_to_alpha(*attrs.fFillOpacity));
|
||||
}
|
||||
|
||||
template <>
|
||||
@ -189,7 +189,7 @@ void commitToPaint<SkSVGAttribute::kStrokeDashArray>(const SkSVGPresentationAttr
|
||||
|
||||
SkASSERT((intervals.count() & 1) == 0);
|
||||
|
||||
const SkScalar phase = ctx.lengthContext().resolve(*pctx->fInherited.fStrokeDashOffset.get(),
|
||||
const SkScalar phase = ctx.lengthContext().resolve(*pctx->fInherited.fStrokeDashOffset,
|
||||
SkSVGLengthContext::LengthType::kOther);
|
||||
pctx->fStrokePaint.setPathEffect(SkDashPathEffect::Make(intervals.begin(),
|
||||
intervals.count(),
|
||||
@ -207,7 +207,7 @@ template <>
|
||||
void commitToPaint<SkSVGAttribute::kStrokeLineCap>(const SkSVGPresentationAttributes& attrs,
|
||||
const SkSVGRenderContext&,
|
||||
SkSVGPresentationContext* pctx) {
|
||||
const auto& cap = *attrs.fStrokeLineCap.get();
|
||||
const auto& cap = *attrs.fStrokeLineCap;
|
||||
SkASSERT(cap.type() != SkSVGLineCap::Type::kInherit);
|
||||
|
||||
pctx->fStrokePaint.setStrokeCap(toSkCap(cap));
|
||||
@ -217,7 +217,7 @@ template <>
|
||||
void commitToPaint<SkSVGAttribute::kStrokeLineJoin>(const SkSVGPresentationAttributes& attrs,
|
||||
const SkSVGRenderContext&,
|
||||
SkSVGPresentationContext* pctx) {
|
||||
const auto& join = *attrs.fStrokeLineJoin.get();
|
||||
const auto& join = *attrs.fStrokeLineJoin;
|
||||
SkASSERT(join.type() != SkSVGLineJoin::Type::kInherit);
|
||||
|
||||
pctx->fStrokePaint.setStrokeJoin(toSkJoin(join));
|
||||
@ -227,21 +227,21 @@ template <>
|
||||
void commitToPaint<SkSVGAttribute::kStrokeMiterLimit>(const SkSVGPresentationAttributes& attrs,
|
||||
const SkSVGRenderContext&,
|
||||
SkSVGPresentationContext* pctx) {
|
||||
pctx->fStrokePaint.setStrokeMiter(*attrs.fStrokeMiterLimit.get());
|
||||
pctx->fStrokePaint.setStrokeMiter(*attrs.fStrokeMiterLimit);
|
||||
}
|
||||
|
||||
template <>
|
||||
void commitToPaint<SkSVGAttribute::kStrokeOpacity>(const SkSVGPresentationAttributes& attrs,
|
||||
const SkSVGRenderContext&,
|
||||
SkSVGPresentationContext* pctx) {
|
||||
pctx->fStrokePaint.setAlpha(opacity_to_alpha(*attrs.fStrokeOpacity.get()));
|
||||
pctx->fStrokePaint.setAlpha(opacity_to_alpha(*attrs.fStrokeOpacity));
|
||||
}
|
||||
|
||||
template <>
|
||||
void commitToPaint<SkSVGAttribute::kStrokeWidth>(const SkSVGPresentationAttributes& attrs,
|
||||
const SkSVGRenderContext& ctx,
|
||||
SkSVGPresentationContext* pctx) {
|
||||
auto strokeWidth = ctx.lengthContext().resolve(*attrs.fStrokeWidth.get(),
|
||||
auto strokeWidth = ctx.lengthContext().resolve(*attrs.fStrokeWidth,
|
||||
SkSVGLengthContext::LengthType::kOther);
|
||||
pctx->fStrokePaint.setStrokeWidth(strokeWidth);
|
||||
}
|
||||
@ -462,11 +462,11 @@ void SkSVGRenderContext::updatePaintsWithCurrentColor(const SkSVGPresentationAtt
|
||||
}
|
||||
|
||||
const SkPaint* SkSVGRenderContext::fillPaint() const {
|
||||
const SkSVGPaint::Type paintType = fPresentationContext->fInherited.fFill.get()->type();
|
||||
const SkSVGPaint::Type paintType = fPresentationContext->fInherited.fFill->type();
|
||||
return paintType != SkSVGPaint::Type::kNone ? &fPresentationContext->fFillPaint : nullptr;
|
||||
}
|
||||
|
||||
const SkPaint* SkSVGRenderContext::strokePaint() const {
|
||||
const SkSVGPaint::Type paintType = fPresentationContext->fInherited.fStroke.get()->type();
|
||||
const SkSVGPaint::Type paintType = fPresentationContext->fInherited.fStroke->type();
|
||||
return paintType != SkSVGPaint::Type::kNone ? &fPresentationContext->fStrokePaint : nullptr;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ bool SkSVGSVG::onPrepareToRender(SkSVGRenderContext* ctx) const {
|
||||
auto viewPort = SkSize::Make(viewPortRect.width(), viewPortRect.height());
|
||||
|
||||
if (fViewBox.isValid()) {
|
||||
const SkRect& viewBox = *fViewBox.get();
|
||||
const SkRect& viewBox = *fViewBox;
|
||||
|
||||
// An empty viewbox disables rendering.
|
||||
if (viewBox.isEmpty()) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
SkSVGShape::SkSVGShape(SkSVGTag t) : INHERITED(t) {}
|
||||
|
||||
void SkSVGShape::onRender(const SkSVGRenderContext& ctx) const {
|
||||
const auto fillType = ctx.presentationContext().fInherited.fFillRule.get()->asFillType();
|
||||
const auto fillType = ctx.presentationContext().fInherited.fFillRule->asFillType();
|
||||
|
||||
// TODO: this approach forces duplicate geometry resolution in onDraw(); refactor to avoid.
|
||||
if (const SkPaint* fillPaint = ctx.fillPaint()) {
|
||||
|
@ -461,7 +461,7 @@ static void fuzz_img(sk_sp<SkData> bytes, uint8_t scale, uint8_t mode) {
|
||||
// This is mostly copied from DMSrcSink's CodecSrc::draw method.
|
||||
SkDebugf("Decoding\n");
|
||||
std::unique_ptr<SkCodec> codec(SkCodec::MakeFromData(bytes));
|
||||
if (nullptr == codec.get()) {
|
||||
if (nullptr == codec) {
|
||||
SkDebugf("[terminated] Couldn't create codec.\n");
|
||||
return;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ protected:
|
||||
SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
|
||||
SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props);
|
||||
canvas = surface.get() ? surface->getCanvas() : inputCanvas;
|
||||
canvas = surface ? surface->getCanvas() : inputCanvas;
|
||||
// init our new canvas with the old canvas's matrix
|
||||
canvas->setMatrix(inputCanvas->getTotalMatrix());
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public:
|
||||
SkEncodedInfo copy() const {
|
||||
auto copy = SkEncodedInfo::Make(fWidth, fHeight, fColor, fAlpha, fBitsPerComponent);
|
||||
if (fProfile) {
|
||||
copy.fProfile = std::make_unique<ICCProfile>(*fProfile.get());
|
||||
copy.fProfile = std::make_unique<ICCProfile>(*fProfile);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
@ -1604,7 +1604,7 @@ protected:
|
||||
|
||||
if (fRedraw || fRepeat) {
|
||||
|
||||
if (fRedraw || fParagraph.get() == nullptr) {
|
||||
if (fRedraw || fParagraph == nullptr) {
|
||||
ParagraphBuilderImpl builder(paragraph_style, fontCollection);
|
||||
builder.pushStyle(text_style);
|
||||
auto utf16text = zalgo.zalgo("SkParagraph");
|
||||
|
@ -177,7 +177,7 @@ void OneLineShaper::finish(TextRange blockText, SkScalar height, SkScalar& advan
|
||||
if (block.isFullyResolved()) {
|
||||
// Just move the entire run
|
||||
block.fRun->fIndex = this->fParagraph->fRuns.size();
|
||||
this->fParagraph->fRuns.emplace_back(*block.fRun.get());
|
||||
this->fParagraph->fRuns.emplace_back(*block.fRun);
|
||||
block.fRun.reset();
|
||||
continue;
|
||||
} else if (run == nullptr) {
|
||||
|
@ -4916,7 +4916,7 @@ DEF_TEST(SkParagraph_Fallbacks, reporter) {
|
||||
auto paragraph = builder.Build();
|
||||
paragraph->layout(TestCanvasWidth);
|
||||
paragraph->paint(canvas.get(), 0, 0);
|
||||
canvas.get()->translate(0, paragraph.get()->getHeight() + 10);
|
||||
canvas.get()->translate(0, paragraph->getHeight() + 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ static void releaseProc(const void* ptr, void* context) {
|
||||
std::unique_ptr<SkCodec> SkHeifCodec::MakeFromStream(std::unique_ptr<SkStream> stream,
|
||||
SkCodec::SelectionPolicy selectionPolicy, Result* result) {
|
||||
std::unique_ptr<HeifDecoder> heifDecoder(createHeifDecoder());
|
||||
if (heifDecoder.get() == nullptr) {
|
||||
if (heifDecoder == nullptr) {
|
||||
*result = kInternalError;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ void SkBitmapDevice::drawDevice(SkBaseDevice* device, int x, int y, const SkPain
|
||||
draw.fMatrixProvider = &matrixProvider;
|
||||
draw.fRC = &fRCStack.rc();
|
||||
paint.writable()->setShader(src->fBitmap.makeShader());
|
||||
draw.drawBitmap(*src->fCoverage.get(),
|
||||
draw.drawBitmap(*src->fCoverage,
|
||||
SkMatrix::Translate(SkIntToScalar(x),SkIntToScalar(y)), nullptr, *paint);
|
||||
} else {
|
||||
BDDraw(this).drawSprite(src->fBitmap, x, y, *paint);
|
||||
|
@ -94,7 +94,7 @@ const SkRect& SkClipStack::Element::getBounds() const {
|
||||
case DeviceSpaceType::kRRect:
|
||||
return fDeviceSpaceRRect.getBounds();
|
||||
case DeviceSpaceType::kPath:
|
||||
return fDeviceSpacePath.get()->getBounds();
|
||||
return fDeviceSpacePath->getBounds();
|
||||
case DeviceSpaceType::kShader:
|
||||
// Shaders have infinite bounds since any pixel could have clipped or full coverage
|
||||
// (which is different from wide-open, where every pixel has 1.0 coverage, or empty
|
||||
@ -115,7 +115,7 @@ bool SkClipStack::Element::contains(const SkRect& rect) const {
|
||||
case DeviceSpaceType::kRRect:
|
||||
return fDeviceSpaceRRect.contains(rect);
|
||||
case DeviceSpaceType::kPath:
|
||||
return fDeviceSpacePath.get()->conservativelyContainsRect(rect);
|
||||
return fDeviceSpacePath->conservativelyContainsRect(rect);
|
||||
case DeviceSpaceType::kEmpty:
|
||||
case DeviceSpaceType::kShader:
|
||||
return false;
|
||||
@ -133,7 +133,7 @@ bool SkClipStack::Element::contains(const SkRRect& rrect) const {
|
||||
// We don't currently have a generalized rrect-rrect containment.
|
||||
return fDeviceSpaceRRect.contains(rrect.getBounds()) || rrect == fDeviceSpaceRRect;
|
||||
case DeviceSpaceType::kPath:
|
||||
return fDeviceSpacePath.get()->conservativelyContainsRect(rrect.getBounds());
|
||||
return fDeviceSpacePath->conservativelyContainsRect(rrect.getBounds());
|
||||
case DeviceSpaceType::kEmpty:
|
||||
case DeviceSpaceType::kShader:
|
||||
return false;
|
||||
@ -147,18 +147,18 @@ void SkClipStack::Element::invertShapeFillType() {
|
||||
switch (fDeviceSpaceType) {
|
||||
case DeviceSpaceType::kRect:
|
||||
fDeviceSpacePath.init();
|
||||
fDeviceSpacePath.get()->addRect(this->getDeviceSpaceRect());
|
||||
fDeviceSpacePath.get()->setFillType(SkPathFillType::kInverseEvenOdd);
|
||||
fDeviceSpacePath->addRect(this->getDeviceSpaceRect());
|
||||
fDeviceSpacePath->setFillType(SkPathFillType::kInverseEvenOdd);
|
||||
fDeviceSpaceType = DeviceSpaceType::kPath;
|
||||
break;
|
||||
case DeviceSpaceType::kRRect:
|
||||
fDeviceSpacePath.init();
|
||||
fDeviceSpacePath.get()->addRRect(fDeviceSpaceRRect);
|
||||
fDeviceSpacePath.get()->setFillType(SkPathFillType::kInverseEvenOdd);
|
||||
fDeviceSpacePath->addRRect(fDeviceSpaceRRect);
|
||||
fDeviceSpacePath->setFillType(SkPathFillType::kInverseEvenOdd);
|
||||
fDeviceSpaceType = DeviceSpaceType::kPath;
|
||||
break;
|
||||
case DeviceSpaceType::kPath:
|
||||
fDeviceSpacePath.get()->toggleInverseFillType();
|
||||
fDeviceSpacePath->toggleInverseFillType();
|
||||
break;
|
||||
case DeviceSpaceType::kShader:
|
||||
fShader = as_SB(fShader)->makeInvertAlpha();
|
||||
@ -237,7 +237,7 @@ void SkClipStack::Element::initPath(int saveCount, const SkPath& path, const SkM
|
||||
void SkClipStack::Element::initAsPath(int saveCount, const SkPath& path, const SkMatrix& m,
|
||||
SkClipOp op, bool doAA) {
|
||||
path.transform(m, fDeviceSpacePath.init());
|
||||
fDeviceSpacePath.get()->setIsVolatile(true);
|
||||
fDeviceSpacePath->setIsVolatile(true);
|
||||
fDeviceSpaceType = DeviceSpaceType::kPath;
|
||||
this->initCommon(saveCount, op, doAA);
|
||||
}
|
||||
@ -263,7 +263,7 @@ void SkClipStack::Element::asDeviceSpacePath(SkPath* path) const {
|
||||
path->addRRect(fDeviceSpaceRRect);
|
||||
break;
|
||||
case DeviceSpaceType::kPath:
|
||||
*path = *fDeviceSpacePath.get();
|
||||
*path = *fDeviceSpacePath;
|
||||
break;
|
||||
case DeviceSpaceType::kShader:
|
||||
path->reset();
|
||||
@ -529,9 +529,9 @@ void SkClipStack::Element::updateBoundAndGenID(const Element* prior) {
|
||||
fFiniteBoundType = kNormal_BoundsType;
|
||||
break;
|
||||
case DeviceSpaceType::kPath:
|
||||
fFiniteBound = fDeviceSpacePath.get()->getBounds();
|
||||
fFiniteBound = fDeviceSpacePath->getBounds();
|
||||
|
||||
if (fDeviceSpacePath.get()->isInverseFillType()) {
|
||||
if (fDeviceSpacePath->isInverseFillType()) {
|
||||
fFiniteBoundType = kInsideOut_BoundsType;
|
||||
} else {
|
||||
fFiniteBoundType = kNormal_BoundsType;
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
//!< Call if getDeviceSpaceType() is kPath to get the path.
|
||||
const SkPath& getDeviceSpacePath() const {
|
||||
SkASSERT(DeviceSpaceType::kPath == fDeviceSpaceType);
|
||||
return *fDeviceSpacePath.get();
|
||||
return *fDeviceSpacePath;
|
||||
}
|
||||
|
||||
//!< Call if getDeviceSpaceType() is kRRect to get the round-rect.
|
||||
@ -176,7 +176,7 @@ public:
|
||||
*/
|
||||
bool isInverseFilled() const {
|
||||
return DeviceSpaceType::kPath == fDeviceSpaceType &&
|
||||
fDeviceSpacePath.get()->isInverseFillType();
|
||||
fDeviceSpacePath->isInverseFillType();
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
fAxis[i] = that.fAxis[i];
|
||||
}
|
||||
}
|
||||
bool hasStream() const { return fStream.get() != nullptr; }
|
||||
bool hasStream() const { return fStream != nullptr; }
|
||||
std::unique_ptr<SkStreamAsset> detachStream() { return std::move(fStream); }
|
||||
SkStreamAsset* getStream() { return fStream.get(); }
|
||||
SkStreamAsset const* getStream() const { return fStream.get(); }
|
||||
|
@ -203,7 +203,7 @@ bool operator==(const SkPath& a, const SkPath& b) {
|
||||
// note: don't need to look at isConvex or bounds, since just comparing the
|
||||
// raw data is sufficient.
|
||||
return &a == &b ||
|
||||
(a.fFillType == b.fFillType && *a.fPathRef.get() == *b.fPathRef.get());
|
||||
(a.fFillType == b.fFillType && *a.fPathRef == *b.fPathRef);
|
||||
}
|
||||
|
||||
void SkPath::swap(SkPath& that) {
|
||||
@ -1005,7 +1005,7 @@ bool SkPath::isZeroLengthSincePoint(int startPtIndex) const {
|
||||
if (count < 2) {
|
||||
return true;
|
||||
}
|
||||
const SkPoint* pts = fPathRef.get()->points() + startPtIndex;
|
||||
const SkPoint* pts = fPathRef->points() + startPtIndex;
|
||||
const SkPoint& first = *pts;
|
||||
for (int index = 1; index < count; ++index) {
|
||||
if (first != pts[index]) {
|
||||
@ -1635,7 +1635,7 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst, SkApplyPerspectiveCl
|
||||
} else {
|
||||
SkPathConvexityType convexity = this->getConvexityTypeOrUnknown();
|
||||
|
||||
SkPathRef::CreateTransformedCopy(&dst->fPathRef, *fPathRef.get(), matrix);
|
||||
SkPathRef::CreateTransformedCopy(&dst->fPathRef, *fPathRef, matrix);
|
||||
|
||||
if (this != dst) {
|
||||
dst->fLastMoveToIndex = fLastMoveToIndex;
|
||||
@ -2487,7 +2487,7 @@ bool SkPathPriv::CheapComputeFirstDirection(const SkPath& path, FirstDirection*
|
||||
return false;
|
||||
}
|
||||
|
||||
ContourIter iter(*path.fPathRef.get());
|
||||
ContourIter iter(*path.fPathRef);
|
||||
|
||||
// initialize with our logical y-min
|
||||
SkScalar ymax = path.getBounds().fTop;
|
||||
|
@ -317,7 +317,7 @@ bool SkPictureData::parseStreamTag(SkStream* stream,
|
||||
} else {
|
||||
tf = SkTypeface::MakeDeserialize(stream);
|
||||
}
|
||||
if (!tf.get()) { // failed to deserialize
|
||||
if (!tf) { // failed to deserialize
|
||||
// fTFPlayback asserts it never has a null, so we plop in
|
||||
// the default here.
|
||||
tf = SkTypeface::MakeDefault();
|
||||
|
@ -81,7 +81,7 @@ sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPicture(uint32_t finishFlag
|
||||
drawableList ? drawableList->newDrawableSnapshot() : nullptr
|
||||
};
|
||||
|
||||
if (fBBH.get()) {
|
||||
if (fBBH) {
|
||||
SkAutoTMalloc<SkRect> bounds(fRecord->count());
|
||||
SkAutoTMalloc<SkBBoxHierarchy::Metadata> meta(fRecord->count());
|
||||
SkRecordFillBounds(fCullRect, *fRecord, bounds, meta);
|
||||
@ -138,7 +138,7 @@ sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable(uint32_t finishFl
|
||||
|
||||
SkRecordOptimize(fRecord.get());
|
||||
|
||||
if (fBBH.get()) {
|
||||
if (fBBH) {
|
||||
SkAutoTMalloc<SkRect> bounds(fRecord->count());
|
||||
SkAutoTMalloc<SkBBoxHierarchy::Metadata> meta(fRecord->count());
|
||||
SkRecordFillBounds(fCullRect, *fRecord, bounds, meta);
|
||||
|
@ -269,7 +269,7 @@ sk_sp<SkVertices> SkVertices::Builder::detach() {
|
||||
if (fVertices) {
|
||||
fVertices->fBounds.setBounds(fVertices->fPositions, fVertices->fVertexCount);
|
||||
if (fVertices->fMode == kTriangleFan_VertexMode) {
|
||||
if (fIntermediateFanIndices.get()) {
|
||||
if (fIntermediateFanIndices) {
|
||||
SkASSERT(fVertices->fIndexCount);
|
||||
auto tempIndices = this->indices();
|
||||
for (int t = 0; t < fVertices->fIndexCount - 2; ++t) {
|
||||
|
@ -275,7 +275,7 @@ static void draw_shape_with_mask_filter(GrRecordingContext* context,
|
||||
}
|
||||
|
||||
tmpShape.init(origShape.applyStyle(GrStyle::Apply::kPathEffectAndStrokeRec, styleScale));
|
||||
if (tmpShape.get()->isEmpty()) {
|
||||
if (tmpShape->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ public:
|
||||
|
||||
const GrXferProcessor& getXferProcessor() const {
|
||||
if (fXferProcessor) {
|
||||
return *fXferProcessor.get();
|
||||
return *fXferProcessor;
|
||||
} else {
|
||||
// A null xp member means the common src-over case. GrXferProcessor's ref'ing
|
||||
// mechanism is not thread safe so we do not hold a ref on this global.
|
||||
@ -149,7 +149,7 @@ public:
|
||||
}
|
||||
|
||||
const GrFragmentProcessor& getFragmentProcessor(int idx) const {
|
||||
return *fFragmentProcessors[idx].get();
|
||||
return *fFragmentProcessors[idx];
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
@ -27,7 +27,7 @@ bool GrWaitRenderTask::onExecute(GrOpFlushState* flushState) {
|
||||
// If we don't have a semaphore here it means we failed to wrap it. That happens if the
|
||||
// client didn't give us a valid semaphore to begin with. Therefore, it is fine to not wait
|
||||
// on it.
|
||||
if (fSemaphores[i].get()) {
|
||||
if (fSemaphores[i]) {
|
||||
flushState->gpu()->waitSemaphore(fSemaphores[i].get());
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ GrStyledShape& GrStyledShape::operator=(const GrStyledShape& that) {
|
||||
sk_careful_memcpy(fInheritedKey.get(), that.fInheritedKey.get(),
|
||||
sizeof(uint32_t) * fInheritedKey.count());
|
||||
if (that.fInheritedPathForListeners.isValid()) {
|
||||
fInheritedPathForListeners.set(*that.fInheritedPathForListeners.get());
|
||||
fInheritedPathForListeners.set(*that.fInheritedPathForListeners);
|
||||
} else {
|
||||
fInheritedPathForListeners.reset();
|
||||
}
|
||||
@ -52,7 +52,7 @@ GrStyledShape GrStyledShape::MakeFilled(const GrStyledShape& original, FillInver
|
||||
GrStyledShape result;
|
||||
SkASSERT(result.fStyle.isSimpleFill());
|
||||
if (original.fInheritedPathForListeners.isValid()) {
|
||||
result.fInheritedPathForListeners.set(*original.fInheritedPathForListeners.get());
|
||||
result.fInheritedPathForListeners.set(*original.fInheritedPathForListeners);
|
||||
}
|
||||
|
||||
result.fShape = original.fShape;
|
||||
@ -322,7 +322,7 @@ GrStyledShape::GrStyledShape(const GrStyledShape& that)
|
||||
sk_careful_memcpy(fInheritedKey.get(), that.fInheritedKey.get(),
|
||||
sizeof(uint32_t) * fInheritedKey.count());
|
||||
if (that.fInheritedPathForListeners.isValid()) {
|
||||
fInheritedPathForListeners.set(*that.fInheritedPathForListeners.get());
|
||||
fInheritedPathForListeners.set(*that.fInheritedPathForListeners);
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ GrStyledShape::GrStyledShape(const GrStyledShape& parent, GrStyle::Apply apply,
|
||||
if (!parent.fStyle.applyPathEffectToPath(&fShape.path(), &strokeRec, *srcForPathEffect,
|
||||
scale)) {
|
||||
tmpParent.init(*srcForPathEffect, GrStyle(strokeRec, nullptr));
|
||||
*this = tmpParent.get()->applyStyle(apply, scale);
|
||||
*this = tmpParent->applyStyle(apply, scale);
|
||||
return;
|
||||
}
|
||||
// A path effect has access to change the res scale but we aren't expecting it to and it
|
||||
@ -374,17 +374,17 @@ GrStyledShape::GrStyledShape(const GrStyledShape& parent, GrStyle::Apply apply,
|
||||
// the simpler shape so that applying both path effect and the strokerec all at
|
||||
// once produces the same key.
|
||||
tmpParent.init(fShape.path(), GrStyle(strokeRec, nullptr));
|
||||
tmpParent.get()->setInheritedKey(parent, GrStyle::Apply::kPathEffectOnly, scale);
|
||||
tmpParent->setInheritedKey(parent, GrStyle::Apply::kPathEffectOnly, scale);
|
||||
if (!tmpPath.isValid()) {
|
||||
tmpPath.init();
|
||||
}
|
||||
tmpParent.get()->asPath(tmpPath.get());
|
||||
tmpParent->asPath(tmpPath.get());
|
||||
SkStrokeRec::InitStyle fillOrHairline;
|
||||
// The parent shape may have simplified away the strokeRec, check for that here.
|
||||
if (tmpParent.get()->style().applies()) {
|
||||
if (tmpParent->style().applies()) {
|
||||
SkAssertResult(tmpParent.get()->style().applyToPath(&fShape.path(), &fillOrHairline,
|
||||
*tmpPath.get(), scale));
|
||||
} else if (tmpParent.get()->style().isSimpleFill()) {
|
||||
} else if (tmpParent->style().isSimpleFill()) {
|
||||
fillOrHairline = SkStrokeRec::kFill_InitStyle;
|
||||
} else {
|
||||
SkASSERT(tmpParent.get()->style().isSimpleHairline());
|
||||
@ -412,7 +412,7 @@ GrStyledShape::GrStyledShape(const GrStyledShape& parent, GrStyle::Apply apply,
|
||||
}
|
||||
|
||||
if (parent.fInheritedPathForListeners.isValid()) {
|
||||
fInheritedPathForListeners.set(*parent.fInheritedPathForListeners.get());
|
||||
fInheritedPathForListeners.set(*parent.fInheritedPathForListeners);
|
||||
} else if (parent.fShape.isPath() && !parent.fShape.path().isVolatile()) {
|
||||
fInheritedPathForListeners.set(parent.fShape.path());
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
size_t size = eagerCount * stride;
|
||||
fVertexBuffer = fResourceProvider->createBuffer(size, GrGpuBufferType::kVertex,
|
||||
kStatic_GrAccessPattern);
|
||||
if (!fVertexBuffer.get()) {
|
||||
if (!fVertexBuffer) {
|
||||
return nullptr;
|
||||
}
|
||||
if (fCanMapVB) {
|
||||
|
@ -947,7 +947,7 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, int left, int top, int widt
|
||||
|
||||
// If we copied the data into a temporary image first, copy that image into our main texture
|
||||
// now.
|
||||
if (copyTexture.get()) {
|
||||
if (copyTexture) {
|
||||
SkASSERT(dataColorType == GrColorType::kRGB_888x);
|
||||
SkAssertResult(this->copySurface(tex, copyTexture.get(), SkIRect::MakeWH(width, height),
|
||||
SkIPoint::Make(left, top)));
|
||||
|
@ -370,7 +370,7 @@ sk_sp<SkCachedData> SkImage_Lazy::getPlanes(
|
||||
|
||||
void* planes[SkYUVASizeInfo::kMaxCount];
|
||||
|
||||
if (data.get()) {
|
||||
if (data) {
|
||||
planes[0] = (void*)data->data(); // we should always have at least one plane
|
||||
|
||||
for (int i = 1; i < SkYUVASizeInfo::kMaxCount; ++i) {
|
||||
|
@ -449,7 +449,7 @@ protected:
|
||||
|
||||
sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override {
|
||||
std::unique_ptr<SkStreamAsset> stream = SkStream::MakeFromFile(path);
|
||||
return stream.get() ? this->makeFromStream(std::move(stream), ttcIndex) : nullptr;
|
||||
return stream ? this->makeFromStream(std::move(stream), ttcIndex) : nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset> stream,
|
||||
@ -550,7 +550,7 @@ private:
|
||||
addFamily(*family, isolated, familyIndex++);
|
||||
family->fallbackFamilies.foreach([this, isolated, &familyIndex]
|
||||
(SkString, std::unique_ptr<FontFamily>* fallbackFamily) {
|
||||
addFamily(*(*fallbackFamily).get(), isolated, familyIndex++);
|
||||
addFamily(**fallbackFamily, isolated, familyIndex++);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ static const TagHandler fileHandler = {
|
||||
// 'lang' (string) [default ""]
|
||||
// 'index' (non-negative integer) [default 0]
|
||||
// The character data should be a filename.
|
||||
FontFamily& currentFamily = *self->fCurrentFamily.get();
|
||||
FontFamily& currentFamily = *self->fCurrentFamily;
|
||||
FontFileInfo& newFileInfo = currentFamily.fFonts.push_back();
|
||||
if (attributes) {
|
||||
for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
|
||||
|
@ -1841,7 +1841,7 @@ std::unique_ptr<Expression> IRGenerator::convertBinaryExpression(const ASTNode&
|
||||
if (!left || !right) {
|
||||
return nullptr;
|
||||
}
|
||||
std::unique_ptr<Expression> result = this->constantFold(*left.get(), op, *right.get());
|
||||
std::unique_ptr<Expression> result = this->constantFold(*left, op, *right);
|
||||
if (!result) {
|
||||
result = std::make_unique<BinaryExpression>(expression.fOffset, std::move(left), op,
|
||||
std::move(right), *resultType);
|
||||
|
@ -297,7 +297,7 @@ std::unique_ptr<SkCanvas> SkCanvasStateUtils::MakeFromCanvasState(const SkCanvas
|
||||
// Iterate over the layers and add them to the n-way canvas
|
||||
for (int i = state_v1->layerCount - 1; i >= 0; --i) {
|
||||
std::unique_ptr<SkCanvas> canvasLayer = make_canvas_from_canvas_layer(state_v1->layers[i]);
|
||||
if (!canvasLayer.get()) {
|
||||
if (!canvasLayer) {
|
||||
return nullptr;
|
||||
}
|
||||
canvas->pushCanvas(std::move(canvasLayer), SkIPoint::Make(state_v1->layers[i].x,
|
||||
|
@ -119,7 +119,7 @@ static void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies, const char* lab
|
||||
fontFamilies[i]->fallbackFamilies.foreach(
|
||||
[](SkString, std::unique_ptr<FontFamily>* fallbackFamily) {
|
||||
SkDebugf(" Fallback for: %s\n", (*fallbackFamily)->fFallbackFor.c_str());
|
||||
DumpFiles(*(*fallbackFamily).get());
|
||||
DumpFiles(**fallbackFamily);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ static void test_read_beyond_buffer(skiatest::Reporter* reporter, size_t bufferS
|
||||
// Create a buffer that matches the length of the stream.
|
||||
auto bufferedStream = android::skia::FrontBufferedStream::Make(
|
||||
std::unique_ptr<SkStream>(memStream), bufferSize);
|
||||
test_hasLength(reporter, *bufferedStream.get(), *memStream);
|
||||
test_hasLength(reporter, *bufferedStream, *memStream);
|
||||
|
||||
// Attempt to read one more than the bufferSize
|
||||
test_read(reporter, bufferedStream.get(), gAbcs, bufferSize + 1);
|
||||
@ -214,7 +214,7 @@ static void test_length_combos(skiatest::Reporter* reporter, size_t bufferSize)
|
||||
new LengthOptionalStream(SkToBool(hasLen), SkToBool(hasPos));
|
||||
auto buffered = android::skia::FrontBufferedStream::Make(
|
||||
std::unique_ptr<SkStream>(stream), bufferSize);
|
||||
test_hasLength(reporter, *buffered.get(), *stream);
|
||||
test_hasLength(reporter, *buffered, *stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ static void test_linear_fuzzer(skiatest::Reporter*) {
|
||||
SkTLazy<SkMatrix> localMatrix;
|
||||
if (config.fLocalMatrix) {
|
||||
localMatrix.init();
|
||||
localMatrix.get()->set9(config.fLocalMatrix);
|
||||
localMatrix->set9(config.fLocalMatrix);
|
||||
}
|
||||
|
||||
paint.setShader(SkGradientShader::MakeLinear(config.fPts,
|
||||
|
@ -726,7 +726,7 @@ static void test_fail_affects_transparent_black(skiatest::Reporter* reporter,
|
||||
SkIPoint offset;
|
||||
sk_sp<SkSpecialImage> result(as_IFB(greenFilter)->filterImage(ctx).imageAndOffset(&offset));
|
||||
REPORTER_ASSERT(reporter, nullptr != result.get());
|
||||
if (result.get()) {
|
||||
if (result) {
|
||||
SkBitmap resultBM;
|
||||
REPORTER_ASSERT(reporter, special_image_to_bitmap(result.get(), &resultBM));
|
||||
REPORTER_ASSERT(reporter, *resultBM.getAddr32(0, 0) == SK_ColorGREEN);
|
||||
|
@ -66,7 +66,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
|
||||
// Multiple normal refs
|
||||
{
|
||||
sk_sp<GrTextureProxy> proxy((*make)(dContext));
|
||||
if (proxy.get()) {
|
||||
if (proxy) {
|
||||
proxy->ref();
|
||||
proxy->ref();
|
||||
|
||||
|
@ -72,7 +72,7 @@ private:
|
||||
struct LookupTrait {
|
||||
// We use the data as a hash, this is not really optimal but is fine until proven otherwise
|
||||
static const SkData& GetKey(const UrlData& data) {
|
||||
return *data.fData.get();
|
||||
return *data.fData;
|
||||
}
|
||||
|
||||
static uint32_t Hash(const SkData& key) {
|
||||
|
@ -1098,7 +1098,7 @@ void DrawAnnotationCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlData
|
||||
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
||||
MakeJsonRect(writer, fRect);
|
||||
writer.appendString("key", fKey.c_str());
|
||||
if (fValue.get()) {
|
||||
if (fValue) {
|
||||
// TODO: dump out the "value"
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ void TestSVGTypeface::Glyph::withSVG(Fn&& fn) const {
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<SkSVGDOM> svg = SkSVGDOM::MakeFromStream(*stream.get());
|
||||
sk_sp<SkSVGDOM> svg = SkSVGDOM::MakeFromStream(*stream);
|
||||
if (!svg) {
|
||||
return;
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv
|
||||
auto restore = testCtx->makeCurrentAndAutoRestore();
|
||||
grCtx = testCtx->makeContext(grOptions);
|
||||
}
|
||||
if (!grCtx.get()) {
|
||||
if (!grCtx) {
|
||||
return ContextInfo();
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
auto pic(load_picture(path));
|
||||
if (pic.get()) {
|
||||
if (pic) {
|
||||
std::unique_ptr<SkLuaCanvas> canvas(
|
||||
new SkLuaCanvas(SkScalarCeilToInt(pic->cullRect().width()),
|
||||
SkScalarCeilToInt(pic->cullRect().height()),
|
||||
|
@ -258,7 +258,7 @@ static int renderer(
|
||||
return 0;
|
||||
}
|
||||
if (gPurgeFontCaches) discardableManager.purgeAll();
|
||||
push_font_data(*pic.get(), &server, colorSpace, writeFd);
|
||||
push_font_data(*pic, &server, colorSpace, writeFd);
|
||||
}
|
||||
} else {
|
||||
stream = skpData;
|
||||
|
@ -23,7 +23,7 @@ SKPSlide::SKPSlide(const SkString& name, std::unique_ptr<SkStream> stream)
|
||||
SKPSlide::~SKPSlide() {}
|
||||
|
||||
void SKPSlide::draw(SkCanvas* canvas) {
|
||||
if (fPic.get()) {
|
||||
if (fPic) {
|
||||
bool isOffset = SkToBool(fCullRect.left() | fCullRect.top());
|
||||
if (isOffset) {
|
||||
canvas->save();
|
||||
|
Loading…
Reference in New Issue
Block a user