skia2/include/core
commit-bot@chromium.org a5572e5bb2 Add a class to allocate small objects w/o extra calls to new.
Add SkSmallAllocator, a template for allocating small (as defined by the
instantiation) objects without extra calls to new. Add a helper macro to
make using it simple.

Remove SkTemplatesPriv.h, whose behavior is replaced by SkSmallAllocator.
The old SK_PLACEMENT_NEW had the following drawbacks:
- Easily confused with SkNEW_PLACEMENT.
- Requires passing around lots of void*s along with the storageSize.
- Requires using a separate class for deleting it.
- We had multiple ways Auto objects for deleting in different places.
- It always did a straight heap allocation on Windows, meaning Windows
  did not get any advantages from the confusing code.
The new SkSmallAllocator simplifies things:
- It is clear about what it does.
- It takes care of the deletion in one place that is automatically
  handled.

Further, the new class can be used to create more than one object. This
is in preparation for BUG=skia:1976, for which we would like to create
a new object without extra heap allocations. The plan is to create both
the blitter and the new object on the stack using the SkSmallAllocator.

Add a new test for SkSmallAllocator.

SkShader.h:
Move the private version of CreateBitmapShader to SkBitmapProcShader
(which already has the implementation) and remove the friend class
(which was only used to call this private function). This allows
SkSmallAllocator to reside in the private src/ directory.

SkBitmapProcShader:
Move CreateBitmapShader and the macro for the storage size here. With
the macro in a (private) header, the (private) headers with function
declarations (which now depend on the storage size used) can see the
macro.
Use SkSmallAllocator in CreateBitmapShader.
Change the macro to kBlitterStorageByteCount, since SkSmallAllocator
takes a byte count as its template parameter.

SkBlitter:
Use the SkSmallAllocator.
Remove Sk3DShader::fKillProc and SkAutoCallProc. Both of their
behaviors have been moved into SkSmallAllocator (SkAutoCallProc was
unnecessary anyway, because the only time we ever used it we also
called detach(), so its auto behavior never happened).
Create the Sk3DShader on the stack, if there's room.
Remove the helper version of Choose, which was unused.

SmallAllocatorTest:
Test for the new class.

The rest:
Use SkSmallAllocator.

BUG=skia:1976
R=reed@google.com, mtklein@google.com

Author: scroggo@google.com

Review URL: https://codereview.chromium.org/179343005

git-svn-id: http://skia.googlecode.com/svn/trunk@13696 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-03-07 03:24:41 +00:00
..
SkAdvancedTypefaceMetrics.h Revert "[PDF] Fix font embedding restrictions." 2013-12-10 17:22:41 +00:00
SkAnnotation.h Factory methods for heap-allocated SkAnnotation objects. 2014-02-27 11:47:36 +00:00
SkBitmap.h remove SK_SUPPORT_DEEPCOPYTO_CONFIG code -- no longer used 2014-03-05 02:34:58 +00:00
SkBitmapDevice.h Change device factories to take SkImageInfo instead of SkBitmap::Config 2014-02-16 00:59:25 +00:00
SkBlitRow.h remove dst/rendertarget support for kARGB_4444_Config 2013-06-21 18:30:53 +00:00
SkBounder.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkCanvas.h Now that the matching changes have landed in Chromium we can clean up the API on our side. 2014-03-06 13:18:07 +00:00
SkChecksum.h Add SkChecksum::Murmur3. 2013-07-23 20:25:34 +00:00
SkChunkAlloc.h combine glyph and image bulk alloc, and adjust initial alloc size, to reduce total waste from 50% to 30% 2013-06-19 19:25:36 +00:00
SkClipStack.h Use SkTLazy to hold path in SkClipStack::Element 2014-02-27 17:39:46 +00:00
SkColor.h SkAlpha constant defs 2013-07-19 17:43:27 +00:00
SkColorFilter.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkColorPriv.h SkSplay and SkUnsplay work on any uint32_t, not just SkPMColor. 2013-12-04 00:42:07 +00:00
SkColorShader.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkColorTable.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkComposeShader.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkData.h SkOnce: add option to call another cleanup function once at exit. 2014-01-24 22:38:39 +00:00
SkDataTable.h Remove SkDataTable from SkFlattenable hierarchy. 2013-10-15 20:39:57 +00:00
SkDeque.h This CL addresses "SkCanvas::save flags are not respected by GPU backend" (https://code.google.com/p/skia/issues/detail?id=1503). 2013-08-16 00:53:34 +00:00
SkDevice.h add SkCanvas::drawDRRect 2014-02-21 02:32:36 +00:00
SkDeviceProperties.h Mask orientation and layout correctly. 2013-05-06 22:23:08 +00:00
SkDither.h Result of running tools/sanitize_source_files.py (which was added in https://codereview.appspot.com/6465078/) 2012-08-23 18:09:54 +00:00
SkDocument.h remove SkFloatToScalar macro 2013-11-25 19:44:07 +00:00
SkDraw.h Move distance field font code into GrDistanceFieldTextContext. 2013-12-19 16:12:25 +00:00
SkDrawFilter.h Add GPU support for roundrects 2013-04-25 15:27:00 +00:00
SkDrawLooper.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkDynamicAnnotations.h TSAN: use somewhat pithier SK_ANNOTATE_UNPROTECTED_READ. 2014-02-04 18:00:23 +00:00
SkEmptyShader.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkEndian.h SkBitmapHasher: use 64-bit-truncated MD5 instead of 64-bit CityHash 2013-05-03 17:35:39 +00:00
SkError.h Sanitizing source files in Housekeeper-Nightly 2013-09-05 07:01:19 +00:00
SkFixed.h remove SK_SUPPORTED_DEPRECATED_FIXEDROUND, no longer needed 2014-01-06 18:49:32 +00:00
SkFlate.h Result of running tools/sanitize_source_files.py (which was added in https://codereview.appspot.com/6465078/) 2012-08-23 18:09:54 +00:00
SkFlattenable.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkFlattenableBuffers.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkFlattenableSerialization.h Removed unnecessary define 2013-11-08 15:24:12 +00:00
SkFloatBits.h remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats 2013-12-17 16:44:46 +00:00
SkFloatingPoint.h Add sk_float_rsqrt with SSE + NEON fast paths. 2013-11-08 20:14:16 +00:00
SkFontHost.h Remove SK_FONTHOST_USES_FONTMGR. 2013-11-11 15:53:29 +00:00
SkFontLCDConfig.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-03-13 07:01:04 +00:00
SkGeometry.h Stub for conic section max curvature 2014-02-21 19:49:10 +00:00
SkGraphics.h Sanitizing source files in Housekeeper-Nightly 2013-09-27 07:01:29 +00:00
SkImage.h Revert of Revert "Serialization of SkPictureImageFilter" (https://codereview.chromium.org/153583007/) 2014-02-07 12:20:04 +00:00
SkImageDecoder.h Deprecate two more functions using SK_ATTR_DEPRECATED macro. 2014-01-15 00:19:21 +00:00
SkImageEncoder.h Rewrite SkTRegistry to take any trivially-copyable type. 2013-09-04 17:20:18 +00:00
SkImageFilter.h Cleanup patch to move all of SkImageFilterUtils into SkImageFilter. 2014-03-03 22:13:56 +00:00
SkImageGenerator.h Add Options to SkDecodingImageGenerator, simplify API. 2014-01-02 13:15:13 +00:00
SkImageInfo.h use colortype instead of config 2014-02-20 20:55:37 +00:00
SkInstCnt.h Make leak counters thread-safe and turn them on by default for Debug 2014-01-17 17:55:02 +00:00
SkLineClipper.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkMallocPixelRef.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkMask.h Guard against most unintentionally ephemeral SkAutoFoo instantiations. 2013-11-18 16:03:59 +00:00
SkMaskFilter.h Factory methods for heap-allocated SkMaskFilter objects. 2014-02-21 10:13:32 +00:00
SkMath.h Revert "Revert of https://codereview.chromium.org/113823003/" 2013-12-30 14:40:38 +00:00
SkMatrix.h remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats 2013-12-17 16:44:46 +00:00
SkMetaData.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkOnce.h SkOnce in is_lcd_supported instead of hand rolled double-checked locking. 2014-02-10 19:58:49 +00:00
SkOSFile.h Fix bug in setting directories for tests. 2013-06-06 14:59:56 +00:00
SkPackBits.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkPaint.h Adding code to calculate Underline Thickness from Font Metrics, this will be useful when Skia is used with Blink/Chrome. Blink changes are uploaded with code change in patch https://codereview.chromium.org/147703002/ 2014-03-01 20:12:26 +00:00
SkPaintOptionsAndroid.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkPath.h Revert of r13379 (Move fLastMoveToIndex from SkPath to SkPathRef - https://codereview.chromium.org/146913002/) due to image quality regression in Chromium. See crbug.com/343123 (Regression - UI issue observed for any "Notification infobars" in Chrome browser) 2014-02-12 17:44:30 +00:00
SkPathEffect.h Factory methods for heap-allocated SkPathEffect and SkXfermode objects. 2014-02-20 20:40:19 +00:00
SkPathMeasure.h add SK_API 2013-05-08 13:25:02 +00:00
SkPathRef.h Revert of r13379 (Move fLastMoveToIndex from SkPath to SkPathRef - https://codereview.chromium.org/146913002/) due to image quality regression in Chromium. See crbug.com/343123 (Regression - UI issue observed for any "Notification infobars" in Chrome browser) 2014-02-12 17:44:30 +00:00
SkPicture.h This CL is motivated by the desire to make the skpinfo tool work a bit better. The main concern is that the assumptions made w.r.t. written bytes may not be valid for all SkWStream sub-classes. 2014-03-05 18:25:20 +00:00
SkPixelRef.h remove SK_SUPPORT_LEGACY_ONLOCKPIXELS completely 2014-02-10 15:43:29 +00:00
SkPoint.h remove SkScalarMul from public headers 2014-01-27 13:41:02 +00:00
SkPostConfig.h Make leak counters thread-safe and turn them on by default for Debug 2014-01-17 17:55:02 +00:00
SkPreConfig.h Enable the SSSE3 files to be built for Android when SSSE3 is not present. 2014-02-25 18:14:08 +00:00
SkRasterizer.h Builder class for SkLayerRasterizer. 2014-02-26 13:27:37 +00:00
SkReadBuffer.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkReader32.h Checking structure sizes before reading them from memory to avoid overflowing the buffer's stream. 2013-11-05 15:46:56 +00:00
SkRect.h speedup SkRect::intersect 2014-01-01 20:32:45 +00:00
SkRefCnt.h TSAN: use somewhat pithier SK_ANNOTATE_UNPROTECTED_READ. 2014-02-04 18:00:23 +00:00
SkRegion.h Checking structure sizes before reading them from memory to avoid overflowing the buffer's stream. 2013-11-05 15:46:56 +00:00
SkRRect.h Sanitizing source files in Housekeeper-Nightly 2014-03-05 03:02:06 +00:00
SkScalar.h remove SkScalarMul from public headers 2014-01-27 13:41:02 +00:00
SkShader.h Add a class to allocate small objects w/o extra calls to new. 2014-03-07 03:24:41 +00:00
SkSize.h deprecate SkScalarRound (and its ilk), use SkScalarRound[ToInt,ToScalar]. #define SK_SUPPORT_DEPRECATED_SCALARROUND for legacy clients 2013-12-17 19:22:07 +00:00
SkStream.h Add size_t bytesWritten() const to SkWStream. 2014-03-06 17:16:26 +00:00
SkString.h remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats 2013-12-17 16:44:46 +00:00
SkStringUtils.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-29 07:05:52 +00:00
SkStrokeRec.h Make GrContext cache the gpu paths 2013-11-01 15:23:44 +00:00
SkSurface.h Use factories instead of directly creating SkImageInfo. 2014-02-17 17:02:17 +00:00
SkTArray.h Repurpose GrGLCoordTransform as GrGLProgramEffects 2013-10-03 15:17:58 +00:00
SkTDArray.h SkWriter32: throw in the SkTDArray towel. 2014-02-13 18:35:54 +00:00
SkTDict.h Make SkTDArray accessors const-friendly. 2013-02-28 19:03:13 +00:00
SkTDStack.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkTemplates.h fix auto-delete bug that crept in with new fast blur path; is causing 2014-01-31 01:00:49 +00:00
SkThread.h SkOnce in is_lcd_supported instead of hand rolled double-checked locking. 2014-02-10 19:58:49 +00:00
SkTileGridPicture.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-03-01 12:12:55 +00:00
SkTime.h Guard against most unintentionally ephemeral SkAutoFoo instantiations. 2013-11-18 16:03:59 +00:00
SkTInternalLList.h Make SkTInternalLList::validate validate all nodes 2013-12-04 14:51:31 +00:00
SkTLazy.h Use SkTLazy to hold path in SkClipStack::Element 2014-02-27 17:39:46 +00:00
SkTrace.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkTRegistry.h Rewrite SkTRegistry to take any trivially-copyable type. 2013-09-04 17:20:18 +00:00
SkTSearch.h One SkTSearch to rule them all. Allow key to be of different type than the array. 2013-05-17 19:05:03 +00:00
SkTypeface.h move getAdvancedTypefaceMetrics into private, as only skia internals call it 2014-01-27 21:02:14 +00:00
SkTypes.h Add size_t bytesWritten() const to SkWStream. 2014-03-06 17:16:26 +00:00
SkUnitMapper.h Refactor read and write buffers. 2014-01-30 18:58:24 +00:00
SkUnPreMultiply.h Factor out UnPreMultiplyPreservingByteOrder 2014-01-15 22:24:58 +00:00
SkUtils.h More Windows 64b compilation warning fixes 2013-11-21 14:24:16 +00:00
SkWeakRefCnt.h Split atomic and mutex implementations and make inlinable. 2013-12-18 15:27:39 +00:00
SkWriteBuffer.h Set write buffer flags only in SkWriteBuffer and SkFlatController constructors. 2014-01-30 22:16:32 +00:00
SkWriter32.h SkWriter32: throw in the SkTDArray towel. 2014-02-13 18:35:54 +00:00
SkXfermode.h Factory methods for heap-allocated SkPathEffect and SkXfermode objects. 2014-02-20 20:40:19 +00:00