[Texmap] Hierarchy of layers with opacity may result in wrong blending.
https://bugs.webkit.org/show_bug.cgi?id=113732

Patch by Noam Rosenthal <noam@webkit.org> on 2013-04-10
Reviewed by Allan Sandfeld Jensen.

Source/WebCore:

This is a combination of three issues with nested intermediate surfaces:
- glScissor inside an intermediate surface should not be mirrored.
- The current surface should be passed to the next surface in paintOptions.
- When clipping for the non-overlap region, the containing surface offset
should be applied.

Though the changes are separate, they cannot be tested separately as neither
fixes a testable case on its own.

Tests: compositing/overlap-blending/nested-non-overlap-clipping.html
       compositing/overlap-blending/nested-overlap.html

* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::ClipStack::reset):
(WebCore::TextureMapperGL::ClipStack::apply):
(WebCore::TextureMapperGL::beginPainting):
(WebCore::BitmapTextureGL::clearIfNeeded):
* platform/graphics/texmap/TextureMapperGL.h:
(ClipStack):
    Do not mirror the scissor clip when painting to an FBO.
    Also a minor refactor to avoid reading the viewport values from the driver.

* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::paintUsingOverlapRegions):
    Apply the offset when clipping for a non-overlap region.
(WebCore::TextureMapperLayer::paintIntoSurface):
    Make sure the current surface is passed to the next one.

LayoutTests:

Added two ref-tests for nested composited overlaps.
This ref-test does not work on Mac due to a slight mismatch opacity value on CoreAnimation.
A new bug has been posted, and TestExpectations has been updated.

* compositing/overlap-blending/nested-non-overlap-clipping-expected.html: Added.
* compositing/overlap-blending/nested-non-overlap-clipping.html: Added.
* compositing/overlap-blending/nested-overlap-expected.html: Added.
* compositing/overlap-blending/nested-overlap.html: Added.
* platform/mac/TestExpectations: Skipped new tests and created bug.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148090 268f45cc-cd09-0410-ab3c-d52691b4dbfc