aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2017-01-10 15:02:26 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-11 15:36:45 +0000
commita5494f117086d712855e4b6289c58c92d1549bcf (patch)
tree1f43412b8e0d5047f738d26e1bb165b29b542af8
parent21d742dbafde600d7f0d3b7de95cd083dd54ad97 (diff)
SkTypes.h : move SkAutoMalloc into SkAutoMalloc.h
* SkAutoFree moved to SkTemplates.h (now implmented with unique_ptr). * SkAutoMalloc and SkAutoSMalloc moved to SkAutoMalloc.h * "SkAutoFree X(sk_malloc_throw(N));" --> "SkAutoMalloc X(N);" Change-Id: Idacd86ca09e22bf092422228599ae0d9bedded88 Reviewed-on: https://skia-review.googlesource.com/4543 Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
-rw-r--r--bench/AndroidCodecBench.h1
-rw-r--r--bench/CodecBench.h1
-rw-r--r--bench/ColorCodecBench.h1
-rw-r--r--bench/nanobench.cpp7
-rw-r--r--dm/DMSrcSink.cpp7
-rw-r--r--gm/drawatlas.cpp2
-rw-r--r--include/core/SkTypes.h216
-rw-r--r--include/private/SkTemplates.h2
-rw-r--r--src/core/SkAAClip.h1
-rw-r--r--src/core/SkAutoMalloc.h174
-rw-r--r--src/core/SkBlitter.h2
-rw-r--r--src/core/SkColorSpace_ICC.cpp3
-rw-r--r--src/core/SkDistanceFieldGen.cpp2
-rw-r--r--src/core/SkFontStream.cpp1
-rw-r--r--src/core/SkICC.cpp1
-rw-r--r--src/core/SkLinearBitmapPipeline_sample.h1
-rw-r--r--src/core/SkMaskFilter.cpp8
-rw-r--r--src/core/SkPictureData.cpp3
-rw-r--r--src/core/SkScalerContext.cpp9
-rw-r--r--src/core/SkScan_AAAPath.cpp5
-rw-r--r--src/effects/gradients/SkGradientShaderPriv.h10
-rw-r--r--src/gpu/GrDistanceFieldGenFromVector.cpp10
-rw-r--r--src/gpu/GrYUVProvider.cpp1
-rw-r--r--src/gpu/SkGr.cpp6
-rw-r--r--src/gpu/gl/GrGLGpu.cpp16
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp1
-rw-r--r--src/gpu/gl/builders/GrGLShaderStringBuilder.cpp7
-rw-r--r--src/gpu/ops/GrAADistanceFieldPathRenderer.cpp1
-rw-r--r--src/gpu/ops/GrMSAAPathRenderer.cpp5
-rw-r--r--src/gpu/text/GrAtlasGlyphCache.cpp1
-rw-r--r--src/gpu/vk/GrVkBackendContext.cpp1
-rw-r--r--src/gpu/vk/GrVkPipelineStateDataManager.h1
-rw-r--r--src/pipe/SkPipeCanvas.cpp5
-rw-r--r--src/ports/SkFontConfigInterface_direct.cpp2
-rw-r--r--src/ports/SkFontHost_FreeType.cpp1
-rw-r--r--src/ports/SkFontHost_mac.cpp1
-rw-r--r--src/ports/SkImageEncoder_WIC.cpp4
-rw-r--r--tests/CodecTest.cpp5
-rw-r--r--tests/ColorFilterTest.cpp2
-rw-r--r--tests/FontHostTest.cpp1
-rw-r--r--tests/FrontBufferedStreamTest.cpp2
-rw-r--r--tests/MallocPixelRefTest.cpp1
-rw-r--r--tests/PaintBreakTextTest.cpp1
-rw-r--r--tests/PaintTest.cpp1
-rw-r--r--tests/PathTest.cpp6
-rw-r--r--tests/RegionTest.cpp1
-rw-r--r--tests/StreamTest.cpp1
-rw-r--r--tests/Writer32Test.cpp1
-rw-r--r--tests/YUVTest.cpp3
-rw-r--r--third_party/ktx/ktx.cpp4
-rw-r--r--tools/SkShaper_harfbuzz.cpp7
-rw-r--r--tools/debugger/SkDrawCommand.cpp3
-rw-r--r--tools/viewer/sk_app/VulkanWindowContext.cpp1
-rw-r--r--tools/viewer/sk_app/win/RasterWindowContext_win.cpp3
54 files changed, 287 insertions, 276 deletions
diff --git a/bench/AndroidCodecBench.h b/bench/AndroidCodecBench.h
index 8cdd7fec04..528ecabb6b 100644
--- a/bench/AndroidCodecBench.h
+++ b/bench/AndroidCodecBench.h
@@ -9,6 +9,7 @@
#define AndroidCodecBench_DEFINED
#include "Benchmark.h"
+#include "SkAutoMalloc.h"
#include "SkData.h"
#include "SkImageInfo.h"
#include "SkRefCnt.h"
diff --git a/bench/CodecBench.h b/bench/CodecBench.h
index 5b4db24004..dc44704ab6 100644
--- a/bench/CodecBench.h
+++ b/bench/CodecBench.h
@@ -9,6 +9,7 @@
#define CodecBench_DEFINED
#include "Benchmark.h"
+#include "SkAutoMalloc.h"
#include "SkData.h"
#include "SkImageInfo.h"
#include "SkRefCnt.h"
diff --git a/bench/ColorCodecBench.h b/bench/ColorCodecBench.h
index 9159bcf9ad..e5048f8d7b 100644
--- a/bench/ColorCodecBench.h
+++ b/bench/ColorCodecBench.h
@@ -9,6 +9,7 @@
#define ColorCodecBench_DEFINED
#include "Benchmark.h"
+#include "SkAutoMalloc.h"
#include "SkData.h"
#include "SkImageInfo.h"
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index c9456db969..34aaee8dd0 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -25,8 +25,9 @@
#include "Stats.h"
#include "SkAndroidCodec.h"
-#include "SkBitmapRegionDecoder.h"
+#include "SkAutoMalloc.h"
#include "SkBBoxHierarchy.h"
+#include "SkBitmapRegionDecoder.h"
#include "SkCanvas.h"
#include "SkCodec.h"
#include "SkCommonFlags.h"
@@ -38,13 +39,13 @@
#include "SkOSPath.h"
#include "SkPictureRecorder.h"
#include "SkPictureUtils.h"
+#include "SkSVGDOM.h"
+#include "SkScan.h"
#include "SkString.h"
#include "SkSurface.h"
-#include "SkSVGDOM.h"
#include "SkTaskGroup.h"
#include "SkThreadUtils.h"
#include "ThermalManager.h"
-#include "SkScan.h"
#include <stdlib.h>
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 594a4b7182..cea87f7056 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -8,11 +8,12 @@
#include "DMSrcSink.h"
#include "Resources.h"
#include "SkAndroidCodec.h"
+#include "SkAutoMalloc.h"
#include "SkCodec.h"
#include "SkCodecImageGenerator.h"
#include "SkColorSpace.h"
-#include "SkColorSpace_XYZ.h"
#include "SkColorSpaceXform.h"
+#include "SkColorSpace_XYZ.h"
#include "SkCommonFlags.h"
#include "SkData.h"
#include "SkDebugCanvas.h"
@@ -37,10 +38,10 @@
#include "SkRecorder.h"
#include "SkSVGCanvas.h"
#include "SkStream.h"
-#include "SkTLogic.h"
#include "SkSwizzler.h"
-#include <functional>
+#include "SkTLogic.h"
#include <cmath>
+#include <functional>
#if defined(SK_BUILD_FOR_WIN)
#include "SkAutoCoInitialize.h"
diff --git a/gm/drawatlas.cpp b/gm/drawatlas.cpp
index c098e15429..2526177d6c 100644
--- a/gm/drawatlas.cpp
+++ b/gm/drawatlas.cpp
@@ -6,6 +6,8 @@
*/
#include "gm.h"
+
+#include "SkAutoMalloc.h"
#include "SkCanvas.h"
#include "SkRSXform.h"
#include "SkSurface.h"
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 2cc4b9c8a9..f9e1a059fb 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -509,222 +509,6 @@ private:
SkNoncopyable& operator=(const SkNoncopyable&);
};
-class SkAutoFree : SkNoncopyable {
-public:
- SkAutoFree() : fPtr(NULL) {}
- explicit SkAutoFree(void* ptr) : fPtr(ptr) {}
- ~SkAutoFree() { sk_free(fPtr); }
-
- /** Return the currently allocate buffer, or null
- */
- void* get() const { return fPtr; }
-
- /** Assign a new ptr allocated with sk_malloc (or null), and return the
- previous ptr. Note it is the caller's responsibility to sk_free the
- returned ptr.
- */
- void* set(void* ptr) {
- void* prev = fPtr;
- fPtr = ptr;
- return prev;
- }
-
- /** Transfer ownership of the current ptr to the caller, setting the
- internal reference to null. Note the caller is reponsible for calling
- sk_free on the returned address.
- */
- void* release() { return this->set(NULL); }
-
- /** Free the current buffer, and set the internal reference to NULL. Same
- as calling sk_free(release())
- */
- void reset() {
- sk_free(fPtr);
- fPtr = NULL;
- }
-
-private:
- void* fPtr;
- // illegal
- SkAutoFree(const SkAutoFree&);
- SkAutoFree& operator=(const SkAutoFree&);
-};
-#define SkAutoFree(...) SK_REQUIRE_LOCAL_VAR(SkAutoFree)
-
-/**
- * Manage an allocated block of heap memory. This object is the sole manager of
- * the lifetime of the block, so the caller must not call sk_free() or delete
- * on the block, unless release() was called.
- */
-class SkAutoMalloc : SkNoncopyable {
-public:
- explicit SkAutoMalloc(size_t size = 0) {
- fPtr = size ? sk_malloc_throw(size) : NULL;
- fSize = size;
- }
-
- ~SkAutoMalloc() {
- sk_free(fPtr);
- }
-
- /**
- * Passed to reset to specify what happens if the requested size is smaller
- * than the current size (and the current block was dynamically allocated).
- */
- enum OnShrink {
- /**
- * If the requested size is smaller than the current size, and the
- * current block is dynamically allocated, free the old block and
- * malloc a new block of the smaller size.
- */
- kAlloc_OnShrink,
-
- /**
- * If the requested size is smaller than the current size, and the
- * current block is dynamically allocated, just return the old
- * block.
- */
- kReuse_OnShrink
- };
-
- /**
- * Reallocates the block to a new size. The ptr may or may not change.
- */
- void* reset(size_t size = 0, OnShrink shrink = kAlloc_OnShrink, bool* didChangeAlloc = NULL) {
- if (size == fSize || (kReuse_OnShrink == shrink && size < fSize)) {
- if (didChangeAlloc) {
- *didChangeAlloc = false;
- }
- return fPtr;
- }
-
- sk_free(fPtr);
- fPtr = size ? sk_malloc_throw(size) : NULL;
- fSize = size;
- if (didChangeAlloc) {
- *didChangeAlloc = true;
- }
-
- return fPtr;
- }
-
- /**
- * Return the allocated block.
- */
- void* get() { return fPtr; }
- const void* get() const { return fPtr; }
-
- /** Transfer ownership of the current ptr to the caller, setting the
- internal reference to null. Note the caller is reponsible for calling
- sk_free on the returned address.
- */
- void* release() {
- void* ptr = fPtr;
- fPtr = NULL;
- fSize = 0;
- return ptr;
- }
-
-private:
- void* fPtr;
- size_t fSize; // can be larger than the requested size (see kReuse)
-};
-#define SkAutoMalloc(...) SK_REQUIRE_LOCAL_VAR(SkAutoMalloc)
-
-/**
- * Manage an allocated block of memory. If the requested size is <= kSizeRequested (or slightly
- * more), then the allocation will come from the stack rather than the heap. This object is the
- * sole manager of the lifetime of the block, so the caller must not call sk_free() or delete on
- * the block.
- */
-template <size_t kSizeRequested> class SkAutoSMalloc : SkNoncopyable {
-public:
- /**
- * Creates initially empty storage. get() returns a ptr, but it is to a zero-byte allocation.
- * Must call reset(size) to return an allocated block.
- */
- SkAutoSMalloc() {
- fPtr = fStorage;
- fSize = kSize;
- }
-
- /**
- * Allocate a block of the specified size. If size <= kSizeRequested (or slightly more), then
- * the allocation will come from the stack, otherwise it will be dynamically allocated.
- */
- explicit SkAutoSMalloc(size_t size) {
- fPtr = fStorage;
- fSize = kSize;
- this->reset(size);
- }
-
- /**
- * Free the allocated block (if any). If the block was small enough to have been allocated on
- * the stack, then this does nothing.
- */
- ~SkAutoSMalloc() {
- if (fPtr != (void*)fStorage) {
- sk_free(fPtr);
- }
- }
-
- /**
- * Return the allocated block. May return non-null even if the block is of zero size. Since
- * this may be on the stack or dynamically allocated, the caller must not call sk_free() on it,
- * but must rely on SkAutoSMalloc to manage it.
- */
- void* get() const { return fPtr; }
-
- /**
- * Return a new block of the requested size, freeing (as necessary) any previously allocated
- * block. As with the constructor, if size <= kSizeRequested (or slightly more) then the return
- * block may be allocated locally, rather than from the heap.
- */
- void* reset(size_t size,
- SkAutoMalloc::OnShrink shrink = SkAutoMalloc::kAlloc_OnShrink,
- bool* didChangeAlloc = NULL) {
- size = (size < kSize) ? kSize : size;
- bool alloc = size != fSize && (SkAutoMalloc::kAlloc_OnShrink == shrink || size > fSize);
- if (didChangeAlloc) {
- *didChangeAlloc = alloc;
- }
- if (alloc) {
- if (fPtr != (void*)fStorage) {
- sk_free(fPtr);
- }
-
- if (size == kSize) {
- SkASSERT(fPtr != fStorage); // otherwise we lied when setting didChangeAlloc.
- fPtr = fStorage;
- } else {
- fPtr = sk_malloc_flags(size, SK_MALLOC_THROW | SK_MALLOC_TEMP);
- }
-
- fSize = size;
- }
- SkASSERT(fSize >= size && fSize >= kSize);
- SkASSERT((fPtr == fStorage) || fSize > kSize);
- return fPtr;
- }
-
-private:
- // Align up to 32 bits.
- static const size_t kSizeAlign4 = SkAlign4(kSizeRequested);
-#if defined(GOOGLE3)
- // Stack frame size is limited for GOOGLE3. 4k is less than the actual max, but some functions
- // have multiple large stack allocations.
- static const size_t kMaxBytes = 4 * 1024;
- static const size_t kSize = kSizeRequested > kMaxBytes ? kMaxBytes : kSizeAlign4;
-#else
- static const size_t kSize = kSizeAlign4;
-#endif
-
- void* fPtr;
- size_t fSize; // can be larger than the requested size (see kReuse)
- uint32_t fStorage[kSize >> 2];
-};
-// Can't guard the constructor because it's a template class.
-
#endif /* C++ */
#endif
diff --git a/include/private/SkTemplates.h b/include/private/SkTemplates.h
index 5c6403d509..f50af8b7f9 100644
--- a/include/private/SkTemplates.h
+++ b/include/private/SkTemplates.h
@@ -462,4 +462,6 @@ private:
SkAlignedSStorage<sizeof(T)*N> fStorage;
};
+using SkAutoFree = std::unique_ptr<void, SkFunctionWrapper<void, void, sk_free>>;
+
#endif
diff --git a/src/core/SkAAClip.h b/src/core/SkAAClip.h
index 7b29ef142a..c94756fd5f 100644
--- a/src/core/SkAAClip.h
+++ b/src/core/SkAAClip.h
@@ -8,6 +8,7 @@
#ifndef SkAAClip_DEFINED
#define SkAAClip_DEFINED
+#include "SkAutoMalloc.h"
#include "SkBlitter.h"
#include "SkRegion.h"
diff --git a/src/core/SkAutoMalloc.h b/src/core/SkAutoMalloc.h
new file mode 100644
index 0000000000..7be882547d
--- /dev/null
+++ b/src/core/SkAutoMalloc.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkAutoMalloc_DEFINED
+#define SkAutoMalloc_DEFINED
+
+#include "SkTypes.h"
+
+#include <memory>
+
+/**
+ * Manage an allocated block of heap memory. This object is the sole manager of
+ * the lifetime of the block, so the caller must not call sk_free() or delete
+ * on the block, unless release() was called.
+ */
+class SkAutoMalloc : SkNoncopyable {
+public:
+ explicit SkAutoMalloc(size_t size = 0)
+ : fPtr(size ? sk_malloc_throw(size) : nullptr), fSize(size) {}
+
+ /**
+ * Passed to reset to specify what happens if the requested size is smaller
+ * than the current size (and the current block was dynamically allocated).
+ */
+ enum OnShrink {
+ /**
+ * If the requested size is smaller than the current size, and the
+ * current block is dynamically allocated, free the old block and
+ * malloc a new block of the smaller size.
+ */
+ kAlloc_OnShrink,
+
+ /**
+ * If the requested size is smaller than the current size, and the
+ * current block is dynamically allocated, just return the old
+ * block.
+ */
+ kReuse_OnShrink
+ };
+
+ /**
+ * Reallocates the block to a new size. The ptr may or may not change.
+ */
+ void* reset(size_t size = 0, OnShrink shrink = kAlloc_OnShrink) {
+ if (size != fSize && (size > fSize || kReuse_OnShrink != shrink)) {
+ fPtr.reset(size ? sk_malloc_throw(size) : nullptr);
+ fSize = size;
+ }
+ return fPtr.get();
+ }
+
+ /**
+ * Return the allocated block.
+ */
+ void* get() { return fPtr.get(); }
+ const void* get() const { return fPtr.get(); }
+
+ /** Transfer ownership of the current ptr to the caller, setting the
+ internal reference to null. Note the caller is reponsible for calling
+ sk_free on the returned address.
+ */
+ void* release() {
+ fSize = 0;
+ return fPtr.release();
+ }
+
+private:
+ struct WrapFree {
+ void operator()(void* p) { sk_free(p); }
+ };
+ std::unique_ptr<void, WrapFree> fPtr;
+ size_t fSize; // can be larger than the requested size (see kReuse)
+};
+#define SkAutoMalloc(...) SK_REQUIRE_LOCAL_VAR(SkAutoMalloc)
+
+/**
+ * Manage an allocated block of memory. If the requested size is <= kSizeRequested (or slightly
+ * more), then the allocation will come from the stack rather than the heap. This object is the
+ * sole manager of the lifetime of the block, so the caller must not call sk_free() or delete on
+ * the block.
+ */
+template <size_t kSizeRequested> class SkAutoSMalloc : SkNoncopyable {
+public:
+ /**
+ * Creates initially empty storage. get() returns a ptr, but it is to a zero-byte allocation.
+ * Must call reset(size) to return an allocated block.
+ */
+ SkAutoSMalloc() {
+ fPtr = fStorage;
+ fSize = kSize;
+ }
+
+ /**
+ * Allocate a block of the specified size. If size <= kSizeRequested (or slightly more), then
+ * the allocation will come from the stack, otherwise it will be dynamically allocated.
+ */
+ explicit SkAutoSMalloc(size_t size) {
+ fPtr = fStorage;
+ fSize = kSize;
+ this->reset(size);
+ }
+
+ /**
+ * Free the allocated block (if any). If the block was small enough to have been allocated on
+ * the stack, then this does nothing.
+ */
+ ~SkAutoSMalloc() {
+ if (fPtr != (void*)fStorage) {
+ sk_free(fPtr);
+ }
+ }
+
+ /**
+ * Return the allocated block. May return non-null even if the block is of zero size. Since
+ * this may be on the stack or dynamically allocated, the caller must not call sk_free() on it,
+ * but must rely on SkAutoSMalloc to manage it.
+ */
+ void* get() const { return fPtr; }
+
+ /**
+ * Return a new block of the requested size, freeing (as necessary) any previously allocated
+ * block. As with the constructor, if size <= kSizeRequested (or slightly more) then the return
+ * block may be allocated locally, rather than from the heap.
+ */
+ void* reset(size_t size,
+ SkAutoMalloc::OnShrink shrink = SkAutoMalloc::kAlloc_OnShrink,
+ bool* didChangeAlloc = nullptr) {
+ size = (size < kSize) ? kSize : size;
+ bool alloc = size != fSize && (SkAutoMalloc::kAlloc_OnShrink == shrink || size > fSize);
+ if (didChangeAlloc) {
+ *didChangeAlloc = alloc;
+ }
+ if (alloc) {
+ if (fPtr != (void*)fStorage) {
+ sk_free(fPtr);
+ }
+
+ if (size == kSize) {
+ SkASSERT(fPtr != fStorage); // otherwise we lied when setting didChangeAlloc.
+ fPtr = fStorage;
+ } else {
+ fPtr = sk_malloc_flags(size, SK_MALLOC_THROW | SK_MALLOC_TEMP);
+ }
+
+ fSize = size;
+ }
+ SkASSERT(fSize >= size && fSize >= kSize);
+ SkASSERT((fPtr == fStorage) || fSize > kSize);
+ return fPtr;
+ }
+
+private:
+ // Align up to 32 bits.
+ static const size_t kSizeAlign4 = SkAlign4(kSizeRequested);
+#if defined(GOOGLE3)
+ // Stack frame size is limited for GOOGLE3. 4k is less than the actual max, but some functions
+ // have multiple large stack allocations.
+ static const size_t kMaxBytes = 4 * 1024;
+ static const size_t kSize = kSizeRequested > kMaxBytes ? kMaxBytes : kSizeAlign4;
+#else
+ static const size_t kSize = kSizeAlign4;
+#endif
+
+ void* fPtr;
+ size_t fSize; // can be larger than the requested size (see kReuse)
+ uint32_t fStorage[kSize >> 2];
+};
+// Can't guard the constructor because it's a template class.
+
+#endif
diff --git a/src/core/SkBlitter.h b/src/core/SkBlitter.h
index f03a308243..fd6ca8c110 100644
--- a/src/core/SkBlitter.h
+++ b/src/core/SkBlitter.h
@@ -8,12 +8,12 @@
#ifndef SkBlitter_DEFINED
#define SkBlitter_DEFINED
+#include "SkAutoMalloc.h"
#include "SkBitmapProcShader.h"
#include "SkColor.h"
#include "SkRect.h"
#include "SkRegion.h"
#include "SkShader.h"
-#include "SkTypes.h"
class SkMatrix;
class SkPaint;
diff --git a/src/core/SkColorSpace_ICC.cpp b/src/core/SkColorSpace_ICC.cpp
index 29291a3e00..ff4b9018dd 100644
--- a/src/core/SkColorSpace_ICC.cpp
+++ b/src/core/SkColorSpace_ICC.cpp
@@ -5,11 +5,12 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkColorSpace.h"
+#include "SkColorSpacePriv.h"
#include "SkColorSpace_A2B.h"
#include "SkColorSpace_Base.h"
#include "SkColorSpace_XYZ.h"
-#include "SkColorSpacePriv.h"
#include "SkEndian.h"
#include "SkFixed.h"
#include "SkICCPriv.h"
diff --git a/src/core/SkDistanceFieldGen.cpp b/src/core/SkDistanceFieldGen.cpp
index 7e4675bbc1..f227d6a30d 100644
--- a/src/core/SkDistanceFieldGen.cpp
+++ b/src/core/SkDistanceFieldGen.cpp
@@ -5,8 +5,10 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkDistanceFieldGen.h"
#include "SkPoint.h"
+#include "SkTemplates.h"
struct DFData {
float fAlpha; // alpha value of source texel
diff --git a/src/core/SkFontStream.cpp b/src/core/SkFontStream.cpp
index b2ffe8deba..e9f23f9f24 100644
--- a/src/core/SkFontStream.cpp
+++ b/src/core/SkFontStream.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkEndian.h"
#include "SkFontStream.h"
#include "SkStream.h"
diff --git a/src/core/SkICC.cpp b/src/core/SkICC.cpp
index b47cc71574..6b09f29dae 100644
--- a/src/core/SkICC.cpp
+++ b/src/core/SkICC.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkColorSpace_Base.h"
#include "SkColorSpace_XYZ.h"
#include "SkColorSpacePriv.h"
diff --git a/src/core/SkLinearBitmapPipeline_sample.h b/src/core/SkLinearBitmapPipeline_sample.h
index 8e53136fea..0bfe8f26ae 100644
--- a/src/core/SkLinearBitmapPipeline_sample.h
+++ b/src/core/SkLinearBitmapPipeline_sample.h
@@ -10,6 +10,7 @@
#include <tuple>
+#include "SkAutoMalloc.h"
#include "SkColor.h"
#include "SkColorPriv.h"
#include "SkFixed.h"
diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp
index 85ee38d6dd..8ad13aab97 100644
--- a/src/core/SkMaskFilter.cpp
+++ b/src/core/SkMaskFilter.cpp
@@ -5,15 +5,15 @@
* found in the LICENSE file.
*/
-
#include "SkMaskFilter.h"
+
+#include "SkAutoMalloc.h"
#include "SkBlitter.h"
-#include "SkDraw.h"
#include "SkCachedData.h"
+#include "SkDraw.h"
#include "SkPath.h"
-#include "SkRasterClip.h"
#include "SkRRect.h"
-#include "SkTypes.h"
+#include "SkRasterClip.h"
#if SK_SUPPORT_GPU
#include "GrTexture.h"
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 1aff1e46b9..9780b7d104 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -4,7 +4,10 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#include <new>
+
+#include "SkAutoMalloc.h"
#include "SkImageGenerator.h"
#include "SkPictureData.h"
#include "SkPictureRecord.h"
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index c06222d4d8..4835b5297d 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -5,8 +5,9 @@
* found in the LICENSE file.
*/
-
#include "SkScalerContext.h"
+
+#include "SkAutoMalloc.h"
#include "SkAutoPixmapStorage.h"
#include "SkColorPriv.h"
#include "SkDescriptor.h"
@@ -16,13 +17,13 @@
#include "SkMaskFilter.h"
#include "SkMaskGamma.h"
#include "SkMatrix22.h"
-#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
#include "SkPathEffect.h"
-#include "SkRasterizer.h"
#include "SkRasterClip.h"
+#include "SkRasterizer.h"
+#include "SkReadBuffer.h"
#include "SkStroke.h"
#include "SkStrokeRec.h"
+#include "SkWriteBuffer.h"
#define ComputeBWRowBytes(width) (((unsigned)(width) + 7) >> 3)
diff --git a/src/core/SkScan_AAAPath.cpp b/src/core/SkScan_AAAPath.cpp
index f96e7b9bb8..8c0a748bdf 100644
--- a/src/core/SkScan_AAAPath.cpp
+++ b/src/core/SkScan_AAAPath.cpp
@@ -5,10 +5,11 @@
* found in the LICENSE file.
*/
+#include "SkAnalyticEdge.h"
#include "SkAntiRun.h"
+#include "SkAutoMalloc.h"
#include "SkBlitter.h"
#include "SkEdge.h"
-#include "SkAnalyticEdge.h"
#include "SkEdgeBuilder.h"
#include "SkGeometry.h"
#include "SkPath.h"
@@ -17,8 +18,8 @@
#include "SkRegion.h"
#include "SkScan.h"
#include "SkScanPriv.h"
-#include "SkTemplates.h"
#include "SkTSort.h"
+#include "SkTemplates.h"
#include "SkUtils.h"
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 4b7bbb0a0a..48ccbd50d0 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -10,15 +10,17 @@
#include "SkGradientBitmapCache.h"
#include "SkGradientShader.h"
+
+#include "SkAutoMalloc.h"
#include "SkClampRange.h"
#include "SkColorPriv.h"
#include "SkColorSpace.h"
-#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
#include "SkMallocPixelRef.h"
-#include "SkUtils.h"
-#include "SkShader.h"
#include "SkOnce.h"
+#include "SkReadBuffer.h"
+#include "SkShader.h"
+#include "SkUtils.h"
+#include "SkWriteBuffer.h"
#if SK_SUPPORT_GPU
#define GR_GL_USE_ACCURATE_HARD_STOP_GRADIENTS 1
diff --git a/src/gpu/GrDistanceFieldGenFromVector.cpp b/src/gpu/GrDistanceFieldGenFromVector.cpp
index 8179500660..4a509e67af 100644
--- a/src/gpu/GrDistanceFieldGenFromVector.cpp
+++ b/src/gpu/GrDistanceFieldGenFromVector.cpp
@@ -7,12 +7,14 @@
#include "SkDistanceFieldGen.h"
#include "GrDistanceFieldGenFromVector.h"
-#include "SkMatrix.h"
-#include "SkPoint.h"
+
+#include "GrConfig.h"
+#include "GrPathUtils.h"
+#include "SkAutoMalloc.h"
#include "SkGeometry.h"
+#include "SkMatrix.h"
#include "SkPathOps.h"
-#include "GrPathUtils.h"
-#include "GrConfig.h"
+#include "SkPoint.h"
/**
* If a scanline (a row of texel) cross from the kRight_SegSide
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 6fbad18841..9f88c72d22 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -11,6 +11,7 @@
#include "effects/GrGammaEffect.h"
#include "effects/GrYUVEffect.h"
+#include "SkAutoMalloc.h"
#include "SkCachedData.h"
#include "SkRefCnt.h"
#include "SkResourceCache.h"
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 9d6072c551..c1a4160b83 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
-
#include "SkGr.h"
#include "SkGrPriv.h"
@@ -19,16 +18,17 @@
#include "GrXferProcessor.h"
#include "GrYUVProvider.h"
+#include "SkAutoMalloc.h"
#include "SkBlendModePriv.h"
+#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkConfig8888.h"
-#include "SkCanvas.h"
#include "SkData.h"
#include "SkMaskFilter.h"
#include "SkMessageBus.h"
#include "SkMipMap.h"
-#include "SkPixelRef.h"
#include "SkPM4fPriv.h"
+#include "SkPixelRef.h"
#include "SkResourceCache.h"
#include "SkTemplates.h"
#include "SkYUVPlanesCache.h"
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 74e52583dd..95a01ab695 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -6,31 +6,33 @@
*/
#include "GrGLGpu.h"
+
+#include "../private/GrGLSL.h"
+#include "GrFixedClip.h"
#include "GrGLBuffer.h"
#include "GrGLGpuCommandBuffer.h"
#include "GrGLStencilAttachment.h"
#include "GrGLTextureRenderTarget.h"
-#include "GrFixedClip.h"
#include "GrGpuResourcePriv.h"
#include "GrMesh.h"
-#include "GrPipeline.h"
#include "GrPLSGeometryProcessor.h"
+#include "GrPipeline.h"
#include "GrRenderTargetPriv.h"
#include "GrShaderCaps.h"
#include "GrSurfacePriv.h"
#include "GrTexturePriv.h"
#include "GrTypes.h"
-#include "builders/GrGLShaderStringBuilder.h"
-#include "glsl/GrGLSLPLSPathRendering.h"
-#include "instanced/GLInstancedRendering.h"
+#include "SkAutoMalloc.h"
#include "SkMakeUnique.h"
#include "SkMipMap.h"
#include "SkPixmap.h"
-#include "SkStrokeRec.h"
#include "SkSLCompiler.h"
+#include "SkStrokeRec.h"
#include "SkTemplates.h"
#include "SkTypes.h"
-#include "../private/GrGLSL.h"
+#include "builders/GrGLShaderStringBuilder.h"
+#include "glsl/GrGLSLPLSPathRendering.h"
+#include "instanced/GLInstancedRendering.h"
#define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
#define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X)
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 045593ff42..c3e81fb358 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -14,6 +14,7 @@
#include "GrShaderCaps.h"
#include "GrSwizzle.h"
#include "GrTexture.h"
+#include "SkAutoMalloc.h"
#include "SkTraceEvent.h"
#include "gl/GrGLGpu.h"
#include "gl/GrGLProgram.h"
diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
index df44edd07e..6c719fe305 100644
--- a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
@@ -6,11 +6,12 @@
*/
#include "GrGLShaderStringBuilder.h"
-#include "gl/GrGLGpu.h"
-#include "gl/GrGLSLPrettyPrint.h"
-#include "SkTraceEvent.h"
+#include "SkAutoMalloc.h"
#include "SkSLCompiler.h"
#include "SkSLGLSLCodeGenerator.h"
+#include "SkTraceEvent.h"
+#include "gl/GrGLGpu.h"
+#include "gl/GrGLSLPrettyPrint.h"
#include "ir/SkSLProgram.h"
#define GL_CALL(X) GR_GL_CALL(gpu->glInterface(), X)
diff --git a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp
index c9b30f5154..616b69f276 100644
--- a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp
@@ -21,6 +21,7 @@
#include "ops/GrMeshDrawOp.h"
#include "SkPathOps.h"
+#include "SkAutoMalloc.h"
#include "SkDistanceFieldGen.h"
#include "GrDistanceFieldGenFromVector.h"
diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp
index cc6781cac4..53e4690eff 100644
--- a/src/gpu/ops/GrMSAAPathRenderer.cpp
+++ b/src/gpu/ops/GrMSAAPathRenderer.cpp
@@ -16,6 +16,7 @@
#include "GrPathStencilSettings.h"
#include "GrPathUtils.h"
#include "GrPipelineBuilder.h"
+#include "SkAutoMalloc.h"
#include "SkGeometry.h"
#include "SkTraceEvent.h"
#include "gl/GrGLVaryingHandler.h"
@@ -346,7 +347,7 @@ private:
MSAAQuadVertices quads;
size_t quadVertexStride = sizeof(MSAAQuadVertices::Vertex);
- SkAutoFree quadVertexPtr(sk_malloc_throw(fMaxQuadVertices * quadVertexStride));
+ SkAutoMalloc quadVertexPtr(fMaxQuadVertices * quadVertexStride);
quads.vertices = (MSAAQuadVertices::Vertex*) quadVertexPtr.get();
quads.nextVertex = quads.vertices;
SkDEBUGCODE(quads.verticesEnd = quads.vertices + fMaxQuadVertices;)
@@ -369,7 +370,7 @@ private:
SkAutoFree quadIndexPtr;
if (fIsIndexed) {
quads.indices = (uint16_t*)sk_malloc_throw(3 * fMaxQuadVertices * sizeof(uint16_t));
- quadIndexPtr.set(quads.indices);
+ quadIndexPtr.reset(quads.indices);
quads.nextIndex = quads.indices;
} else {
quads.indices = nullptr;
diff --git a/src/gpu/text/GrAtlasGlyphCache.cpp b/src/gpu/text/GrAtlasGlyphCache.cpp
index 5d85f4919d..e51f6cc381 100644
--- a/src/gpu/text/GrAtlasGlyphCache.cpp
+++ b/src/gpu/text/GrAtlasGlyphCache.cpp
@@ -11,6 +11,7 @@
#include "GrRectanizer.h"
#include "GrResourceProvider.h"
#include "GrSurfacePriv.h"
+#include "SkAutoMalloc.h"
#include "SkString.h"
#include "SkDistanceFieldGen.h"
diff --git a/src/gpu/vk/GrVkBackendContext.cpp b/src/gpu/vk/GrVkBackendContext.cpp
index 93ae01ff6f..5a9de04d39 100644
--- a/src/gpu/vk/GrVkBackendContext.cpp
+++ b/src/gpu/vk/GrVkBackendContext.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "vk/GrVkBackendContext.h"
#include "vk/GrVkExtensions.h"
#include "vk/GrVkInterface.h"
diff --git a/src/gpu/vk/GrVkPipelineStateDataManager.h b/src/gpu/vk/GrVkPipelineStateDataManager.h
index 312c6c659d..4a061a66f9 100644
--- a/src/gpu/vk/GrVkPipelineStateDataManager.h
+++ b/src/gpu/vk/GrVkPipelineStateDataManager.h
@@ -10,6 +10,7 @@
#include "glsl/GrGLSLProgramDataManager.h"
+#include "SkAutoMalloc.h"
#include "vk/GrVkUniformHandler.h"
class GrVkGpu;
diff --git a/src/pipe/SkPipeCanvas.cpp b/src/pipe/SkPipeCanvas.cpp
index 33b58a4165..e707f0db19 100644
--- a/src/pipe/SkPipeCanvas.cpp
+++ b/src/pipe/SkPipeCanvas.cpp
@@ -5,15 +5,16 @@
* found in the LICENSE file.
*/
-#include "SkPathEffect.h"
+#include "SkAutoMalloc.h"
#include "SkColorFilter.h"
#include "SkDrawLooper.h"
#include "SkImageFilter.h"
#include "SkMaskFilter.h"
+#include "SkPathEffect.h"
#include "SkPipeCanvas.h"
#include "SkPipeFormat.h"
-#include "SkRasterizer.h"
#include "SkRSXform.h"
+#include "SkRasterizer.h"
#include "SkShader.h"
#include "SkStream.h"
#include "SkTextBlob.h"
diff --git a/src/ports/SkFontConfigInterface_direct.cpp b/src/ports/SkFontConfigInterface_direct.cpp
index df68fae0a8..c1a73e626c 100644
--- a/src/ports/SkFontConfigInterface_direct.cpp
+++ b/src/ports/SkFontConfigInterface_direct.cpp
@@ -7,6 +7,7 @@
/* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */
+#include "SkAutoMalloc.h"
#include "SkBuffer.h"
#include "SkDataTable.h"
#include "SkFixed.h"
@@ -19,7 +20,6 @@
#include "SkTDArray.h"
#include "SkTemplates.h"
#include "SkTypeface.h"
-#include "SkTypes.h"
#include <fontconfig/fontconfig.h>
#include <unistd.h>
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 15bc14d213..47790f3644 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -25,7 +25,6 @@
#include "SkStream.h"
#include "SkString.h"
#include "SkTemplates.h"
-#include "SkTypes.h"
#include <memory>
#if defined(SK_CAN_USE_DLOPEN)
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 274c9253a9..ce4895419f 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -20,6 +20,7 @@
#endif
#include "SkAdvancedTypefaceMetrics.h"
+#include "SkAutoMalloc.h"
#include "SkCGUtils.h"
#include "SkColorPriv.h"
#include "SkDescriptor.h"
diff --git a/src/ports/SkImageEncoder_WIC.cpp b/src/ports/SkImageEncoder_WIC.cpp
index 52f4599433..6bc8b5473e 100644
--- a/src/ports/SkImageEncoder_WIC.cpp
+++ b/src/ports/SkImageEncoder_WIC.cpp
@@ -28,14 +28,16 @@
#undef INT64_MAX
#undef UINT64_MAX
-#include <wincodec.h>
#include "SkAutoCoInitialize.h"
+#include "SkAutoMalloc.h"
#include "SkBitmap.h"
#include "SkImageEncoderPriv.h"
#include "SkIStream.h"
+#include "SkImageEncoder.h"
#include "SkStream.h"
#include "SkTScopedComPtr.h"
#include "SkUnPreMultiply.h"
+#include <wincodec.h>
//All Windows SDKs back to XPSP2 export the CLSID_WICImagingFactory symbol.
//In the Windows8 SDK the CLSID_WICImagingFactory symbol is still exported
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 01e9cc4d45..0f6d54c8d7 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -8,18 +8,19 @@
#include "FakeStreams.h"
#include "Resources.h"
#include "SkAndroidCodec.h"
+#include "SkAutoMalloc.h"
#include "SkBitmap.h"
#include "SkCodec.h"
#include "SkCodecImageGenerator.h"
#include "SkColorSpace_XYZ.h"
#include "SkData.h"
-#include "SkImageEncoder.h"
#include "SkFrontBufferedStream.h"
+#include "SkImageEncoder.h"
#include "SkMD5.h"
+#include "SkPngChunkReader.h"
#include "SkRandom.h"
#include "SkStream.h"
#include "SkStreamPriv.h"
-#include "SkPngChunkReader.h"
#include "Test.h"
#include "png.h"
diff --git a/tests/ColorFilterTest.cpp b/tests/ColorFilterTest.cpp
index ad2dd0fc35..b6456a6414 100644
--- a/tests/ColorFilterTest.cpp
+++ b/tests/ColorFilterTest.cpp
@@ -5,10 +5,12 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkColor.h"
#include "SkColorFilter.h"
#include "SkColorPriv.h"
#include "SkLumaColorFilter.h"
+#include "SkRandom.h"
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkRandom.h"
diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp
index 55c524424f..3d54c57fe7 100644
--- a/tests/FontHostTest.cpp
+++ b/tests/FontHostTest.cpp
@@ -6,6 +6,7 @@
*/
#include "Resources.h"
+#include "SkAutoMalloc.h"
#include "SkEndian.h"
#include "SkFontStream.h"
#include "SkOSFile.h"
diff --git a/tests/FrontBufferedStreamTest.cpp b/tests/FrontBufferedStreamTest.cpp
index a3862741e3..69ff488358 100644
--- a/tests/FrontBufferedStreamTest.cpp
+++ b/tests/FrontBufferedStreamTest.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkBitmap.h"
#include "SkCodec.h"
#include "SkFrontBufferedStream.h"
#include "SkRefCnt.h"
#include "SkStream.h"
-#include "SkTypes.h"
#include "Test.h"
static void test_read(skiatest::Reporter* reporter, SkStream* bufferedStream,
diff --git a/tests/MallocPixelRefTest.cpp b/tests/MallocPixelRefTest.cpp
index 09e1b934e9..7e2bece7be 100644
--- a/tests/MallocPixelRefTest.cpp
+++ b/tests/MallocPixelRefTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkData.h"
#include "SkMallocPixelRef.h"
#include "Test.h"
diff --git a/tests/PaintBreakTextTest.cpp b/tests/PaintBreakTextTest.cpp
index 474bbf686a..b716c60c99 100644
--- a/tests/PaintBreakTextTest.cpp
+++ b/tests/PaintBreakTextTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkPaint.h"
#include "Test.h"
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index 76bfb02923..55a82a73e4 100644
--- a/tests/PaintTest.cpp
+++ b/tests/PaintTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkLayerDrawLooper.h"
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 2059c36db3..0ace812ef1 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include <cmath>
+#include "SkAutoMalloc.h"
#include "SkCanvas.h"
#include "SkGeometry.h"
#include "SkPaint.h"
#include "SkParse.h"
#include "SkParsePath.h"
-#include "SkPathPriv.h"
#include "SkPathEffect.h"
+#include "SkPathPriv.h"
#include "SkRRect.h"
#include "SkRandom.h"
#include "SkReader32.h"
@@ -20,9 +20,9 @@
#include "SkStream.h"
#include "SkStrokeRec.h"
#include "SkSurface.h"
-#include "SkTypes.h"
#include "SkWriter32.h"
#include "Test.h"
+#include <cmath>
static void set_radii(SkVector radii[4], int index, float rad) {
sk_bzero(radii, sizeof(SkVector) * 4);
diff --git a/tests/RegionTest.cpp b/tests/RegionTest.cpp
index 4a96056419..172082248a 100644
--- a/tests/RegionTest.cpp
+++ b/tests/RegionTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
diff --git a/tests/StreamTest.cpp b/tests/StreamTest.cpp
index ff23ca2341..fba09c989a 100644
--- a/tests/StreamTest.cpp
+++ b/tests/StreamTest.cpp
@@ -6,6 +6,7 @@
*/
#include "Resources.h"
+#include "SkAutoMalloc.h"
#include "SkData.h"
#include "SkFrontBufferedStream.h"
#include "SkOSFile.h"
diff --git a/tests/Writer32Test.cpp b/tests/Writer32Test.cpp
index 3eab94cd2d..6cb79f8270 100644
--- a/tests/Writer32Test.cpp
+++ b/tests/Writer32Test.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkAutoMalloc.h"
#include "SkRandom.h"
#include "SkReader32.h"
#include "SkWriter32.h"
diff --git a/tests/YUVTest.cpp b/tests/YUVTest.cpp
index 913997b3c3..0c31c0929a 100644
--- a/tests/YUVTest.cpp
+++ b/tests/YUVTest.cpp
@@ -5,8 +5,9 @@
* found in the LICENSE file.
*/
-#include "SkCodec.h"
#include "Resources.h"
+#include "SkAutoMalloc.h"
+#include "SkCodec.h"
#include "SkStream.h"
#include "SkTemplates.h"
#include "SkYUVSizeInfo.h"
diff --git a/third_party/ktx/ktx.cpp b/third_party/ktx/ktx.cpp
index ba3ba1fc27..a65c6f220b 100644
--- a/third_party/ktx/ktx.cpp
+++ b/third_party/ktx/ktx.cpp
@@ -6,9 +6,11 @@
*/
#include "ktx.h"
+
+#include "SkAutoMalloc.h"
#include "SkBitmap.h"
-#include "SkStream.h"
#include "SkEndian.h"
+#include "SkStream.h"
#include "gl/GrGLDefines.h"
#include "GrConfig.h"
diff --git a/tools/SkShaper_harfbuzz.cpp b/tools/SkShaper_harfbuzz.cpp
index 2c4d21180d..9c7d69e92d 100644
--- a/tools/SkShaper_harfbuzz.cpp
+++ b/tools/SkShaper_harfbuzz.cpp
@@ -28,10 +28,9 @@ std::unique_ptr<hb_blob_t, HBFBlobDel> stream_to_blob(std::unique_ptr<SkStreamAs
[](void* p) { delete (SkStreamAsset*)p; }));
} else {
// SkDebugf("Extra SkStreamAsset copy\n");
- SkAutoMalloc autoMalloc(size);
- asset->read(autoMalloc.get(), size);
- void* ptr = autoMalloc.get();
- blob.reset(hb_blob_create((char*)autoMalloc.release(), SkToUInt(size),
+ void* ptr = size ? sk_malloc_throw(size) : nullptr;
+ asset->read(ptr, size);
+ blob.reset(hb_blob_create((char*)ptr, SkToUInt(size),
HB_MEMORY_MODE_READONLY, ptr, sk_free));
}
SkASSERT(blob);
diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp
index 4eaf2ea84a..6dea988831 100644
--- a/tools/debugger/SkDrawCommand.cpp
+++ b/tools/debugger/SkDrawCommand.cpp
@@ -9,6 +9,7 @@
#include "png.h"
+#include "SkAutoMalloc.h"
#include "SkBlurMaskFilter.h"
#include "SkColorFilter.h"
#include "SkDashPathEffect.h"
@@ -704,7 +705,7 @@ void SkDrawCommand::WritePNG(const uint8_t* rgba, unsigned width, unsigned heigh
bool SkDrawCommand::flatten(const SkImage& image, Json::Value* target,
UrlDataManager& urlDataManager) {
size_t rowBytes = 4 * image.width();
- SkAutoFree buffer(sk_malloc_throw(rowBytes * image.height()));
+ SkAutoMalloc buffer(rowBytes * image.height());
SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height(),
kN32_SkColorType, kPremul_SkAlphaType);
if (!image.readPixels(dstInfo, buffer.get(), rowBytes, 0, 0)) {
diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp
index c8335d28b4..4802e214b4 100644
--- a/tools/viewer/sk_app/VulkanWindowContext.cpp
+++ b/tools/viewer/sk_app/VulkanWindowContext.cpp
@@ -8,6 +8,7 @@
#include "GrContext.h"
#include "GrRenderTarget.h"
+#include "SkAutoMalloc.h"
#include "SkSurface.h"
#include "VulkanWindowContext.h"
diff --git a/tools/viewer/sk_app/win/RasterWindowContext_win.cpp b/tools/viewer/sk_app/win/RasterWindowContext_win.cpp
index ca738db288..96fe8f22a9 100644
--- a/tools/viewer/sk_app/win/RasterWindowContext_win.cpp
+++ b/tools/viewer/sk_app/win/RasterWindowContext_win.cpp
@@ -5,9 +5,10 @@
* found in the LICENSE file.
*/
-#include "WindowContextFactory_win.h"
#include "../RasterWindowContext.h"
+#include "SkAutoMalloc.h"
#include "SkSurface.h"
+#include "WindowContextFactory_win.h"
#include <Windows.h>