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.
5 #ifndef PaintInvalidationState_h
6 #define PaintInvalidationState_h
8 #include "platform/geometry/LayoutRect.h"
9 #include "platform/transforms/AffineTransform.h"
10 #include "wtf/Noncopyable.h"
14 class RenderLayerModelObject;
16 class RenderSVGModelObject;
19 class PaintInvalidationState {
20 WTF_MAKE_NONCOPYABLE(PaintInvalidationState);
22 PaintInvalidationState(const PaintInvalidationState& next, RenderLayerModelObject& renderer, const RenderLayerModelObject& paintInvalidationContainer);
23 PaintInvalidationState(const PaintInvalidationState& next, const RenderSVGModelObject& renderer);
25 explicit PaintInvalidationState(const RenderView&);
27 const LayoutRect& clipRect() const { return m_clipRect; }
28 const LayoutSize& paintOffset() const { return m_paintOffset; }
29 const AffineTransform& svgTransform() const { ASSERT(m_svgTransform); return *m_svgTransform; }
31 bool cachedOffsetsEnabled() const { return m_cachedOffsetsEnabled; }
32 bool isClipped() const { return m_clipped; }
34 bool forceCheckForPaintInvalidation() const { return m_forceCheckForPaintInvalidation; }
35 void setForceCheckForPaintInvalidation() { m_forceCheckForPaintInvalidation = true; }
37 const RenderLayerModelObject& paintInvalidationContainer() const { return m_paintInvalidationContainer; }
39 bool canMapToContainer(const RenderLayerModelObject* container) const
41 return m_cachedOffsetsEnabled && container == &m_paintInvalidationContainer;
44 void applyClipIfNeeded(const RenderObject&);
45 void addClipRectRelativeToPaintOffset(const LayoutSize& clipSize);
47 friend class ForceHorriblySlowRectMapping;
50 mutable bool m_cachedOffsetsEnabled;
51 bool m_forceCheckForPaintInvalidation;
53 LayoutRect m_clipRect;
55 // x/y offset from paint invalidation container. Includes relative positioning and scroll offsets.
56 LayoutSize m_paintOffset;
58 const RenderLayerModelObject& m_paintInvalidationContainer;
60 // Transform from the initial viewport coordinate system of an outermost
61 // SVG root to the userspace _before_ the relevant element. Combining this
62 // with |m_paintOffset| yields the "final" offset.
63 OwnPtr<AffineTransform> m_svgTransform;
68 #endif // PaintInvalidationState_h