skia2/include/core
lsalzman 40254c2c2d SkBlendARGB32 and S32[A]_Blend_BlitRow32 are currently formulated as: SkAlphaMulQ(src, src_scale) + SkAlphaMulQ(dst, dst_scale), which boils down to ((src*src_scale)>>8) + ((dst*dst_scale)>>8). In particular, note that the intermediate precision is discarded before the two parts are added together, causing the final result to possibly inaccurate.
In Firefox, we use SkCanvas::saveLayer in combination with a backdrop that initializes the layer to the background. When this is blended back onto background using transparency, where the source and destination pixel colors are the same, the resulting color after the blend is not preserved due to the lost precision mentioned above. In cases where this operation is repeatedly performed, this causes substantially noticeable differences in color as evidenced in this downstream Firefox bug report:  https://bugzilla.mozilla.org/show_bug.cgi?id=1200684

In the test-case in the downstream report, essentially it does blend(src=0xFF2E3338, dst=0xFF2E3338, scale=217), which gives the result 0xFF2E3237, while we would expect to get back 0xFF2E3338.

This problem goes away if the blend is instead reformulated to effectively do (src*src_scale + dst*dst_scale)>>8, which keeps the intermediate precision during the addition before shifting it off.

This modifies the blending operations thusly. The performance should remain mostly unchanged, or possibly improve slightly, so there should be no real downside to doing this, with the benefit of making the results more accurate. Without this, it is currently unsafe for Firefox to blend a layer back onto itself that was initialized with a copy of its background.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2097883002
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot

[mtklein adds...]
No public API changes.
TBR=reed@google.com

Review-Url: https://codereview.chromium.org/2097883002
2016-08-05 11:48:45 -07:00
..
SkAnnotation.h remove unneeded flag for annotations 2016-03-05 06:00:12 -08:00
SkBBHFactory.h Revert of Add non-inline SkRTreeFactory constructor to fix clang-cl (patchset #2 id:20001 of https://codereview.chromium.org/1676833002/ ) 2016-02-26 16:31:12 -08:00
SkBitmap.h remove/deprecate SkBitmap::getTexture, as it now always returns false 2016-07-25 08:29:10 -07:00
SkBitmapDevice.h remove fClipStack and attach/deattach-from-canvas 2016-07-25 08:05:23 -07:00
SkBlitRow.h Port SkBlitRow::Color32 to SkOpts. 2015-09-10 10:38:02 -07:00
SkBlurTypes.h move common blur types into central header 2014-04-28 16:25:35 +00:00
SkCanvas.h Add drawImageLattice() and drawBitmapLattice() APIs 2016-08-02 08:05:56 -07:00
SkChunkAlloc.h MIPS32r2: Fix Chromium runtime crash 2016-06-05 13:14:21 -07:00
SkClipStack.h Repurpose Release_Developer BUILDTYPE and remove SK_DEVELOPER. 2016-04-29 06:41:35 -07:00
SkColor.h Change SkColor4f to RGBA channel order 2016-06-24 06:31:47 -07:00
SkColorFilter.h Add SkRasterPipeline blitter. 2016-07-22 11:05:04 -07:00
SkColorPriv.h SkBlendARGB32 and S32[A]_Blend_BlitRow32 are currently formulated as: SkAlphaMulQ(src, src_scale) + SkAlphaMulQ(dst, dst_scale), which boils down to ((src*src_scale)>>8) + ((dst*dst_scale)>>8). In particular, note that the intermediate precision is discarded before the two parts are added together, causing the final result to possibly inaccurate. 2016-08-05 11:48:45 -07:00
SkColorSpace.h Add SkColorSpace::Equals() API 2016-08-01 09:43:08 -07:00
SkColorTable.h Ensure that SkColorTable->fCount is set properly after decodes 2016-05-17 08:52:11 -07:00
SkData.h Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. 2016-08-02 14:40:46 -07:00
SkDataTable.h Move to SkDataTable::MakeXXX and sk_sp. 2016-08-05 06:51:50 -07: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 drawImageLattice() and drawBitmapLattice() APIs 2016-08-02 08:05:56 -07:00
SkDocument.h SkPDF: allow overriding Producer metadata 2016-06-30 08:22:04 -07:00
SkDraw.h SkPixmap::setColorSpace 2016-06-09 11:03:45 -07:00
SkDrawable.h Make SkDrawable an SkFlattenable 2016-04-25 06:40:26 -07:00
SkDrawFilter.h SkPaintFilterCanvas cleanup 2016-01-12 12:14:10 -08:00
SkDrawLooper.h Revert of Delete SkFlattenable::Type (patchset #2 id:20001 of https://codereview.chromium.org/1834303003/ ) 2016-04-04 14:57:19 -07:00
SkError.h Sanitizing source files in Housekeeper-Nightly 2013-09-05 07:01:19 +00:00
SkFilterQuality.h Skia Filter Quality and Scaling Metrics 2016-04-18 09:14:00 -07:00
SkFlattenable.h SkLightingShader normal vector CPU computation refactor. 2016-06-27 11:40:45 -07:00
SkFlattenableSerialization.h Revert of Delete SkFlattenable::Type (part 1) (patchset #1 id:1 of https://codereview.chromium.org/1861013002/ ) 2016-04-05 12:00:49 -07:00
SkFont.h typedef uint16_t SkGlyphID 2016-07-25 07:18:12 -07:00
SkFontLCDConfig.h Add SK_API to SkFontLCDConfig. 2016-05-03 11:56:03 -07:00
SkFontStyle.h Remove 'Ulta' width. 2016-08-02 10:43:29 -07:00
SkGraphics.h add SkGraphics::PurageAllCaches 2016-02-22 06:19:54 -08:00
SkImage.h Adding an SkColorSpace to SkImage_Gpu 2016-07-20 13:55:39 -07:00
SkImageEncoder.h Delete SkARGBImageEncoder. 2016-08-02 12:57:33 -07:00
SkImageFilter.h Adding color space to SkSpecialImage 2016-07-21 07:15:37 -07:00
SkImageGenerator.h Enable generating SkImage with the same uniqueID in SkImageGenerator subclass 2016-05-02 01:43:38 -07:00
SkImageInfo.h Add SkColorSpace::Equals() API 2016-08-01 09:43:08 -07:00
SkLights.h Fix dtor bug in SkLights 2016-08-03 09:40:39 -07:00
SkMallocPixelRef.h For non-opaque SkBitmapDevices, replace malloc-then-zero with calloc. 2015-11-05 09:46:23 -08:00
SkMask.h Add default ctor to SkMask 2015-12-17 11:33:12 -08:00
SkMaskFilter.h Fix up flags to SkGpuBlurUtils::GaussianBlur 2016-06-27 11:11:05 -07:00
SkMath.h SkLeanWindows.h: #include "Windows.h" fewer places 2016-06-07 17:21:10 -07:00
SkMatrix44.h SkMatrix44 clarifications and clean-ups 2016-06-23 12:42:29 -07:00
SkMatrix.h Revert of change mapRectScaleTranslate to pass args/ret by value (patchset #1 id:1 of https://codereview.chromium.org/2137853002/ ) 2016-07-10 11:45:35 -07:00
SkMetaData.h "NULL !=" = NULL 2014-09-05 13:34:00 -07:00
SkMilestone.h Update skia milestone to next 2016-06-30 07:31:09 -07:00
SkMultiPictureDraw.h Move SkTDArray to private. 2016-02-18 08:53:33 -08:00
SkOSFile.h add fsync to try to get complete skps from webpage picture capture 2015-12-16 13:41:23 -08:00
SkPaint.h SkPaint intercept API for SkTextBlob and horizontal text 2016-07-28 09:47:24 -07:00
SkPath.h Avoid warnings on GCC 4.8.4 2016-07-26 14:10:17 -07:00
SkPathEffect.h SkPathEffect.h: add SK_API where needed 2016-04-21 10:54:11 -07:00
SkPathMeasure.h fix path getSegment comment 2016-03-23 11:15:57 -07:00
SkPathRef.h Always init SkPathRef variables. 2016-07-22 13:51:42 -07:00
SkPicture.h Update typeface serialization style. 2016-07-25 16:54:59 -07:00
SkPictureAnalyzer.h SkPictureAnalyzer: expose the number of slow GPU commands. 2016-06-09 12:43:30 -07:00
SkPictureRecorder.h Sketch SkPictureRecorder::optimizeFor(GrContext*). 2016-08-01 13:17:47 -07:00
SkPixelRef.h remove/deprecate SkBitmap::getTexture, as it now always returns false 2016-07-25 08:29:10 -07:00
SkPixelSerializer.h SkPixelSerializer: remove deprecated virtual 2015-12-10 09:30:57 -08:00
SkPixmap.h SkPixmap::setColorSpace 2016-06-09 11:03:45 -07:00
SkPngChunkReader.h Delete SkImageDecoder 2016-03-24 10:41:47 -07:00
SkPoint3.h Update SkLightingShader to support rotation 2015-08-20 05:15:07 -07:00
SkPoint.h handle large conic weights 2016-07-13 10:56:53 -07:00
SkPostConfig.h Default fake gamma to sRGB. 2016-08-01 09:22:12 -07:00
SkPreConfig.h spin off easy stuff from Herb's windows GN CL 2016-08-04 06:19:33 -07:00
SkRasterizer.h Revert of Delete SkFlattenable::Type (patchset #2 id:20001 of https://codereview.chromium.org/1834303003/ ) 2016-04-04 14:57:19 -07:00
SkRect.h In GrShape detect that stroked axis-aligned lines are rrects. 2016-07-18 07:31:13 -07:00
SkRefCnt.h sk_sp for Ganesh. 2016-06-09 08:01:03 -07:00
SkRegion.h inline very common intersect+rect_rgn 2016-06-30 07:47:34 -07:00
SkRRect.h Make GrShape track the winding direction and starting point for rrect types. 2016-06-06 14:01:25 -07:00
SkRSXform.h add helper to create RSXform w/ anchorPt 2015-07-30 05:46:05 -07:00
SkRWBuffer.h Fixes for SkRWBuffer 2016-04-22 06:59:01 -07:00
SkScalar.h Swap SkGpuBlurUtils over to using SkIRects 2016-05-13 05:06:19 -07:00
SkShader.h Always return ImageShader, even from SkShader::MakeBitmapShader 2016-08-02 06:12:06 -07: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 SkWStream::writeText inlined. 2016-04-11 19:41:48 -07:00
SkString.h Reverse dependency between SkScalar.h and SkFixed.h. 2016-04-07 08:49:31 -07:00
SkStrokeRec.h Unify implementations of stroking radius calculationsns 2016-04-29 07:07:03 -07:00
SkSurface.h Remove SkSurface::MakeRenderTargetDirect 2016-08-04 08:45:02 -07:00
SkSurfaceProps.h Remove SkSurfaceProps gamma-correctness flag entirely. 2016-07-26 11:36:05 -07:00
SkSwizzle.h Add missing SK_API to SkSwizzle.h 2016-03-24 07:50:14 -07:00
SkTextBlob.h typedef uint16_t SkGlyphID 2016-07-25 07:18:12 -07:00
SkTime.h Make SkTime SK_API so that SkTime::GetDateTime() is visible to the clients. 2016-05-02 15:04:46 -07:00
SkTLazy.h Fix typo in SkTLazy copy ctor. src is a reference, not a pointer. 2016-03-25 09:11:35 -07:00
SkTraceMemoryDump.h Add support for light dumps in SkTraceMemoryDump interface. 2015-09-30 04:31:23 -07:00
SkTRegistry.h Rewrite SkTRegistry to take any trivially-copyable type. 2013-09-04 17:20:18 +00:00
SkTypeface.h Add test for typeface style round trip. 2016-07-25 15:11:49 -07:00
SkTypes.h require semi at the end of SkASSERT and friends 2016-07-27 12:02:07 -07:00
SkUnPreMultiply.h Factor out UnPreMultiplyPreservingByteOrder 2014-01-15 22:24:58 +00:00
SkWriteBuffer.h Prototype code that turns any/every flattenable into JSON 2016-05-04 11:06:28 -07:00
SkWriter32.h Remove SkWriter32::contiguousArray(). 2016-04-29 14:45:36 -07:00
SkXfermode.h Add SkRasterPipeline blitter. 2016-07-22 11:05:04 -07:00
SkYUVSizeInfo.h Update Skia's YUV API 2016-03-10 05:44:43 -08:00