Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: Source/web/PageOverlay.cpp

Issue 867063004: [Slimming Paint] Paint the inspector overlay with GraphicsLayer DisplayList. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 19 matching lines...) Expand all
30 #include "web/PageOverlay.h" 30 #include "web/PageOverlay.h"
31 31
32 #include "core/frame/Settings.h" 32 #include "core/frame/Settings.h"
33 #include "core/page/Page.h" 33 #include "core/page/Page.h"
34 #include "platform/graphics/GraphicsContext.h" 34 #include "platform/graphics/GraphicsContext.h"
35 #include "platform/graphics/GraphicsLayer.h" 35 #include "platform/graphics/GraphicsLayer.h"
36 #include "platform/graphics/GraphicsLayerClient.h" 36 #include "platform/graphics/GraphicsLayerClient.h"
37 #include "public/platform/WebLayer.h" 37 #include "public/platform/WebLayer.h"
38 #include "public/web/WebPageOverlay.h" 38 #include "public/web/WebPageOverlay.h"
39 #include "public/web/WebViewClient.h" 39 #include "public/web/WebViewClient.h"
40 #include "web/WebGraphicsContextImpl.h"
40 #include "web/WebViewImpl.h" 41 #include "web/WebViewImpl.h"
41 42
42 namespace blink { 43 namespace blink {
43 44
44 namespace {
45
46 WebCanvas* ToWebCanvas(GraphicsContext* gc)
47 {
48 return gc->canvas();
49 }
50
51 } // namespace
52
53 PassOwnPtr<PageOverlay> PageOverlay::create(WebViewImpl* viewImpl, WebPageOverla y* overlay) 45 PassOwnPtr<PageOverlay> PageOverlay::create(WebViewImpl* viewImpl, WebPageOverla y* overlay)
54 { 46 {
55 return adoptPtr(new PageOverlay(viewImpl, overlay)); 47 return adoptPtr(new PageOverlay(viewImpl, overlay));
56 } 48 }
57 49
58 PageOverlay::PageOverlay(WebViewImpl* viewImpl, WebPageOverlay* overlay) 50 PageOverlay::PageOverlay(WebViewImpl* viewImpl, WebPageOverlay* overlay)
59 : m_viewImpl(viewImpl) 51 : m_viewImpl(viewImpl)
60 , m_overlay(overlay) 52 , m_overlay(overlay)
61 , m_zOrder(0) 53 , m_zOrder(0)
62 { 54 {
63 } 55 }
64 56
65 class OverlayGraphicsLayerClientImpl : public GraphicsLayerClient {
66 public:
67 static PassOwnPtr<OverlayGraphicsLayerClientImpl> create(WebPageOverlay* ove rlay)
68 {
69 return adoptPtr(new OverlayGraphicsLayerClientImpl(overlay));
70 }
71
72 virtual ~OverlayGraphicsLayerClientImpl() { }
73
74 virtual void paintContents(const GraphicsLayer*, GraphicsContext& gc, Graphi csLayerPaintingPhase, const IntRect& inClip)
75 {
76 gc.save();
77 m_overlay->paintPageOverlay(ToWebCanvas(&gc));
78 gc.restore();
79 }
80
81 virtual String debugName(const GraphicsLayer* graphicsLayer) override
82 {
83 return String("WebViewImpl Page Overlay Content Layer");
84 }
85
86 private:
87 explicit OverlayGraphicsLayerClientImpl(WebPageOverlay* overlay)
88 : m_overlay(overlay)
89 {
90 }
91
92 WebPageOverlay* m_overlay;
93 };
94
95 void PageOverlay::clear() 57 void PageOverlay::clear()
96 { 58 {
97 invalidateWebFrame(); 59 invalidateWebFrame();
98 60
99 if (m_layer) { 61 if (m_layer) {
100 m_layer->removeFromParent(); 62 m_layer->removeFromParent();
101 if (Page* page = m_viewImpl->page()) 63 if (Page* page = m_viewImpl->page())
102 page->inspectorController().didRemovePageOverlay(m_layer.get()); 64 page->inspectorController().didRemovePageOverlay(m_layer.get());
103 m_layer = nullptr; 65 m_layer = nullptr;
104 m_layerClient = nullptr;
105 } 66 }
106 } 67 }
107 68
108 void PageOverlay::update() 69 void PageOverlay::update()
109 { 70 {
110 invalidateWebFrame(); 71 invalidateWebFrame();
111 72
112 if (!m_layer) { 73 if (!m_layer) {
113 m_layerClient = OverlayGraphicsLayerClientImpl::create(m_overlay); 74 m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), this );
114 m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), m_la yerClient.get());
115 m_layer->setDrawsContent(true); 75 m_layer->setDrawsContent(true);
116 76
117 if (Page* page = m_viewImpl->page()) 77 if (Page* page = m_viewImpl->page())
118 page->inspectorController().willAddPageOverlay(m_layer.get()); 78 page->inspectorController().willAddPageOverlay(m_layer.get());
119 79
120 // This is required for contents of overlay to stay in sync with the pag e while scrolling. 80 // This is required for contents of overlay to stay in sync with the pag e while scrolling.
121 WebLayer* platformLayer = m_layer->platformLayer(); 81 WebLayer* platformLayer = m_layer->platformLayer();
122 platformLayer->setShouldScrollOnMainThread(true); 82 platformLayer->setShouldScrollOnMainThread(true);
123 } 83 }
124 84
125 FloatSize size(m_viewImpl->size()); 85 FloatSize size(m_viewImpl->size());
126 if (size != m_layer->size()) { 86 if (size != m_layer->size()) {
127 // Triggers re-adding to root layer to ensure that we are on top of 87 // Triggers re-adding to root layer to ensure that we are on top of
128 // scrollbars. 88 // scrollbars.
129 m_layer->removeFromParent(); 89 m_layer->removeFromParent();
130 m_layer->setSize(size); 90 m_layer->setSize(size);
131 } 91 }
132 92
133 m_viewImpl->setOverlayLayer(m_layer.get()); 93 m_viewImpl->setOverlayLayer(m_layer.get());
134 m_layer->setNeedsDisplay(); 94 m_layer->setNeedsDisplay();
135 } 95 }
136 96
137 void PageOverlay::paintWebFrame(GraphicsContext& gc) 97 void PageOverlay::paintWebFrame(GraphicsContext& gc)
138 { 98 {
139 if (!m_viewImpl->isAcceleratedCompositingActive()) { 99 WebGraphicsContextImpl contextWrapper(gc, displayItemClient(), DisplayItem:: PageOverlay);
140 gc.save(); 100 m_overlay->paintPageOverlay(&contextWrapper, m_viewImpl->size());
141 m_overlay->paintPageOverlay(ToWebCanvas(&gc)); 101 }
142 gc.restore(); 102
143 } 103 void PageOverlay::paintContents(const GraphicsLayer*, GraphicsContext& gc, Graph icsLayerPaintingPhase, const IntRect& inClip)
104 {
105 paintWebFrame(gc);
106 }
107
108 String PageOverlay::debugName(const GraphicsLayer*)
109 {
110 return "WebViewImpl Page Overlay Content Layer";
144 } 111 }
145 112
146 void PageOverlay::invalidateWebFrame() 113 void PageOverlay::invalidateWebFrame()
147 { 114 {
148 // WebPageOverlay does the actual painting of the overlay. 115 // WebPageOverlay does the actual painting of the overlay.
149 // Here we just make sure to invalidate. 116 // Here we just make sure to invalidate.
150 if (!m_viewImpl->isAcceleratedCompositingActive()) { 117 if (!m_viewImpl->isAcceleratedCompositingActive()) {
151 // FIXME: able to invalidate a smaller rect. 118 // FIXME: able to invalidate a smaller rect.
152 // FIXME: Is it important to just invalidate a smaller rect given that 119 // FIXME: Is it important to just invalidate a smaller rect given that
153 // this is not on a critical codepath? In order to do so, we'd 120 // this is not on a critical codepath? In order to do so, we'd
154 // have to take scrolling into account. 121 // have to take scrolling into account.
155 const WebSize& size = m_viewImpl->size(); 122 const WebSize& size = m_viewImpl->size();
156 WebRect damagedRect(0, 0, size.width, size.height); 123 WebRect damagedRect(0, 0, size.width, size.height);
157 if (m_viewImpl->client()) 124 if (m_viewImpl->client())
158 m_viewImpl->client()->didInvalidateRect(damagedRect); 125 m_viewImpl->client()->didInvalidateRect(damagedRect);
159 } 126 }
160 } 127 }
161 128
162 } // namespace blink 129 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698