2009-06-23 Simon Fraser <simon.fraser@apple.com>

        Reviewed by Dave Hyatt.

        https://bugs.webkit.org/show_bug.cgi?id=24863

        Fix reflection painting on elements with compositing layers.

        Test: compositing/reflections/reflection-on-composited.html

        * rendering/RenderLayer.h:
        Add a new PaintLayerPaintingReflection flag which is set while painting inside
        reflections.
        (WebCore::RenderLayer::setPaintingInsideReflection):
        Add a setter so that RenderLayerBacking can call it.

        * rendering/RenderLayer.cpp:
        (WebCore::shouldDoSoftwarePaint):
        Utility to clarify the logic of when a composited layer should do a software paint.

        (WebCore::RenderLayer::paintLayer):
        Use shouldDoSoftwarePaint() to determine when to software-paint a reflected layer.
        Remove transform-related tests from the reflection-painting if test because they appear
        to be unnecessary.

        * rendering/RenderLayerBacking.cpp:
        (WebCore::RenderLayerBacking::paintIntoLayer):
        Add the code to paint reflections to the composited layer painting method.

        * rendering/RenderReplica.cpp:
        (WebCore::RenderReplica::paint):
        Set the PaintLayerPaintingReflection flag.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@45005 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 218b0a13
2009-06-23 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dave Hyatt.
https://bugs.webkit.org/show_bug.cgi?id=24863
Testcase for reflections on composited layers.
* compositing/reflections/reflection-on-composited.html: Added.
* platform/mac/compositing/reflections/reflection-on-composited-expected.txt: Added.
2009-06-23 Antti Koivisto <antti@apple.com>
Reviewed by Darin Adler.
......
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reflections on composited element</title>
<style type="text/css" media="screen">
.reflected {
height: 100px;
width: 200px;
margin: 20px;
margin-bottom: 120px;
background-color: gray;
-webkit-box-reflect: below 2px;
}
.transformed {
-webkit-transform: rotate3d(0, 0, 1, 0);
}
</style>
</head>
<body>
<div class="transformed reflected">Here is some text</div>
<div id="container" class="transformed">
<div class="reflected">Here is some text</div>
</div>
</body>
</html>
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x460
RenderBlock {HTML} at (0,0) size 800x460
RenderBody {BODY} at (8,20) size 784x320
layer at (28,20) size 200x202
RenderBlock {DIV} at (20,0) size 200x100 [bgcolor=#808080]
RenderText {#text} at (0,0) size 109x18
text run at (0,0) width 109: "Here is some text"
layer at (8,240) size 784x100
RenderBlock {DIV} at (0,220) size 784x100
layer at (28,240) size 200x202
RenderBlock {DIV} at (20,0) size 200x100 [bgcolor=#808080]
RenderText {#text} at (0,0) size 109x18
text run at (0,0) width 109: "Here is some text"
2009-06-23 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dave Hyatt.
https://bugs.webkit.org/show_bug.cgi?id=24863
Fix reflection painting on elements with compositing layers.
Test: compositing/reflections/reflection-on-composited.html
* rendering/RenderLayer.h:
Add a new PaintLayerPaintingReflection flag which is set while painting inside
reflections.
(WebCore::RenderLayer::setPaintingInsideReflection):
Add a setter so that RenderLayerBacking can call it.
* rendering/RenderLayer.cpp:
(WebCore::shouldDoSoftwarePaint):
Utility to clarify the logic of when a composited layer should do a software paint.
(WebCore::RenderLayer::paintLayer):
Use shouldDoSoftwarePaint() to determine when to software-paint a reflected layer.
Remove transform-related tests from the reflection-painting if test because they appear
to be unnecessary.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintIntoLayer):
Add the code to paint reflections to the composited layer painting method.
* rendering/RenderReplica.cpp:
(WebCore::RenderReplica::paint):
Set the PaintLayerPaintingReflection flag.
2009-06-23 Antti Koivisto <antti@apple.com>
Reviewed by Darin Adler.
......
......@@ -1930,6 +1930,11 @@ static void performOverlapTests(RenderObject::OverlapTestRequestMap& overlapTest
overlapTestRequests.remove(overlappedRequestClients[i]);
}
static bool shouldDoSoftwarePaint(const RenderLayer* layer, bool paintingReflection)
{
return paintingReflection && !layer->has3DTransform();
}
void RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
const IntRect& paintDirtyRect, PaintRestriction paintRestriction,
RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap* overlapTestRequests,
......@@ -1941,7 +1946,7 @@ void RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
// but we need to ensure that we don't cache clip rects computed with the wrong root in this case.
if (p->updatingControlTints())
paintFlags |= PaintLayerTemporaryClipRects;
else if (!backing()->paintingGoesToWindow()) {
else if (!backing()->paintingGoesToWindow() && !shouldDoSoftwarePaint(this, paintFlags & PaintLayerPaintingReflection)) {
// If this RenderLayer should paint into its backing, that will be done via RenderLayerBacking::paintIntoLayer().
return;
}
......@@ -2012,10 +2017,10 @@ void RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
bool haveTransparency = localPaintFlags & PaintLayerHaveTransparency;
// Paint the reflection first if we have one.
if (m_reflection && !m_paintingInsideReflection && (!m_transform || (paintFlags & PaintLayerAppliedTransform))) {
if (m_reflection && !m_paintingInsideReflection) {
// Mark that we are now inside replica painting.
m_paintingInsideReflection = true;
reflectionLayer()->paintLayer(rootLayer, p, paintDirtyRect, paintRestriction, paintingRoot, overlapTestRequests, localPaintFlags);
reflectionLayer()->paintLayer(rootLayer, p, paintDirtyRect, paintRestriction, paintingRoot, overlapTestRequests, localPaintFlags | PaintLayerPaintingReflection);
m_paintingInsideReflection = false;
}
......
......@@ -442,7 +442,8 @@ private:
enum PaintLayerFlag {
PaintLayerHaveTransparency = 1,
PaintLayerAppliedTransform = 1 << 1,
PaintLayerTemporaryClipRects = 1 << 2
PaintLayerTemporaryClipRects = 1 << 2,
PaintLayerPaintingReflection = 1 << 3
};
typedef unsigned PaintLayerFlags;
......@@ -489,6 +490,7 @@ private:
void createReflection();
void updateReflectionStyle();
bool paintingInsideReflection() const { return m_paintingInsideReflection; }
void setPaintingInsideReflection(bool b) { m_paintingInsideReflection = b; }
void parentClipRects(const RenderLayer* rootLayer, ClipRects&, bool temporaryClipRects = false) const;
......
......@@ -749,6 +749,14 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext*
m_owningLayer->updateLayerListsIfNeeded();
// Paint the reflection first if we have one.
if (m_owningLayer->hasReflection()) {
// Mark that we are now inside replica painting.
m_owningLayer->setPaintingInsideReflection(true);
m_owningLayer->reflectionLayer()->paintLayer(rootLayer, context, paintDirtyRect, paintRestriction, paintingRoot, 0, RenderLayer::PaintLayerPaintingReflection);
m_owningLayer->setPaintingInsideReflection(false);
}
// Calculate the clip rects we should use.
IntRect layerBounds, damageRect, clipRectToApply, outlineRect;
m_owningLayer->calculateRects(rootLayer, paintDirtyRect, layerBounds, damageRect, clipRectToApply, outlineRect);
......
......@@ -73,7 +73,7 @@ void RenderReplica::paint(PaintInfo& paintInfo, int tx, int ty)
layer()->parent()->paintLayer(layer()->transform() ? layer()->parent() : layer()->enclosingTransformedAncestor(),
paintInfo.context, paintInfo.rect,
PaintRestrictionNone, 0, 0,
RenderLayer::PaintLayerHaveTransparency | RenderLayer::PaintLayerAppliedTransform | RenderLayer::PaintLayerTemporaryClipRects);
RenderLayer::PaintLayerHaveTransparency | RenderLayer::PaintLayerAppliedTransform | RenderLayer::PaintLayerTemporaryClipRects | RenderLayer::PaintLayerPaintingReflection);
else if (paintInfo.phase == PaintPhaseMask)
paintMask(paintInfo, tx, ty);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment