aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
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 /src
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>
Diffstat (limited to 'src')
-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
29 files changed, 243 insertions, 40 deletions
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