Enable ClangTidy check modernize-make-unique.

The majority of existing call sites were automatically updated using
clang-tidy -fix. A small handful required a manual update,
e.g. CppCodeGen.

This check is a bit lenient, and in particular will not flag cases like
`std::unique_ptr<Base>(new Derived())` which is still pretty common
throughout our codebase. This CL does not attempt to replace all the
cases that ClangTidy does not flag.

Change-Id: I5eba48ef880e25d22de80f321a68c389ba769e36
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307459
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
John Stiles 2020-08-03 13:21:46 -04:00 committed by Skia Commit-Bot
parent 1788380a97
commit fbd050bd0b
100 changed files with 415 additions and 351 deletions

View File

@ -1 +1 @@
Checks: '-*,bugprone-use-after-move,bugprone-unused-raii,bugprone-undelegated-constructor,bugprone-argument-comment,performance-for-range-copy,bugprone-bool-pointer-implicit-conversion,readability-redundant-preprocessor,misc-definitions-in-headers,google-build-namespaces'
Checks: '-*,bugprone-use-after-move,bugprone-unused-raii,bugprone-undelegated-constructor,bugprone-argument-comment,performance-for-range-copy,bugprone-bool-pointer-implicit-conversion,readability-redundant-preprocessor,misc-definitions-in-headers,modernize-make-unique,google-build-namespaces'

View File

@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
#include <memory>
#include "bench/Benchmark.h"
#include "include/core/SkCanvas.h"
@ -97,7 +99,7 @@ protected:
kPremul_SkAlphaType, nullptr);
SkRandom random;
int numImages = fLayerCnt * fTileGridSize.fWidth * fTileGridSize.fHeight;
fImages.reset(new sk_sp<SkImage>[numImages]);
fImages = std::make_unique<sk_sp<SkImage>[]>(numImages);
for (int i = 0; i < numImages; ++i) {
auto surf = canvas->makeSurface(ii);
SkColor color = random.nextU();

View File

@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
#include <memory>
#include "bench/Benchmark.h"
#include "include/core/SkCanvas.h"
@ -75,7 +77,7 @@ private:
SkSurfaceCharacterization c = create_characterization(context);
fRecorder.reset(new SkDeferredDisplayListRecorder(c));
fRecorder = std::make_unique<SkDeferredDisplayListRecorder>(c);
}
// We defer the clean up of the DDLs so it is done outside of the timing loop

View File

@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
#include <memory>
#include "bench/Benchmark.h"
#include "include/core/SkCanvas.h"
@ -37,7 +39,7 @@ protected:
auto ii = SkImageInfo::Make(kImageSize.fWidth, kImageSize.fHeight, kRGBA_8888_SkColorType,
kPremul_SkAlphaType, nullptr);
SkRandom random;
fImages.reset(new sk_sp<SkImage>[fImageCnt]);
fImages = std::make_unique<sk_sp<SkImage>[]>(fImageCnt);
for (int i = 0; i < fImageCnt; ++i) {
auto surf = canvas->makeSurface(ii);
SkColor color = random.nextU();

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <memory>
#include "bench/Benchmark.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
@ -43,8 +45,8 @@ public:
void onDelayedSetup() override {
std::unique_ptr<SkBBHFactory> factory;
switch (fBBH) {
case kNone: break;
case kRTree: factory.reset(new SkRTreeFactory); break;
case kNone: break;
case kRTree: factory = std::make_unique<SkRTreeFactory>(); break;
}
SkPictureRecorder recorder;

View File

@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
#include <memory>
#include "bench/Benchmark.h"
#include "include/core/SkSize.h"
#include "include/private/SkTDArray.h"
@ -25,8 +27,8 @@
*/
class RectanizerBench : public Benchmark {
public:
static const int kWidth = 1024;
static const int kHeight = 1024;
static constexpr int kWidth = 1024;
static constexpr int kHeight = 1024;
enum RectanizerType {
kPow2_RectanizerType,
@ -74,10 +76,10 @@ protected:
SkASSERT(nullptr == fRectanizer.get());
if (kPow2_RectanizerType == fRectanizerType) {
fRectanizer.reset(new GrRectanizerPow2(kWidth, kHeight));
fRectanizer = std::make_unique<GrRectanizerPow2>(kWidth, kHeight);
} else {
SkASSERT(kSkyline_RectanizerType == fRectanizerType);
fRectanizer.reset(new GrRectanizerSkyline(kWidth, kHeight));
fRectanizer = std::make_unique<GrRectanizerSkyline>(kWidth, kHeight);
}
}

View File

@ -58,6 +58,7 @@
#include <cinttypes>
#include <stdlib.h>
#include <memory>
#include <thread>
extern bool gSkForceRasterPipelineBlitter;
@ -246,7 +247,7 @@ struct GPUTarget : public Target {
bool init(SkImageInfo info, Benchmark* bench) override {
GrContextOptions options = grContextOpts;
bench->modifyGrContextOptions(&options);
this->factory.reset(new GrContextFactory(options));
this->factory = std::make_unique<GrContextFactory>(options);
uint32_t flags = this->config.useDFText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag :
0;
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);

View File

@ -10,6 +10,7 @@
#include "FrontBufferedStream.h"
#include <algorithm>
#include <memory>
namespace {
class FrontBufferedStream : public SkStreamRewindable {
@ -76,8 +77,8 @@ std::unique_ptr<SkStreamRewindable> FrontBufferedStream::Make(std::unique_ptr<Sk
if (!stream) {
return nullptr;
}
auto frontBufferedStream = std::unique_ptr<::FrontBufferedStream>(
new ::FrontBufferedStream(std::move(stream), bufferSize));
auto frontBufferedStream = std::make_unique<::FrontBufferedStream>(
std::move(stream), bufferSize);
if (frontBufferedStream->failedToAllocateBuffer()) {
return nullptr;
}

View File

@ -40,6 +40,7 @@
#include "tools/trace/EventTracingPriv.h"
#include "tools/trace/SkDebugfTracer.h"
#include <memory>
#include <vector>
#include <stdlib.h>
@ -1168,7 +1169,7 @@ struct Task {
hash.writeStream(data, data->getLength());
data->rewind();
} else {
hashAndEncode.reset(new HashAndEncode(bitmap));
hashAndEncode = std::make_unique<HashAndEncode>(bitmap);
hashAndEncode->write(&hash);
}
SkMD5::Digest digest = hash.finish();
@ -1227,7 +1228,7 @@ struct Task {
CGContextDrawPDFPage(ctx.get(), page);
// Skip calling hashAndEncode->write(SkMD5*)... we want the .pdf's hash.
hashAndEncode.reset(new HashAndEncode(rasterized));
hashAndEncode = std::make_unique<HashAndEncode>(rasterized);
WriteToDisk(task, md5, "png", nullptr,0, &rasterized, hashAndEncode.get());
} else
#endif

View File

@ -1,5 +1,7 @@
// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include <memory>
#include "tools/fiddle/examples.h"
// HASH=4486d0c0b22ad2931db130f42da4c80c
REG_FIDDLE(Canvas_accessTopRasterHandle, 256, 256, true, 0) {
@ -25,8 +27,7 @@ public:
void draw(SkCanvas* canvas) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1);
std::unique_ptr<SkCanvas> c2 =
SkRasterHandleAllocator::MakeCanvas(std::unique_ptr<CustomAllocator>(
new CustomAllocator()), info);
SkRasterHandleAllocator::MakeCanvas(std::make_unique<CustomAllocator>(), info);
char* context = (char*) c2->accessTopRasterHandle();
SkDebugf("context = %.4s\n", context);
}

View File

@ -230,7 +230,7 @@ protected:
break;
}
data.reset(new SkPoint[numPts]);
data = std::make_unique<SkPoint[]>(numPts);
create_ngon(numPts, data.get(), width, height);
points = data.get();

View File

@ -201,13 +201,13 @@ static std::unique_ptr<GrFragmentProcessor> wrap(std::unique_ptr<GrFragmentProce
EffectType effectType) {
switch (effectType) {
case kConstant:
return std::unique_ptr<GrFragmentProcessor>(new ConstantMatrixEffect(std::move(fp)));
return std::make_unique<ConstantMatrixEffect>(std::move(fp));
case kUniform:
return std::unique_ptr<GrFragmentProcessor>(new UniformMatrixEffect(std::move(fp)));
return std::make_unique<UniformMatrixEffect>(std::move(fp));
case kVariable:
return std::unique_ptr<GrFragmentProcessor>(new VariableMatrixEffect(std::move(fp)));
return std::make_unique<VariableMatrixEffect>(std::move(fp));
case kExplicit:
return std::unique_ptr<GrFragmentProcessor>(new ExplicitCoordEffect(std::move(fp)));
return std::make_unique<ExplicitCoordEffect>(std::move(fp));
}
SkUNREACHABLE;
}

View File

@ -443,7 +443,7 @@ protected:
if (index < (int)SK_ARRAY_COUNT(PolygonOffsetData::gConvexPoints)) {
// manually specified
*numPts = (int)PolygonOffsetData::gConvexSizes[index];
data->reset(new SkPoint[*numPts]);
*data = std::make_unique<SkPoint[]>(*numPts);
if (SkPathDirection::kCW == dir) {
for (int i = 0; i < *numPts; ++i) {
(*data)[i] = PolygonOffsetData::gConvexPoints[index][i];
@ -467,7 +467,7 @@ protected:
width = kMaxPathHeight / 5;
}
data->reset(new SkPoint[*numPts]);
*data = std::make_unique<SkPoint[]>(*numPts);
create_ngon(*numPts, data->get(), width, height, dir);
}
@ -478,7 +478,7 @@ protected:
if (index < (int)SK_ARRAY_COUNT(PolygonOffsetData::gSimplePoints)) {
// manually specified
*numPts = (int)PolygonOffsetData::gSimpleSizes[index];
data->reset(new SkPoint[*numPts]);
*data = std::make_unique<SkPoint[]>(*numPts);
if (SkPathDirection::kCW == dir) {
for (int i = 0; i < *numPts; ++i) {
(*data)[i] = PolygonOffsetData::gSimplePoints[index][i];
@ -501,7 +501,7 @@ protected:
// squash horizontally
width = kMaxPathHeight / 5;
data->reset(new SkPoint[*numPts]);
*data = std::make_unique<SkPoint[]>(*numPts);
create_ngon(*numPts, data->get(), width, height, dir);
}

View File

@ -8,6 +8,8 @@
#ifndef SkEncodedInfo_DEFINED
#define SkEncodedInfo_DEFINED
#include <memory>
#include "include/core/SkData.h"
#include "include/core/SkImageInfo.h"
#include "include/third_party/skcms/skcms.h"
@ -220,7 +222,7 @@ public:
SkEncodedInfo copy() const {
auto copy = SkEncodedInfo::Make(fWidth, fHeight, fColor, fAlpha, fBitsPerComponent);
if (fProfile) {
copy.fProfile.reset(new ICCProfile(*fProfile.get()));
copy.fProfile = std::make_unique<ICCProfile>(*fProfile.get());
}
return copy;
}

View File

@ -35,6 +35,7 @@
#include <chrono>
#include <cmath>
#include <memory>
#include "stdlib.h"
@ -238,7 +239,7 @@ bool AnimationBuilder::dispatchColorProperty(const sk_sp<sksg::Color>& c) const
fPropertyObserver->onColorProperty(fPropertyObserverContext,
[&]() {
dispatched = true;
return std::unique_ptr<ColorPropertyHandle>(new ColorPropertyHandle(c));
return std::make_unique<ColorPropertyHandle>(c);
});
}
@ -252,7 +253,7 @@ bool AnimationBuilder::dispatchOpacityProperty(const sk_sp<sksg::OpacityEffect>&
fPropertyObserver->onOpacityProperty(fPropertyObserverContext,
[&]() {
dispatched = true;
return std::unique_ptr<OpacityPropertyHandle>(new OpacityPropertyHandle(o));
return std::make_unique<OpacityPropertyHandle>(o);
});
}
@ -266,7 +267,7 @@ bool AnimationBuilder::dispatchTextProperty(const sk_sp<TextAdapter>& t) const {
fPropertyObserver->onTextProperty(fPropertyObserverContext,
[&]() {
dispatched = true;
return std::unique_ptr<TextPropertyHandle>(new TextPropertyHandle(t));
return std::make_unique<TextPropertyHandle>(t);
});
}
@ -280,7 +281,7 @@ bool AnimationBuilder::dispatchTransformProperty(const sk_sp<TransformAdapter2D>
fPropertyObserver->onTransformProperty(fPropertyObserverContext,
[&]() {
dispatched = true;
return std::unique_ptr<TransformPropertyHandle>(new TransformPropertyHandle(t));
return std::make_unique<TransformPropertyHandle>(t);
});
}

View File

@ -1,4 +1,6 @@
// Copyright 2019 Google LLC.
#include <memory>
#include "modules/skparagraph/include/ParagraphCache.h"
#include "modules/skparagraph/src/ParagraphImpl.h"
@ -278,7 +280,7 @@ bool ParagraphCache::updateParagraph(ParagraphImpl* paragraph) {
std::unique_ptr<Entry>* entry = fLRUCacheMap.find(key);
if (!entry) {
ParagraphCacheValue* value = new ParagraphCacheValue(paragraph);
fLRUCacheMap.insert(key, std::unique_ptr<Entry>(new Entry(value)));
fLRUCacheMap.insert(key, std::make_unique<Entry>(value));
fChecker(paragraph, "addedParagraph", true);
return true;
} else {

View File

@ -25,6 +25,7 @@
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <tuple>
#include <type_traits>
#include <utility>
@ -571,7 +572,7 @@ std::unique_ptr<Run> TextLine::shapeEllipsis(const SkString& ellipsis, Run* run)
Buffer runBuffer(const RunInfo& info) override {
SkASSERT(!fRun);
fRun = std::unique_ptr<Run>(new Run(nullptr, info, 0, fLineHeight, 0, 0));
fRun = std::make_unique<Run>(nullptr, info, 0, fLineHeight, 0, 0);
return fRun->newRunBuffer();
}

View File

@ -903,7 +903,7 @@ void ShaperDrivenWrapper::wrap(char const * const utf8, size_t utf8Bytes,
modelGlyphOffset = 0;
SkVector advance = {0, 0};
modelText.reset(new TextProps[utf8runLength + 1]());
modelText = std::make_unique<TextProps[]>(utf8runLength + 1);
size_t modelStartCluster = utf8Start - utf8;
for (size_t i = 0; i < model.fNumGlyphs; ++i) {
SkASSERT(modelStartCluster <= model.fGlyphs[i].fCluster);
@ -990,7 +990,7 @@ void ShaperDrivenWrapper::wrap(char const * const utf8, size_t utf8Bytes,
line.fAdvance = {0, 0};
} else {
if (bestUsesModelForGlyphs) {
best.fGlyphs.reset(new ShapedGlyph[best.fNumGlyphs]);
best.fGlyphs = std::make_unique<ShapedGlyph[]>(best.fNumGlyphs);
memcpy(best.fGlyphs.get(), model.fGlyphs.get() + modelGlyphOffset,
best.fNumGlyphs * sizeof(ShapedGlyph));
modelGlyphOffset += best.fNumGlyphs;

View File

@ -5,9 +5,12 @@
* found in the LICENSE file.
*/
#include "src/codec/SkBmpCodec.h"
#include <memory>
#include "include/core/SkStream.h"
#include "include/private/SkColorData.h"
#include "src/codec/SkBmpCodec.h"
#include "src/codec/SkBmpMaskCodec.h"
#include "src/codec/SkBmpRLECodec.h"
#include "src/codec/SkBmpStandardCodec.h"
@ -482,11 +485,11 @@ SkCodec::Result SkBmpCodec::ReadHeader(SkStream* stream, bool inIco,
// Set the image info and create a codec.
auto info = SkEncodedInfo::Make(width, height, color, alpha, bitsPerComponent);
codecOut->reset(new SkBmpStandardCodec(std::move(info),
*codecOut = std::make_unique<SkBmpStandardCodec>(std::move(info),
std::unique_ptr<SkStream>(stream),
bitsPerPixel, numColors, bytesPerColor,
offset - bytesRead, rowOrder, isOpaque,
inIco));
inIco);
return static_cast<SkBmpStandardCodec*>(codecOut->get())->didCreateSrcBuffer()
? kSuccess : kInvalidInput;
}
@ -541,9 +544,9 @@ SkCodec::Result SkBmpCodec::ReadHeader(SkStream* stream, bool inIco,
alpha = SkEncodedInfo::kOpaque_Alpha;
}
auto info = SkEncodedInfo::Make(width, height, color, alpha, 8);
codecOut->reset(new SkBmpMaskCodec(std::move(info),
*codecOut = std::make_unique<SkBmpMaskCodec>(std::move(info),
std::unique_ptr<SkStream>(stream), bitsPerPixel,
masks.release(), rowOrder));
masks.release(), rowOrder);
return static_cast<SkBmpMaskCodec*>(codecOut->get())->didCreateSrcBuffer()
? kSuccess : kInvalidInput;
}
@ -573,10 +576,10 @@ SkCodec::Result SkBmpCodec::ReadHeader(SkStream* stream, bool inIco,
// For that reason, we always indicate that we are kBGRA.
auto info = SkEncodedInfo::Make(width, height, SkEncodedInfo::kBGRA_Color,
SkEncodedInfo::kBinary_Alpha, 8);
codecOut->reset(new SkBmpRLECodec(std::move(info),
*codecOut = std::make_unique<SkBmpRLECodec>(std::move(info),
std::unique_ptr<SkStream>(stream), bitsPerPixel,
numColors, bytesPerColor, offset - bytesRead,
rowOrder));
rowOrder);
}
return kSuccess;
}

View File

@ -5,9 +5,12 @@
* found in the LICENSE file.
*/
#include "src/codec/SkBmpRLECodec.h"
#include <memory>
#include "include/core/SkStream.h"
#include "include/private/SkColorData.h"
#include "src/codec/SkBmpRLECodec.h"
#include "src/codec/SkCodecPriv.h"
/*
@ -552,7 +555,7 @@ private:
SkSampler* SkBmpRLECodec::getSampler(bool createIfNecessary) {
if (!fSampler && createIfNecessary) {
fSampler.reset(new SkBmpRLESampler(this));
fSampler = std::make_unique<SkBmpRLESampler>(this);
}
return fSampler.get();

View File

@ -35,6 +35,7 @@
#include <cmath> // for std::round,floor,ceil
#include <limits>
#include <memory>
namespace {
@ -566,9 +567,9 @@ private:
bool readDng() {
try {
// Due to the limit of DNG SDK, we need to reset host and info.
fHost.reset(new SkDngHost(&fAllocator));
fInfo.reset(new dng_info);
fDngStream.reset(new SkDngStream(fStream.get()));
fHost = std::make_unique<SkDngHost>(&fAllocator);
fInfo = std::make_unique<dng_info>();
fDngStream = std::make_unique<SkDngStream>(fStream.get());
fHost->ValidateSizes();
fInfo->Parse(*fHost, *fDngStream);
@ -620,9 +621,9 @@ std::unique_ptr<SkCodec> SkRawCodec::MakeFromStream(std::unique_ptr<SkStream> st
Result* result) {
std::unique_ptr<SkRawStream> rawStream;
if (is_asset_stream(*stream)) {
rawStream.reset(new SkRawAssetStream(std::move(stream)));
rawStream = std::make_unique<SkRawAssetStream>(std::move(stream));
} else {
rawStream.reset(new SkRawBufferedStream(std::move(stream)));
rawStream = std::make_unique<SkRawBufferedStream>(std::move(stream));
}
// Does not take the ownership of rawStream.

View File

@ -47,6 +47,7 @@
#include "src/image/SkSurface_Base.h"
#include "src/utils/SkPatchUtils.h"
#include <memory>
#include <new>
#if SK_SUPPORT_GPU
@ -1241,7 +1242,8 @@ void SkCanvas::internalSaveBehind(const SkRect* localBounds) {
// we really need the save, so we can wack the fMCRec
this->checkForDeferredSave();
fMCRec->fBackImage.reset(new BackImage{std::move(backImage), devBounds.topLeft()});
fMCRec->fBackImage =
std::make_unique<BackImage>(BackImage{std::move(backImage), devBounds.topLeft()});
SkPaint paint;
paint.setBlendMode(SkBlendMode::kClear);

View File

@ -12,9 +12,11 @@
#include "include/private/SkChecksum.h"
#include "src/core/SkPictureFlat.h"
#include <memory>
///////////////////////////////////////////////////////////////////////////////
void SkTypefacePlayback::setCount(size_t count) {
fCount = count;
fArray.reset(new sk_sp<SkTypeface>[count]);
fArray = std::make_unique<sk_sp<SkTypeface>[]>(count);
}

View File

@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
#include <memory>
#include "include/core/SkData.h"
#include "include/core/SkDrawable.h"
#include "include/core/SkPictureRecorder.h"
@ -19,8 +21,8 @@
SkPictureRecorder::SkPictureRecorder() {
fActivelyRecording = false;
fMiniRecorder.reset(new SkMiniRecorder);
fRecorder.reset(new SkRecorder(nullptr, SkRect::MakeEmpty(), fMiniRecorder.get()));
fMiniRecorder = std::make_unique<SkMiniRecorder>();
fRecorder = std::make_unique<SkRecorder>(nullptr, SkRect::MakeEmpty(), fMiniRecorder.get());
}
SkPictureRecorder::~SkPictureRecorder() {}

View File

@ -15,6 +15,7 @@
#include "src/core/SkCanvasPriv.h"
#include "src/utils/SkPatchUtils.h"
#include <memory>
#include <new>
SkDrawableList::~SkDrawableList() {
@ -178,7 +179,7 @@ void SkRecorder::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const
void SkRecorder::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
if (fDrawPictureMode == Record_DrawPictureMode) {
if (!fDrawableList) {
fDrawableList.reset(new SkDrawableList);
fDrawableList = std::make_unique<SkDrawableList>();
}
fDrawableList->append(drawable);
this->append<SkRecords::DrawDrawable>(this->copy(matrix), drawable->getBounds(), fDrawableList->count() - 1);

View File

@ -5,9 +5,12 @@
* found in the LICENSE file
*/
#include "src/core/SkSpecialSurface.h"
#include <memory>
#include "include/core/SkCanvas.h"
#include "src/core/SkSpecialImage.h"
#include "src/core/SkSpecialSurface.h"
#include "src/core/SkSurfacePriv.h"
///////////////////////////////////////////////////////////////////////////////
@ -70,7 +73,7 @@ public:
fBitmap.setInfo(info, info.minRowBytes());
fBitmap.setPixelRef(std::move(pr), 0, 0);
fCanvas.reset(new SkCanvas(fBitmap, this->props()));
fCanvas = std::make_unique<SkCanvas>(fBitmap, this->props());
fCanvas->clipRect(SkRect::Make(subset));
#ifdef SK_IS_BOT
fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness
@ -132,7 +135,7 @@ public:
return;
}
fCanvas.reset(new SkCanvas(std::move(device)));
fCanvas = std::make_unique<SkCanvas>(std::move(device));
fCanvas->clipRect(SkRect::Make(subset));
#ifdef SK_IS_BOT
fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness

View File

@ -11,6 +11,8 @@
#include "src/core/SkSafeMath.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/GrBufferAllocPool.h"
#include <memory>
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrCpuBuffer.h"
@ -26,7 +28,7 @@ sk_sp<GrBufferAllocPool::CpuBufferCache> GrBufferAllocPool::CpuBufferCache::Make
GrBufferAllocPool::CpuBufferCache::CpuBufferCache(int maxBuffersToCache)
: fMaxBuffersToCache(maxBuffersToCache) {
if (fMaxBuffersToCache) {
fBuffers.reset(new Buffer[fMaxBuffersToCache]);
fBuffers = std::make_unique<Buffer[]>(fMaxBuffersToCache);
}
}

View File

@ -36,6 +36,7 @@
#include "src/image/SkImage_GpuBase.h"
#include "src/image/SkSurface_Gpu.h"
#include <atomic>
#include <memory>
#define ASSERT_OWNED_PROXY(P) \
SkASSERT(!(P) || !((P)->peekTexture()) || (P)->peekTexture()->getContext() == this)
@ -73,7 +74,7 @@ bool GrContext::init() {
SkASSERT(this->getTextBlobCache());
if (fGpu) {
fStrikeCache.reset(new GrStrikeCache{});
fStrikeCache = std::make_unique<GrStrikeCache>();
fResourceCache = new GrResourceCache(this->caps(), this->singleOwner(), this->contextID());
fResourceProvider = new GrResourceProvider(fGpu.get(), fResourceCache, this->singleOwner());
fMappedBufferManager = std::make_unique<GrClientMappedBufferManager>(this->contextID());

View File

@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
#include <memory>
#include "include/gpu/GrContextThreadSafeProxy.h"
#include "src/gpu/GrContextThreadSafeProxyPriv.h"
@ -36,7 +38,7 @@ GrContextThreadSafeProxy::~GrContextThreadSafeProxy() = default;
void GrContextThreadSafeProxy::init(sk_sp<const GrCaps> caps) {
fCaps = std::move(caps);
fTextBlobCache.reset(new GrTextBlobCache(fContextID));
fTextBlobCache = std::make_unique<GrTextBlobCache>(fContextID);
}
SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(

View File

@ -7,6 +7,8 @@
#include "src/gpu/GrDrawOpAtlas.h"
#include <memory>
#include "src/core/SkOpts.h"
#include "src/gpu/GrOnFlushResourceProvider.h"
#include "src/gpu/GrOpFlushState.h"
@ -608,7 +610,7 @@ bool GrDrawOpAtlas::createPages(
fViews[i] = GrSurfaceProxyView(std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle);
// set up allocated plots
fPages[i].fPlotArray.reset(new sk_sp<Plot>[ numPlotsX * numPlotsY ]);
fPages[i].fPlotArray = std::make_unique<sk_sp<Plot>[]>(numPlotsX * numPlotsY);
sk_sp<Plot>* currPlot = fPages[i].fPlotArray.get();
for (int y = numPlotsY - 1, r = 0; y >= 0; --y, ++r) {

View File

@ -7,6 +7,8 @@
#include "src/gpu/GrDrawingManager.h"
#include <memory>
#include "include/core/SkDeferredDisplayList.h"
#include "include/gpu/GrBackendSemaphore.h"
#include "include/gpu/GrDirectContext.h"
@ -915,7 +917,8 @@ GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawP
GrPathRenderer::StencilSupport* stencilSupport) {
if (!fPathRendererChain) {
fPathRendererChain.reset(new GrPathRendererChain(fContext, fOptionsForPathRendererChain));
fPathRendererChain =
std::make_unique<GrPathRendererChain>(fContext, fOptionsForPathRendererChain);
}
GrPathRenderer* pr = fPathRendererChain->getPathRenderer(args, drawType, stencilSupport);
@ -946,7 +949,7 @@ GrPathRenderer* GrDrawingManager::getSoftwarePathRenderer() {
GrCoverageCountingPathRenderer* GrDrawingManager::getCoverageCountingPathRenderer() {
if (!fPathRendererChain) {
fPathRendererChain.reset(new GrPathRendererChain(fContext, fOptionsForPathRendererChain));
fPathRendererChain = std::make_unique<GrPathRendererChain>(fContext, fOptionsForPathRendererChain);
}
return fPathRendererChain->getCoverageCountingPathRenderer();
}

View File

@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
#include <memory>
#include "include/private/GrImageContext.h"
#include "src/gpu/GrCaps.h"
@ -16,7 +18,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
GrImageContext::GrImageContext(sk_sp<GrContextThreadSafeProxy> proxy)
: INHERITED(std::move(proxy)) {
fProxyProvider.reset(new GrProxyProvider(this));
fProxyProvider = std::make_unique<GrProxyProvider>(this);
}
GrImageContext::~GrImageContext() {}

View File

@ -7,6 +7,8 @@
#include "src/gpu/GrProcessorUnitTest.h"
#include <memory>
#include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrRecordingContextPriv.h"
@ -24,7 +26,7 @@ GrProcessorTestData::GrProcessorTestData(SkRandom* random, GrRecordingContext* c
std::unique_ptr<GrFragmentProcessor> inputFP)
: fRandom(random), fContext(context), fInputFP(std::move(inputFP)) {
fViews.reset(views, numViews);
fArena = std::unique_ptr<SkArenaAlloc>(new SkArenaAlloc(1000));
fArena = std::make_unique<SkArenaAlloc>(1000);
}
GrProcessorTestData::~GrProcessorTestData() {}

View File

@ -7,6 +7,8 @@
#include "src/gpu/GrSurfaceContext.h"
#include <memory>
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "src/core/SkAutoPixmapStorage.h"
@ -54,12 +56,12 @@ std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* con
context->priv().caps()->getWriteSwizzle(proxy->backendFormat(), colorType);
}
GrSurfaceProxyView writeView(readView.refProxy(), readView.origin(), writeSwizzle);
surfaceContext.reset(new GrRenderTargetContext(context, std::move(readView),
surfaceContext = std::make_unique<GrRenderTargetContext>(context, std::move(readView),
std::move(writeView), colorType,
std::move(colorSpace), nullptr));
std::move(colorSpace), nullptr);
} else {
surfaceContext.reset(new GrSurfaceContext(context, std::move(readView), colorType,
alphaType, std::move(colorSpace)));
surfaceContext = std::make_unique<GrSurfaceContext>(context, std::move(readView), colorType,
alphaType, std::move(colorSpace));
}
SkDEBUGCODE(surfaceContext->validate();)
return surfaceContext;
@ -267,7 +269,7 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz
size_t tmpRB = tmpInfo.minRowBytes();
size_t size = tmpRB * tmpInfo.height();
// Chrome MSAN bots require the data to be initialized (hence the ()).
tmpPixels.reset(new char[size]());
tmpPixels = std::make_unique<char[]>(size);
readDst = tmpPixels.get();
readRB = tmpRB;

View File

@ -108,7 +108,7 @@ GrAARectEffect::GrAARectEffect(const GrAARectEffect& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrAARectEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrAARectEffect(*this));
return std::make_unique<GrAARectEffect>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAARectEffect);
#if GR_TEST_UTILS

View File

@ -94,7 +94,7 @@ GrAlphaThresholdFragmentProcessor::GrAlphaThresholdFragmentProcessor(
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor(*this));
return std::make_unique<GrAlphaThresholdFragmentProcessor>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor);
#if GR_TEST_UTILS

View File

@ -79,7 +79,7 @@ GrArithmeticProcessor::GrArithmeticProcessor(const GrArithmeticProcessor& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrArithmeticProcessor::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrArithmeticProcessor(*this));
return std::make_unique<GrArithmeticProcessor>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticProcessor);
#if GR_TEST_UTILS

View File

@ -68,5 +68,5 @@ GrBlurredEdgeFragmentProcessor::GrBlurredEdgeFragmentProcessor(
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrBlurredEdgeFragmentProcessor::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(*this));
return std::make_unique<GrBlurredEdgeFragmentProcessor>(*this);
}

View File

@ -358,7 +358,7 @@ GrCircleBlurFragmentProcessor::GrCircleBlurFragmentProcessor(
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrCircleBlurFragmentProcessor(*this));
return std::make_unique<GrCircleBlurFragmentProcessor>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor);
#if GR_TEST_UTILS

View File

@ -119,7 +119,7 @@ GrCircleEffect::GrCircleEffect(const GrCircleEffect& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrCircleEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrCircleEffect(*this));
return std::make_unique<GrCircleEffect>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleEffect);
#if GR_TEST_UTILS

View File

@ -63,7 +63,7 @@ GrClampFragmentProcessor::GrClampFragmentProcessor(const GrClampFragmentProcesso
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrClampFragmentProcessor::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrClampFragmentProcessor(*this));
return std::make_unique<GrClampFragmentProcessor>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrClampFragmentProcessor);
#if GR_TEST_UTILS

View File

@ -121,7 +121,7 @@ GrColorMatrixFragmentProcessor::GrColorMatrixFragmentProcessor(
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrColorMatrixFragmentProcessor::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrColorMatrixFragmentProcessor(*this));
return std::make_unique<GrColorMatrixFragmentProcessor>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrColorMatrixFragmentProcessor);
#if GR_TEST_UTILS

View File

@ -61,5 +61,5 @@ GrComposeLerpEffect::GrComposeLerpEffect(const GrComposeLerpEffect& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrComposeLerpEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrComposeLerpEffect(*this));
return std::make_unique<GrComposeLerpEffect>(*this);
}

View File

@ -68,7 +68,7 @@ GrConfigConversionEffect::GrConfigConversionEffect(const GrConfigConversionEffec
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrConfigConversionEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrConfigConversionEffect(*this));
return std::make_unique<GrConfigConversionEffect>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConfigConversionEffect);
#if GR_TEST_UTILS

View File

@ -65,7 +65,7 @@ GrConstColorProcessor::GrConstColorProcessor(const GrConstColorProcessor& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrConstColorProcessor::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrConstColorProcessor(*this));
return std::make_unique<GrConstColorProcessor>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConstColorProcessor);
#if GR_TEST_UTILS

View File

@ -51,7 +51,7 @@ GrDeviceSpaceEffect::GrDeviceSpaceEffect(const GrDeviceSpaceEffect& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrDeviceSpaceEffect(*this));
return std::make_unique<GrDeviceSpaceEffect>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDeviceSpaceEffect);
#if GR_TEST_UTILS

View File

@ -73,7 +73,7 @@ GrDitherEffect::GrDitherEffect(const GrDitherEffect& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDitherEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrDitherEffect(*this));
return std::make_unique<GrDitherEffect>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDitherEffect);
#if GR_TEST_UTILS

View File

@ -159,7 +159,7 @@ GrEllipseEffect::GrEllipseEffect(const GrEllipseEffect& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrEllipseEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrEllipseEffect(*this));
return std::make_unique<GrEllipseEffect>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrEllipseEffect);
#if GR_TEST_UTILS

View File

@ -57,5 +57,5 @@ GrHSLToRGBFilterEffect::GrHSLToRGBFilterEffect(const GrHSLToRGBFilterEffect& src
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrHSLToRGBFilterEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrHSLToRGBFilterEffect(*this));
return std::make_unique<GrHSLToRGBFilterEffect>(*this);
}

View File

@ -161,7 +161,7 @@ GrHighContrastFilterEffect::GrHighContrastFilterEffect(const GrHighContrastFilte
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrHighContrastFilterEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrHighContrastFilterEffect(*this));
return std::make_unique<GrHighContrastFilterEffect>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrHighContrastFilterEffect);
#if GR_TEST_UTILS

View File

@ -53,5 +53,5 @@ GrLumaColorFilterEffect::GrLumaColorFilterEffect(const GrLumaColorFilterEffect&
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrLumaColorFilterEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrLumaColorFilterEffect(*this));
return std::make_unique<GrLumaColorFilterEffect>(*this);
}

View File

@ -145,7 +145,7 @@ GrMagnifierEffect::GrMagnifierEffect(const GrMagnifierEffect& src)
this->setUsesSampleCoordsDirectly();
}
std::unique_ptr<GrFragmentProcessor> GrMagnifierEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrMagnifierEffect(*this));
return std::make_unique<GrMagnifierEffect>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
#if GR_TEST_UTILS

View File

@ -67,5 +67,5 @@ GrMixerEffect::GrMixerEffect(const GrMixerEffect& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrMixerEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrMixerEffect(*this));
return std::make_unique<GrMixerEffect>(*this);
}

View File

@ -101,5 +101,5 @@ GrOverrideInputFragmentProcessor::GrOverrideInputFragmentProcessor(
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrOverrideInputFragmentProcessor::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrOverrideInputFragmentProcessor(*this));
return std::make_unique<GrOverrideInputFragmentProcessor>(*this);
}

View File

@ -60,5 +60,5 @@ GrRGBToHSLFilterEffect::GrRGBToHSLFilterEffect(const GrRGBToHSLFilterEffect& src
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrRGBToHSLFilterEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrRGBToHSLFilterEffect(*this));
return std::make_unique<GrRGBToHSLFilterEffect>(*this);
}

View File

@ -157,7 +157,7 @@ GrRRectBlurEffect::GrRRectBlurEffect(const GrRRectBlurEffect& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrRRectBlurEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrRRectBlurEffect(*this));
return std::make_unique<GrRRectBlurEffect>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect);
#if GR_TEST_UTILS

View File

@ -150,7 +150,7 @@ GrRectBlurEffect::GrRectBlurEffect(const GrRectBlurEffect& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrRectBlurEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrRectBlurEffect(*this));
return std::make_unique<GrRectBlurEffect>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
#if GR_TEST_UTILS

View File

@ -7,6 +7,8 @@
#include "src/gpu/gl/GrGLCaps.h"
#include <memory>
#include "include/gpu/GrContextOptions.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkTSearch.h"
@ -1413,7 +1415,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
bool supportsBGRAColorType = GR_IS_GR_GL(standard) &&
(version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra"));
info.fColorTypeInfoCount = supportsBGRAColorType ? 3 : 2;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: RGBA8, Surface: kRGBA_8888
{
@ -1424,8 +1426,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RGBA8, Surface: kRGBA_8888, Data: kRGBA_8888
{
@ -1457,8 +1459,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RGBA8, Surface: kBGRA_8888, Data: kBGRA_8888
{
@ -1491,8 +1493,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 1;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RGBA8, Surface: kRGB_888x, Data: kRGBA_888x
{
@ -1537,7 +1539,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (r8Support) {
info.fColorTypeInfoCount = 2;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: R8, Surface: kAlpha_8
{
@ -1550,8 +1552,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: R8, Surface: kAlpha_8, Data: kAlpha_8
{
@ -1584,8 +1586,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: R8, Surface: kGray_8, Data: kGray_8
{
@ -1663,7 +1665,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (alpha8IsValidForGL || alpha8IsValidForGLES || alpha8IsValidForWebGL) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: ALPHA8, Surface: kAlpha_8
{
@ -1680,8 +1682,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: ALPHA8, Surface: kAlpha_8, Data: kAlpha_8
{
@ -1750,7 +1752,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (lum8Supported) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: LUMINANCE8, Surface: kGray_8
{
@ -1764,8 +1766,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: LUMINANCE8, Surface: kGray_8, Data: kGray_8
{
@ -1878,7 +1880,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: BGRA8, Surface: kBGRA_8888
{
@ -1889,8 +1891,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: BGRA8, Surface: kBGRA_8888, Data: kBGRA_8888
{
@ -1952,7 +1954,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (SkToBool(info.fFlags &FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: RGB565, Surface: kBGR_565
{
@ -1963,8 +1965,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RGB565, Surface: kBGR_565, Data: kBGR_565
{
@ -2058,7 +2060,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
uint32_t flags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
info.fColorTypeInfoCount = 2;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: RGBA16F, Surface: kRGBA_F16
{
@ -2069,8 +2071,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RGBA16F, Surface: kRGBA_F16, Data: kRGBA_F16
{
@ -2102,8 +2104,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RGBA16F, Surface: kRGBA_F16_Clamped, Data: kRGBA_F16_Clamped
{
@ -2182,7 +2184,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (r16FTextureSupport) {
// Format: R16F, Surface: kAlpha_F16
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
{
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
@ -2194,8 +2196,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: R16F, Surface: kAlpha_F16, Data: kAlpha_F16
{
@ -2265,7 +2267,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
}
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: LUMINANCE16F, Surface: kAlpha_F16
{
@ -2282,8 +2284,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: LUMINANCE16F, Surface: kAlpha_F16, Data: kAlpha_F16
{
@ -2346,7 +2348,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
}
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: RGB8, Surface: kRGB_888x
{
@ -2357,8 +2359,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RGB8, Surface: kRGB_888x, Data: kRGB_888x
{
@ -2416,7 +2418,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
}
if (rg8Support) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: RG8, Surface: kRG_88
{
@ -2427,8 +2429,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RG8, Surface: kRG_88, Data: kRG_88
{
@ -2484,7 +2486,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
(version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra"));
info.fColorTypeInfoCount = supportsBGRAColorType ? 2 : 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: RGB10_A2, Surface: kRGBA_1010102
{
@ -2495,8 +2497,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RGB10_A2, Surface: kRGBA_1010102, Data: kRGBA_1010102
{
@ -2528,8 +2530,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RGB10_A2, Surface: kBGRA_1010102, Data: kBGRA_1010102
{
@ -2583,7 +2585,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
}
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: RGBA4, Surface: kABGR_4444
{
@ -2594,8 +2596,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: RGBA4, Surface: kABGR_4444, Data: kABGR_4444
{
@ -2689,7 +2691,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (srgb8Alpha8TextureSupport) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: SRGB8_ALPHA8, Surface: kRGBA_8888_SRGB
{
@ -2700,8 +2702,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 1;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: SRGB8_ALPHA8, Surface: kRGBA_8888_SRGB, Data: kRGBA_8888_SRGB
@ -2820,7 +2822,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (r16Supported) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: R16, Surface: kAlpha_16
{
@ -2833,8 +2835,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: R16, Surface: kAlpha_16, Data: kAlpha_16
{
@ -2891,7 +2893,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (rg16Supported) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: GR_GL_RG16, Surface: kRG_1616
{
@ -2902,8 +2904,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: GR_GL_RG16, Surface: kRG_1616, Data: kRG_1616
{
@ -2960,7 +2962,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (rgba16Support) {
// Format: GR_GL_RGBA16, Surface: kRGBA_16161616
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
{
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
@ -2970,8 +2972,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: GR_GL_RGBA16, Surface: kRGBA_16161616, Data: kRGBA_16161616
{
@ -3051,7 +3053,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
if (rg16FTextureSupport) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: GR_GL_RG16F, Surface: kRG_F16
{
@ -3062,8 +3064,8 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// External IO ColorTypes:
ctInfo.fExternalIOFormatCount = 2;
ctInfo.fExternalIOFormats.reset(
new ColorTypeInfo::ExternalIOFormats[ctInfo.fExternalIOFormatCount]());
ctInfo.fExternalIOFormats = std::make_unique<ColorTypeInfo::ExternalIOFormats[]>(
ctInfo.fExternalIOFormatCount);
int ioIdx = 0;
// Format: GR_GL_RG16F, Surface: kRG_F16, Data: kRG_F16
{

View File

@ -40,6 +40,7 @@
#include "src/sksl/SkSLCompiler.h"
#include <cmath>
#include <memory>
#define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
#define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X)
@ -359,11 +360,11 @@ GrGLGpu::GrGLGpu(std::unique_ptr<GrGLContext> ctx, GrDirectContext* direct)
static_assert(kGrGpuBufferTypeCount == SK_ARRAY_COUNT(fHWBufferState));
if (this->glCaps().shaderCaps()->pathRenderingSupport()) {
fPathRendering.reset(new GrGLPathRendering(this));
fPathRendering = std::make_unique<GrGLPathRendering>(this);
}
if (this->glCaps().samplerObjectSupport()) {
fSamplerObjectCache.reset(new SamplerObjectCache(this));
fSamplerObjectCache = std::make_unique<SamplerObjectCache>(this);
}
}
@ -2204,7 +2205,7 @@ GrOpsRenderPass* GrGLGpu::getOpsRenderPass(
const GrOpsRenderPass::StencilLoadAndStoreInfo& stencilInfo,
const SkTArray<GrSurfaceProxy*, true>& sampledProxies) {
if (!fCachedOpsRenderPass) {
fCachedOpsRenderPass.reset(new GrGLOpsRenderPass(this));
fCachedOpsRenderPass = std::make_unique<GrGLOpsRenderPass>(this);
}
fCachedOpsRenderPass->set(rt, bounds, origin, colorInfo, stencilInfo);

View File

@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
#include <memory>
#include "src/gpu/gl/GrGLGpu.h"
#include "include/gpu/GrContextOptions.h"
@ -96,7 +98,7 @@ sk_sp<GrGLProgram> GrGLGpu::ProgramCache::findOrCreateProgram(GrRenderTarget* re
return nullptr;
}
fGpu->fStats.incNumCompilationSuccesses();
entry = fMap.insert(desc, std::unique_ptr<Entry>(new Entry(std::move(program))));
entry = fMap.insert(desc, std::make_unique<Entry>(std::move(program)));
*stat = Stats::ProgramCacheResult::kMiss;
}
@ -120,6 +122,6 @@ bool GrGLGpu::ProgramCache::precompileShader(const SkData& key, const SkData& da
return false;
}
fMap.insert(desc, std::unique_ptr<Entry>(new Entry(precompiledProgram)));
fMap.insert(desc, std::make_unique<Entry>(precompiledProgram));
return true;
}

View File

@ -23,6 +23,8 @@
#include "src/gpu/gl/GrGLGpu.h"
#include "src/gpu/gl/GrGLProgram.h"
#include "src/gpu/gl/builders/GrGLProgramBuilder.h"
#include <memory>
#include "src/gpu/gl/builders/GrGLShaderStringBuilder.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLGeometryProcessor.h"
@ -115,8 +117,8 @@ void GrGLProgramBuilder::computeCountsAndStrides(GrGLuint programID,
bool bindAttribLocations) {
fVertexAttributeCnt = primProc.numVertexAttributes();
fInstanceAttributeCnt = primProc.numInstanceAttributes();
fAttributes.reset(
new GrGLProgram::Attribute[fVertexAttributeCnt + fInstanceAttributeCnt]);
fAttributes = std::make_unique<GrGLProgram::Attribute[]>(
fVertexAttributeCnt + fInstanceAttributeCnt);
auto addAttr = [&](int i, const auto& a, size_t* stride) {
fAttributes[i].fCPUType = a.cpuType();
fAttributes[i].fGPUType = a.gpuType();

View File

@ -7,6 +7,8 @@
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include <memory>
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrPipeline.h"
#include "src/gpu/GrRenderTarget.h"
@ -130,7 +132,7 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(SkString* outputColor, SkStrin
void GrGLSLProgramBuilder::emitAndInstallFragProcs(SkString* color, SkString* coverage) {
int transformedCoordVarsIdx = 0;
int fpCount = this->pipeline().numFragmentProcessors();
fFragmentProcessors.reset(new std::unique_ptr<GrGLSLFragmentProcessor>[fpCount]);
fFragmentProcessors = std::make_unique<std::unique_ptr<GrGLSLFragmentProcessor>[]>(fpCount);
for (int i = 0; i < fpCount; ++i) {
SkString* inOut = this->pipeline().isColorFragmentProcessor(i) ? color : coverage;
SkString output;

View File

@ -112,5 +112,5 @@ GrClampedGradientEffect::GrClampedGradientEffect(const GrClampedGradientEffect&
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrClampedGradientEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrClampedGradientEffect(*this));
return std::make_unique<GrClampedGradientEffect>(*this);
}

View File

@ -135,7 +135,7 @@ GrDualIntervalGradientColorizer::GrDualIntervalGradientColorizer(
this->setUsesSampleCoordsDirectly();
}
std::unique_ptr<GrFragmentProcessor> GrDualIntervalGradientColorizer::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrDualIntervalGradientColorizer(*this));
return std::make_unique<GrDualIntervalGradientColorizer>(*this);
}
std::unique_ptr<GrFragmentProcessor> GrDualIntervalGradientColorizer::Make(const SkPMColor4f& c0,

View File

@ -51,7 +51,7 @@ GrLinearGradientLayout::GrLinearGradientLayout(const GrLinearGradientLayout& src
this->setUsesSampleCoordsDirectly();
}
std::unique_ptr<GrFragmentProcessor> GrLinearGradientLayout::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrLinearGradientLayout(*this));
return std::make_unique<GrLinearGradientLayout>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradientLayout);
#if GR_TEST_UTILS

View File

@ -51,7 +51,7 @@ GrRadialGradientLayout::GrRadialGradientLayout(const GrRadialGradientLayout& src
this->setUsesSampleCoordsDirectly();
}
std::unique_ptr<GrFragmentProcessor> GrRadialGradientLayout::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrRadialGradientLayout(*this));
return std::make_unique<GrRadialGradientLayout>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradientLayout);
#if GR_TEST_UTILS

View File

@ -86,5 +86,5 @@ GrSingleIntervalGradientColorizer::GrSingleIntervalGradientColorizer(
this->setUsesSampleCoordsDirectly();
}
std::unique_ptr<GrFragmentProcessor> GrSingleIntervalGradientColorizer::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrSingleIntervalGradientColorizer(*this));
return std::make_unique<GrSingleIntervalGradientColorizer>(*this);
}

View File

@ -89,7 +89,7 @@ GrSweepGradientLayout::GrSweepGradientLayout(const GrSweepGradientLayout& src)
this->setUsesSampleCoordsDirectly();
}
std::unique_ptr<GrFragmentProcessor> GrSweepGradientLayout::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrSweepGradientLayout(*this));
return std::make_unique<GrSweepGradientLayout>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradientLayout);
#if GR_TEST_UTILS

View File

@ -91,5 +91,5 @@ GrTiledGradientEffect::GrTiledGradientEffect(const GrTiledGradientEffect& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrTiledGradientEffect::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrTiledGradientEffect(*this));
return std::make_unique<GrTiledGradientEffect>(*this);
}

View File

@ -183,7 +183,7 @@ GrTwoPointConicalGradientLayout::GrTwoPointConicalGradientLayout(
this->setUsesSampleCoordsDirectly();
}
std::unique_ptr<GrFragmentProcessor> GrTwoPointConicalGradientLayout::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrTwoPointConicalGradientLayout(*this));
return std::make_unique<GrTwoPointConicalGradientLayout>(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTwoPointConicalGradientLayout);
#if GR_TEST_UTILS

View File

@ -342,7 +342,7 @@ GrUnrolledBinaryGradientColorizer::GrUnrolledBinaryGradientColorizer(
this->setUsesSampleCoordsDirectly();
}
std::unique_ptr<GrFragmentProcessor> GrUnrolledBinaryGradientColorizer::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrUnrolledBinaryGradientColorizer(*this));
return std::make_unique<GrUnrolledBinaryGradientColorizer>(*this);
}
static const int kMaxIntervals = 8;

View File

@ -5,6 +5,10 @@
* found in the LICENSE file.
*/
#include "src/gpu/vk/GrVkCaps.h"
#include <memory>
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/vk/GrVkBackendContext.h"
#include "include/gpu/vk/GrVkExtensions.h"
@ -17,7 +21,6 @@
#include "src/gpu/GrStencilSettings.h"
#include "src/gpu/GrUtil.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/vk/GrVkCaps.h"
#include "src/gpu/vk/GrVkGpu.h"
#include "src/gpu/vk/GrVkInterface.h"
#include "src/gpu/vk/GrVkRenderTarget.h"
@ -772,7 +775,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 4;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 2;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R8G8B8A8_UNORM, Surface: kRGBA_8888
{
@ -800,7 +803,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 1;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 2;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R8_UNORM, Surface: kAlpha_8
{
@ -829,7 +832,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 4;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_B8G8R8A8_UNORM, Surface: kBGRA_8888
{
@ -848,7 +851,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 2;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R5G6B5_UNORM_PACK16, Surface: kBGR_565
{
@ -867,7 +870,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 8;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 2;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16G16B16A16_SFLOAT, Surface: GrColorType::kRGBA_F16
{
@ -893,7 +896,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 2;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16_SFLOAT, Surface: kAlpha_F16
{
@ -914,7 +917,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 3;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R8G8B8_UNORM, Surface: kRGB_888x
{
@ -933,7 +936,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 2;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R8G8_UNORM, Surface: kRG_88
{
@ -952,7 +955,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 4;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_A2B10G10R10_UNORM_PACK32, Surface: kRGBA_1010102
{
@ -971,7 +974,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 4;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_A2R10G10B10_UNORM_PACK32, Surface: kBGRA_1010102
{
@ -990,7 +993,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 2;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_B4G4R4A4_UNORM_PACK16, Surface: kABGR_4444
{
@ -1012,7 +1015,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 2;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R4G4B4A4_UNORM_PACK16, Surface: kABGR_4444
{
@ -1031,7 +1034,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 4;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R8G8B8A8_SRGB, Surface: kRGBA_8888_SRGB
{
@ -1050,7 +1053,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 2;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16_UNORM, Surface: kAlpha_16
{
@ -1071,7 +1074,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 4;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16G16_UNORM, Surface: kRG_1616
{
@ -1090,7 +1093,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 8;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16G16B16A16_UNORM, Surface: kRGBA_16161616
{
@ -1109,7 +1112,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
info.fBytesPerPixel = 4;
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16G16_SFLOAT, Surface: kRG_F16
{
@ -1133,7 +1136,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
}
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, Surface: kRGB_888x
{
@ -1157,7 +1160,7 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
}
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, Surface: kRGB_888x
{

View File

@ -319,7 +319,7 @@ GrOpsRenderPass* GrVkGpu::getOpsRenderPass(
const GrOpsRenderPass::StencilLoadAndStoreInfo& stencilInfo,
const SkTArray<GrSurfaceProxy*, true>& sampledProxies) {
if (!fCachedOpsRenderPass) {
fCachedOpsRenderPass.reset(new GrVkOpsRenderPass(this));
fCachedOpsRenderPass = std::make_unique<GrVkOpsRenderPass>(this);
}
if (!fCachedOpsRenderPass->set(rt, stencil, origin, bounds,

View File

@ -121,7 +121,7 @@ GrVkPipelineState* GrVkResourceProvider::PipelineStateCache::findOrCreatePipelin
if (!pipelineState) {
return nullptr;
}
entry = fMap.insert(desc, std::unique_ptr<Entry>(new Entry(fGpu, pipelineState)));
entry = fMap.insert(desc, std::make_unique<Entry>(fGpu, pipelineState));
return (*entry)->fPipelineState.get();
}
return (*entry)->fPipelineState.get();

View File

@ -56,7 +56,7 @@ GrVkSecondaryCBDrawContext::~GrVkSecondaryCBDrawContext() {
SkCanvas* GrVkSecondaryCBDrawContext::getCanvas() {
if (!fCachedCanvas) {
fCachedCanvas = std::unique_ptr<SkCanvas>(new SkCanvas(fDevice));
fCachedCanvas = std::make_unique<SkCanvas>(fDevice);
}
return fCachedCanvas.get();
}

View File

@ -280,7 +280,5 @@ const GrVkDescriptorSet* GrVkTexture::cachedSingleDescSet(GrSamplerState state)
void GrVkTexture::addDescriptorSetToCache(const GrVkDescriptorSet* descSet, GrSamplerState state) {
SkASSERT(!fDescSetCache.find(state));
descSet->ref();
fDescSetCache.insert(state,
std::unique_ptr<DescriptorCacheEntry>(
new DescriptorCacheEntry(descSet, this->getVkGpu())));
fDescSetCache.insert(state, std::make_unique<DescriptorCacheEntry>(descSet, this->getVkGpu()));
}

View File

@ -14,6 +14,7 @@
#include "include/private/SkTHash.h"
#include "include/private/SkTo.h"
#include <memory>
#include <new>
#include <type_traits>
#include <utility>
@ -187,7 +188,7 @@ private:
};
static inline std::unique_ptr<SkPDFDict> SkPDFMakeDict(const char* type = nullptr) {
return std::unique_ptr<SkPDFDict>(new SkPDFDict(type));
return std::make_unique<SkPDFDict>(type);
}
#ifdef SK_PDF_LESS_COMPRESSION

View File

@ -23,6 +23,8 @@
#include <stdlib.h>
#include <string.h>
#include <memory>
#define LMP_SYSTEM_FONTS_FILE "/system/etc/fonts.xml"
#define OLD_SYSTEM_FONTS_FILE "/system/etc/system_fonts.xml"
#define FALLBACK_FONTS_FILE "/system/etc/fallback_fonts.xml"
@ -501,7 +503,7 @@ static const TagHandler nameSetHandler = {
static const TagHandler familyHandler = {
/*start*/[](FamilyData* self, const char* tag, const char** attributes) {
self->fCurrentFamily.reset(new FontFamily(self->fBasePath, self->fIsFallback));
self->fCurrentFamily = std::make_unique<FontFamily>(self->fBasePath, self->fIsFallback);
// 'order' (non-negative integer) [default -1]
for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
const char* value = attributes[i+1];

View File

@ -728,7 +728,7 @@ std::unique_ptr<SkStreamAsset> SkTypeface_Mac::onOpenStream(int* ttcIndex) const
}
// reserve memory for stream, and zero it (tables must be zero padded)
fStream.reset(new SkMemoryStream(totalSize));
fStream = std::make_unique<SkMemoryStream>(totalSize);
char* dataStart = (char*)fStream->getMemoryBase();
sk_bzero(dataStart, totalSize);
char* dataPtr = dataStart;

View File

@ -1102,7 +1102,7 @@ void CPPCodeGenerator::writeClone() {
this->write("}\n");
this->writef("std::unique_ptr<GrFragmentProcessor> %s::clone() const {\n",
fFullName.c_str());
this->writef(" return std::unique_ptr<GrFragmentProcessor>(new %s(*this));\n",
this->writef(" return std::make_unique<%s>(*this);\n",
fFullName.c_str());
this->write("}\n");
}

View File

@ -7,6 +7,8 @@
#include "src/sksl/SkSLCompiler.h"
#include <memory>
#include "src/sksl/SkSLByteCodeGenerator.h"
#include "src/sksl/SkSLCFGGenerator.h"
#include "src/sksl/SkSLCPPCodeGenerator.h"
@ -1602,14 +1604,14 @@ std::unique_ptr<Program> Compiler::convertProgram(Program::Kind kind, String tex
std::unique_ptr<String> textPtr(new String(std::move(text)));
fSource = textPtr.get();
fIRGenerator->convertProgram(kind, textPtr->c_str(), textPtr->size(), &elements);
auto result = std::unique_ptr<Program>(new Program(kind,
std::move(textPtr),
settings,
fContext,
inherited,
std::move(elements),
fIRGenerator->fSymbolTable,
fIRGenerator->fInputs));
auto result = std::make_unique<Program>(kind,
std::move(textPtr),
settings,
fContext,
inherited,
std::move(elements),
fIRGenerator->fSymbolTable,
fIRGenerator->fInputs);
if (fErrorCount) {
return nullptr;
}

View File

@ -8,6 +8,8 @@
#ifndef SKSL_CONTEXT
#define SKSL_CONTEXT
#include <memory>
#include "src/sksl/ir/SkSLExpression.h"
#include "src/sksl/ir/SkSLType.h"
@ -401,7 +403,7 @@ private:
Type::Field(mods, "preservesOpaqueInput", boolType),
Type::Field(mods, "hasConstantOutputForConstantInput", boolType)
};
return std::unique_ptr<Type>(new Type("fragmentProcessor", fields));
return std::make_unique<Type>("fragmentProcessor", fields);
}
};

View File

@ -7,6 +7,8 @@
#include "src/sksl/SkSLGLSLCodeGenerator.h"
#include <memory>
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/ir/SkSLExpressionStatement.h"
#include "src/sksl/ir/SkSLExtension.h"
@ -1548,8 +1550,7 @@ void GLSLCodeGenerator::writeForStatement(const ForStatement& f) {
if (fProgram.fSettings.fCaps->addAndTrueToLoopCondition()) {
std::unique_ptr<Expression> and_true(new BinaryExpression(
-1, f.fTest->clone(), Token::Kind::TK_LOGICALAND,
std::unique_ptr<BoolLiteral>(new BoolLiteral(fContext, -1,
true)),
std::make_unique<BoolLiteral>(fContext, -1, true),
*fContext.fBool_Type));
this->writeExpression(*and_true, kTopLevel_Precedence);
} else {

View File

@ -8,6 +8,7 @@
#include "src/sksl/SkSLIRGenerator.h"
#include "limits.h"
#include <memory>
#include <unordered_set>
#include "src/sksl/SkSLCompiler.h"
@ -178,7 +179,7 @@ void IRGenerator::start(const Program::Settings* settings,
}
std::unique_ptr<Extension> IRGenerator::convertExtension(int offset, StringFragment name) {
return std::unique_ptr<Extension>(new Extension(offset, name));
return std::make_unique<Extension>(offset, name);
}
void IRGenerator::finish() {
@ -222,9 +223,8 @@ std::unique_ptr<Statement> IRGenerator::convertSingleStatement(const ASTNode& st
std::vector<std::unique_ptr<Statement>> statements;
statements.push_back(getNormalizeSkPositionCode());
statements.push_back(std::move(result));
return std::unique_ptr<Block>(new Block(statement.fOffset,
std::move(statements),
fSymbolTable));
return std::make_unique<Block>(statement.fOffset, std::move(statements),
fSymbolTable);
}
}
}
@ -261,7 +261,7 @@ std::unique_ptr<Block> IRGenerator::convertBlock(const ASTNode& block) {
}
statements.push_back(std::move(statement));
}
return std::unique_ptr<Block>(new Block(block.fOffset, std::move(statements), fSymbolTable));
return std::make_unique<Block>(block.fOffset, std::move(statements), fSymbolTable);
}
std::unique_ptr<Statement> IRGenerator::convertVarDeclarationStatement(const ASTNode& s) {
@ -404,8 +404,8 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTNo
sizes.push_back(nullptr);
}
}
auto var = std::unique_ptr<Variable>(new Variable(varDecl.fOffset, modifiers,
varData.fName, *type, storage));
auto var = std::make_unique<Variable>(varDecl.fOffset, modifiers, varData.fName, *type,
storage);
if (var->fName == Compiler::RTADJUST_NAME) {
SkASSERT(!fRTAdjust);
SkASSERT(var->fType == *fContext.fFloat4_Type);
@ -440,9 +440,7 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTNo
fSymbolTable->add(name, std::move(var));
}
}
return std::unique_ptr<VarDeclarations>(new VarDeclarations(decls.fOffset,
baseType,
std::move(variables)));
return std::make_unique<VarDeclarations>(decls.fOffset, baseType, std::move(variables));
}
std::unique_ptr<ModifiersDeclaration> IRGenerator::convertModifiersDeclaration(const ASTNode& m) {
@ -469,7 +467,7 @@ std::unique_ptr<ModifiersDeclaration> IRGenerator::convertModifiersDeclaration(c
!fSettings->fCaps->gsInvocationsSupport()) {
modifiers.fLayout.fMaxVertices *= fInvocations;
}
return std::unique_ptr<ModifiersDeclaration>(new ModifiersDeclaration(modifiers));
return std::make_unique<ModifiersDeclaration>(modifiers);
}
std::unique_ptr<Statement> IRGenerator::convertIf(const ASTNode& n) {
@ -736,7 +734,7 @@ std::unique_ptr<Block> IRGenerator::applyInvocationIDWorkaround(std::unique_ptr<
std::unique_ptr<Expression> test(new BinaryExpression(-1,
std::unique_ptr<Expression>(new VariableReference(-1, *loopIdx)),
Token::Kind::TK_LT,
std::unique_ptr<IntLiteral>(new IntLiteral(fContext, -1, fInvocations)),
std::make_unique<IntLiteral>(fContext, -1, fInvocations),
*fContext.fBool_Type));
std::unique_ptr<Expression> next(new PostfixExpression(
std::unique_ptr<Expression>(
@ -762,7 +760,7 @@ std::unique_ptr<Block> IRGenerator::applyInvocationIDWorkaround(std::unique_ptr<
std::unique_ptr<Expression>(new VariableReference(-1, *loopIdx,
VariableReference::kWrite_RefKind)),
Token::Kind::TK_EQ,
std::unique_ptr<IntLiteral>(new IntLiteral(fContext, -1, 0)),
std::make_unique<IntLiteral>(fContext, -1, 0),
*fContext.fInt_Type));
std::unique_ptr<Statement> initializer(new ExpressionStatement(std::move(assignment)));
std::unique_ptr<Statement> loop = std::unique_ptr<Statement>(
@ -770,11 +768,11 @@ std::unique_ptr<Block> IRGenerator::applyInvocationIDWorkaround(std::unique_ptr<
std::move(initializer),
std::move(test),
std::move(next),
std::unique_ptr<Block>(new Block(-1, std::move(loopBody))),
std::make_unique<Block>(-1, std::move(loopBody)),
fSymbolTable));
std::vector<std::unique_ptr<Statement>> children;
children.push_back(std::move(loop));
return std::unique_ptr<Block>(new Block(-1, std::move(children)));
return std::make_unique<Block>(-1, std::move(children));
}
std::unique_ptr<Statement> IRGenerator::getNormalizeSkPositionCode() {
@ -980,13 +978,12 @@ void IRGenerator::convertFunction(const ASTNode& f) {
}
if (!decl) {
// couldn't find an existing declaration
auto newDecl = std::unique_ptr<FunctionDeclaration>(new FunctionDeclaration(
f.fOffset,
fd.fModifiers,
fd.fName,
parameters,
*returnType,
fIsBuiltinCode));
auto newDecl = std::make_unique<FunctionDeclaration>(f.fOffset,
fd.fModifiers,
fd.fName,
parameters,
*returnType,
fIsBuiltinCode);
decl = newDecl.get();
fSymbolTable->add(decl->fName, std::move(newDecl));
}
@ -1138,16 +1135,15 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTNode
old->addWithoutOwnership(id.fInstanceName, var);
} else {
for (size_t i = 0; i < fields.size(); i++) {
old->add(fields[i].fName, std::unique_ptr<Field>(new Field(intf.fOffset, *var,
(int) i)));
old->add(fields[i].fName, std::make_unique<Field>(intf.fOffset, *var, (int)i));
}
}
return std::unique_ptr<InterfaceBlock>(new InterfaceBlock(intf.fOffset,
var,
id.fTypeName,
id.fInstanceName,
std::move(sizes),
symbols));
return std::make_unique<InterfaceBlock>(intf.fOffset,
var,
id.fTypeName,
id.fInstanceName,
std::move(sizes),
symbols);
}
void IRGenerator::getConstantInt(const Expression& value, int64_t* out) {
@ -1193,9 +1189,8 @@ void IRGenerator::convertEnum(const ASTNode& e) {
}
value = std::unique_ptr<Expression>(new IntLiteral(fContext, e.fOffset, currentValue));
++currentValue;
auto var = std::unique_ptr<Variable>(new Variable(e.fOffset, modifiers, child.getString(),
*type, Variable::kGlobal_Storage,
value.get()));
auto var = std::make_unique<Variable>(e.fOffset, modifiers, child.getString(), *type,
Variable::kGlobal_Storage, value.get());
variables.push_back(var.get());
symbols->add(child.getString(), std::move(var));
symbols->takeOwnership(std::move(value));
@ -1292,15 +1287,11 @@ std::unique_ptr<Expression> IRGenerator::convertIdentifier(const ASTNode& identi
std::vector<const FunctionDeclaration*> f = {
(const FunctionDeclaration*) result
};
return std::unique_ptr<FunctionReference>(new FunctionReference(fContext,
identifier.fOffset,
f));
return std::make_unique<FunctionReference>(fContext, identifier.fOffset, f);
}
case Symbol::kUnresolvedFunction_Kind: {
const UnresolvedFunction* f = (const UnresolvedFunction*) result;
return std::unique_ptr<FunctionReference>(new FunctionReference(fContext,
identifier.fOffset,
f->fFunctions));
return std::make_unique<FunctionReference>(fContext, identifier.fOffset, f->fFunctions);
}
case Symbol::kVariable_Kind: {
const Variable* var = (const Variable*) result;
@ -1345,10 +1336,9 @@ std::unique_ptr<Expression> IRGenerator::convertIdentifier(const ASTNode& identi
}
}
// default to kRead_RefKind; this will be corrected later if the variable is written to
return std::unique_ptr<VariableReference>(new VariableReference(
identifier.fOffset,
*var,
VariableReference::kRead_RefKind));
return std::make_unique<VariableReference>(identifier.fOffset,
*var,
VariableReference::kRead_RefKind);
}
case Symbol::kField_Kind: {
const Field* field = (const Field*) result;
@ -1361,13 +1351,11 @@ std::unique_ptr<Expression> IRGenerator::convertIdentifier(const ASTNode& identi
}
case Symbol::kType_Kind: {
const Type* t = (const Type*) result;
return std::unique_ptr<TypeReference>(new TypeReference(fContext, identifier.fOffset,
*t));
return std::make_unique<TypeReference>(fContext, identifier.fOffset, *t);
}
case Symbol::kExternal_Kind: {
ExternalValue* r = (ExternalValue*) result;
return std::unique_ptr<ExternalValueReference>(
new ExternalValueReference(identifier.fOffset, r));
return std::make_unique<ExternalValueReference>(identifier.fOffset, r);
}
default:
ABORT("unsupported symbol type %d\n", result->fKind);
@ -1376,8 +1364,8 @@ std::unique_ptr<Expression> IRGenerator::convertIdentifier(const ASTNode& identi
std::unique_ptr<Section> IRGenerator::convertSection(const ASTNode& s) {
ASTNode::SectionData section = s.getSectionData();
return std::unique_ptr<Section>(new Section(s.fOffset, section.fName, section.fArgument,
section.fText));
return std::make_unique<Section>(s.fOffset, section.fName, section.fArgument,
section.fText);
}
@ -1668,11 +1656,11 @@ std::unique_ptr<Expression> IRGenerator::constantFold(const Expression& left,
}
return std::unique_ptr<Expression>(new BoolLiteral(fContext, left.fOffset, result));
}
#define RESULT(t, op) std::unique_ptr<Expression>(new t ## Literal(fContext, left.fOffset, \
leftVal op rightVal))
#define URESULT(t, op) std::unique_ptr<Expression>(new t ## Literal(fContext, left.fOffset, \
(uint32_t) leftVal op \
(uint32_t) rightVal))
#define RESULT(t, op) std::make_unique<t ## Literal>(fContext, left.fOffset, \
leftVal op rightVal)
#define URESULT(t, op) std::make_unique<t ## Literal>(fContext, left.fOffset, \
(uint32_t) leftVal op \
(uint32_t) rightVal)
if (left.fKind == Expression::kIntLiteral_Kind && right.fKind == Expression::kIntLiteral_Kind) {
int64_t leftVal = ((IntLiteral&) left).fValue;
int64_t rightVal = ((IntLiteral&) right).fValue;
@ -2057,8 +2045,7 @@ std::unique_ptr<Statement> IRGenerator::inlineStatement(int offset,
switch (statement.fKind) {
case Statement::kBlock_Kind: {
const Block& b = (const Block&) statement;
return std::unique_ptr<Statement>(new Block(offset, stmts(b.fStatements), b.fSymbols,
b.fIsScope));
return std::make_unique<Block>(offset, stmts(b.fStatements), b.fSymbols, b.fIsScope);
}
case Statement::kBreak_Kind:
@ -2068,56 +2055,51 @@ std::unique_ptr<Statement> IRGenerator::inlineStatement(int offset,
case Statement::kDo_Kind: {
const DoStatement& d = (const DoStatement&) statement;
return std::unique_ptr<Statement>(new DoStatement(offset,
stmt(d.fStatement),
expr(d.fTest)));
return std::make_unique<DoStatement>(offset, stmt(d.fStatement), expr(d.fTest));
}
case Statement::kExpression_Kind: {
const ExpressionStatement& e = (const ExpressionStatement&) statement;
return std::unique_ptr<Statement>(new ExpressionStatement(expr(e.fExpression)));
return std::make_unique<ExpressionStatement>(expr(e.fExpression));
}
case Statement::kFor_Kind: {
const ForStatement& f = (const ForStatement&) statement;
// need to ensure initializer is evaluated first so that we've already remapped its
// declarations by the time we evaluate test & next
std::unique_ptr<Statement> initializer = stmt(f.fInitializer);
return std::unique_ptr<Statement>(new ForStatement(offset, std::move(initializer),
expr(f.fTest), expr(f.fNext),
stmt(f.fStatement), f.fSymbols));
return std::make_unique<ForStatement>(offset, std::move(initializer), expr(f.fTest),
expr(f.fNext), stmt(f.fStatement), f.fSymbols);
}
case Statement::kIf_Kind: {
const IfStatement& i = (const IfStatement&) statement;
return std::unique_ptr<Statement>(new IfStatement(offset, i.fIsStatic, expr(i.fTest),
stmt(i.fIfTrue), stmt(i.fIfFalse)));
return std::make_unique<IfStatement>(offset, i.fIsStatic, expr(i.fTest),
stmt(i.fIfTrue), stmt(i.fIfFalse));
}
case Statement::kNop_Kind:
return statement.clone();
case Statement::kReturn_Kind: {
const ReturnStatement& r = (const ReturnStatement&) statement;
if (r.fExpression) {
std::unique_ptr<Statement> assignment(new ExpressionStatement(
std::unique_ptr<Expression>(new BinaryExpression(offset,
std::unique_ptr<Expression>(new VariableReference(
offset,
*returnVar,
VariableReference::kWrite_RefKind)),
Token::Kind::TK_EQ,
expr(r.fExpression),
returnVar->fType))));
std::unique_ptr<Statement> assignment = std::make_unique<ExpressionStatement>(
std::make_unique<BinaryExpression>(
offset,
std::make_unique<VariableReference>(offset, *returnVar,
VariableReference::kWrite_RefKind),
Token::Kind::TK_EQ,
expr(r.fExpression),
returnVar->fType));
if (haveEarlyReturns) {
std::vector<std::unique_ptr<Statement>> block;
block.push_back(std::move(assignment));
block.emplace_back(new BreakStatement(offset));
return std::unique_ptr<Statement>(new Block(offset, std::move(block), nullptr,
false));
return std::make_unique<Block>(offset, std::move(block), nullptr, false);
} else {
return assignment;
}
} else {
if (haveEarlyReturns) {
return std::unique_ptr<Statement>(new BreakStatement(offset));
return std::make_unique<BreakStatement>(offset);
} else {
return std::unique_ptr<Statement>(new Nop());
return std::make_unique<Nop>();
}
}
}
@ -2128,10 +2110,8 @@ std::unique_ptr<Statement> IRGenerator::inlineStatement(int offset,
cases.emplace_back(new SwitchCase(offset, expr(sc->fValue),
stmts(sc->fStatements)));
}
return std::unique_ptr<Statement>(new SwitchStatement(offset, ss.fIsStatic,
expr(ss.fValue),
std::move(cases),
ss.fSymbols));
return std::make_unique<SwitchStatement>(offset, ss.fIsStatic, expr(ss.fValue),
std::move(cases), ss.fSymbols);
}
case Statement::kVarDeclaration_Kind: {
const VarDeclaration& decl = (const VarDeclaration&) statement;
@ -2152,8 +2132,8 @@ std::unique_ptr<Statement> IRGenerator::inlineStatement(int offset,
old->fStorage,
initialValue.get())));
(*varMap)[old] = clone;
return std::unique_ptr<Statement>(new VarDeclaration(clone, std::move(sizes),
std::move(initialValue)));
return std::make_unique<VarDeclaration>(clone, std::move(sizes),
std::move(initialValue));
}
case Statement::kVarDeclarations_Kind: {
const VarDeclarations& decls = *((VarDeclarationsStatement&) statement).fDeclaration;
@ -2163,14 +2143,11 @@ std::unique_ptr<Statement> IRGenerator::inlineStatement(int offset,
}
const Type* typePtr = copy_if_needed(&decls.fBaseType, *fSymbolTable);
return std::unique_ptr<Statement>(new VarDeclarationsStatement(
std::unique_ptr<VarDeclarations>(new VarDeclarations(offset, typePtr,
std::move(vars)))));
std::make_unique<VarDeclarations>(offset, typePtr, std::move(vars))));
}
case Statement::kWhile_Kind: {
const WhileStatement& w = (const WhileStatement&) statement;
return std::unique_ptr<Statement>(new WhileStatement(offset,
expr(w.fTest),
stmt(w.fStatement)));
return std::make_unique<WhileStatement>(offset, expr(w.fTest), stmt(w.fStatement));
}
default:
SkASSERT(false);
@ -2280,16 +2257,15 @@ std::unique_ptr<Expression> IRGenerator::inlineCall(
name->appendf("_inlineResult%s%d", inlineSalt.c_str(), varIndex);
String* namePtr = (String*) fSymbolTable->takeOwnership(std::move(name));
resultVar = new Variable(-1, Modifiers(), namePtr->c_str(),
function.fDeclaration.fReturnType,
Variable::kLocal_Storage,
nullptr);
function.fDeclaration.fReturnType,
Variable::kLocal_Storage,
nullptr);
fSymbolTable->add(resultVar->fName, std::unique_ptr<Symbol>(resultVar));
std::vector<std::unique_ptr<VarDeclaration>> variables;
variables.emplace_back(new VarDeclaration(resultVar, {}, nullptr));
fExtraStatements.emplace_back(new VarDeclarationsStatement(
std::unique_ptr<VarDeclarations>(new VarDeclarations(offset,
&resultVar->fType,
std::move(variables)))));
fExtraStatements.emplace_back(
new VarDeclarationsStatement(std::make_unique<VarDeclarations>(
offset, &resultVar->fType, std::move(variables))));
} else {
resultVar = nullptr;
@ -2312,9 +2288,9 @@ std::unique_ptr<Expression> IRGenerator::inlineCall(
vars.emplace_back(new VarDeclaration(argVar, {}, std::move(arguments[i])));
}
fExtraStatements.emplace_back(new VarDeclarationsStatement(
std::unique_ptr<VarDeclarations>(new VarDeclarations(offset,
std::make_unique<VarDeclarations>(offset,
&argVar->fType,
std::move(vars)))));
std::move(vars))));
}
SkASSERT(function.fBody->fKind == Statement::kBlock_Kind);
const Block& body = (Block&) *function.fBody;
@ -2429,8 +2405,8 @@ std::unique_ptr<Expression> IRGenerator::call(int offset,
!has_early_return(*function.fDefinition))) {
return this->inlineCall(offset, *function.fDefinition, std::move(arguments));
}
return std::unique_ptr<FunctionCall>(new FunctionCall(offset, *returnType, function,
std::move(arguments)));
return std::make_unique<FunctionCall>(offset, *returnType, function,
std::move(arguments));
}
/**
@ -2900,8 +2876,8 @@ std::unique_ptr<Expression> IRGenerator::findEnumRef(
const Variable& v = ((VariableReference&) *result).fVariable;
SkASSERT(v.fInitialValue);
SkASSERT(v.fInitialValue->fKind == Expression::kIntLiteral_Kind);
result.reset(new IntLiteral(offset, ((IntLiteral&) *v.fInitialValue).fValue,
&type));
result = std::make_unique<IntLiteral>(
offset, ((IntLiteral&)*v.fInitialValue).fValue, &type);
}
fSymbolTable = old;
return result;

View File

@ -5,9 +5,12 @@
* found in the LICENSE file.
*/
#include "stdio.h"
#include "src/sksl/SkSLASTNode.h"
#include "src/sksl/SkSLParser.h"
#include <memory>
#include "stdio.h"
#include "src/sksl/SkSLASTNode.h"
#include "src/sksl/ir/SkSLModifiers.h"
#include "src/sksl/ir/SkSLSymbolTable.h"
#include "src/sksl/ir/SkSLType.h"
@ -136,7 +139,7 @@ Parser::Parser(const char* text, size_t length, SymbolTable& symbols, ErrorRepor
/* (directive | section | declaration)* END_OF_FILE */
std::unique_ptr<ASTFile> Parser::file() {
fFile.reset(new ASTFile());
fFile = std::make_unique<ASTFile>();
CREATE_NODE(result, 0, ASTNode::Kind::kFile);
fFile->fRoot = result;
for (;;) {
@ -524,8 +527,7 @@ ASTNode::ID Parser::structDeclaration() {
if (!this->expect(Token::Kind::TK_RBRACE, "'}'")) {
return ASTNode::ID::Invalid();
}
fSymbols.add(this->text(name), std::unique_ptr<Type>(new Type(name.fOffset, this->text(name),
fields)));
fSymbols.add(this->text(name), std::make_unique<Type>(name.fOffset, this->text(name), fields));
RETURN_NODE(name.fOffset, ASTNode::Kind::kType,
ASTNode::TypeData(this->text(name), true, false));
}

View File

@ -6,6 +6,8 @@
*/
#include "src/sksl/SkSLRehydrator.h"
#include <memory>
#include "src/sksl/ir/SkSLBinaryExpression.h"
#include "src/sksl/ir/SkSLBreakStatement.h"
#include "src/sksl/ir/SkSLContinueStatement.h"
@ -430,9 +432,8 @@ std::unique_ptr<Statement> Rehydrator::statement() {
SkASSERT(s->fKind == Statement::kVarDeclaration_Kind);
vars.emplace_back((VarDeclaration*) s.release());
}
return std::unique_ptr<Statement>(new VarDeclarationsStatement(
std::unique_ptr<VarDeclarations>(new VarDeclarations(-1, baseType,
std::move(vars)))));
return std::make_unique<VarDeclarationsStatement>(
std::make_unique<VarDeclarations>(-1, baseType, std::move(vars)));
}
case Rehydrator::kVoid_Command:
return nullptr;

View File

@ -7,6 +7,8 @@
#include "src/svg/SkSVGDevice.h"
#include <memory>
#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkColorFilter.h"
@ -692,7 +694,7 @@ SkSVGDevice::SkSVGDevice(const SkISize& size, std::unique_ptr<SkXMLWriter> write
fWriter->writeHeader();
// The root <svg> tag gets closed by the destructor.
fRootElement.reset(new AutoElement("svg", fWriter));
fRootElement = std::make_unique<AutoElement>("svg", fWriter);
fRootElement->addAttribute("xmlns", "http://www.w3.org/2000/svg");
fRootElement->addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
@ -843,7 +845,7 @@ void SkSVGDevice::drawPoints(SkCanvas::PointMode mode, size_t count,
void SkSVGDevice::drawRect(const SkRect& r, const SkPaint& paint) {
std::unique_ptr<AutoElement> svg;
if (RequiresViewportReset(paint)) {
svg.reset(new AutoElement("svg", this, fResourceBucket.get(), MxCp(this), paint));
svg = std::make_unique<AutoElement>("svg", this, fResourceBucket.get(), MxCp(this), paint);
svg->addRectAttributes(r);
}

View File

@ -16,6 +16,7 @@
#include "src/utils/mac/SkUniqueCFRef.h"
#include <climits>
#include <memory>
static CGBitmapInfo compute_cgalpha_info_rgba(SkAlphaType at) {
CGBitmapInfo info = kCGBitmapByteOrder32Big;
@ -97,7 +98,7 @@ static std::unique_ptr<SkBitmap> prepare_for_image_ref(const SkBitmap& bm,
bm.readPixels(copy->info(), copy->getPixels(), copy->rowBytes(), 0, 0);
return copy;
}
return std::unique_ptr<SkBitmap>(new SkBitmap(bm));
return std::make_unique<SkBitmap>(bm);
}
CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm,

View File

@ -7,6 +7,8 @@
#include "src/xml/SkDOM.h"
#include <memory>
#include "include/core/SkStream.h"
#include "include/private/SkTo.h"
#include "src/xml/SkXMLParser.h"
@ -344,7 +346,7 @@ const SkDOM::Node* SkDOM::copy(const SkDOM& dom, const SkDOM::Node* node) {
SkXMLParser* SkDOM::beginParsing() {
SkASSERT(!fParser);
fParser.reset(new SkDOMParser(&fAlloc));
fParser = std::make_unique<SkDOMParser>(&fAlloc);
return fParser.get();
}

View File

@ -960,7 +960,7 @@ DEF_TEST(Codec_wbmp_max_size, r) {
const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header
0x84, 0x80, 0x00, // W: 65536
0x84, 0x80, 0x00 }; // H: 65536
stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false));
stream = std::make_unique<SkMemoryStream>(tooBigWbmp, sizeof(tooBigWbmp), false);
codec = SkCodec::MakeFromStream(std::move(stream));
REPORTER_ASSERT(r, !codec);

View File

@ -8,6 +8,7 @@
#include "tests/Test.h"
#include <array>
#include <memory>
#include <vector>
#include "include/core/SkBitmap.h"
#include "include/gpu/GrDirectContext.h"
@ -436,7 +437,7 @@ private:
GrAppliedClip*,
const GrXferProcessor::DstProxyView&) override {}
void onPrepare(GrOpFlushState* state) override {
fHelper.reset(new DrawMeshHelper(state));
fHelper = std::make_unique<DrawMeshHelper>(state);
fPrepareFn(fHelper.get());
}
void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override {

View File

@ -17,6 +17,7 @@
#include <initializer_list>
#include <functional>
#include <memory>
#include <utility>
uint32_t GrStyledShape::testingOnly_getOriginalGenerationID() const {
@ -586,9 +587,9 @@ private:
}
void init(skiatest::Reporter* r, SkScalar scale) {
fAppliedPE.reset(new GrStyledShape);
fAppliedPEThenStroke.reset(new GrStyledShape);
fAppliedFull.reset(new GrStyledShape);
fAppliedPE = std::make_unique<GrStyledShape>();
fAppliedPEThenStroke = std::make_unique<GrStyledShape>();
fAppliedFull = std::make_unique<GrStyledShape>();
*fAppliedPE = fBase->applyStyle(GrStyle::Apply::kPathEffectOnly, scale);
*fAppliedPEThenStroke =
@ -771,7 +772,7 @@ static sk_sp<SkPathEffect> make_null_dash() {
// the maximum stack frame limit. make_TestCase() moves those temporaries over to the heap.
template <typename... Args>
static std::unique_ptr<TestCase> make_TestCase(Args&&... args) {
return std::unique_ptr<TestCase>{ new TestCase(std::forward<Args>(args)...) };
return std::make_unique<TestCase>( std::forward<Args>(args)... );
}
static void test_basic(skiatest::Reporter* reporter, const Geo& geo) {

View File

@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
#include <memory>
#include "src/core/SkLRUCache.h"
#include "tests/Test.h"
@ -30,7 +32,7 @@ DEF_TEST(LRUCacheSequential, r) {
SkLRUCache<int, std::unique_ptr<Value>> test(kSize);
for (int i = 1; i < kSize * 2; i++) {
REPORTER_ASSERT(r, !test.find(i));
test.insert(i, std::unique_ptr<Value>(new Value(i * i, &instances)));
test.insert(i, std::make_unique<Value>(i * i, &instances));
REPORTER_ASSERT(r, test.find(i));
REPORTER_ASSERT(r, i * i == (*test.find(i))->fValue);
if (i > kSize) {
@ -55,7 +57,7 @@ DEF_TEST(LRUCacheRandom, r) {
for (int i = 0; i < (int) (sizeof(seq) / sizeof(int)); i++) {
int k = seq[i];
if (!test.find(k)) {
test.insert(k, std::unique_ptr<Value>(new Value(k, &instances)));
test.insert(k, std::make_unique<Value>(k, &instances));
}
}
REPORTER_ASSERT(r, kSize == instances);

View File

@ -37,6 +37,7 @@
#include <cstdlib>
#include <cmath>
#include <memory>
#define DUMMY_TEXT "DCT compessed stream."
@ -199,7 +200,7 @@ static void TestPDFDict(skiatest::Reporter* reporter) {
dict->insertInt("n1", SkToSizeT(42));
assert_emit_eq(reporter, *dict, "<</n1 42>>");
dict.reset(new SkPDFDict);
dict = std::make_unique<SkPDFDict>();
assert_emit_eq(reporter, *dict, "<<>>");
dict->insertInt("n1", 42);
@ -213,7 +214,7 @@ static void TestPDFDict(skiatest::Reporter* reporter) {
dict->insertObject(n3, std::move(innerArray));
assert_emit_eq(reporter, *dict, "<</n1 42\n/n2 .5\n/n3 [-100]>>");
dict.reset(new SkPDFDict);
dict = std::make_unique<SkPDFDict>();
assert_emit_eq(reporter, *dict, "<<>>");
dict->insertInt("n1", 24);
@ -240,7 +241,7 @@ static void TestPDFDict(skiatest::Reporter* reporter) {
assert_emit_eq(reporter, *dict, "<</n1 24\n/n2 99\n/n3 .5\n/n4 /AName\n"
"/n5 /AnotherName\n/n6 (A String)\n/n7 (Another String)>>");
dict.reset(new SkPDFDict("DType"));
dict = std::make_unique<SkPDFDict>("DType");
assert_emit_eq(reporter, *dict, "<</Type /DType>>");
}

View File

@ -7,6 +7,8 @@
// This is a GPU-backend specific test. It relies on static intializers to work
#include <memory>
#include "include/core/SkTypes.h"
#include "tests/Test.h"
@ -98,8 +100,8 @@ private:
GP(int numAttribs) : INHERITED(kGP_ClassID), fNumAttribs(numAttribs) {
SkASSERT(numAttribs > 1);
fAttribNames.reset(new SkString[numAttribs]);
fAttributes.reset(new Attribute[numAttribs]);
fAttribNames = std::make_unique<SkString[]>(numAttribs);
fAttributes = std::make_unique<Attribute[]>(numAttribs);
for (auto i = 0; i < numAttribs; ++i) {
fAttribNames[i].printf("attr%d", i);
// This gives us more of a mix of attribute types, and allows the

View File

@ -37,9 +37,9 @@ struct RunHandler final : public SkShaper::RunHandler {
SkShaper::RunHandler::Buffer runBuffer(const SkShaper::RunHandler::RunInfo& info) override {
fGlyphCount = SkToUInt(info.glyphCount);
fRange = info.utf8Range;
fGlyphs.reset(new SkGlyphID[info.glyphCount]);
fPositions.reset(new SkPoint[info.glyphCount]);
fClusters.reset(new uint32_t[info.glyphCount]);
fGlyphs = std::make_unique<SkGlyphID[]>(info.glyphCount);
fPositions = std::make_unique<SkPoint[]>(info.glyphCount);
fClusters = std::make_unique<uint32_t[]>(info.glyphCount);
return SkShaper::RunHandler::Buffer{fGlyphs.get(),
fPositions.get(),
nullptr,

View File

@ -174,7 +174,7 @@ GrTest::GrTest(const GrTest& src)
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrTest::clone() const {
return std::unique_ptr<GrFragmentProcessor>(new GrTest(*this));
return std::make_unique<GrTest>(*this);
}
)__Cpp__"
});

View File

@ -192,10 +192,10 @@ public:
}
std::unique_ptr<GpuDrawHandler> draw;
if (fDContext) {
draw.reset(new DrawHandlerImport(this, ImportDraw, ImportSubmitted, matrix,
clipBounds, bufferInfo));
draw = std::make_unique<DrawHandlerImport>(this, ImportDraw, ImportSubmitted, matrix,
clipBounds, bufferInfo);
} else {
draw.reset(new DrawHandlerBasic(fInterface, fWidth, fHeight));
draw = std::make_unique<DrawHandlerBasic>(fInterface, fWidth, fHeight);
}
return draw;
}

View File

@ -87,7 +87,7 @@ static Display* get_display() {
};
static std::unique_ptr<AutoDisplay> ad;
static SkOnce once;
once([] { ad.reset(new AutoDisplay{}); });
once([] { ad = std::make_unique<AutoDisplay>(); });
return ad->display();
}

View File

@ -7,6 +7,8 @@
#include "tools/skiaserve/Request.h"
#include <memory>
#include "include/core/SkPictureRecorder.h"
#include "include/gpu/GrDirectContext.h"
#include "src/utils/SkJSONWriter.h"
@ -209,7 +211,7 @@ bool Request::initPictureFromStream(SkStream* stream) {
// pour picture into debug canvas
SkIRect bounds = this->getBounds();
fDebugCanvas.reset(new DebugCanvas(bounds.width(), bounds.height()));
fDebugCanvas = std::make_unique<DebugCanvas>(bounds.width(), bounds.height());
fDebugCanvas->drawPicture(fPicture);
// for some reason we need to 'flush' the debug canvas by drawing all of the ops