Skip to content

Commit

Permalink
use std::make_unique
Browse files Browse the repository at this point in the history
Change-Id: I7c672ff6b8eb95ec8c1123a5bfdb202e1644f494
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259281
Commit-Queue: Mike Klein <[email protected]>
Reviewed-by: Ben Wagner <[email protected]>
  • Loading branch information
Mike Klein authored and Skia Commit-Bot committed Dec 12, 2019
1 parent 1521e6b commit f46d5ca
Show file tree
Hide file tree
Showing 103 changed files with 144 additions and 272 deletions.
3 changes: 1 addition & 2 deletions bench/TypefaceBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "bench/Benchmark.h"
#include "include/core/SkFont.h"
#include "include/core/SkTypeface.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkUtils.h"
#include "src/utils/SkUTF.h"

Expand Down Expand Up @@ -255,7 +254,7 @@ class UtfToGlyph : public Benchmark {
};

std::unique_ptr<Line> convertLine(int lineIndex) {
std::unique_ptr<Line> result = skstd::make_unique<Line>();
std::unique_ptr<Line> result = std::make_unique<Line>();

const char* cursor = fText[lineIndex];
size_t len = strlen(cursor);
Expand Down
1 change: 0 additions & 1 deletion dm/DMSrcSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "src/codec/SkSwizzler.h"
#include "src/core/SkAutoMalloc.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkOSFile.h"
#include "src/core/SkOpts.h"
#include "src/core/SkPictureCommon.h"
Expand Down
3 changes: 1 addition & 2 deletions gm/aaclip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ DEF_SIMPLE_GM(aaclip, canvas, 240, 120) {
#ifdef SK_BUILD_FOR_MAC

#include "include/utils/mac/SkCGUtils.h"
#include "src/core/SkMakeUnique.h"

static std::unique_ptr<SkCanvas> make_canvas(const SkBitmap& bm) {
const SkImageInfo& info = bm.info();
Expand All @@ -168,7 +167,7 @@ static std::unique_ptr<SkCanvas> make_canvas(const SkBitmap& bm) {
(SkPMColor*)bm.getPixels(),
bm.rowBytes());
} else {
return skstd::make_unique<SkCanvas>(bm);
return std::make_unique<SkCanvas>(bm);
}
}

Expand Down
3 changes: 1 addition & 2 deletions gm/animated_gif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/utils/SkAnimCodecPlayer.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkOSFile.h"
#include "tools/Resources.h"
#include "tools/ToolUtils.h"
Expand Down Expand Up @@ -197,7 +196,7 @@ class AnimCodecPlayerGM : public skiagm::GM {
completepath.printf("%s%s", root, path.c_str());
auto codec = load_codec(completepath.c_str());
if (codec) {
fPlayers.push_back(skstd::make_unique<SkAnimCodecPlayer>(std::move(codec)));
fPlayers.push_back(std::make_unique<SkAnimCodecPlayer>(std::move(codec)));
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions gm/image_pict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "include/gpu/GrContext.h"
#include "include/gpu/GrTypes.h"
#include "include/private/GrTypesPriv.h"
#include "src/core/SkMakeUnique.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrSamplerState.h"
#include "src/gpu/GrSurfaceContext.h"
Expand Down Expand Up @@ -156,7 +155,7 @@ static std::unique_ptr<SkImageGenerator> make_ras_generator(GrContext*, sk_sp<Sk
canvas.clear(0);
canvas.translate(-100, -100);
canvas.drawPicture(pic);
return skstd::make_unique<RasterGenerator>(bm);
return std::make_unique<RasterGenerator>(bm);
}

class EmptyGenerator : public SkImageGenerator {
Expand Down Expand Up @@ -212,9 +211,9 @@ static std::unique_ptr<SkImageGenerator> make_tex_generator(GrContext* ctx, sk_s
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);

if (!ctx) {
return skstd::make_unique<EmptyGenerator>(info);
return std::make_unique<EmptyGenerator>(info);
}
return skstd::make_unique<TextureGenerator>(ctx, info, pic);
return std::make_unique<TextureGenerator>(ctx, info, pic);
}

class ImageCacheratorGM : public skiagm::GM {
Expand Down
3 changes: 1 addition & 2 deletions gm/imagemasksubset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "include/core/SkSize.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTypes.h"
#include "src/core/SkMakeUnique.h"
#include "tools/ToolUtils.h"

namespace {
Expand Down Expand Up @@ -66,7 +65,7 @@ const MakerT makers[] = {

// SkImage_Lazy
[](SkCanvas*, const SkImageInfo& info) -> sk_sp<SkImage> {
return SkImage::MakeFromGenerator(skstd::make_unique<MaskGenerator>(info));
return SkImage::MakeFromGenerator(std::make_unique<MaskGenerator>(info));
},
};

Expand Down
3 changes: 1 addition & 2 deletions gm/rasterhandleallocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "include/core/SkPixmap.h"
#include "include/core/SkRasterHandleAllocator.h"
#include "include/core/SkSurface.h"
#include "src/core/SkMakeUnique.h"

class GraphicsPort {
protected:
Expand Down Expand Up @@ -298,7 +297,7 @@ DEF_SIMPLE_GM(rasterallocator, canvas, 600, 300) {

const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
std::unique_ptr<SkCanvas> nativeCanvas =
SkRasterHandleAllocator::MakeCanvas(skstd::make_unique<MyAllocator>(), info);
SkRasterHandleAllocator::MakeCanvas(std::make_unique<MyAllocator>(), info);
MyPort nativePort(nativeCanvas.get());
doDraw(&nativePort);

Expand Down
1 change: 0 additions & 1 deletion gn/core.gni
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ skia_core_sources = [
"$_src/core/SkLocalMatrixImageFilter.h",
"$_src/core/SkMD5.cpp",
"$_src/core/SkMD5.h",
"$_src/core/SkMakeUnique.h",
"$_src/core/SkMalloc.cpp",
"$_src/core/SkMallocPixelRef.cpp",
"$_src/core/SkMask.cpp",
Expand Down
2 changes: 1 addition & 1 deletion include/core/SkRasterHandleAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SkMatrix;
*
* std::unique_ptr<SkCanvas> canvas = SkRasterHandleAllocator::MakeCanvas(
* SkImageInfo::Make(...),
* skstd::make_unique<MySubclassRasterHandleAllocator>(...),
* std::make_unique<MySubclassRasterHandleAllocator>(...),
* nullptr);
*
* If you have already allocated the base layer (and its handle, release-proc etc.) then you
Expand Down
1 change: 0 additions & 1 deletion modules/canvaskit/canvaskit_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include "include/utils/SkShadowUtils.h"
#include "modules/skshaper/include/SkShaper.h"
#include "src/core/SkFontMgrPriv.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkResourceCache.h"
#include "src/shaders/SkRTShader.h"

Expand Down
3 changes: 1 addition & 2 deletions modules/canvaskit/skottie_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "include/core/SkTypes.h"
#include "modules/skottie/include/Skottie.h"
#include "modules/sksg/include/SkSGInvalidationController.h"
#include "src/core/SkMakeUnique.h"

#include <string>
#include <vector>
Expand Down Expand Up @@ -86,7 +85,7 @@ class ManagedAnimation final : public SkRefCnt {
public:
static sk_sp<ManagedAnimation> Make(const std::string& json,
sk_sp<skottie::ResourceProvider> rp) {
auto mgr = skstd::make_unique<skottie_utils::CustomPropertyManager>();
auto mgr = std::make_unique<skottie_utils::CustomPropertyManager>();
auto animation = skottie::Animation::Builder()
.setMarkerObserver(mgr->getMarkerObserver())
.setPropertyObserver(mgr->getPropertyObserver())
Expand Down
3 changes: 1 addition & 2 deletions modules/particles/src/SkParticleEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "modules/particles/include/SkParticleDrawable.h"
#include "modules/particles/include/SkReflected.h"
#include "modules/skresources/include/SkResources.h"
#include "src/core/SkMakeUnique.h"
#include "src/sksl/SkSLByteCode.h"
#include "src/sksl/SkSLCompiler.h"

Expand Down Expand Up @@ -126,7 +125,7 @@ void SkParticleEffectParams::prepare(const skresources::ResourceProvider* resour

SkTArray<std::unique_ptr<SkParticleExternalValue>> externalValues;

auto rand = skstd::make_unique<SkRandomExternalValue>("rand", compiler);
auto rand = std::make_unique<SkRandomExternalValue>("rand", compiler);
compiler.registerExternalValue(rand.get());
externalValues.push_back(std::move(rand));

Expand Down
3 changes: 1 addition & 2 deletions modules/skottie/gm/SkottieGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "modules/skottie/include/SkottieProperty.h"
#include "modules/skottie/utils/SkottieUtils.h"
#include "modules/skresources/include/SkResources.h"
#include "src/core/SkMakeUnique.h"
#include "tools/Resources.h"

#include <cmath>
Expand Down Expand Up @@ -102,7 +101,7 @@ class SkottieColorizeGM : public skiagm::GM {

void onOnceBeforeDraw() override {
if (auto stream = GetResourceAsStream("skottie/skottie_sample_search.json")) {
fPropManager = skstd::make_unique<skottie_utils::CustomPropertyManager>();
fPropManager = std::make_unique<skottie_utils::CustomPropertyManager>();
fAnimation = skottie::Animation::Builder()
.setPropertyObserver(fPropManager->getPropertyObserver())
.make(stream.get());
Expand Down
5 changes: 2 additions & 3 deletions modules/skottie/src/SkottieTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "include/encode/SkPngEncoder.h"
#include "modules/skottie/include/Skottie.h"
#include "modules/skresources/include/SkResources.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkOSFile.h"
#include "src/core/SkTaskGroup.h"
#include "src/utils/SkOSPath.h"
Expand Down Expand Up @@ -48,7 +47,7 @@ namespace {

std::unique_ptr<SkFILEWStream> MakeFrameStream(size_t idx, const char* ext) {
const auto frame_file = SkStringPrintf("0%06d.%s", idx, ext);
auto stream = skstd::make_unique<SkFILEWStream>(SkOSPath::Join(FLAGS_writePath[0],
auto stream = std::make_unique<SkFILEWStream>(SkOSPath::Join(FLAGS_writePath[0],
frame_file.c_str()).c_str());
if (!stream->isValid()) {
return nullptr;
Expand Down Expand Up @@ -235,7 +234,7 @@ std::unique_ptr<Sink> MakeSink(const char* fmt, const SkMatrix& scale_matrix) {
if (0 == strcmp(fmt, "png")) return PNGSink::Make(scale_matrix);
if (0 == strcmp(fmt, "skp")) return SKPSink::Make(scale_matrix);
if (0 == strcmp(fmt, "null")) return NullSink::Make(scale_matrix);
if (0 == strcmp(fmt, "mp4")) return skstd::make_unique<MP4Sink>(scale_matrix);
if (0 == strcmp(fmt, "mp4")) return std::make_unique<MP4Sink>(scale_matrix);

SkDebugf("Unknown format: %s\n", FLAGS_format[0]);
return nullptr;
Expand Down
5 changes: 2 additions & 3 deletions modules/skparagraph/src/ParagraphBuilderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "modules/skparagraph/include/ParagraphStyle.h"
#include "modules/skparagraph/src/ParagraphBuilderImpl.h"
#include "modules/skparagraph/src/ParagraphImpl.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkSpan.h"
#include "unicode/unistr.h"

Expand All @@ -12,7 +11,7 @@ namespace textlayout {

std::unique_ptr<ParagraphBuilder> ParagraphBuilder::make(
const ParagraphStyle& style, sk_sp<FontCollection> fontCollection) {
return skstd::make_unique<ParagraphBuilderImpl>(style, fontCollection);
return std::make_unique<ParagraphBuilderImpl>(style, fontCollection);
}

ParagraphBuilderImpl::ParagraphBuilderImpl(
Expand Down Expand Up @@ -146,7 +145,7 @@ std::unique_ptr<Paragraph> ParagraphBuilderImpl::Build() {

// Add one fake placeholder with the rest of the text
addPlaceholder(PlaceholderStyle(), true);
return skstd::make_unique<ParagraphImpl>(
return std::make_unique<ParagraphImpl>(
fUtf8, fParagraphStyle, fStyledBlocks, fPlaceholders, fFontCollection);
}

Expand Down
1 change: 0 additions & 1 deletion modules/skparagraph/src/TextLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "include/core/SkMaskFilter.h"
#include "include/effects/SkDashPathEffect.h"
#include "include/effects/SkDiscretePathEffect.h"
#include "src/core/SkMakeUnique.h"

namespace skia {
namespace textlayout {
Expand Down
3 changes: 1 addition & 2 deletions modules/skresources/src/SkResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "include/core/SkImage.h"
#include "include/utils/SkAnimCodecPlayer.h"
#include "include/utils/SkBase64.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkOSFile.h"
#include "src/utils/SkOSPath.h"

Expand All @@ -21,7 +20,7 @@ namespace skresources {
sk_sp<MultiFrameImageAsset> MultiFrameImageAsset::Make(sk_sp<SkData> data, bool predecode) {
if (auto codec = SkCodec::MakeFromData(std::move(data))) {
return sk_sp<MultiFrameImageAsset>(
new MultiFrameImageAsset(skstd::make_unique<SkAnimCodecPlayer>(std::move(codec)),
new MultiFrameImageAsset(std::make_unique<SkAnimCodecPlayer>(std::move(codec)),
predecode));
}

Expand Down
3 changes: 1 addition & 2 deletions modules/sksg/src/SkSGRenderEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkMaskFilter.h"
#include "include/core/SkShader.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkMaskFilterBase.h"

namespace sksg {
Expand Down Expand Up @@ -178,7 +177,7 @@ void ImageFilterEffect::onRender(SkCanvas* canvas, const RenderContext* ctx) con
}

ImageFilter::ImageFilter(sk_sp<ImageFilter> input)
: ImageFilter(input ? skstd::make_unique<InputsT>(1, std::move(input)) : nullptr) {}
: ImageFilter(input ? std::make_unique<InputsT>(1, std::move(input)) : nullptr) {}

ImageFilter::ImageFilter(std::unique_ptr<InputsT> inputs)
: INHERITED(kBubbleDamage_Trait)
Expand Down
11 changes: 5 additions & 6 deletions modules/skshaper/src/SkShaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "include/core/SkTypeface.h"
#include "include/private/SkTFitsIn.h"
#include "modules/skshaper/include/SkShaper.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkTextBlobPriv.h"
#include "src/utils/SkUTF.h"

Expand Down Expand Up @@ -42,7 +41,7 @@ SkShaper::MakeBiDiRunIterator(const char* utf8, size_t utf8Bytes, uint8_t bidiLe
return bidi;
}
#endif
return skstd::make_unique<SkShaper::TrivialBiDiRunIterator>(bidiLevel, utf8Bytes);
return std::make_unique<SkShaper::TrivialBiDiRunIterator>(bidiLevel, utf8Bytes);
}

std::unique_ptr<SkShaper::ScriptRunIterator>
Expand All @@ -54,7 +53,7 @@ SkShaper::MakeScriptRunIterator(const char* utf8, size_t utf8Bytes, SkFourByteTa
return script;
}
#endif
return skstd::make_unique<SkShaper::TrivialScriptRunIterator>(scriptTag, utf8Bytes);
return std::make_unique<SkShaper::TrivialScriptRunIterator>(scriptTag, utf8Bytes);
}

SkShaper::SkShaper() {}
Expand Down Expand Up @@ -165,7 +164,7 @@ std::unique_ptr<SkShaper::FontRunIterator>
SkShaper::MakeFontMgrRunIterator(const char* utf8, size_t utf8Bytes,
const SkFont& font, sk_sp<SkFontMgr> fallback)
{
return skstd::make_unique<FontMgrRunIterator>(utf8, utf8Bytes, font, std::move(fallback));
return std::make_unique<FontMgrRunIterator>(utf8, utf8Bytes, font, std::move(fallback));
}

std::unique_ptr<SkShaper::FontRunIterator>
Expand All @@ -174,13 +173,13 @@ SkShaper::MakeFontMgrRunIterator(const char* utf8, size_t utf8Bytes, const SkFon
const char* requestName, SkFontStyle requestStyle,
const SkShaper::LanguageRunIterator* language)
{
return skstd::make_unique<FontMgrRunIterator>(utf8, utf8Bytes, font, std::move(fallback),
return std::make_unique<FontMgrRunIterator>(utf8, utf8Bytes, font, std::move(fallback),
requestName, requestStyle, language);
}

std::unique_ptr<SkShaper::LanguageRunIterator>
SkShaper::MakeStdLanguageRunIterator(const char* utf8, size_t utf8Bytes) {
return skstd::make_unique<TrivialLanguageRunIterator>(std::locale().name().c_str(), utf8Bytes);
return std::make_unique<TrivialLanguageRunIterator>(std::locale().name().c_str(), utf8Bytes);
}

void SkTextBlobBuilderRunHandler::beginLine() {
Expand Down
11 changes: 5 additions & 6 deletions modules/skshaper/src/SkShaper_harfbuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "include/private/SkTemplates.h"
#include "include/private/SkTo.h"
#include "modules/skshaper/include/SkShaper.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkSpan.h"
#include "src/core/SkTDPQueue.h"
#include "src/utils/SkUTF.h"
Expand Down Expand Up @@ -762,12 +761,12 @@ static std::unique_ptr<SkShaper> MakeHarfBuzz(sk_sp<SkFontMgr> fontmgr, bool cor
}

if (correct) {
return skstd::make_unique<ShaperDrivenWrapper>(std::move(buffer),
return std::make_unique<ShaperDrivenWrapper>(std::move(buffer),
std::move(lineBreakIterator),
std::move(graphemeBreakIterator),
std::move(fontmgr));
} else {
return skstd::make_unique<ShapeThenWrap>(std::move(buffer),
return std::make_unique<ShapeThenWrap>(std::move(buffer),
std::move(lineBreakIterator),
std::move(graphemeBreakIterator),
std::move(fontmgr));
Expand Down Expand Up @@ -1432,12 +1431,12 @@ SkShaper::MakeIcuBiDiRunIterator(const char* utf8, size_t utf8Bytes, uint8_t bid
return nullptr;
}

return skstd::make_unique<IcuBiDiRunIterator>(utf8, utf8 + utf8Bytes, std::move(bidi));
return std::make_unique<IcuBiDiRunIterator>(utf8, utf8 + utf8Bytes, std::move(bidi));
}

std::unique_ptr<SkShaper::ScriptRunIterator>
SkShaper::MakeHbIcuScriptRunIterator(const char* utf8, size_t utf8Bytes) {
return skstd::make_unique<HbIcuScriptRunIterator>(utf8, utf8Bytes);
return std::make_unique<HbIcuScriptRunIterator>(utf8, utf8Bytes);
}

std::unique_ptr<SkShaper> SkShaper::MakeShaperDrivenWrapper(sk_sp<SkFontMgr> fontmgr) {
Expand All @@ -1459,6 +1458,6 @@ std::unique_ptr<SkShaper> SkShaper::MakeShapeDontWrapOrReorder(sk_sp<SkFontMgr>
return nullptr;
}

return skstd::make_unique<ShapeDontWrapOrReorder>(std::move(buffer), nullptr, nullptr,
return std::make_unique<ShapeDontWrapOrReorder>(std::move(buffer), nullptr, nullptr,
std::move(fontmgr));
}
Loading

0 comments on commit f46d5ca

Please sign in to comment.