skia2/include/core
scroggo@google.com 8d2392487c Add an option on SkImageDecoder to skip writing 0s.
Only implemented for PNG.

Add a getter and setter, and sets the default to false in the
constructor. Also copies the setting in copyFieldsToOther.

Fix an indpendent bug where fDitherImage was not being copied in
copyFieldsToOther.

In SkScaledBitmapSampler::begin, consolidate the settings passed in
by passing a const reference to the decoder. The decoder can be
referenced for its settings of dither, unpremultiplied, and now
skipping writing zeroes. Update callers to use the new API. In png
decoder, rather than passing around a pointer to an initial
read of getDitherImage, and potentially changing it, look at the
field on the decoder itself, and modify it directly. This is a
change in behavior - now if that same decoder is used to decode
a different image, the dither setting has changed. I think this is
okay because A) the typical use case is to use a new decoder for
each decode, B) we do not make any promises that a decode does not
change the decoder and C) it makes the code in SkScaledBitmapSampler
much cleaner.

In SkScaledBitmapScampler, add new row procs for skipping zeroes. Now
that choosing the row proc has five dimensions (src config, dst config,
dither, skip writing zeroes, unpremultiplied), use a new method: each
src/dst combination has a function for choosing the right proc depending
on the decoder.

SkScaledBitmapScampler::RowProc is now public for convenience.

Remove Sample_Gray_D8888_Unpremul, which is effectively no different
from Sample_Gray_D8888.

In cases where unpremultiplied was trivial, such as 565 and when
sampling from gray, decoding may now succeed.

Add a benchmark (currently disabled) for comparing the speed of skipping
writing zeroes versus not skipping. For this particular image, which is
mostly transparent pixels, normal decoding took about 3.6 milliseconds,
while skipping zeroes in the decode took only about 2.5 milliseconds
(this is on a Nexus 4). Presumably it would be slower on an image
with a small amount of transparency, but there will be no slowdown
for an image which reports that it has no transparency.

In SkImageRef_ashmem, always skip writing zeroes, since ashmem
memory is guaranteed to be initialized to 0.

Add a flag to skip writing zeroes in skimage.

Add a regression test for choosing the rowproc to ensure I did not
change any behavior accidentally.

BUG=skia:1661
R=reed@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@11558 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-10-01 17:27:15 +00:00
..
Sk64.h Revert r10705 (ARM Skia NEON patches - 04 - Clean SkFixed / SkLONGLONG) due to 1000+ linux_layout failures (http://build.chromium.org/p/tryserver.chromium/builders/linux_layout_rel/builds/18997/steps/webkit_tests/logs/stdio) 2013-08-15 13:43:23 +00:00
SkAdvancedTypefaceMetrics.h Replace SkTScopedPtr with SkAutoTDelete in Skia. 2013-08-29 22:14:04 +00:00
SkAlpha.h Sanitizing source files in Housekeeper-Nightly 2013-09-21 07:01:53 +00:00
SkAnnotation.h PDF: add support for named destinations. 2013-03-08 09:09:10 +00:00
SkBitmap.h Revert 11247, 11250, 11251, 11257, and 11279 to unblock DEPS roll (https://codereview.chromium.org/24159002/) 2013-09-16 14:04:05 +00:00
SkBitmapDevice.h Split SkDevice into SkBaseDevice and SkBitmapDevice 2013-08-29 11:54:56 +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 Split SkDevice into SkBaseDevice and SkBitmapDevice 2013-08-29 11:54:56 +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 Compact the clipstack for kReplace_Op'd geometry 2013-06-11 11:01:48 +00:00
SkColor.h SkAlpha constant defs 2013-07-19 17:43:27 +00:00
SkColorFilter.h Add printing of SkColorFilter-derived classes to debugger 2013-05-23 14:00:17 +00:00
SkColorPriv.h ARM Skia NEON patches - 01 - Simple fixes 2013-07-15 13:10:31 +00:00
SkColorShader.h Added print out of SkShader information to debugger 2013-01-15 20:17:47 +00:00
SkColorTable.h Implement multi-threaded picture playback via cloning. 2012-08-29 18:52:07 +00:00
SkComposeShader.h Added print out of SkShader information to debugger 2013-01-15 20:17:47 +00:00
SkData.h Sanitizing source files in Housekeeper-Nightly 2013-06-11 07:01:17 +00:00
SkDataSet.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
SkDataTable.h specialize SkDataTable for arrays where all elements are the same size. 2013-04-21 01:37:46 +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 Baby step in making SkGpuDevice no longer derive from SkBitmapDevice 2013-09-17 12:26:23 +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 The two leaks are: 2013-07-11 22:29:29 +00:00
SkDraw.h Split SkDevice into SkBaseDevice and SkBitmapDevice 2013-08-29 11:54:56 +00:00
SkDrawFilter.h Add GPU support for roundrects 2013-04-25 15:27:00 +00:00
SkDrawLooper.h Added toString to SkDrawLooper-derived classes 2013-01-28 20:21:59 +00:00
SkEmptyShader.h Added print out of SkShader information to debugger 2013-01-15 20:17:47 +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 Revert r10705 (ARM Skia NEON patches - 04 - Clean SkFixed / SkLONGLONG) due to 1000+ linux_layout failures (http://build.chromium.org/p/tryserver.chromium/builders/linux_layout_rel/builds/18997/steps/webkit_tests/logs/stdio) 2013-08-15 13:43:23 +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 I'm investigating how to make the IPC transfer a bit more secure on the 2013-09-19 18:40:49 +00:00
SkFlattenableBuffers.h Revert 11247, 11250, 11251, 11257, and 11279 to unblock DEPS roll (https://codereview.chromium.org/24159002/) 2013-09-16 14:04:05 +00:00
SkFlattenableSerialization.h Revert 11247, 11250, 11251, 11257, and 11279 to unblock DEPS roll (https://codereview.chromium.org/24159002/) 2013-09-16 14:04:05 +00:00
SkFloatBits.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkFloatingPoint.h path ops -- use standard max, min, double-is-nan 2013-04-23 11:56:44 +00:00
SkFontHost.h Revert "Revert "Revert "try enabling FONTHOST_USES_FONTMGR and see what breaks""" 2013-07-31 19:36:07 +00:00
SkFontLCDConfig.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-03-13 07:01:04 +00:00
SkGeometry.h Add implicit hairline conic rendering to GPU 2013-07-12 20:15:34 +00:00
SkGraphics.h Sanitizing source files in Housekeeper-Nightly 2013-09-27 07:01:29 +00:00
SkImage.h Patch SkImage.h so Chrome will compile 2013-09-22 21:57:03 +00:00
SkImageDecoder.h Add an option on SkImageDecoder to skip writing 0s. 2013-10-01 17:27:15 +00:00
SkImageEncoder.h Rewrite SkTRegistry to take any trivially-copyable type. 2013-09-04 17:20:18 +00:00
SkImageFilter.h Split SkDevice into SkBaseDevice and SkBitmapDevice 2013-08-29 11:54:56 +00:00
SkImageFilterUtils.h Added ctm matrix to GPU path 2013-08-05 16:53:50 +00:00
SkImageTypes.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-02-20 07:02:30 +00:00
SkInstCnt.h Removed unused parameters 2013-03-11 18:50:03 +00:00
SkLineClipper.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkMallocPixelRef.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
SkMask.h Sanitizing source files in Housekeeper-Nightly 2013-05-03 07:01:00 +00:00
SkMaskFilter.h Sanitizing source files in Housekeeper-Nightly 2013-07-04 07:01:07 +00:00
SkMath.h Add SkDivMod with a special case for ARM. 2013-09-26 19:22:54 +00:00
SkMatrix.h Add homogeneous point mapping to Matrix 2013-08-15 21:12:11 +00:00
SkMetaData.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +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 Nobody defines SK_SUPPORT_HINTING_SCALE_FACTOR any more, so remove it. 2013-08-15 21:20:14 +00:00
SkPaintOptionsAndroid.h We don't flatten or unflatten SkPaintOptionsAndroid. Reproduce and fix. 2013-09-26 15:16:12 +00:00
SkPath.h Move bound and isFinite into pathref 2013-09-26 12:18:23 +00:00
SkPathEffect.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkPathMeasure.h add SK_API 2013-05-08 13:25:02 +00:00
SkPathRef.h Added SK_API to SkPathRef.h 2013-09-29 14:48:38 +00:00
SkPicture.h Move bound and isFinite into pathref 2013-09-26 12:18:23 +00:00
SkPixelRef.h start to remove lockPixels from bitmapshader 2013-09-13 16:04:49 +00:00
SkPoint.h add asScalars() to document when we want to treat SkPoint or SkRect as an array 2013-03-08 16:07:54 +00:00
SkPostConfig.h create a macro for testing if skcolor and skpmcolor have same shift values 2013-08-20 20:28:03 +00:00
SkPreConfig.h Remove 2 unused defines USE_CHROMIUM_SKIA and SK_BUILD_FOR_CHROMIUM 2013-09-19 14:29:12 +00:00
SkRasterizer.h change all interfaces for SkRasterizer to const, in preparation for marking it 2012-12-18 16:57:03 +00:00
SkReader32.h revert 6766, thereby re-landing 6762-6763 now that the bots are ready 2012-12-12 20:48:18 +00:00
SkRect.h Revert 11247, 11250, 11251, 11257, and 11279 to unblock DEPS roll (https://codereview.chromium.org/24159002/) 2013-09-16 14:04:05 +00:00
SkRefCnt.h Remove GrRefCnt.h in favor of SkRefCnt.h 2013-09-09 13:38:37 +00:00
SkRegion.h Add getRectCount to SkRegtion 2013-07-17 21:39:28 +00:00
SkRRect.h Split SkDevice into SkBaseDevice and SkBitmapDevice 2013-08-29 11:54:56 +00:00
SkScalar.h remove outdated debugging code now that we no longer support fixed point 2013-05-23 16:41:42 +00:00
SkScalarCompare.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkShader.h Two and three color GPU gradients without textures. 2013-09-09 15:36:26 +00:00
SkSize.h must always include another skia header (unless you're SkTypes.h). In this case, 2012-11-26 20:18:00 +00:00
SkStream.h Handle SkStream::rewind properly. 2013-08-28 13:08:54 +00:00
SkString.h fix https://code.google.com/p/skia/issues/detail?id=1356 2013-06-19 18:52:42 +00:00
SkStringUtils.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-29 07:05:52 +00:00
SkStrokeRec.h Follow up on the previous patch : 2012-12-17 21:16:45 +00:00
SkSurface.h promote SkImage::AlphaType to SkAlphaType 2013-09-20 19:33:52 +00:00
SkTArray.h Sanitizing source files in Housekeeper-Nightly 2013-06-15 07:00:53 +00:00
SkTDArray.h fix copy in SkTDArray 2013-07-01 17:04:32 +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 Replace SkTScopedPtr with SkAutoTDelete in Skia. 2013-08-29 22:14:04 +00:00
SkThread_platform.h explicitly initialize all entries in array of SkBaseMatrix, since we can't say 2013-04-12 15:34:53 +00:00
SkThread.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
SkTileGridPicture.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-03-01 12:12:55 +00:00
SkTime.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkTInternalLList.h Fix compiler error in SkTInternalList.h 2012-12-03 23:34:32 +00:00
SkTLazy.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-04-02 07:01:34 +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 Add getFamilyNames to SkTypeface. 2013-08-07 17:09:22 +00:00
SkTypes.h Add sk_calloc. Remove SkMemory_stdlib, which seems unused. 2013-09-20 14:31:45 +00:00
SkUnitMapper.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SkUnPreMultiply.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
SkUtils.h Fix a few clang errors while trying to build tools target. 2013-03-26 21:48:58 +00:00
SkWeakRefCnt.h more SkInstCnt plumbing 2012-06-26 17:55:30 +00:00
SkWriter32.h Create a semi-stable API for capturing the state of an SkCanvas and reconstructing that state across different versions of Skia. 2013-08-29 20:20:40 +00:00
SkXfermode.h remove dst/rendertarget support for kARGB_4444_Config 2013-06-21 18:30:53 +00:00