Bug 113732 - [Texmap] Hierarchy of layers with opacity may result in wrong blending.
Summary: [Texmap] Hierarchy of layers with opacity may result in wrong blending.
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Noam Rosenthal
Depends on: 114278
Blocks: 50418 112446 114290
  Show dependency treegraph
Reported: 2013-04-01 16:44 PDT by Bruno Abinader (history only)
Modified: 2013-04-10 04:47 PDT (History)
11 users (show)

See Also:

Test (1.89 KB, text/html)
2013-04-01 16:44 PDT, Bruno Abinader (history only)
no flags Details
Expected result (3.47 KB, image/png)
2013-04-01 16:45 PDT, Bruno Abinader (history only)
no flags Details
Actual result (4.10 KB, image/png)
2013-04-01 16:46 PDT, Bruno Abinader (history only)
no flags Details
Much simplified test case (564 bytes, text/html)
2013-04-05 08:37 PDT, Noam Rosenthal
no flags Details
Exploratory patch (841 bytes, application/octet-stream)
2013-04-09 05:37 PDT, Bruno Abinader (history only)
no flags Details
Patch (13.52 KB, patch)
2013-04-09 09:25 PDT, Noam Rosenthal
no flags Details | Formatted Diff | Diff
Patch (13.81 KB, patch)
2013-04-09 10:12 PDT, Noam Rosenthal
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2 (557.15 KB, application/zip)
2013-04-09 14:15 PDT, Build Bot
no flags Details
Patch (14.53 KB, patch)
2013-04-10 01:18 PDT, Noam Rosenthal
no flags Details | Formatted Diff | Diff
Patch (14.54 KB, patch)
2013-04-10 01:19 PDT, Noam Rosenthal
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Abinader (history only) 2013-04-01 16:44:50 PDT
Created attachment 196038 [details]

When working on a layout test for bug 50418, I have noticed that composited layers with a mixed set of layout positioning methods (fixed, absolute, relative, float) causes some visual artifacts with layout and rendering (see attached test). In Chrome it behaves correctly, while on both EFL and Qt running MiniBrowser I observed the same issues.
Comment 1 Bruno Abinader (history only) 2013-04-01 16:45:55 PDT
Created attachment 196039 [details]
Expected result

Expected result as obtained from Chrome.
Comment 2 Bruno Abinader (history only) 2013-04-01 16:46:54 PDT
Created attachment 196040 [details]
Actual result

Actual (buggy) result from both Qt and EFL builds (might also be happening on other AC-enabled ports).
Comment 3 Bruno Abinader (history only) 2013-04-03 06:04:05 PDT
I found out yesterday two things:

1. If we change both location and size of the tileRect passed to paintWithIntermediateSurface to be IntPoint(0,0) and maxTextureSize, respectively, the texture layers are properly rendered but with messy opacity blending.

2. When using "-webkit-transform-style: preserve-3d;" on all composited layers, the issue disappears. My guess is that this makes shouldBlend() return false, thus forcing codepath to not enter paintUsingOverlapRegions().
Comment 4 Noam Rosenthal 2013-04-03 06:23:48 PDT
Yes, the bug is probably in the overlap region calculation then.
Comment 5 Noam Rosenthal 2013-04-05 08:37:42 PDT
Created attachment 196637 [details]
Much simplified test case
Comment 6 Bruno Abinader (history only) 2013-04-09 05:33:37 PDT
(In reply to comment #5)
> Created an attachment (id=196637) [details]
> Much simplified test case

No'am, I haven't noticed any issues with your testcase, at least not on EFL port. I have a fix for the surface positioning issue (see below), however opacity blending results are still wrong.

diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
index 5911513..70c98be 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
@@ -412,7 +412,10 @@ void TextureMapperLayer::paintWithIntermediateSurface(const TextureMapperPaintOp
         mainSurface = replicaSurface;
-    commitSurface(options, mainSurface, rect, options.opacity);
+    // Offset needs to be reset when committing to surface.
+    TextureMapperPaintOptions surfaceOptions(options);
+    surfaceOptions.offset = IntSize();
+    commitSurface(surfaceOptions, mainSurface, rect, options.opacity);
 void TextureMapperLayer::paintRecursive(const TextureMapperPaintOptions& options)

Can you please test this on your environment to see if it works? I'll attach it as a patch to make it easy to apply.
Comment 7 Bruno Abinader (history only) 2013-04-09 05:37:53 PDT
Created attachment 197035 [details]
Exploratory patch

When committing the surface, resetting the offset value makes the painted surfaces being correctly positioned. However, the opacity blending still have incorrect values when compared to non-composited result.
Comment 8 Bruno Abinader (history only) 2013-04-09 05:52:04 PDT
Comment on attachment 197035 [details]
Exploratory patch

As Noam commented on IRC, this fix is wrong (only affects the provided test-case).
Comment 9 Noam Rosenthal 2013-04-09 09:25:28 PDT
Created attachment 197136 [details]
Comment 10 Allan Sandfeld Jensen 2013-04-09 09:51:43 PDT
Comment on attachment 197136 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=197136&action=review

> Source/WebCore/platform/graphics/texmap/TextureMapperGL.h:100
> +        enum MirrorMode {
> +            ShouldNotMirror,
> +            ShouldMirror
> +        };

Could you add a comment about what MirrorMode represents?
Comment 11 Noam Rosenthal 2013-04-09 10:12:24 PDT
Created attachment 197141 [details]
Comment 12 Build Bot 2013-04-09 14:15:33 PDT
Comment on attachment 197141 [details]

Attachment 197141 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-commit-queue.appspot.com/results/17690016

New failing tests:
Comment 13 Build Bot 2013-04-09 14:15:35 PDT
Created attachment 197174 [details]
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-12  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.2
Comment 14 Noam Rosenthal 2013-04-10 01:18:22 PDT
Created attachment 197220 [details]
Comment 15 Noam Rosenthal 2013-04-10 01:19:36 PDT
Created attachment 197221 [details]
Comment 16 WebKit Commit Bot 2013-04-10 04:47:02 PDT
Comment on attachment 197221 [details]

Clearing flags on attachment: 197221

Committed r148090: <http://trac.webkit.org/changeset/148090>
Comment 17 WebKit Commit Bot 2013-04-10 04:47:06 PDT
All reviewed patches have been landed.  Closing bug.