Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Issue 2097883002: revise row blits to keep intermediate precision so that color is preserved when blended against its… (Closed)

Created:
4 years, 6 months ago by lsalzman1
Modified:
4 years, 4 months ago
Reviewers:
mtklein, mtklein_C, reed1
CC:
reviews_skia.org, ethannicholas
Base URL:
https://skia.googlesource.com/skia@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

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 Committed: https://skia.googlesource.com/skia/+/40254c2c2dc28a34f96294d5a1ad94a99b0be8a6

Patch Set 1 #

Patch Set 2 : Fix overflow in destination scale calculation #

Total comments: 1

Patch Set 3 : support old broken lerp via SK_SUPPORT_LEGACY_BROKEN_LERP define #

Patch Set 4 : fix typo in SkPMLerp_SSE2 #

Patch Set 5 : guard more changes with SK_SUPPORT_LEGACY_BROKEN_LERP #

Unified diffs Side-by-side diffs Delta from patch set Stats (+179 lines, -43 lines) Patch
M gm/blend.cpp View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
M include/core/SkColorPriv.h View 1 2 2 chunks +37 lines, -0 lines 0 comments Download
M src/core/SkBlitRow_D16.cpp View 1 1 chunk +1 line, -1 line 0 comments Download
M src/core/SkBlitRow_D32.cpp View 1 2 1 chunk +7 lines, -5 lines 0 comments Download
M src/core/SkBlitter_A8.cpp View 1 1 chunk +1 line, -1 line 0 comments Download
M src/core/SkBlitter_ARGB32.cpp View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M src/core/SkSpriteBlitter_RGB16.cpp View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M src/opts/SkBlitRow_opts_SSE2.cpp View 1 2 3 chunks +3 lines, -8 lines 0 comments Download
M src/opts/SkBlitRow_opts_arm_neon.cpp View 1 2 7 chunks +33 lines, -4 lines 0 comments Download
M src/opts/SkBlitRow_opts_mips_dsp.cpp View 1 2 1 chunk +6 lines, -0 lines 0 comments Download
M src/opts/SkColor_opts_SSE2.h View 1 2 3 2 chunks +80 lines, -21 lines 0 comments Download

Messages

Total messages: 68 (32 generated)
lsalzman1
4 years, 6 months ago (2016-06-24 18:24:47 UTC) #4
lsalzman1
4 years, 5 months ago (2016-06-29 22:16:29 UTC) #7
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2097883002/1
4 years, 5 months ago (2016-06-29 22:37:58 UTC) #9
mtklein
Do you have someone (including yourself) fluent enough in MIPS assembly to vouch for that ...
4 years, 5 months ago (2016-06-29 22:44:35 UTC) #11
lsalzman1
On 2016/06/29 22:44:35, mtklein wrote: > Do you have someone (including yourself) fluent enough in ...
4 years, 5 months ago (2016-06-29 23:51:41 UTC) #12
mtklein
On 2016/06/29 23:51:41, lsalzman1 wrote: > On 2016/06/29 22:44:35, mtklein wrote: > > Do you ...
4 years, 5 months ago (2016-06-30 13:29:53 UTC) #13
lsalzman1
On 2016/06/30 13:29:53, mtklein wrote: > Hmm. This looks wrong. > > That red linux_blink_rel ...
4 years, 5 months ago (2016-06-30 14:53:53 UTC) #14
mtklein
On 2016/06/30 14:53:53, lsalzman1 wrote: > On 2016/06/30 13:29:53, mtklein wrote: > > Hmm. This ...
4 years, 5 months ago (2016-06-30 15:10:54 UTC) #15
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2097883002/20001
4 years, 5 months ago (2016-06-30 21:01:17 UTC) #17
lsalzman1
I managed to reproduce at least some of the problems in Firefox using some adapted ...
4 years, 5 months ago (2016-06-30 21:08:47 UTC) #18
mtklein
On 2016/06/30 21:08:47, lsalzman1 wrote: > I managed to reproduce at least some of the ...
4 years, 5 months ago (2016-06-30 21:12:56 UTC) #20
lsalzman1
Le sigh, the gm blend failures seem to be with regards to my second change ...
4 years, 5 months ago (2016-07-01 14:27:58 UTC) #21
lsalzman1
On 2016/07/01 14:27:58, lsalzman1 wrote: > Le sigh, the gm blend failures seem to be ...
4 years, 5 months ago (2016-07-01 18:56:28 UTC) #22
lsalzman1
On 2016/07/01 14:27:58, lsalzman1 wrote: > Le sigh, the gm blend failures seem to be ...
4 years, 5 months ago (2016-07-01 19:02:18 UTC) #23
lsalzman1
Any decisions?
4 years, 5 months ago (2016-07-18 17:53:45 UTC) #24
mtklein
On 2016/07/18 17:53:45, lsalzman1 wrote: > Any decisions? Sorry, just haven't circled back yet.
4 years, 5 months ago (2016-07-18 18:21:07 UTC) #25
commit-bot: I haz the power
Your CL relies on deprecated CQ feature(s): * Specifying master names in CQ_INCLUDE_TRYBOTS part of ...
4 years, 4 months ago (2016-07-26 19:20:08 UTC) #28
mtklein
> Looks like trying to modify src scale significantly causes adverse movement on > Firefox's ...
4 years, 4 months ago (2016-07-26 19:29:33 UTC) #30
mtklein
https://codereview.chromium.org/2097883002/diff/20001/include/core/SkColorPriv.h File include/core/SkColorPriv.h (right): https://codereview.chromium.org/2097883002/diff/20001/include/core/SkColorPriv.h#newcode206 include/core/SkColorPriv.h:206: #define SkAlphaMulInv256(value, alpha256) (((256<<8) - (value) * (alpha256)) >> ...
4 years, 4 months ago (2016-07-26 19:29:43 UTC) #31
lsalzman1
Okay, I'll try to get to fixing those issues this week. We're in the final ...
4 years, 4 months ago (2016-07-28 02:15:10 UTC) #35
mtklein
On 2016/07/28 02:15:10, lsalzman1 wrote: > Okay, I'll try to get to fixing those issues ...
4 years, 4 months ago (2016-07-28 13:31:53 UTC) #36
lsalzman1
I finally got around to tracking down some last issues in Firefox's unit tests. I ...
4 years, 4 months ago (2016-08-03 22:12:58 UTC) #38
commit-bot: I haz the power
Your CL relies on deprecated CQ feature(s): * Specifying master names in CQ_INCLUDE_TRYBOTS part of ...
4 years, 4 months ago (2016-08-04 16:40:35 UTC) #41
mtklein_C
On 2016/08/03 at 22:12:58, lsalzman wrote: > I finally got around to tracking down some ...
4 years, 4 months ago (2016-08-04 17:04:55 UTC) #44
lsalzman1
Is this safe to commit now?
4 years, 4 months ago (2016-08-05 14:19:48 UTC) #46
mtklein_C
On 2016/08/05 at 14:19:48, lsalzman wrote: > Is this safe to commit now? Yes, I ...
4 years, 4 months ago (2016-08-05 14:23:01 UTC) #47
lsalzman1
On 2016/08/05 14:23:01, mtklein_C wrote: > On 2016/08/05 at 14:19:48, lsalzman wrote: > > Is ...
4 years, 4 months ago (2016-08-05 14:40:24 UTC) #48
mtklein_C
On 2016/08/05 at 14:40:24, lsalzman wrote: > On 2016/08/05 14:23:01, mtklein_C wrote: > > On ...
4 years, 4 months ago (2016-08-05 15:37:11 UTC) #51
lsalzman1
On 2016/08/05 15:37:11, mtklein_C wrote: > On 2016/08/05 at 14:40:24, lsalzman wrote: > > On ...
4 years, 4 months ago (2016-08-05 17:24:56 UTC) #53
lsalzman1
On 2016/08/05 15:37:11, mtklein_C wrote: > On 2016/08/05 at 14:40:24, lsalzman wrote: > > On ...
4 years, 4 months ago (2016-08-05 17:26:24 UTC) #54
mtklein_C
On 2016/08/05 at 17:26:24, lsalzman wrote: > On 2016/08/05 15:37:11, mtklein_C wrote: > > On ...
4 years, 4 months ago (2016-08-05 17:49:07 UTC) #57
lsalzman1
On 2016/08/05 17:49:07, mtklein_C wrote: > On 2016/08/05 at 17:26:24, lsalzman wrote: > > On ...
4 years, 4 months ago (2016-08-05 18:41:16 UTC) #60
mtklein_C
fire away!
4 years, 4 months ago (2016-08-05 18:46:54 UTC) #62
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2097883002/80001
4 years, 4 months ago (2016-08-05 18:47:50 UTC) #65
mtklein
+Ethan, FYI This change will cause many 8888 diffs. I will triage them.
4 years, 4 months ago (2016-08-05 18:48:25 UTC) #66
commit-bot: I haz the power
4 years, 4 months ago (2016-08-05 18:48:52 UTC) #68
Message was sent while issue was closed.
Committed patchset #5 (id:80001) as
https://skia.googlesource.com/skia/+/40254c2c2dc28a34f96294d5a1ad94a99b0be8a6

Powered by Google App Engine
This is Rietveld 408576698