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/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;