OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * | 10 * |
(...skipping 11 matching lines...) Expand all Loading... |
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #ifndef PageOverlay_h | 29 #ifndef PageOverlay_h |
30 #define PageOverlay_h | 30 #define PageOverlay_h |
31 | 31 |
| 32 #include "platform/graphics/GraphicsLayer.h" |
| 33 #include "platform/graphics/GraphicsLayerClient.h" |
32 #include "wtf/OwnPtr.h" | 34 #include "wtf/OwnPtr.h" |
33 #include "wtf/PassOwnPtr.h" | 35 #include "wtf/PassOwnPtr.h" |
| 36 #include "wtf/text/WTFString.h" |
34 | 37 |
35 namespace blink { | 38 namespace blink { |
36 | 39 |
37 class GraphicsContext; | 40 class GraphicsContext; |
38 class GraphicsLayer; | 41 class GraphicsLayer; |
39 class GraphicsLayerClient; | 42 class GraphicsLayerClient; |
40 class WebPageOverlay; | 43 class WebPageOverlay; |
41 class WebViewImpl; | 44 class WebViewImpl; |
42 | 45 |
43 class PageOverlay { | 46 // Manages a layer than is overlaid on a WebView's content. |
| 47 // |
| 48 // Clients can paint by providing either exactly one of the following: |
| 49 // - WebPageOverlay (which paints using a WebCanvas) |
| 50 // - PageOverlay::Painter (which paints using a GraphicsContext) |
| 51 // |
| 52 // In particular, if a client expects to paint web content (which, when |
| 53 // Slimming Paint is enabled, uses a DisplayItemList attached to |
| 54 // GraphicsContext), it should provide the latter. |
| 55 class PageOverlay : public GraphicsLayerClient { |
44 public: | 56 public: |
| 57 class Painter { |
| 58 public: |
| 59 // The callee is responsible for saving the GraphicsContext, |
| 60 // if it is required. |
| 61 virtual void paintPageOverlay(GraphicsContext&) = 0; |
| 62 }; |
| 63 |
45 static PassOwnPtr<PageOverlay> create(WebViewImpl*, WebPageOverlay*); | 64 static PassOwnPtr<PageOverlay> create(WebViewImpl*, WebPageOverlay*); |
| 65 static PassOwnPtr<PageOverlay> create(WebViewImpl*, Painter*); |
46 | 66 |
47 ~PageOverlay() { } | 67 ~PageOverlay() { } |
48 | 68 |
| 69 // Exactly one of these should be non-null. |
49 WebPageOverlay* overlay() const { return m_overlay; } | 70 WebPageOverlay* overlay() const { return m_overlay; } |
50 void setOverlay(WebPageOverlay* overlay) { m_overlay = overlay; } | 71 Painter* overlayPainter() const { return m_overlayPainter; } |
51 | 72 |
52 int zOrder() const { return m_zOrder; } | 73 int zOrder() const { return m_zOrder; } |
53 void setZOrder(int zOrder) { m_zOrder = zOrder; } | 74 void setZOrder(int zOrder) { m_zOrder = zOrder; } |
54 | 75 |
55 void clear(); | 76 void clear(); |
56 void update(); | 77 void update(); |
57 void paintWebFrame(GraphicsContext&); | 78 void paintWebFrame(GraphicsContext&); |
58 | 79 |
59 GraphicsLayer* graphicsLayer() const { return m_layer.get(); } | 80 GraphicsLayer* graphicsLayer() const { return m_layer.get(); } |
60 | 81 |
| 82 // GraphicsLayerClient implementation |
| 83 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPain
tingPhase, const IntRect& inClip) override; |
| 84 String debugName(const GraphicsLayer*) override; |
| 85 |
61 private: | 86 private: |
62 PageOverlay(WebViewImpl*, WebPageOverlay*); | 87 PageOverlay(WebViewImpl*, WebPageOverlay*); |
| 88 PageOverlay(WebViewImpl*, Painter*); |
| 89 |
63 void invalidateWebFrame(); | 90 void invalidateWebFrame(); |
64 | 91 |
65 WebViewImpl* m_viewImpl; | 92 WebViewImpl* m_viewImpl; |
66 WebPageOverlay* m_overlay; | 93 WebPageOverlay* m_overlay; |
67 OwnPtr<GraphicsLayerClient> m_layerClient; | 94 Painter* m_overlayPainter; |
68 OwnPtr<GraphicsLayer> m_layer; | 95 OwnPtr<GraphicsLayer> m_layer; |
69 int m_zOrder; | 96 int m_zOrder; |
70 }; | 97 }; |
71 | 98 |
72 } // namespace blink | 99 } // namespace blink |
73 | 100 |
74 #endif // PageOverlay_h | 101 #endif // PageOverlay_h |
OLD | NEW |