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

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

Issue 171343003: Use compositor for page popups. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « Source/web/WebPagePopupImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 { 131 {
132 if (m_popup->m_webView->client()) 132 if (m_popup->m_webView->client())
133 m_popup->m_webView->client()->didChangeCursor(WebCursorInfo(cursor)) ; 133 m_popup->m_webView->client()->didChangeCursor(WebCursorInfo(cursor)) ;
134 } 134 }
135 135
136 virtual void needTouchEvents(bool needsTouchEvents) OVERRIDE 136 virtual void needTouchEvents(bool needsTouchEvents) OVERRIDE
137 { 137 {
138 m_popup->widgetClient()->hasTouchEventHandlers(needsTouchEvents); 138 m_popup->widgetClient()->hasTouchEventHandlers(needsTouchEvents);
139 } 139 }
140 140
141 virtual GraphicsLayerFactory* graphicsLayerFactory() const OVERRIDE
142 {
143 return m_popup->m_webView->graphicsLayerFactory();
144 }
145
146 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer* graphicsLayer) O VERRIDE
147 {
148 m_popup->setRootGraphicsLayer(graphicsLayer);
149 }
150
141 WebPagePopupImpl* m_popup; 151 WebPagePopupImpl* m_popup;
142 }; 152 };
143 153
144 class PagePopupFeaturesClient : public ContextFeaturesClient { 154 class PagePopupFeaturesClient : public ContextFeaturesClient {
145 virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool) OVERRI DE; 155 virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool) OVERRI DE;
146 }; 156 };
147 157
148 bool PagePopupFeaturesClient::isEnabled(Document*, ContextFeatures::FeatureType type, bool defaultValue) 158 bool PagePopupFeaturesClient::isEnabled(Document*, ContextFeatures::FeatureType type, bool defaultValue)
149 { 159 {
150 if (type == ContextFeatures::PagePopup) 160 if (type == ContextFeatures::PagePopup)
151 return true; 161 return true;
152 return defaultValue; 162 return defaultValue;
153 } 163 }
154 164
155 // WebPagePopupImpl ------------------------------------------------------------ ---- 165 // WebPagePopupImpl ------------------------------------------------------------ ----
156 166
157 WebPagePopupImpl::WebPagePopupImpl(WebWidgetClient* client) 167 WebPagePopupImpl::WebPagePopupImpl(WebWidgetClient* client)
158 : m_widgetClient(client) 168 : m_widgetClient(client)
159 , m_closing(false) 169 , m_closing(false)
170 , m_layerTreeView(0)
171 , m_rootLayer(0)
172 , m_rootGraphicsLayer(0)
173 , m_isAcceleratedCompositingActive(false)
160 { 174 {
161 ASSERT(client); 175 ASSERT(client);
162 } 176 }
163 177
164 WebPagePopupImpl::~WebPagePopupImpl() 178 WebPagePopupImpl::~WebPagePopupImpl()
165 { 179 {
166 ASSERT(!m_page); 180 ASSERT(!m_page);
167 } 181 }
168 182
169 bool WebPagePopupImpl::initialize(WebViewImpl* webView, PagePopupClient* popupCl ient, const IntRect&) 183 bool WebPagePopupImpl::initialize(WebViewImpl* webView, PagePopupClient* popupCl ient, const IntRect&)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 { 231 {
218 if (!m_page) 232 if (!m_page)
219 return; 233 return;
220 234
221 if (m_page->mainFrame()) 235 if (m_page->mainFrame())
222 m_page->mainFrame()->loader().frameDetached(); 236 m_page->mainFrame()->loader().frameDetached();
223 237
224 m_page.clear(); 238 m_page.clear();
225 } 239 }
226 240
241 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer)
242 {
243 m_rootGraphicsLayer = layer;
244 m_rootLayer = layer ? layer->platformLayer() : 0;
245
246 setIsAcceleratedCompositingActive(layer);
247 if (m_layerTreeView) {
248 if (m_rootLayer) {
249 m_layerTreeView->setRootLayer(*m_rootLayer);
250 } else {
251 m_layerTreeView->clearRootLayer();
252 }
253 }
254 }
255
256 void WebPagePopupImpl::setIsAcceleratedCompositingActive(bool enter)
257 {
258 if (m_isAcceleratedCompositingActive == enter)
259 return;
260
261 if (!enter) {
262 m_isAcceleratedCompositingActive = false;
263 m_widgetClient->didDeactivateCompositor();
264 } else if (m_layerTreeView) {
265 m_isAcceleratedCompositingActive = true;
266 m_widgetClient->didActivateCompositor(0);
267 } else {
268 TRACE_EVENT0("webkit", "WebPagePopupImpl::setIsAcceleratedCompositingAct ive(true)");
269
270 m_widgetClient->initializeLayerTreeView();
271 m_layerTreeView = m_widgetClient->layerTreeView();
272 if (m_layerTreeView) {
273 m_layerTreeView->setVisible(true);
274 m_widgetClient->didActivateCompositor(0);
275 m_isAcceleratedCompositingActive = true;
276 m_layerTreeView->setDeviceScaleFactor(m_widgetClient->deviceScaleFac tor());
jamesr 2014/02/20 22:00:33 apparently we don't have a way to update the devic
277 } else {
278 m_isAcceleratedCompositingActive = false;
279 m_widgetClient->didDeactivateCompositor();
280 }
281 }
282 }
283
227 WebSize WebPagePopupImpl::size() 284 WebSize WebPagePopupImpl::size()
228 { 285 {
229 return m_popupClient->contentSize(); 286 return m_popupClient->contentSize();
230 } 287 }
231 288
232 void WebPagePopupImpl::animate(double) 289 void WebPagePopupImpl::animate(double)
233 { 290 {
234 PageWidgetDelegate::animate(m_page.get(), monotonicallyIncreasingTime()); 291 PageWidgetDelegate::animate(m_page.get(), monotonicallyIncreasingTime());
235 } 292 }
236 293
294 void WebPagePopupImpl::enterForceCompositingMode(bool enter)
295 {
296 if (m_page->settings().forceCompositingMode() == enter)
297 return;
298
299 TRACE_EVENT1("webkit", "WebPagePopupImpl::enterForceCompositingMode", "enter ", enter);
300 m_page->settings().setForceCompositingMode(enter);
301 if (enter) {
302 if (!m_page)
303 return;
304 Frame* mainFrame = m_page->mainFrame();
305 if (!mainFrame)
306 return;
307 mainFrame->view()->updateCompositingLayersAfterStyleChange();
308 }
309 }
310
311 void WebPagePopupImpl::didExitCompositingMode()
312 {
313 setIsAcceleratedCompositingActive(false);
314 m_widgetClient->didInvalidateRect(IntRect(0, 0, size().width, size().height) );
315 m_page->mainFrame()->document()->setNeedsStyleRecalc(SubtreeStyleChange);
316 }
317
318 void WebPagePopupImpl::willCloseLayerTreeView()
319 {
320 setIsAcceleratedCompositingActive(false);
321 m_layerTreeView = 0;
322 }
323
237 void WebPagePopupImpl::layout() 324 void WebPagePopupImpl::layout()
238 { 325 {
239 PageWidgetDelegate::layout(m_page.get()); 326 PageWidgetDelegate::layout(m_page.get());
240 } 327 }
241 328
242 void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOption s) 329 void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOption s)
243 { 330 {
244 if (!m_closing) 331 if (!m_closing)
245 PageWidgetDelegate::paint(m_page.get(), 0, canvas, rect, PageWidgetDeleg ate::Opaque); 332 PageWidgetDelegate::paint(m_page.get(), 0, canvas, rect, PageWidgetDeleg ate::Opaque);
246 } 333 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // A WebPagePopupImpl instance usually has two references. 424 // A WebPagePopupImpl instance usually has two references.
338 // - One owned by the instance itself. It represents the visible widget. 425 // - One owned by the instance itself. It represents the visible widget.
339 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the 426 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the
340 // WebPagePopupImpl to close. 427 // WebPagePopupImpl to close.
341 // We need them because the closing operation is asynchronous and the widget 428 // We need them because the closing operation is asynchronous and the widget
342 // can be closed while the WebViewImpl is unaware of it. 429 // can be closed while the WebViewImpl is unaware of it.
343 return adoptRef(new WebPagePopupImpl(client)).leakRef(); 430 return adoptRef(new WebPagePopupImpl(client)).leakRef();
344 } 431 }
345 432
346 } // namespace blink 433 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebPagePopupImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698