Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / paint / ReplicaPainter.cpp
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/paint/ReplicaPainter.h"
7
8 #include "core/paint/LayerPainter.h"
9 #include "core/rendering/GraphicsContextAnnotator.h"
10 #include "core/rendering/PaintInfo.h"
11 #include "core/rendering/RenderLayer.h"
12 #include "core/rendering/RenderReplica.h"
13
14 namespace blink {
15
16 void ReplicaPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
17 {
18     ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderReplica);
19
20     if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseMask)
21         return;
22
23     LayoutPoint adjustedPaintOffset = paintOffset + m_renderReplica.location();
24
25     if (paintInfo.phase == PaintPhaseForeground) {
26         // Turn around and paint the parent layer. Use temporary clipRects, so that the layer doesn't end up caching clip rects
27         // computing using the wrong rootLayer
28         RenderLayer* rootPaintingLayer = m_renderReplica.layer()->transform() ? m_renderReplica.layer()->parent() : m_renderReplica.layer()->enclosingTransformedAncestor();
29         LayerPaintingInfo paintingInfo(rootPaintingLayer, paintInfo.rect, PaintBehaviorNormal, LayoutSize(), 0);
30         PaintLayerFlags flags = PaintLayerHaveTransparency | PaintLayerAppliedTransform | PaintLayerUncachedClipRects | PaintLayerPaintingReflection;
31         LayerPainter(*m_renderReplica.layer()->parent()).paintLayer(paintInfo.context, paintingInfo, flags);
32     } else if (paintInfo.phase == PaintPhaseMask) {
33         m_renderReplica.paintMask(paintInfo, adjustedPaintOffset);
34     }
35 }
36
37 } // namespace blink