OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BackgroundImageGeometry_h | 5 #ifndef BackgroundImageGeometry_h |
6 #define BackgroundImageGeometry_h | 6 #define BackgroundImageGeometry_h |
7 | 7 |
| 8 #include "core/paint/PaintPhase.h" |
8 #include "platform/geometry/IntPoint.h" | 9 #include "platform/geometry/IntPoint.h" |
9 #include "platform/geometry/IntRect.h" | 10 #include "platform/geometry/IntRect.h" |
10 #include "platform/geometry/IntSize.h" | 11 #include "platform/geometry/IntSize.h" |
11 #include "wtf/Allocator.h" | 12 #include "wtf/Allocator.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
| 16 class FillLayer; |
| 17 class LayoutBoxModelObject; |
| 18 class LayoutObject; |
| 19 class LayoutRect; |
| 20 |
15 class BackgroundImageGeometry { | 21 class BackgroundImageGeometry { |
16 STACK_ALLOCATED(); | 22 STACK_ALLOCATED(); |
17 public: | 23 public: |
18 BackgroundImageGeometry() | 24 BackgroundImageGeometry() |
19 : m_hasNonLocalGeometry(false) | 25 : m_hasNonLocalGeometry(false) |
20 { } | 26 { } |
21 | 27 |
| 28 void calculate(const LayoutBoxModelObject&, const LayoutBoxModelObject* pain
tContainer, |
| 29 const GlobalPaintFlags, const FillLayer&, const LayoutRect& paintRect, |
| 30 LayoutObject* backgroundObject = nullptr); |
| 31 |
22 IntRect destRect() const { return m_destRect; } | 32 IntRect destRect() const { return m_destRect; } |
23 void setDestRect(const IntRect& destRect) | 33 IntSize tileSize() const { return m_tileSize; } |
24 { | 34 IntPoint phase() const { return m_phase; } |
25 m_destRect = destRect; | 35 // Space-size represents extra width and height that may be added to |
26 } | 36 // the image if used as a pattern with background-repeat: space. |
| 37 IntSize spaceSize() const { return m_repeatSpacing; } |
| 38 // Has background-attachment: fixed. Implies that we can't always cheaply co
mpute destRect. |
| 39 bool hasNonLocalGeometry() const { return m_hasNonLocalGeometry; } |
27 | 40 |
28 IntPoint phase() const { return m_phase; } | 41 private: |
29 void setPhase(const IntPoint& phase) | 42 void setDestRect(const IntRect& destRect) { m_destRect = destRect; } |
30 { | 43 void setPhase(const IntPoint& phase) { m_phase = phase; } |
31 m_phase = phase; | 44 void setTileSize(const IntSize& tileSize) { m_tileSize = tileSize; } |
32 } | 45 void setSpaceSize(const IntSize& repeatSpacing) { m_repeatSpacing = repeatSp
acing; } |
33 | |
34 IntSize tileSize() const { return m_tileSize; } | |
35 void setTileSize(const IntSize& tileSize) | |
36 { | |
37 m_tileSize = tileSize; | |
38 } | |
39 | |
40 // Space-size represents extra width and height that may be added to | |
41 // the image if used as a pattern with repeat: space | |
42 IntSize spaceSize() const { return m_repeatSpacing; } | |
43 void setSpaceSize(const IntSize& repeatSpacing) | |
44 { | |
45 m_repeatSpacing = repeatSpacing; | |
46 } | |
47 | |
48 void setPhaseX(int x) { m_phase.setX(x); } | 46 void setPhaseX(int x) { m_phase.setX(x); } |
49 void setPhaseY(int y) { m_phase.setY(y); } | 47 void setPhaseY(int y) { m_phase.setY(y); } |
50 | |
51 void setNoRepeatX(int xOffset); | 48 void setNoRepeatX(int xOffset); |
52 void setNoRepeatY(int yOffset); | 49 void setNoRepeatY(int yOffset); |
53 | 50 |
54 void useFixedAttachment(const IntPoint& attachmentPoint); | 51 void useFixedAttachment(const IntPoint& attachmentPoint); |
| 52 void clip(const IntRect&); |
| 53 void setHasNonLocalGeometry() { m_hasNonLocalGeometry = true; } |
55 | 54 |
56 void clip(const IntRect&); | |
57 | |
58 void setHasNonLocalGeometry() { m_hasNonLocalGeometry = true; } | |
59 bool hasNonLocalGeometry() const { return m_hasNonLocalGeometry; } | |
60 | |
61 private: | |
62 IntRect m_destRect; | 55 IntRect m_destRect; |
63 IntPoint m_phase; | 56 IntPoint m_phase; |
64 IntSize m_tileSize; | 57 IntSize m_tileSize; |
65 IntSize m_repeatSpacing; | 58 IntSize m_repeatSpacing; |
66 bool m_hasNonLocalGeometry; // Has background-attachment: fixed. Implies tha
t we can't always cheaply compute destRect. | 59 bool m_hasNonLocalGeometry; |
67 }; | 60 }; |
68 | 61 |
69 } // namespace blink | 62 } // namespace blink |
70 | 63 |
71 #endif // BackgroundImageGeometry_h | 64 #endif // BackgroundImageGeometry_h |
OLD | NEW |