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 TransparencyDisplayItem_h | 5 #ifndef TransparencyDisplayItem_h |
6 #define TransparencyDisplayItem_h | 6 #define TransparencyDisplayItem_h |
7 | 7 |
8 #include "core/paint/ViewDisplayList.h" | 8 #include "core/paint/ViewDisplayList.h" |
9 #include "platform/geometry/LayoutRect.h" | 9 #include "platform/geometry/LayoutRect.h" |
10 #include "public/platform/WebBlendMode.h" | 10 #include "public/platform/WebBlendMode.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
| 14 enum TransparencyClipBehavior { |
| 15 ClipToRect, |
| 16 DoNotClip |
| 17 }; |
| 18 |
| 19 // FIXME: Move this file to TransparencyRecorder |
| 20 |
14 class BeginTransparencyDisplayItem : public DisplayItem { | 21 class BeginTransparencyDisplayItem : public DisplayItem { |
15 public: | 22 public: |
16 BeginTransparencyDisplayItem(const RenderObject* renderer, Type type, const
LayoutRect& clipRect, const WebBlendMode& blendMode, const float opacity) | 23 BeginTransparencyDisplayItem(const RenderObject* renderer, Type type, const
LayoutRect& clipRect, const WebBlendMode& blendMode, const float opacity, Transp
arencyClipBehavior clipBehavior) |
17 : DisplayItem(renderer, type) | 24 : DisplayItem(renderer, type) |
18 , m_clipRect(clipRect) | 25 , m_clipRect(clipRect) |
19 , m_blendMode(blendMode) | 26 , m_blendMode(blendMode) |
20 , m_opacity(opacity) { } | 27 , m_opacity(opacity) |
| 28 , m_clipBehavior(clipBehavior) { } |
21 virtual void replay(GraphicsContext*) override; | 29 virtual void replay(GraphicsContext*) override; |
22 | 30 |
23 private: | 31 private: |
24 #ifndef NDEBUG | 32 #ifndef NDEBUG |
25 virtual WTF::String asDebugString() const override; | 33 virtual WTF::String asDebugString() const override; |
26 #endif | 34 #endif |
27 | 35 |
28 bool hasBlendMode() const { return m_blendMode != WebBlendModeNormal; } | 36 bool hasBlendMode() const { return m_blendMode != WebBlendModeNormal; } |
29 | 37 |
30 const LayoutRect m_clipRect; | 38 const LayoutRect m_clipRect; |
31 const WebBlendMode m_blendMode; | 39 const WebBlendMode m_blendMode; |
32 const float m_opacity; | 40 const float m_opacity; |
| 41 const TransparencyClipBehavior m_clipBehavior; |
33 }; | 42 }; |
34 | 43 |
35 class EndTransparencyDisplayItem : public DisplayItem { | 44 class EndTransparencyDisplayItem : public DisplayItem { |
36 public: | 45 public: |
37 EndTransparencyDisplayItem(const RenderObject* renderer, Type type) | 46 EndTransparencyDisplayItem(const RenderObject* renderer, Type type, Transpar
encyClipBehavior clipBehavior) |
38 : DisplayItem(renderer, type) { } | 47 : DisplayItem(renderer, type), m_clipBehavior(clipBehavior) { } |
39 virtual void replay(GraphicsContext*) override; | 48 virtual void replay(GraphicsContext*) override; |
40 | 49 |
41 private: | 50 private: |
42 #ifndef NDEBUG | 51 #ifndef NDEBUG |
43 virtual WTF::String asDebugString() const override; | 52 virtual WTF::String asDebugString() const override; |
44 #endif | 53 #endif |
| 54 const TransparencyClipBehavior m_clipBehavior; |
| 55 }; |
| 56 |
| 57 class TransparencyRecorder { |
| 58 public: |
| 59 explicit TransparencyRecorder(GraphicsContext*, const RenderObject*, Display
Item::Type, const LayoutRect& clipRect, const WebBlendMode&, const float opacity
, TransparencyClipBehavior = ClipToRect); |
| 60 |
| 61 ~TransparencyRecorder(); |
| 62 |
| 63 private: |
| 64 const RenderObject* m_renderer; |
| 65 const DisplayItem::Type m_type; |
| 66 GraphicsContext* m_graphicsContext; |
| 67 const TransparencyClipBehavior m_clipBehavior; |
45 }; | 68 }; |
46 | 69 |
47 } // namespace blink | 70 } // namespace blink |
48 | 71 |
49 #endif // TransparencyDisplayItem_h | 72 #endif // TransparencyDisplayItem_h |
OLD | NEW |