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>
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp
index c113f6d..61a2c51 100644
--- a/src/codec/SkBmpCodec.cpp
+++ b/src/codec/SkBmpCodec.cpp
@@ -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 @@
// 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 @@
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 @@
// 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;
}
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp
index 86ebac4..2b40647 100644
--- a/src/codec/SkBmpRLECodec.cpp
+++ b/src/codec/SkBmpRLECodec.cpp
@@ -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 @@
SkSampler* SkBmpRLECodec::getSampler(bool createIfNecessary) {
if (!fSampler && createIfNecessary) {
- fSampler.reset(new SkBmpRLESampler(this));
+ fSampler = std::make_unique<SkBmpRLESampler>(this);
}
return fSampler.get();
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp
index a2ec989..7c619fb 100644
--- a/src/codec/SkRawCodec.cpp
+++ b/src/codec/SkRawCodec.cpp
@@ -35,6 +35,7 @@
#include <cmath> // for std::round,floor,ceil
#include <limits>
+#include <memory>
namespace {
@@ -566,9 +567,9 @@
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 @@
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.
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index ebdc1f0..9630b7f 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -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 @@
// 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);
diff --git a/src/core/SkPictureFlat.cpp b/src/core/SkPictureFlat.cpp
index a15f2e7..24c979e 100644
--- a/src/core/SkPictureFlat.cpp
+++ b/src/core/SkPictureFlat.cpp
@@ -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);
}
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
index d1d1b62..7a5392d 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -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() {}
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 4ff6c1a..ab867a3 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -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::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);
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 90e3e45..895aa4d 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -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 @@
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 @@
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
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp
index a3453c3..a07f789 100644
--- a/src/gpu/GrBufferAllocPool.cpp
+++ b/src/gpu/GrBufferAllocPool.cpp
@@ -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 @@
GrBufferAllocPool::CpuBufferCache::CpuBufferCache(int maxBuffersToCache)
: fMaxBuffersToCache(maxBuffersToCache) {
if (fMaxBuffersToCache) {
- fBuffers.reset(new Buffer[fMaxBuffersToCache]);
+ fBuffers = std::make_unique<Buffer[]>(fMaxBuffersToCache);
}
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 5eabf23..4e1b27e 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -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 @@
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());
diff --git a/src/gpu/GrContextThreadSafeProxy.cpp b/src/gpu/GrContextThreadSafeProxy.cpp
index b4fbed6..1642c92 100644
--- a/src/gpu/GrContextThreadSafeProxy.cpp
+++ b/src/gpu/GrContextThreadSafeProxy.cpp
@@ -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 @@
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(
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index 39bb49b..6ea095c 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -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 @@
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) {
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 5677f29..9343bbe 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -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::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 @@
GrCoverageCountingPathRenderer* GrDrawingManager::getCoverageCountingPathRenderer() {
if (!fPathRendererChain) {
- fPathRendererChain.reset(new GrPathRendererChain(fContext, fOptionsForPathRendererChain));
+ fPathRendererChain = std::make_unique<GrPathRendererChain>(fContext, fOptionsForPathRendererChain);
}
return fPathRendererChain->getCoverageCountingPathRenderer();
}
diff --git a/src/gpu/GrImageContext.cpp b/src/gpu/GrImageContext.cpp
index 8993a38..d2ceed8 100644
--- a/src/gpu/GrImageContext.cpp
+++ b/src/gpu/GrImageContext.cpp
@@ -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() {}
diff --git a/src/gpu/GrProcessorUnitTest.cpp b/src/gpu/GrProcessorUnitTest.cpp
index 186901d..0f47ba5 100644
--- a/src/gpu/GrProcessorUnitTest.cpp
+++ b/src/gpu/GrProcessorUnitTest.cpp
@@ -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 @@
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() {}
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index d2233b4..5e51da4 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -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 @@
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 @@
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;
diff --git a/src/gpu/effects/generated/GrAARectEffect.cpp b/src/gpu/effects/generated/GrAARectEffect.cpp
index 2fe13d2..65be82a 100644
--- a/src/gpu/effects/generated/GrAARectEffect.cpp
+++ b/src/gpu/effects/generated/GrAARectEffect.cpp
@@ -108,7 +108,7 @@
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
diff --git a/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.cpp b/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.cpp
index 2828d29..74bdabe 100644
--- a/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.cpp
@@ -94,7 +94,7 @@
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
diff --git a/src/gpu/effects/generated/GrArithmeticProcessor.cpp b/src/gpu/effects/generated/GrArithmeticProcessor.cpp
index 2eec006..29a57f6 100644
--- a/src/gpu/effects/generated/GrArithmeticProcessor.cpp
+++ b/src/gpu/effects/generated/GrArithmeticProcessor.cpp
@@ -79,7 +79,7 @@
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
diff --git a/src/gpu/effects/generated/GrBlurredEdgeFragmentProcessor.cpp b/src/gpu/effects/generated/GrBlurredEdgeFragmentProcessor.cpp
index ade30f7..ff9bb22 100644
--- a/src/gpu/effects/generated/GrBlurredEdgeFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrBlurredEdgeFragmentProcessor.cpp
@@ -68,5 +68,5 @@
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrBlurredEdgeFragmentProcessor::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(*this));
+ return std::make_unique<GrBlurredEdgeFragmentProcessor>(*this);
}
diff --git a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
index 83b865a..d6c1d6f 100644
--- a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
@@ -358,7 +358,7 @@
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
diff --git a/src/gpu/effects/generated/GrCircleEffect.cpp b/src/gpu/effects/generated/GrCircleEffect.cpp
index 692f157..3871b73 100644
--- a/src/gpu/effects/generated/GrCircleEffect.cpp
+++ b/src/gpu/effects/generated/GrCircleEffect.cpp
@@ -119,7 +119,7 @@
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
diff --git a/src/gpu/effects/generated/GrClampFragmentProcessor.cpp b/src/gpu/effects/generated/GrClampFragmentProcessor.cpp
index a0bd66b..182a2a0 100644
--- a/src/gpu/effects/generated/GrClampFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrClampFragmentProcessor.cpp
@@ -63,7 +63,7 @@
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
diff --git a/src/gpu/effects/generated/GrColorMatrixFragmentProcessor.cpp b/src/gpu/effects/generated/GrColorMatrixFragmentProcessor.cpp
index 41cc9e1..2a75692 100644
--- a/src/gpu/effects/generated/GrColorMatrixFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrColorMatrixFragmentProcessor.cpp
@@ -121,7 +121,7 @@
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
diff --git a/src/gpu/effects/generated/GrComposeLerpEffect.cpp b/src/gpu/effects/generated/GrComposeLerpEffect.cpp
index 2be8c25..2b6b610 100644
--- a/src/gpu/effects/generated/GrComposeLerpEffect.cpp
+++ b/src/gpu/effects/generated/GrComposeLerpEffect.cpp
@@ -61,5 +61,5 @@
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrComposeLerpEffect::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrComposeLerpEffect(*this));
+ return std::make_unique<GrComposeLerpEffect>(*this);
}
diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.cpp b/src/gpu/effects/generated/GrConfigConversionEffect.cpp
index c28b70c..4e38451 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.cpp
@@ -68,7 +68,7 @@
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
diff --git a/src/gpu/effects/generated/GrConstColorProcessor.cpp b/src/gpu/effects/generated/GrConstColorProcessor.cpp
index 80ccd2b..571287a 100644
--- a/src/gpu/effects/generated/GrConstColorProcessor.cpp
+++ b/src/gpu/effects/generated/GrConstColorProcessor.cpp
@@ -65,7 +65,7 @@
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
diff --git a/src/gpu/effects/generated/GrDeviceSpaceEffect.cpp b/src/gpu/effects/generated/GrDeviceSpaceEffect.cpp
index afb5254..fb3e24d 100644
--- a/src/gpu/effects/generated/GrDeviceSpaceEffect.cpp
+++ b/src/gpu/effects/generated/GrDeviceSpaceEffect.cpp
@@ -51,7 +51,7 @@
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
diff --git a/src/gpu/effects/generated/GrDitherEffect.cpp b/src/gpu/effects/generated/GrDitherEffect.cpp
index fdaac86..d3bba75 100644
--- a/src/gpu/effects/generated/GrDitherEffect.cpp
+++ b/src/gpu/effects/generated/GrDitherEffect.cpp
@@ -73,7 +73,7 @@
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
diff --git a/src/gpu/effects/generated/GrEllipseEffect.cpp b/src/gpu/effects/generated/GrEllipseEffect.cpp
index 447b7b7..76ef4b2 100644
--- a/src/gpu/effects/generated/GrEllipseEffect.cpp
+++ b/src/gpu/effects/generated/GrEllipseEffect.cpp
@@ -159,7 +159,7 @@
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
diff --git a/src/gpu/effects/generated/GrHSLToRGBFilterEffect.cpp b/src/gpu/effects/generated/GrHSLToRGBFilterEffect.cpp
index 41a06df..a933aca 100644
--- a/src/gpu/effects/generated/GrHSLToRGBFilterEffect.cpp
+++ b/src/gpu/effects/generated/GrHSLToRGBFilterEffect.cpp
@@ -57,5 +57,5 @@
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrHSLToRGBFilterEffect::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrHSLToRGBFilterEffect(*this));
+ return std::make_unique<GrHSLToRGBFilterEffect>(*this);
}
diff --git a/src/gpu/effects/generated/GrHighContrastFilterEffect.cpp b/src/gpu/effects/generated/GrHighContrastFilterEffect.cpp
index aaad538..817e9ef 100644
--- a/src/gpu/effects/generated/GrHighContrastFilterEffect.cpp
+++ b/src/gpu/effects/generated/GrHighContrastFilterEffect.cpp
@@ -161,7 +161,7 @@
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
diff --git a/src/gpu/effects/generated/GrLumaColorFilterEffect.cpp b/src/gpu/effects/generated/GrLumaColorFilterEffect.cpp
index 0d497f1..3e1350a 100644
--- a/src/gpu/effects/generated/GrLumaColorFilterEffect.cpp
+++ b/src/gpu/effects/generated/GrLumaColorFilterEffect.cpp
@@ -53,5 +53,5 @@
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrLumaColorFilterEffect::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrLumaColorFilterEffect(*this));
+ return std::make_unique<GrLumaColorFilterEffect>(*this);
}
diff --git a/src/gpu/effects/generated/GrMagnifierEffect.cpp b/src/gpu/effects/generated/GrMagnifierEffect.cpp
index a0cd0e9..b176d0c 100644
--- a/src/gpu/effects/generated/GrMagnifierEffect.cpp
+++ b/src/gpu/effects/generated/GrMagnifierEffect.cpp
@@ -145,7 +145,7 @@
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
diff --git a/src/gpu/effects/generated/GrMixerEffect.cpp b/src/gpu/effects/generated/GrMixerEffect.cpp
index 6a9d989..2f1c6a5 100644
--- a/src/gpu/effects/generated/GrMixerEffect.cpp
+++ b/src/gpu/effects/generated/GrMixerEffect.cpp
@@ -67,5 +67,5 @@
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrMixerEffect::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrMixerEffect(*this));
+ return std::make_unique<GrMixerEffect>(*this);
}
diff --git a/src/gpu/effects/generated/GrOverrideInputFragmentProcessor.cpp b/src/gpu/effects/generated/GrOverrideInputFragmentProcessor.cpp
index 4dd2db7..4b30fce 100644
--- a/src/gpu/effects/generated/GrOverrideInputFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrOverrideInputFragmentProcessor.cpp
@@ -101,5 +101,5 @@
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrOverrideInputFragmentProcessor::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrOverrideInputFragmentProcessor(*this));
+ return std::make_unique<GrOverrideInputFragmentProcessor>(*this);
}
diff --git a/src/gpu/effects/generated/GrRGBToHSLFilterEffect.cpp b/src/gpu/effects/generated/GrRGBToHSLFilterEffect.cpp
index 8eac916..f7b3869 100644
--- a/src/gpu/effects/generated/GrRGBToHSLFilterEffect.cpp
+++ b/src/gpu/effects/generated/GrRGBToHSLFilterEffect.cpp
@@ -60,5 +60,5 @@
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrRGBToHSLFilterEffect::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrRGBToHSLFilterEffect(*this));
+ return std::make_unique<GrRGBToHSLFilterEffect>(*this);
}
diff --git a/src/gpu/effects/generated/GrRRectBlurEffect.cpp b/src/gpu/effects/generated/GrRRectBlurEffect.cpp
index b463dc0..7ae5849 100644
--- a/src/gpu/effects/generated/GrRRectBlurEffect.cpp
+++ b/src/gpu/effects/generated/GrRRectBlurEffect.cpp
@@ -157,7 +157,7 @@
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
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.cpp b/src/gpu/effects/generated/GrRectBlurEffect.cpp
index 972e053..9c19e2e 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.cpp
+++ b/src/gpu/effects/generated/GrRectBlurEffect.cpp
@@ -150,7 +150,7 @@
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
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 45dea94..eb8bacd 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -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 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
}
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 @@
// 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 @@
}
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 @@
// 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 @@
}
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 @@
// 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 @@
(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 @@
// 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 @@
// 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 @@
}
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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
{
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 7965730..768aeef 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -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 @@
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 @@
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);
diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp
index dab80f0..5fc828f 100644
--- a/src/gpu/gl/GrGLGpuProgramCache.cpp
+++ b/src/gpu/gl/GrGLGpuProgramCache.cpp
@@ -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 @@
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 @@
return false;
}
- fMap.insert(desc, std::unique_ptr<Entry>(new Entry(precompiledProgram)));
+ fMap.insert(desc, std::make_unique<Entry>(precompiledProgram));
return true;
}
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 7a152ca..cbb0a44 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -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 @@
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();
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 61fa782..19edaca 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -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::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;
diff --git a/src/gpu/gradients/generated/GrClampedGradientEffect.cpp b/src/gpu/gradients/generated/GrClampedGradientEffect.cpp
index 29a8644..f0c75f6 100644
--- a/src/gpu/gradients/generated/GrClampedGradientEffect.cpp
+++ b/src/gpu/gradients/generated/GrClampedGradientEffect.cpp
@@ -112,5 +112,5 @@
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrClampedGradientEffect::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrClampedGradientEffect(*this));
+ return std::make_unique<GrClampedGradientEffect>(*this);
}
diff --git a/src/gpu/gradients/generated/GrDualIntervalGradientColorizer.cpp b/src/gpu/gradients/generated/GrDualIntervalGradientColorizer.cpp
index c4d8dd6..4997042 100644
--- a/src/gpu/gradients/generated/GrDualIntervalGradientColorizer.cpp
+++ b/src/gpu/gradients/generated/GrDualIntervalGradientColorizer.cpp
@@ -135,7 +135,7 @@
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,
diff --git a/src/gpu/gradients/generated/GrLinearGradientLayout.cpp b/src/gpu/gradients/generated/GrLinearGradientLayout.cpp
index 11cdf6a..4133c0f 100644
--- a/src/gpu/gradients/generated/GrLinearGradientLayout.cpp
+++ b/src/gpu/gradients/generated/GrLinearGradientLayout.cpp
@@ -51,7 +51,7 @@
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
diff --git a/src/gpu/gradients/generated/GrRadialGradientLayout.cpp b/src/gpu/gradients/generated/GrRadialGradientLayout.cpp
index 029c0d1..6f8f325 100644
--- a/src/gpu/gradients/generated/GrRadialGradientLayout.cpp
+++ b/src/gpu/gradients/generated/GrRadialGradientLayout.cpp
@@ -51,7 +51,7 @@
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
diff --git a/src/gpu/gradients/generated/GrSingleIntervalGradientColorizer.cpp b/src/gpu/gradients/generated/GrSingleIntervalGradientColorizer.cpp
index 8ee0cbd..0bf70a1 100644
--- a/src/gpu/gradients/generated/GrSingleIntervalGradientColorizer.cpp
+++ b/src/gpu/gradients/generated/GrSingleIntervalGradientColorizer.cpp
@@ -86,5 +86,5 @@
this->setUsesSampleCoordsDirectly();
}
std::unique_ptr<GrFragmentProcessor> GrSingleIntervalGradientColorizer::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrSingleIntervalGradientColorizer(*this));
+ return std::make_unique<GrSingleIntervalGradientColorizer>(*this);
}
diff --git a/src/gpu/gradients/generated/GrSweepGradientLayout.cpp b/src/gpu/gradients/generated/GrSweepGradientLayout.cpp
index b71b389..8bb3372 100644
--- a/src/gpu/gradients/generated/GrSweepGradientLayout.cpp
+++ b/src/gpu/gradients/generated/GrSweepGradientLayout.cpp
@@ -89,7 +89,7 @@
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
diff --git a/src/gpu/gradients/generated/GrTiledGradientEffect.cpp b/src/gpu/gradients/generated/GrTiledGradientEffect.cpp
index 235b9d4..a8022fb 100644
--- a/src/gpu/gradients/generated/GrTiledGradientEffect.cpp
+++ b/src/gpu/gradients/generated/GrTiledGradientEffect.cpp
@@ -91,5 +91,5 @@
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrTiledGradientEffect::clone() const {
- return std::unique_ptr<GrFragmentProcessor>(new GrTiledGradientEffect(*this));
+ return std::make_unique<GrTiledGradientEffect>(*this);
}
diff --git a/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.cpp b/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.cpp
index 758af5a..9c0afde 100644
--- a/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.cpp
+++ b/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.cpp
@@ -183,7 +183,7 @@
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
diff --git a/src/gpu/gradients/generated/GrUnrolledBinaryGradientColorizer.cpp b/src/gpu/gradients/generated/GrUnrolledBinaryGradientColorizer.cpp
index 38eb82e..ff9914d 100644
--- a/src/gpu/gradients/generated/GrUnrolledBinaryGradientColorizer.cpp
+++ b/src/gpu/gradients/generated/GrUnrolledBinaryGradientColorizer.cpp
@@ -342,7 +342,7 @@
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;
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 58229f8..b40dd22 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
}
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
{
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index ba1fcca..cb0883c 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -319,7 +319,7 @@
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,
diff --git a/src/gpu/vk/GrVkPipelineStateCache.cpp b/src/gpu/vk/GrVkPipelineStateCache.cpp
index 769ca1b..e2c3c04 100644
--- a/src/gpu/vk/GrVkPipelineStateCache.cpp
+++ b/src/gpu/vk/GrVkPipelineStateCache.cpp
@@ -121,7 +121,7 @@
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();
diff --git a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
index d31228b..6bd7d02 100644
--- a/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
+++ b/src/gpu/vk/GrVkSecondaryCBDrawContext.cpp
@@ -56,7 +56,7 @@
SkCanvas* GrVkSecondaryCBDrawContext::getCanvas() {
if (!fCachedCanvas) {
- fCachedCanvas = std::unique_ptr<SkCanvas>(new SkCanvas(fDevice));
+ fCachedCanvas = std::make_unique<SkCanvas>(fDevice);
}
return fCachedCanvas.get();
}
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index 287883c..2c0d699 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -280,7 +280,5 @@
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()));
}
diff --git a/src/pdf/SkPDFTypes.h b/src/pdf/SkPDFTypes.h
index 1555a4c..45ba6c5 100644
--- a/src/pdf/SkPDFTypes.h
+++ b/src/pdf/SkPDFTypes.h
@@ -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 @@
};
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
diff --git a/src/ports/SkFontMgr_android_parser.cpp b/src/ports/SkFontMgr_android_parser.cpp
index 60b94bd..c5c4092 100644
--- a/src/ports/SkFontMgr_android_parser.cpp
+++ b/src/ports/SkFontMgr_android_parser.cpp
@@ -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 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];
diff --git a/src/ports/SkTypeface_mac_ct.cpp b/src/ports/SkTypeface_mac_ct.cpp
index 5eadcf8..923b98f 100644
--- a/src/ports/SkTypeface_mac_ct.cpp
+++ b/src/ports/SkTypeface_mac_ct.cpp
@@ -728,7 +728,7 @@
}
// 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;
diff --git a/src/sksl/SkSLCPPCodeGenerator.cpp b/src/sksl/SkSLCPPCodeGenerator.cpp
index a95b36c..efffa2d 100644
--- a/src/sksl/SkSLCPPCodeGenerator.cpp
+++ b/src/sksl/SkSLCPPCodeGenerator.cpp
@@ -1102,7 +1102,7 @@
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");
}
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 5342d69..101d71c 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -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<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;
}
diff --git a/src/sksl/SkSLContext.h b/src/sksl/SkSLContext.h
index 277f85b..1cca5e6 100644
--- a/src/sksl/SkSLContext.h
+++ b/src/sksl/SkSLContext.h
@@ -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 @@
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);
}
};
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 3b46c44..e41967a 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -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 @@
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 {
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index 2e91875..febc59c 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -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 @@
}
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::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 @@
}
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 @@
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 @@
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 @@
!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<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<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::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 @@
}
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 @@
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 @@
}
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::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 @@
}
}
// 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 @@
}
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<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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
!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 @@
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;
diff --git a/src/sksl/SkSLParser.cpp b/src/sksl/SkSLParser.cpp
index 4262f2f..d7e19ea 100644
--- a/src/sksl/SkSLParser.cpp
+++ b/src/sksl/SkSLParser.cpp
@@ -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 @@
/* (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 @@
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));
}
diff --git a/src/sksl/SkSLRehydrator.cpp b/src/sksl/SkSLRehydrator.cpp
index d1f6681..45c0c89 100644
--- a/src/sksl/SkSLRehydrator.cpp
+++ b/src/sksl/SkSLRehydrator.cpp
@@ -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 @@
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;
diff --git a/src/svg/SkSVGDevice.cpp b/src/svg/SkSVGDevice.cpp
index 801d19e..d1fe42b 100644
--- a/src/svg/SkSVGDevice.cpp
+++ b/src/svg/SkSVGDevice.cpp
@@ -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 @@
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::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);
}
diff --git a/src/utils/mac/SkCreateCGImageRef.cpp b/src/utils/mac/SkCreateCGImageRef.cpp
index 4248b1b..74e9ce2 100644
--- a/src/utils/mac/SkCreateCGImageRef.cpp
+++ b/src/utils/mac/SkCreateCGImageRef.cpp
@@ -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 @@
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,
diff --git a/src/xml/SkDOM.cpp b/src/xml/SkDOM.cpp
index 0f39135..feee5a8 100644
--- a/src/xml/SkDOM.cpp
+++ b/src/xml/SkDOM.cpp
@@ -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 @@
SkXMLParser* SkDOM::beginParsing() {
SkASSERT(!fParser);
- fParser.reset(new SkDOMParser(&fAlloc));
+ fParser = std::make_unique<SkDOMParser>(&fAlloc);
return fParser.get();
}