#define AndroidCodecBench_DEFINED
#include "Benchmark.h"
-#include "SkAutoMalloc.h"
#include "SkData.h"
#include "SkImageInfo.h"
#include "SkRefCnt.h"
#define CodecBench_DEFINED
#include "Benchmark.h"
-#include "SkAutoMalloc.h"
#include "SkData.h"
#include "SkImageInfo.h"
#include "SkRefCnt.h"
#define ColorCodecBench_DEFINED
#include "Benchmark.h"
-#include "SkAutoMalloc.h"
#include "SkData.h"
#include "SkImageInfo.h"
#include "Stats.h"
#include "SkAndroidCodec.h"
-#include "SkAutoMalloc.h"
-#include "SkBBoxHierarchy.h"
#include "SkBitmapRegionDecoder.h"
+#include "SkBBoxHierarchy.h"
#include "SkCanvas.h"
#include "SkCodec.h"
#include "SkCommonFlags.h"
#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>
#include "DMSrcSink.h"
#include "Resources.h"
#include "SkAndroidCodec.h"
-#include "SkAutoMalloc.h"
#include "SkCodec.h"
#include "SkCodecImageGenerator.h"
#include "SkColorSpace.h"
-#include "SkColorSpaceXform.h"
#include "SkColorSpace_XYZ.h"
+#include "SkColorSpaceXform.h"
#include "SkCommonFlags.h"
#include "SkData.h"
#include "SkDebugCanvas.h"
#include "SkRecorder.h"
#include "SkSVGCanvas.h"
#include "SkStream.h"
-#include "SkSwizzler.h"
#include "SkTLogic.h"
-#include <cmath>
+#include "SkSwizzler.h"
#include <functional>
+#include <cmath>
#if defined(SK_BUILD_FOR_WIN)
#include "SkAutoCoInitialize.h"
*/
#include "gm.h"
-
-#include "SkAutoMalloc.h"
#include "SkCanvas.h"
#include "SkRSXform.h"
#include "SkSurface.h"
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
SkAlignedSStorage<sizeof(T)*N> fStorage;
};
-using SkAutoFree = std::unique_ptr<void, SkFunctionWrapper<void, void, sk_free>>;
-
#endif
#ifndef SkAAClip_DEFINED
#define SkAAClip_DEFINED
-#include "SkAutoMalloc.h"
#include "SkBlitter.h"
#include "SkRegion.h"
+++ /dev/null
-/*
- * 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
#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;
* 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"
* 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
* found in the LICENSE file.
*/
-#include "SkAutoMalloc.h"
#include "SkEndian.h"
#include "SkFontStream.h"
#include "SkStream.h"
* found in the LICENSE file.
*/
-#include "SkAutoMalloc.h"
#include "SkColorSpace_Base.h"
#include "SkColorSpace_XYZ.h"
#include "SkColorSpacePriv.h"
#include <tuple>
-#include "SkAutoMalloc.h"
#include "SkColor.h"
#include "SkColorPriv.h"
#include "SkFixed.h"
* found in the LICENSE file.
*/
-#include "SkMaskFilter.h"
-#include "SkAutoMalloc.h"
+#include "SkMaskFilter.h"
#include "SkBlitter.h"
-#include "SkCachedData.h"
#include "SkDraw.h"
+#include "SkCachedData.h"
#include "SkPath.h"
-#include "SkRRect.h"
#include "SkRasterClip.h"
+#include "SkRRect.h"
+#include "SkTypes.h"
#if SK_SUPPORT_GPU
#include "GrTexture.h"
* 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"
* found in the LICENSE file.
*/
-#include "SkScalerContext.h"
-#include "SkAutoMalloc.h"
+#include "SkScalerContext.h"
#include "SkAutoPixmapStorage.h"
#include "SkColorPriv.h"
#include "SkDescriptor.h"
#include "SkMaskFilter.h"
#include "SkMaskGamma.h"
#include "SkMatrix22.h"
+#include "SkReadBuffer.h"
+#include "SkWriteBuffer.h"
#include "SkPathEffect.h"
-#include "SkRasterClip.h"
#include "SkRasterizer.h"
-#include "SkReadBuffer.h"
+#include "SkRasterClip.h"
#include "SkStroke.h"
#include "SkStrokeRec.h"
-#include "SkWriteBuffer.h"
#define ComputeBWRowBytes(width) (((unsigned)(width) + 7) >> 3)
* 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"
#include "SkRegion.h"
#include "SkScan.h"
#include "SkScanPriv.h"
-#include "SkTSort.h"
#include "SkTemplates.h"
+#include "SkTSort.h"
#include "SkUtils.h"
///////////////////////////////////////////////////////////////////////////////
#include "SkGradientBitmapCache.h"
#include "SkGradientShader.h"
-
-#include "SkAutoMalloc.h"
#include "SkClampRange.h"
#include "SkColorPriv.h"
#include "SkColorSpace.h"
-#include "SkMallocPixelRef.h"
-#include "SkOnce.h"
#include "SkReadBuffer.h"
-#include "SkShader.h"
-#include "SkUtils.h"
#include "SkWriteBuffer.h"
+#include "SkMallocPixelRef.h"
+#include "SkUtils.h"
+#include "SkShader.h"
+#include "SkOnce.h"
#if SK_SUPPORT_GPU
#define GR_GL_USE_ACCURATE_HARD_STOP_GRADIENTS 1
#include "SkDistanceFieldGen.h"
#include "GrDistanceFieldGenFromVector.h"
-
-#include "GrConfig.h"
-#include "GrPathUtils.h"
-#include "SkAutoMalloc.h"
-#include "SkGeometry.h"
#include "SkMatrix.h"
-#include "SkPathOps.h"
#include "SkPoint.h"
+#include "SkGeometry.h"
+#include "SkPathOps.h"
+#include "GrPathUtils.h"
+#include "GrConfig.h"
/**
* If a scanline (a row of texel) cross from the kRight_SegSide
#include "effects/GrGammaEffect.h"
#include "effects/GrYUVEffect.h"
-#include "SkAutoMalloc.h"
#include "SkCachedData.h"
#include "SkRefCnt.h"
#include "SkResourceCache.h"
* found in the LICENSE file.
*/
+
#include "SkGr.h"
#include "SkGrPriv.h"
#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 "SkPM4fPriv.h"
#include "SkPixelRef.h"
+#include "SkPM4fPriv.h"
#include "SkResourceCache.h"
#include "SkTemplates.h"
#include "SkYUVPlanesCache.h"
*/
#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 "GrPLSGeometryProcessor.h"
#include "GrPipeline.h"
+#include "GrPLSGeometryProcessor.h"
#include "GrRenderTargetPriv.h"
#include "GrShaderCaps.h"
#include "GrSurfacePriv.h"
#include "GrTexturePriv.h"
#include "GrTypes.h"
-#include "SkAutoMalloc.h"
+#include "builders/GrGLShaderStringBuilder.h"
+#include "glsl/GrGLSLPLSPathRendering.h"
+#include "instanced/GLInstancedRendering.h"
#include "SkMakeUnique.h"
#include "SkMipMap.h"
#include "SkPixmap.h"
-#include "SkSLCompiler.h"
#include "SkStrokeRec.h"
+#include "SkSLCompiler.h"
#include "SkTemplates.h"
#include "SkTypes.h"
-#include "builders/GrGLShaderStringBuilder.h"
-#include "glsl/GrGLSLPLSPathRendering.h"
-#include "instanced/GLInstancedRendering.h"
+#include "../private/GrGLSL.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)
#include "GrShaderCaps.h"
#include "GrSwizzle.h"
#include "GrTexture.h"
-#include "SkAutoMalloc.h"
#include "SkTraceEvent.h"
#include "gl/GrGLGpu.h"
#include "gl/GrGLProgram.h"
*/
#include "GrGLShaderStringBuilder.h"
-#include "SkAutoMalloc.h"
-#include "SkSLCompiler.h"
-#include "SkSLGLSLCodeGenerator.h"
-#include "SkTraceEvent.h"
#include "gl/GrGLGpu.h"
#include "gl/GrGLSLPrettyPrint.h"
+#include "SkTraceEvent.h"
+#include "SkSLCompiler.h"
+#include "SkSLGLSLCodeGenerator.h"
#include "ir/SkSLProgram.h"
#define GL_CALL(X) GR_GL_CALL(gpu->glInterface(), X)
#include "ops/GrMeshDrawOp.h"
#include "SkPathOps.h"
-#include "SkAutoMalloc.h"
#include "SkDistanceFieldGen.h"
#include "GrDistanceFieldGenFromVector.h"
#include "GrPathStencilSettings.h"
#include "GrPathUtils.h"
#include "GrPipelineBuilder.h"
-#include "SkAutoMalloc.h"
#include "SkGeometry.h"
#include "SkTraceEvent.h"
#include "gl/GrGLVaryingHandler.h"
MSAAQuadVertices quads;
size_t quadVertexStride = sizeof(MSAAQuadVertices::Vertex);
- SkAutoMalloc quadVertexPtr(fMaxQuadVertices * quadVertexStride);
+ SkAutoFree quadVertexPtr(sk_malloc_throw(fMaxQuadVertices * quadVertexStride));
quads.vertices = (MSAAQuadVertices::Vertex*) quadVertexPtr.get();
quads.nextVertex = quads.vertices;
SkDEBUGCODE(quads.verticesEnd = quads.vertices + fMaxQuadVertices;)
SkAutoFree quadIndexPtr;
if (fIsIndexed) {
quads.indices = (uint16_t*)sk_malloc_throw(3 * fMaxQuadVertices * sizeof(uint16_t));
- quadIndexPtr.reset(quads.indices);
+ quadIndexPtr.set(quads.indices);
quads.nextIndex = quads.indices;
} else {
quads.indices = nullptr;
#include "GrRectanizer.h"
#include "GrResourceProvider.h"
#include "GrSurfacePriv.h"
-#include "SkAutoMalloc.h"
#include "SkString.h"
#include "SkDistanceFieldGen.h"
* found in the LICENSE file.
*/
-#include "SkAutoMalloc.h"
#include "vk/GrVkBackendContext.h"
#include "vk/GrVkExtensions.h"
#include "vk/GrVkInterface.h"
#include "glsl/GrGLSLProgramDataManager.h"
-#include "SkAutoMalloc.h"
#include "vk/GrVkUniformHandler.h"
class GrVkGpu;
* found in the LICENSE file.
*/
-#include "SkAutoMalloc.h"
+#include "SkPathEffect.h"
#include "SkColorFilter.h"
#include "SkDrawLooper.h"
#include "SkImageFilter.h"
#include "SkMaskFilter.h"
-#include "SkPathEffect.h"
#include "SkPipeCanvas.h"
#include "SkPipeFormat.h"
-#include "SkRSXform.h"
#include "SkRasterizer.h"
+#include "SkRSXform.h"
#include "SkShader.h"
#include "SkStream.h"
#include "SkTextBlob.h"
/* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */
-#include "SkAutoMalloc.h"
#include "SkBuffer.h"
#include "SkDataTable.h"
#include "SkFixed.h"
#include "SkTDArray.h"
#include "SkTemplates.h"
#include "SkTypeface.h"
+#include "SkTypes.h"
#include <fontconfig/fontconfig.h>
#include <unistd.h>
#include "SkStream.h"
#include "SkString.h"
#include "SkTemplates.h"
+#include "SkTypes.h"
#include <memory>
#if defined(SK_CAN_USE_DLOPEN)
#endif
#include "SkAdvancedTypefaceMetrics.h"
-#include "SkAutoMalloc.h"
#include "SkCGUtils.h"
#include "SkColorPriv.h"
#include "SkDescriptor.h"
#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
#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 "SkFrontBufferedStream.h"
#include "SkImageEncoder.h"
+#include "SkFrontBufferedStream.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"
* 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"
*/
#include "Resources.h"
-#include "SkAutoMalloc.h"
#include "SkEndian.h"
#include "SkFontStream.h"
#include "SkOSFile.h"
* 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,
* found in the LICENSE file.
*/
-#include "SkAutoMalloc.h"
#include "SkData.h"
#include "SkMallocPixelRef.h"
#include "Test.h"
* found in the LICENSE file.
*/
-#include "SkAutoMalloc.h"
#include "SkPaint.h"
#include "Test.h"
* found in the LICENSE file.
*/
-#include "SkAutoMalloc.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkLayerDrawLooper.h"
* found in the LICENSE file.
*/
-#include "SkAutoMalloc.h"
+#include <cmath>
#include "SkCanvas.h"
#include "SkGeometry.h"
#include "SkPaint.h"
#include "SkParse.h"
#include "SkParsePath.h"
-#include "SkPathEffect.h"
#include "SkPathPriv.h"
+#include "SkPathEffect.h"
#include "SkRRect.h"
#include "SkRandom.h"
#include "SkReader32.h"
#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);
* found in the LICENSE file.
*/
-#include "SkAutoMalloc.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
*/
#include "Resources.h"
-#include "SkAutoMalloc.h"
#include "SkData.h"
#include "SkFrontBufferedStream.h"
#include "SkOSFile.h"
* found in the LICENSE file.
*/
-#include "SkAutoMalloc.h"
#include "SkRandom.h"
#include "SkReader32.h"
#include "SkWriter32.h"
* found in the LICENSE file.
*/
-#include "Resources.h"
-#include "SkAutoMalloc.h"
#include "SkCodec.h"
+#include "Resources.h"
#include "SkStream.h"
#include "SkTemplates.h"
#include "SkYUVSizeInfo.h"
*/
#include "ktx.h"
-
-#include "SkAutoMalloc.h"
#include "SkBitmap.h"
-#include "SkEndian.h"
#include "SkStream.h"
+#include "SkEndian.h"
#include "gl/GrGLDefines.h"
#include "GrConfig.h"
[](void* p) { delete (SkStreamAsset*)p; }));
} else {
// SkDebugf("Extra SkStreamAsset copy\n");
- void* ptr = size ? sk_malloc_throw(size) : nullptr;
- asset->read(ptr, size);
- blob.reset(hb_blob_create((char*)ptr, SkToUInt(size),
+ SkAutoMalloc autoMalloc(size);
+ asset->read(autoMalloc.get(), size);
+ void* ptr = autoMalloc.get();
+ blob.reset(hb_blob_create((char*)autoMalloc.release(), SkToUInt(size),
HB_MEMORY_MODE_READONLY, ptr, sk_free));
}
SkASSERT(blob);
#include "png.h"
-#include "SkAutoMalloc.h"
#include "SkBlurMaskFilter.h"
#include "SkColorFilter.h"
#include "SkDashPathEffect.h"
bool SkDrawCommand::flatten(const SkImage& image, Json::Value* target,
UrlDataManager& urlDataManager) {
size_t rowBytes = 4 * image.width();
- SkAutoMalloc buffer(rowBytes * image.height());
+ SkAutoFree buffer(sk_malloc_throw(rowBytes * image.height()));
SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height(),
kN32_SkColorType, kPremul_SkAlphaType);
if (!image.readPixels(dstInfo, buffer.get(), rowBytes, 0, 0)) {
#include "GrContext.h"
#include "GrRenderTarget.h"
-#include "SkAutoMalloc.h"
#include "SkSurface.h"
#include "VulkanWindowContext.h"
* 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>