Changeset 202855 in webkit
- Timestamp:
- Jul 6, 2016 4:32:07 AM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r202852 r202855 1 2016-07-06 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Duplicated code in DrawingAreaImpl and CoordinatedDrawingArea 4 https://bugs.webkit.org/show_bug.cgi?id=159259 5 6 Reviewed by Žan Doberšek. 7 8 It seems that CoordinatedDrawingArea is just a copy paste of DrawingAreaImpl with non-accelerated code path 9 removed. There's actually nothing (or very little) specific to coordinated graphics in the 10 CoordinatedDrawingArea implementation. This patch renames CoordinatedDrawingArea as AcceleratedDrawingArea and 11 makes DrawingAreaImpl inherit from it, so that in case of accelerated compositing the parent class is used, and 12 DrawingAreaImpl only adds the non accelerated code path. 13 14 * PlatformEfl.cmake: 15 * PlatformGTK.cmake: 16 * WebProcess/WebPage/AcceleratedDrawingArea.cpp: Renamed from Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp. 17 (WebKit::AcceleratedDrawingArea::~AcceleratedDrawingArea): 18 (WebKit::AcceleratedDrawingArea::AcceleratedDrawingArea): 19 (WebKit::AcceleratedDrawingArea::setNeedsDisplay): 20 (WebKit::AcceleratedDrawingArea::setNeedsDisplayInRect): 21 (WebKit::AcceleratedDrawingArea::scroll): 22 (WebKit::AcceleratedDrawingArea::pageBackgroundTransparencyChanged): 23 (WebKit::AcceleratedDrawingArea::setLayerTreeStateIsFrozen): 24 (WebKit::AcceleratedDrawingArea::forceRepaint): 25 (WebKit::AcceleratedDrawingArea::forceRepaintAsync): 26 (WebKit::AcceleratedDrawingArea::setPaintingEnabled): 27 (WebKit::AcceleratedDrawingArea::updatePreferences): 28 (WebKit::AcceleratedDrawingArea::mainFrameContentSizeChanged): 29 (WebKit::AcceleratedDrawingArea::layerHostDidFlushLayers): 30 (WebKit::AcceleratedDrawingArea::graphicsLayerFactory): 31 (WebKit::AcceleratedDrawingArea::setRootCompositingLayer): 32 (WebKit::AcceleratedDrawingArea::scheduleCompositingLayerFlush): 33 (WebKit::AcceleratedDrawingArea::scheduleCompositingLayerFlushImmediately): 34 (WebKit::AcceleratedDrawingArea::updateBackingStoreState): 35 (WebKit::AcceleratedDrawingArea::sendDidUpdateBackingStoreState): 36 (WebKit::AcceleratedDrawingArea::suspendPainting): 37 (WebKit::AcceleratedDrawingArea::resumePainting): 38 (WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode): 39 (WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingModeSoon): 40 (WebKit::AcceleratedDrawingArea::didReceiveCoordinatedLayerTreeHostMessage): 41 (WebKit::AcceleratedDrawingArea::viewStateDidChange): 42 (WebKit::AcceleratedDrawingArea::attachViewOverlayGraphicsLayer): 43 * WebProcess/WebPage/AcceleratedDrawingArea.h: Renamed from Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.h. 44 (WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingModePending): 45 (WebKit::AcceleratedDrawingArea::didUpdateBackingStoreState): 46 (WebKit::AcceleratedDrawingArea::exitAcceleratedCompositingMode): 47 * WebProcess/WebPage/DrawingArea.cpp: 48 (WebKit::DrawingArea::create): 49 * WebProcess/WebPage/DrawingAreaImpl.cpp: 50 (WebKit::DrawingAreaImpl::DrawingAreaImpl): 51 (WebKit::DrawingAreaImpl::setNeedsDisplay): 52 (WebKit::DrawingAreaImpl::setNeedsDisplayInRect): 53 (WebKit::DrawingAreaImpl::scroll): 54 (WebKit::DrawingAreaImpl::forceRepaint): 55 (WebKit::DrawingAreaImpl::setRootCompositingLayer): 56 (WebKit::DrawingAreaImpl::updateBackingStoreState): 57 (WebKit::DrawingAreaImpl::didUpdateBackingStoreState): 58 (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState): 59 (WebKit::DrawingAreaImpl::suspendPainting): 60 (WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode): 61 (WebKit::DrawingAreaImpl::~DrawingAreaImpl): Deleted. 62 (WebKit::DrawingAreaImpl::mainFrameContentSizeChanged): Deleted. 63 (WebKit::DrawingAreaImpl::updatePreferences): Deleted. 64 (WebKit::DrawingAreaImpl::didUpdate): Deleted. 65 (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): Deleted. 66 (WebKit::DrawingAreaImpl::scheduleDisplay): Deleted. 67 (WebKit::DrawingAreaImpl::displayTimerFired): Deleted. 68 (WebKit::DrawingAreaImpl::display): Deleted. 69 (WebKit::shouldPaintBoundsRect): Deleted. 70 (WebKit::DrawingAreaImpl::setNativeSurfaceHandleForCompositing): Deleted. 71 * WebProcess/WebPage/DrawingAreaImpl.h: 72 1 73 2016-07-06 Youenn Fablet <youenn@apple.com> 2 74 -
trunk/Source/WebKit2/PlatformEfl.cmake
r202675 r202855 197 197 WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp 198 198 199 WebProcess/WebPage/AcceleratedDrawingArea.cpp 199 200 WebProcess/WebPage/DrawingAreaImpl.cpp 200 201 201 202 WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp 202 203 WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp 203 WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp204 204 WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 205 205 WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp -
trunk/Source/WebKit2/PlatformGTK.cmake
r202675 r202855 340 340 WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp 341 341 342 WebProcess/WebPage/AcceleratedDrawingArea.cpp 342 343 WebProcess/WebPage/DrawingAreaImpl.cpp 343 344 -
trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp
r202854 r202855 26 26 27 27 #include "config.h" 28 29 #if USE(COORDINATED_GRAPHICS) 30 #include "CoordinatedDrawingArea.h" 31 32 #include "CoordinatedLayerTreeHost.h" 28 #include "AcceleratedDrawingArea.h" 29 33 30 #include "DrawingAreaProxyMessages.h" 34 #include "LayerTreeContext.h" 35 #include "PageOverlayController.h" 36 #include "ShareableBitmap.h" 31 #include "LayerTreeHost.h" 37 32 #include "UpdateInfo.h" 38 33 #include "WebPage.h" 39 34 #include "WebPageCreationParameters.h" 40 35 #include "WebPreferencesKeys.h" 41 #include "WebProcess.h"42 #include <WebCore/GraphicsContext.h>43 36 #include <WebCore/MainFrame.h> 44 37 #include <WebCore/Page.h> … … 50 43 namespace WebKit { 51 44 52 CoordinatedDrawingArea::~CoordinatedDrawingArea() 53 { 54 m_layerTreeHost->invalidate(); 55 } 56 57 CoordinatedDrawingArea::CoordinatedDrawingArea(WebPage& webPage, const WebPageCreationParameters& parameters) 45 AcceleratedDrawingArea::~AcceleratedDrawingArea() 46 { 47 if (m_layerTreeHost) 48 m_layerTreeHost->invalidate(); 49 } 50 51 AcceleratedDrawingArea::AcceleratedDrawingArea(WebPage& webPage, const WebPageCreationParameters& parameters) 52 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) 58 53 : DrawingArea(DrawingAreaTypeCoordinated, webPage) 59 , m_backingStoreStateID(0) 60 , m_isPaintingEnabled(true) 61 , m_inUpdateBackingStoreState(false) 62 , m_shouldSendDidUpdateBackingStoreState(false) 63 , m_compositingAccordingToProxyMessages(false) 64 , m_layerTreeStateIsFrozen(false) 65 , m_wantsToExitAcceleratedCompositingMode(false) 66 , m_isPaintingSuspended(false) 67 , m_exitCompositingTimer(RunLoop::main(), this, &CoordinatedDrawingArea::exitAcceleratedCompositingMode) 68 { 69 // Always use compositing in CoordinatedGraphics 70 enterAcceleratedCompositingMode(0); 71 72 if (!(parameters.viewState & ViewState::IsVisible)) 54 #else 55 : DrawingArea(DrawingAreaTypeImpl, webPage) 56 #endif 57 , m_exitCompositingTimer(RunLoop::main(), this, &AcceleratedDrawingArea::exitAcceleratedCompositingMode) 58 { 59 if (!m_webPage.isVisible()) 73 60 suspendPainting(); 74 61 } 75 62 76 void CoordinatedDrawingArea::setNeedsDisplay()63 void AcceleratedDrawingArea::setNeedsDisplay() 77 64 { 78 65 if (!m_isPaintingEnabled) 79 66 return; 80 67 81 m_layerTreeHost->setNonCompositedContentsNeedDisplay(); 82 } 83 84 void CoordinatedDrawingArea::setNeedsDisplayInRect(const IntRect& rect) 68 if (m_layerTreeHost) 69 m_layerTreeHost->setNonCompositedContentsNeedDisplay(); 70 } 71 72 void AcceleratedDrawingArea::setNeedsDisplayInRect(const IntRect& rect) 85 73 { 86 74 if (!m_isPaintingEnabled) 87 75 return; 88 76 89 m_layerTreeHost->setNonCompositedContentsNeedDisplayInRect(rect); 90 } 91 92 void CoordinatedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) 77 if (m_layerTreeHost) 78 m_layerTreeHost->setNonCompositedContentsNeedDisplayInRect(rect); 79 } 80 81 void AcceleratedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) 93 82 { 94 83 if (!m_isPaintingEnabled) 95 84 return; 96 85 97 m_layerTreeHost->scrollNonCompositedContents(scrollRect); 98 } 99 100 void CoordinatedDrawingArea::pageBackgroundTransparencyChanged() 101 { 102 m_layerTreeHost->pageBackgroundTransparencyChanged(); 103 } 104 105 void CoordinatedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen) 86 if (m_layerTreeHost) 87 m_layerTreeHost->scrollNonCompositedContents(scrollRect); 88 } 89 90 void AcceleratedDrawingArea::pageBackgroundTransparencyChanged() 91 { 92 if (m_layerTreeHost) 93 m_layerTreeHost->pageBackgroundTransparencyChanged(); 94 } 95 96 void AcceleratedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen) 106 97 { 107 98 if (m_layerTreeStateIsFrozen == isFrozen) … … 110 101 m_layerTreeStateIsFrozen = isFrozen; 111 102 112 m_layerTreeHost->setLayerFlushSchedulingEnabled(!isFrozen); 103 if (m_layerTreeHost) 104 m_layerTreeHost->setLayerFlushSchedulingEnabled(!isFrozen); 113 105 114 106 if (isFrozen) … … 118 110 } 119 111 120 void CoordinatedDrawingArea::forceRepaint()112 void AcceleratedDrawingArea::forceRepaint() 121 113 { 122 114 setNeedsDisplay(); 123 115 124 116 m_webPage.layoutIfNeeded(); 117 118 if (!m_layerTreeHost) 119 return; 125 120 126 121 // FIXME: We need to do the same work as the layerHostDidFlushLayers function here, … … 137 132 } 138 133 139 bool CoordinatedDrawingArea::forceRepaintAsync(uint64_t callbackID)140 { 141 return m_layerTreeHost ->forceRepaintAsync(callbackID);142 } 143 144 void CoordinatedDrawingArea::setPaintingEnabled(bool paintingEnabled)134 bool AcceleratedDrawingArea::forceRepaintAsync(uint64_t callbackID) 135 { 136 return m_layerTreeHost && m_layerTreeHost->forceRepaintAsync(callbackID); 137 } 138 139 void AcceleratedDrawingArea::setPaintingEnabled(bool paintingEnabled) 145 140 { 146 141 m_isPaintingEnabled = paintingEnabled; 147 142 } 148 143 149 void CoordinatedDrawingArea::updatePreferences(const WebPreferencesStore& store)144 void AcceleratedDrawingArea::updatePreferences(const WebPreferencesStore& store) 150 145 { 151 146 m_webPage.corePage()->settings().setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey())); 152 } 153 154 void CoordinatedDrawingArea::mainFrameContentSizeChanged(const WebCore::IntSize& size) 155 { 156 if (m_webPage.useFixedLayout()) 147 if (!m_layerTreeHost) 148 enterAcceleratedCompositingMode(nullptr); 149 } 150 151 void AcceleratedDrawingArea::mainFrameContentSizeChanged(const IntSize& size) 152 { 153 if (m_webPage.useFixedLayout() && m_layerTreeHost) 157 154 m_layerTreeHost->sizeDidChange(size); 158 155 m_webPage.mainFrame()->pageOverlayController().didChangeDocumentSize(); 159 156 } 160 157 161 void CoordinatedDrawingArea::layerHostDidFlushLayers() 162 { 158 void AcceleratedDrawingArea::layerHostDidFlushLayers() 159 { 160 ASSERT(m_layerTreeHost); 163 161 m_layerTreeHost->forceRepaint(); 164 162 … … 175 173 } 176 174 177 GraphicsLayerFactory* CoordinatedDrawingArea::graphicsLayerFactory() 178 { 179 return m_layerTreeHost->graphicsLayerFactory(); 180 } 181 182 void CoordinatedDrawingArea::setRootCompositingLayer(GraphicsLayer* graphicsLayer) 183 { 175 GraphicsLayerFactory* AcceleratedDrawingArea::graphicsLayerFactory() 176 { 177 return m_layerTreeHost ? m_layerTreeHost->graphicsLayerFactory() : nullptr; 178 } 179 180 void AcceleratedDrawingArea::setRootCompositingLayer(GraphicsLayer* graphicsLayer) 181 { 182 ASSERT(m_layerTreeHost); 183 184 184 // FIXME: Instead of using nested if statements, we should keep a compositing state 185 // enum in the CoordinatedDrawingArea object and have a changeAcceleratedCompositingState function185 // enum in the AcceleratedDrawingArea object and have a changeAcceleratedCompositingState function 186 186 // that takes the new state. 187 187 … … 200 200 } 201 201 202 void CoordinatedDrawingArea::scheduleCompositingLayerFlush() 203 { 204 m_layerTreeHost->scheduleLayerFlush(); 205 } 206 207 void CoordinatedDrawingArea::scheduleCompositingLayerFlushImmediately() 202 void AcceleratedDrawingArea::scheduleCompositingLayerFlush() 203 { 204 if (m_layerTreeHost) 205 m_layerTreeHost->scheduleLayerFlush(); 206 } 207 208 void AcceleratedDrawingArea::scheduleCompositingLayerFlushImmediately() 208 209 { 209 210 scheduleCompositingLayerFlush(); 210 211 } 211 212 212 void CoordinatedDrawingArea::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize& size, const WebCore::IntSize& scrollOffset)213 void AcceleratedDrawingArea::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const IntSize& size, const IntSize& scrollOffset) 213 214 { 214 215 ASSERT(!m_inUpdateBackingStoreState); … … 225 226 m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset); 226 227 228 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) 227 229 // Coordinated Graphics sets the size of the root layer to contents size. 228 230 if (!m_webPage.useFixedLayout()) 229 231 m_layerTreeHost->sizeDidChange(m_webPage.size()); 232 #else 233 if (m_layerTreeHost) 234 m_layerTreeHost->sizeDidChange(m_webPage.size()); 235 #endif 230 236 } else { 231 237 ASSERT(size == m_webPage.size()); … … 237 243 } 238 244 245 didUpdateBackingStoreState(); 246 239 247 if (respondImmediately) { 240 248 // Make sure to resume painting if we're supposed to respond immediately, otherwise we'll just … … 249 257 } 250 258 251 void CoordinatedDrawingArea::sendDidUpdateBackingStoreState()259 void AcceleratedDrawingArea::sendDidUpdateBackingStoreState() 252 260 { 253 261 ASSERT(m_shouldSendDidUpdateBackingStoreState); … … 256 264 257 265 UpdateInfo updateInfo; 258 259 LayerTreeContext layerTreeContext;260 261 266 updateInfo.viewSize = m_webPage.size(); 262 267 updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor(); 263 268 264 layerTreeContext = m_layerTreeHost->layerTreeContext(); 265 266 // We don't want the layer tree host to notify after the next scheduled 267 // layer flush because that might end up sending an EnterAcceleratedCompositingMode 268 // message back to the UI process, but the updated layer tree context 269 // will be sent back in the DidUpdateBackingStoreState message. 270 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false); 271 m_layerTreeHost->forceRepaint(); 269 LayerTreeContext layerTreeContext; 270 if (m_layerTreeHost) { 271 layerTreeContext = m_layerTreeHost->layerTreeContext(); 272 273 // We don't want the layer tree host to notify after the next scheduled 274 // layer flush because that might end up sending an EnterAcceleratedCompositingMode 275 // message back to the UI process, but the updated layer tree context 276 // will be sent back in the DidUpdateBackingStoreState message. 277 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false); 278 m_layerTreeHost->forceRepaint(); 279 } 272 280 273 281 m_webPage.send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext)); … … 275 283 } 276 284 277 void CoordinatedDrawingArea::suspendPainting()285 void AcceleratedDrawingArea::suspendPainting() 278 286 { 279 287 ASSERT(!m_isPaintingSuspended); 280 288 281 m_layerTreeHost->pauseRendering(); 289 if (m_layerTreeHost) 290 m_layerTreeHost->pauseRendering(); 282 291 283 292 m_isPaintingSuspended = true; … … 286 295 } 287 296 288 void CoordinatedDrawingArea::resumePainting()297 void AcceleratedDrawingArea::resumePainting() 289 298 { 290 299 if (!m_isPaintingSuspended) { … … 294 303 } 295 304 296 m_layerTreeHost->resumeRendering(); 305 if (m_layerTreeHost) 306 m_layerTreeHost->resumeRendering(); 297 307 298 308 m_isPaintingSuspended = false; … … 304 314 } 305 315 306 void CoordinatedDrawingArea::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)316 void AcceleratedDrawingArea::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer) 307 317 { 308 318 m_exitCompositingTimer.stop(); 309 319 m_wantsToExitAcceleratedCompositingMode = false; 310 320 321 m_webPage.send(Messages::DrawingAreaProxy::WillEnterAcceleratedCompositingMode(m_backingStoreStateID)); 322 323 ASSERT(!m_layerTreeHost); 311 324 m_layerTreeHost = LayerTreeHost::create(m_webPage); 325 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER) 326 if (m_nativeSurfaceHandleForCompositing) 327 m_layerTreeHost->setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing); 328 #endif 312 329 if (!m_inUpdateBackingStoreState) 313 330 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true); 331 if (m_isPaintingSuspended) 332 m_layerTreeHost->pauseRendering(); 314 333 315 334 m_layerTreeHost->setRootCompositingLayer(graphicsLayer); 316 335 } 317 336 318 void CoordinatedDrawingArea::exitAcceleratedCompositingModeSoon()337 void AcceleratedDrawingArea::exitAcceleratedCompositingModeSoon() 319 338 { 320 339 if (m_layerTreeStateIsFrozen) { … … 329 348 } 330 349 331 void CoordinatedDrawingArea::didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder) 350 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) 351 void AcceleratedDrawingArea::didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder) 332 352 { 333 353 m_layerTreeHost->didReceiveCoordinatedLayerTreeHostMessage(connection, decoder); 334 354 } 335 336 void CoordinatedDrawingArea::viewStateDidChange(ViewState::Flags changed, bool, const Vector<uint64_t>&) 355 #endif 356 357 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER) 358 void AcceleratedDrawingArea::setNativeSurfaceHandleForCompositing(uint64_t handle) 359 { 360 m_nativeSurfaceHandleForCompositing = handle; 361 if (m_layerTreeHost) { 362 m_webPage.corePage()->settings().setAcceleratedCompositingEnabled(true); 363 m_layerTreeHost->setNativeSurfaceHandleForCompositing(handle); 364 } 365 } 366 367 void AcceleratedDrawingArea::destroyNativeSurfaceHandleForCompositing(bool& handled) 368 { 369 handled = true; 370 setNativeSurfaceHandleForCompositing(0); 371 } 372 #endif 373 374 void AcceleratedDrawingArea::viewStateDidChange(ViewState::Flags changed, bool, const Vector<uint64_t>&) 337 375 { 338 376 if (changed & ViewState::IsVisible) { … … 344 382 } 345 383 346 void CoordinatedDrawingArea::attachViewOverlayGraphicsLayer(WebCore::Frame* frame, WebCore::GraphicsLayer* viewOverlayRootLayer)384 void AcceleratedDrawingArea::attachViewOverlayGraphicsLayer(Frame* frame, GraphicsLayer* viewOverlayRootLayer) 347 385 { 348 386 if (!frame->isMainFrame()) 349 387 return; 350 388 351 m_layerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer); 389 if (m_layerTreeHost) 390 m_layerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer); 352 391 } 353 392 354 393 } // namespace WebKit 355 #endif // USE(COORDINATED_GRAPHICS) -
trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h
r202854 r202855 25 25 */ 26 26 27 #ifndef CoordinatedDrawingArea_h 28 #define CoordinatedDrawingArea_h 29 30 #if USE(COORDINATED_GRAPHICS) 27 #pragma once 31 28 32 29 #include "DrawingArea.h" 33 #include "LayerTreeHost.h"34 #include <WebCore/Region.h>35 30 #include <wtf/RunLoop.h> 36 31 37 32 namespace WebKit { 38 33 39 class CoordinatedDrawingArea : public DrawingArea { 34 class LayerTreeHost; 35 36 class AcceleratedDrawingArea : public DrawingArea { 40 37 public: 41 CoordinatedDrawingArea(WebPage&, const WebPageCreationParameters&);42 virtual ~ CoordinatedDrawingArea();38 AcceleratedDrawingArea(WebPage&, const WebPageCreationParameters&); 39 virtual ~AcceleratedDrawingArea(); 43 40 44 pr ivate:41 protected: 45 42 // DrawingArea 46 43 void setNeedsDisplay() override; … … 63 60 void scheduleCompositingLayerFlushImmediately() override; 64 61 62 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) 65 63 void didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection&, IPC::MessageDecoder&) override; 64 #endif 65 66 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER) 67 void setNativeSurfaceHandleForCompositing(uint64_t) override; 68 void destroyNativeSurfaceHandleForCompositing(bool&) override; 69 #endif 66 70 67 71 void viewStateDidChange(WebCore::ViewState::Flags, bool /* wantsDidUpdateViewState */, const Vector<uint64_t>& /* callbackIDs */) override; … … 72 76 // IPC message handlers. 73 77 void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset) override; 78 79 void exitAcceleratedCompositingModeSoon(); 80 bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); } 81 74 82 virtual void suspendPainting(); 75 83 virtual void resumePainting(); 76 84 77 void sendDidUpdateBackingStoreState(); 85 virtual void sendDidUpdateBackingStoreState(); 86 virtual void didUpdateBackingStoreState() { } 78 87 79 void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*); 80 void exitAcceleratedCompositingModeSoon(); 81 bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); } 82 void exitAcceleratedCompositingMode() { } 88 virtual void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*); 89 virtual void exitAcceleratedCompositingMode() { } 83 90 84 uint64_t m_backingStoreStateID ;91 uint64_t m_backingStoreStateID { 0 }; 85 92 86 93 // Whether painting is enabled. If painting is disabled, any calls to setNeedsDisplay and scroll are ignored. 87 bool m_isPaintingEnabled ;94 bool m_isPaintingEnabled { true }; 88 95 89 96 // Whether we're currently processing an UpdateBackingStoreState message. 90 bool m_inUpdateBackingStoreState ;97 bool m_inUpdateBackingStoreState { false }; 91 98 92 99 // When true, we should send an UpdateBackingStoreState message instead of any other messages 93 100 // we normally send to the UI process. 94 bool m_shouldSendDidUpdateBackingStoreState ;101 bool m_shouldSendDidUpdateBackingStoreState { false }; 95 102 96 103 // True between sending the 'enter compositing' messages, and the 'exit compositing' message. 97 bool m_compositingAccordingToProxyMessages ;104 bool m_compositingAccordingToProxyMessages { false }; 98 105 99 106 // When true, we maintain the layer tree in its current state by not leaving accelerated compositing mode 100 107 // and not scheduling layer flushes. 101 bool m_layerTreeStateIsFrozen ;108 bool m_layerTreeStateIsFrozen { false }; 102 109 103 110 // True when we were asked to exit accelerated compositing mode but couldn't because layer tree 104 111 // state was frozen. 105 bool m_wantsToExitAcceleratedCompositingMode ;112 bool m_wantsToExitAcceleratedCompositingMode { false }; 106 113 107 114 // Whether painting is suspended. We'll still keep track of the dirty region but we 108 115 // won't paint until painting has resumed again. 109 bool m_isPaintingSuspended ;116 bool m_isPaintingSuspended { false }; 110 117 111 RunLoop::Timer< CoordinatedDrawingArea> m_exitCompositingTimer;118 RunLoop::Timer<AcceleratedDrawingArea> m_exitCompositingTimer; 112 119 113 120 // The layer tree host that handles accelerated compositing. … … 116 123 117 124 } // namespace WebKit 118 119 #endif // USE(COORDINATED_GRAPHICS)120 121 #endif // CoordinatedDrawingArea_h -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp
r190615 r202855 40 40 #else 41 41 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) 42 #include " CoordinatedDrawingArea.h"42 #include "AcceleratedDrawingArea.h" 43 43 #else 44 44 #include "DrawingAreaImpl.h" … … 63 63 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) 64 64 case DrawingAreaTypeCoordinated: 65 return std::make_unique< CoordinatedDrawingArea>(webPage, parameters);65 return std::make_unique<AcceleratedDrawingArea>(webPage, parameters); 66 66 #else 67 67 case DrawingAreaTypeImpl: … … 77 77 : m_type(type) 78 78 , m_webPage(webPage) 79 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK)80 , m_nativeSurfaceHandleForCompositing(0)81 #endif82 79 { 83 80 WebProcess::singleton().addMessageReceiver(Messages::DrawingArea::messageReceiverName(), m_webPage.pageID(), *this); -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h
r202621 r202855 147 147 WebPage& m_webPage; 148 148 149 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK)150 uint64_t m_nativeSurfaceHandleForCompositing ;149 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER) 150 uint64_t m_nativeSurfaceHandleForCompositing { 0 }; 151 151 #endif 152 152 -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
r202611 r202855 28 28 29 29 #include "DrawingAreaProxyMessages.h" 30 #include "LayerTree Context.h"30 #include "LayerTreeHost.h" 31 31 #include "ShareableBitmap.h" 32 32 #include "UpdateInfo.h" … … 34 34 #include "WebPageCreationParameters.h" 35 35 #include "WebPreferencesKeys.h" 36 #include "WebProcess.h"37 36 #include <WebCore/GraphicsContext.h> 38 #include <WebCore/MainFrame.h>39 37 #include <WebCore/Page.h> 40 38 #include <WebCore/Settings.h> … … 46 44 DrawingAreaImpl::~DrawingAreaImpl() 47 45 { 48 if (m_layerTreeHost)49 m_layerTreeHost->invalidate();50 46 } 51 47 52 48 DrawingAreaImpl::DrawingAreaImpl(WebPage& webPage, const WebPageCreationParameters& parameters) 53 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS) 54 : DrawingArea(DrawingAreaTypeCoordinated, webPage) 55 #else 56 : DrawingArea(DrawingAreaTypeImpl, webPage) 57 #endif 58 , m_backingStoreStateID(0) 59 , m_isPaintingEnabled(true) 60 , m_inUpdateBackingStoreState(false) 61 , m_shouldSendDidUpdateBackingStoreState(false) 62 , m_isWaitingForDidUpdate(false) 63 , m_compositingAccordingToProxyMessages(false) 64 , m_layerTreeStateIsFrozen(false) 65 , m_wantsToExitAcceleratedCompositingMode(false) 66 , m_isPaintingSuspended(!(parameters.viewState & ViewState::IsVisible)) 67 , m_alwaysUseCompositing(false) 49 : AcceleratedDrawingArea(webPage, parameters) 68 50 , m_displayTimer(RunLoop::main(), this, &DrawingAreaImpl::displayTimerFired) 69 , m_exitCompositingTimer(RunLoop::main(), this, &DrawingAreaImpl::exitAcceleratedCompositingMode)70 51 { 71 52 } … … 73 54 void DrawingAreaImpl::setNeedsDisplay() 74 55 { 56 if (m_layerTreeHost) { 57 ASSERT(m_dirtyRegion.isEmpty()); 58 AcceleratedDrawingArea::setNeedsDisplay(); 59 return; 60 } 61 62 setNeedsDisplayInRect(m_webPage.bounds()); 63 } 64 65 void DrawingAreaImpl::setNeedsDisplayInRect(const IntRect& rect) 66 { 67 if (m_layerTreeHost) { 68 ASSERT(m_dirtyRegion.isEmpty()); 69 AcceleratedDrawingArea::setNeedsDisplayInRect(rect); 70 return; 71 } 72 75 73 if (!m_isPaintingEnabled) 76 74 return; 77 75 78 if (m_layerTreeHost) {79 ASSERT(m_dirtyRegion.isEmpty());80 m_layerTreeHost->setNonCompositedContentsNeedDisplay();81 return;82 }83 84 setNeedsDisplayInRect(m_webPage.bounds());85 }86 87 void DrawingAreaImpl::setNeedsDisplayInRect(const IntRect& rect)88 {89 if (!m_isPaintingEnabled)90 return;91 92 if (m_layerTreeHost) {93 ASSERT(m_dirtyRegion.isEmpty());94 m_layerTreeHost->setNonCompositedContentsNeedDisplayInRect(rect);95 return;96 }97 98 76 IntRect dirtyRect = rect; 99 77 dirtyRect.intersect(m_webPage.bounds()); 100 101 78 if (dirtyRect.isEmpty()) 102 79 return; … … 108 85 void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) 109 86 { 110 if (!m_isPaintingEnabled)111 return;112 113 87 if (m_layerTreeHost) { 114 88 ASSERT(m_scrollRect.isEmpty()); 115 89 ASSERT(m_scrollOffset.isEmpty()); 116 90 ASSERT(m_dirtyRegion.isEmpty()); 117 118 m_layerTreeHost->scrollNonCompositedContents(scrollRect); 119 return; 120 } 91 AcceleratedDrawingArea::scroll(scrollRect, scrollDelta); 92 return; 93 } 94 95 if (!m_isPaintingEnabled) 96 return; 121 97 122 98 if (scrollRect.isEmpty()) … … 152 128 // And add them back. 153 129 m_dirtyRegion.unite(movedDirtyRegionInScrollRect); 154 } 155 130 } 131 156 132 // Compute the scroll repaint region. 157 133 Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta)); … … 164 140 } 165 141 166 void DrawingAreaImpl::pageBackgroundTransparencyChanged()167 {168 if (m_layerTreeHost)169 m_layerTreeHost->pageBackgroundTransparencyChanged();170 }171 172 void DrawingAreaImpl::setLayerTreeStateIsFrozen(bool isFrozen)173 {174 if (m_layerTreeStateIsFrozen == isFrozen)175 return;176 177 m_layerTreeStateIsFrozen = isFrozen;178 179 if (m_layerTreeHost)180 m_layerTreeHost->setLayerFlushSchedulingEnabled(!isFrozen);181 182 if (isFrozen)183 m_exitCompositingTimer.stop();184 else if (m_wantsToExitAcceleratedCompositingMode)185 exitAcceleratedCompositingModeSoon();186 }187 188 142 void DrawingAreaImpl::forceRepaint() 189 143 { … … 192 146 return; 193 147 } 194 195 148 m_forceRepaintAfterBackingStoreStateUpdate = false; 149 150 if (m_layerTreeHost) { 151 AcceleratedDrawingArea::forceRepaint(); 152 return; 153 } 154 196 155 setNeedsDisplay(); 197 198 156 m_webPage.layoutIfNeeded(); 199 200 if (m_layerTreeHost) {201 // FIXME: We need to do the same work as the layerHostDidFlushLayers function here,202 // but clearly it doesn't make sense to call the function with that name.203 // Consider refactoring and renaming it.204 if (m_compositingAccordingToProxyMessages)205 m_layerTreeHost->forceRepaint();206 else {207 // Call setShouldNotifyAfterNextScheduledLayerFlush(false) here to208 // prevent layerHostDidFlushLayers() from being called a second time.209 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);210 layerHostDidFlushLayers();211 }212 return;213 }214 215 157 m_isWaitingForDidUpdate = false; 216 158 display(); 217 }218 219 bool DrawingAreaImpl::forceRepaintAsync(uint64_t callbackID)220 {221 return m_layerTreeHost && m_layerTreeHost->forceRepaintAsync(callbackID);222 }223 224 void DrawingAreaImpl::setPaintingEnabled(bool paintingEnabled)225 {226 m_isPaintingEnabled = paintingEnabled;227 159 } 228 160 … … 254 186 } 255 187 256 void DrawingAreaImpl::layerHostDidFlushLayers()257 {258 ASSERT(m_layerTreeHost);259 260 m_layerTreeHost->forceRepaint();261 262 if (m_shouldSendDidUpdateBackingStoreState && !exitAcceleratedCompositingModePending()) {263 sendDidUpdateBackingStoreState();264 return;265 }266 267 if (!m_layerTreeHost)268 return;269 270 ASSERT(!m_compositingAccordingToProxyMessages);271 if (!exitAcceleratedCompositingModePending()) {272 m_webPage.send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));273 m_compositingAccordingToProxyMessages = true;274 }275 }276 277 GraphicsLayerFactory* DrawingAreaImpl::graphicsLayerFactory()278 {279 if (m_layerTreeHost)280 return m_layerTreeHost->graphicsLayerFactory();281 282 return 0;283 }284 285 188 void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer) 286 189 { 287 // FIXME: Instead of using nested if statements, we should keep a compositing state 288 // enum in the DrawingAreaImpl object and have a changeAcceleratedCompositingState function 289 // that takes the new state. 290 291 if (graphicsLayer) { 292 if (!m_layerTreeHost) { 293 // We're actually entering accelerated compositing mode. 294 enterAcceleratedCompositingMode(graphicsLayer); 295 } else { 296 // We're already in accelerated compositing mode, but the root compositing layer changed. 297 298 m_exitCompositingTimer.stop(); 299 m_wantsToExitAcceleratedCompositingMode = false; 300 301 // If we haven't sent the EnterAcceleratedCompositingMode message, make sure that the 302 // layer tree host calls us back after the next layer flush so we can send it then. 303 if (!m_compositingAccordingToProxyMessages) 304 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true); 305 306 m_layerTreeHost->setRootCompositingLayer(graphicsLayer); 190 if (m_layerTreeHost) { 191 AcceleratedDrawingArea::setRootCompositingLayer(graphicsLayer); 192 193 if (!graphicsLayer && !m_alwaysUseCompositing) { 194 // We'll exit accelerated compositing mode on a timer, to avoid re-entering 195 // compositing code via display() and layout. 196 // If we're leaving compositing mode because of a setSize, it is safe to 197 // exit accelerated compositing mode right away. 198 if (m_inUpdateBackingStoreState) 199 exitAcceleratedCompositingMode(); 200 else 201 exitAcceleratedCompositingModeSoon(); 307 202 } 308 } else { 309 if (m_layerTreeHost) { 310 m_layerTreeHost->setRootCompositingLayer(0); 311 if (!m_alwaysUseCompositing) { 312 // We'll exit accelerated compositing mode on a timer, to avoid re-entering 313 // compositing code via display() and layout. 314 // If we're leaving compositing mode because of a setSize, it is safe to 315 // exit accelerated compositing mode right away. 316 if (m_inUpdateBackingStoreState) 317 exitAcceleratedCompositingMode(); 318 else 319 exitAcceleratedCompositingModeSoon(); 320 } 321 } 322 } 323 } 324 325 void DrawingAreaImpl::scheduleCompositingLayerFlush() 326 { 327 if (!m_layerTreeHost) 328 return; 329 m_layerTreeHost->scheduleLayerFlush(); 330 } 331 332 void DrawingAreaImpl::scheduleCompositingLayerFlushImmediately() 333 { 334 scheduleCompositingLayerFlush(); 203 return; 204 } 205 206 if (!graphicsLayer) 207 return; 208 209 // We're actually entering accelerated compositing mode. 210 enterAcceleratedCompositingMode(graphicsLayer); 335 211 } 336 212 337 213 void DrawingAreaImpl::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize& size, const WebCore::IntSize& scrollOffset) 338 214 { 339 ASSERT(!m_inUpdateBackingStoreState); 340 m_inUpdateBackingStoreState = true; 341 342 ASSERT_ARG(stateID, stateID >= m_backingStoreStateID); 343 if (stateID != m_backingStoreStateID) { 344 m_backingStoreStateID = stateID; 345 m_shouldSendDidUpdateBackingStoreState = true; 346 347 m_webPage.setDeviceScaleFactor(deviceScaleFactor); 348 m_webPage.setSize(size); 349 m_webPage.layoutIfNeeded(); 350 m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset); 351 352 if (m_layerTreeHost) 353 m_layerTreeHost->sizeDidChange(m_webPage.size()); 354 else 355 m_dirtyRegion = m_webPage.bounds(); 356 } else { 357 ASSERT(size == m_webPage.size()); 358 if (!m_shouldSendDidUpdateBackingStoreState) { 359 // We've already sent a DidUpdateBackingStoreState message for this state. We have nothing more to do. 360 m_inUpdateBackingStoreState = false; 361 return; 362 } 363 } 364 215 bool shouldUpdateDirtyRegion = stateID != m_backingStoreStateID && !m_layerTreeHost; 216 AcceleratedDrawingArea::updateBackingStoreState(stateID, respondImmediately, deviceScaleFactor, size, scrollOffset); 217 if (shouldUpdateDirtyRegion) 218 m_dirtyRegion = m_webPage.bounds(); 219 220 if (m_forceRepaintAfterBackingStoreStateUpdate) 221 forceRepaint(); 222 } 223 224 void DrawingAreaImpl::didUpdateBackingStoreState() 225 { 365 226 // The UI process has updated to a new backing store state. Any Update messages we sent before 366 227 // this point will be ignored. We wait to set this to false until after updating the page's … … 369 230 // sendDidUpdateBackingStoreState; otherwise we shouldn't do one right now. 370 231 m_isWaitingForDidUpdate = false; 371 372 if (respondImmediately) {373 // Make sure to resume painting if we're supposed to respond immediately, otherwise we'll just374 // send back an empty UpdateInfo struct.375 if (m_isPaintingSuspended)376 resumePainting();377 378 sendDidUpdateBackingStoreState();379 }380 381 m_inUpdateBackingStoreState = false;382 if (m_forceRepaintAfterBackingStoreStateUpdate)383 forceRepaint();384 232 } 385 233 … … 389 237 ASSERT(m_shouldSendDidUpdateBackingStoreState); 390 238 391 m_shouldSendDidUpdateBackingStoreState = false; 392 393 UpdateInfo updateInfo; 394 395 if (!m_isPaintingSuspended && !m_layerTreeHost) 239 if (!m_isPaintingSuspended && !m_layerTreeHost) { 240 UpdateInfo updateInfo; 396 241 display(updateInfo); 397 398 LayerTreeContext layerTreeContext; 399 400 if (m_isPaintingSuspended || m_layerTreeHost) { 401 updateInfo.viewSize = m_webPage.size(); 402 updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor(); 403 404 if (m_layerTreeHost) { 405 layerTreeContext = m_layerTreeHost->layerTreeContext(); 406 407 // We don't want the layer tree host to notify after the next scheduled 408 // layer flush because that might end up sending an EnterAcceleratedCompositingMode 409 // message back to the UI process, but the updated layer tree context 410 // will be sent back in the DidUpdateBackingStoreState message. 411 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false); 412 m_layerTreeHost->forceRepaint(); 242 if (!m_layerTreeHost) { 243 m_shouldSendDidUpdateBackingStoreState = false; 244 245 LayerTreeContext layerTreeContext; 246 m_webPage.send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext)); 247 m_compositingAccordingToProxyMessages = false; 248 return; 413 249 } 414 250 } 415 251 416 m_webPage.send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext)); 417 m_compositingAccordingToProxyMessages = !layerTreeContext.isEmpty(); 252 AcceleratedDrawingArea::sendDidUpdateBackingStoreState(); 418 253 } 419 254 … … 433 268 void DrawingAreaImpl::suspendPainting() 434 269 { 435 ASSERT(!m_isPaintingSuspended); 436 437 if (m_layerTreeHost) 438 m_layerTreeHost->pauseRendering(); 439 440 m_isPaintingSuspended = true; 270 AcceleratedDrawingArea::suspendPainting(); 441 271 m_displayTimer.stop(); 442 272 } 443 273 444 void DrawingAreaImpl::resumePainting()445 {446 if (!m_isPaintingSuspended) {447 // FIXME: We can get a call to resumePainting when painting is not suspended.448 // This happens when sending a synchronous message to create a new page. See <rdar://problem/8976531>.449 return;450 }451 452 if (m_layerTreeHost)453 m_layerTreeHost->resumeRendering();454 455 m_isPaintingSuspended = false;456 457 // FIXME: We shouldn't always repaint everything here.458 setNeedsDisplay();459 }460 461 274 void DrawingAreaImpl::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer) 462 275 { 463 m_exitCompositingTimer.stop(); 464 m_wantsToExitAcceleratedCompositingMode = false; 465 466 m_webPage.send(Messages::DrawingAreaProxy::WillEnterAcceleratedCompositingMode(m_backingStoreStateID)); 467 468 ASSERT(!m_layerTreeHost); 469 470 m_layerTreeHost = LayerTreeHost::create(m_webPage); 471 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK) 472 if (m_nativeSurfaceHandleForCompositing) 473 m_layerTreeHost->setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing); 474 #endif 475 if (!m_inUpdateBackingStoreState) 476 m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true); 477 478 m_layerTreeHost->setRootCompositingLayer(graphicsLayer); 479 276 AcceleratedDrawingArea::enterAcceleratedCompositingMode(graphicsLayer); 277 480 278 // Non-composited content will now be handled exclusively by the layer tree host. 481 279 m_dirtyRegion = Region(); … … 529 327 } 530 328 531 void DrawingAreaImpl::exitAcceleratedCompositingModeSoon()532 {533 if (m_layerTreeStateIsFrozen) {534 m_wantsToExitAcceleratedCompositingMode = true;535 return;536 }537 538 if (exitAcceleratedCompositingModePending())539 return;540 541 m_exitCompositingTimer.startOneShot(0);542 }543 544 329 void DrawingAreaImpl::scheduleDisplay() 545 330 { … … 682 467 } 683 468 684 void DrawingAreaImpl::attachViewOverlayGraphicsLayer(WebCore::Frame* frame, WebCore::GraphicsLayer* viewOverlayRootLayer)685 {686 if (!frame->isMainFrame())687 return;688 689 if (!m_layerTreeHost)690 return;691 692 m_layerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer);693 }694 695 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK)696 void DrawingAreaImpl::setNativeSurfaceHandleForCompositing(uint64_t handle)697 {698 m_nativeSurfaceHandleForCompositing = handle;699 700 if (m_layerTreeHost) {701 m_webPage.corePage()->settings().setAcceleratedCompositingEnabled(true);702 m_layerTreeHost->setNativeSurfaceHandleForCompositing(handle);703 }704 }705 706 void DrawingAreaImpl::destroyNativeSurfaceHandleForCompositing(bool& handled)707 {708 handled = true;709 setNativeSurfaceHandleForCompositing(0);710 }711 #endif712 713 469 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h
r202621 r202855 24 24 */ 25 25 26 #ifndef DrawingAreaImpl_h 27 #define DrawingAreaImpl_h 26 #pragma once 28 27 29 #include "DrawingArea.h" 30 #include "LayerTreeHost.h" 28 #include "AcceleratedDrawingArea.h" 31 29 #include <WebCore/Region.h> 32 #include <wtf/RunLoop.h>33 30 34 31 namespace WebCore { 35 32 class GraphicsContext; 36 33 } 37 34 … … 41 38 class UpdateInfo; 42 39 43 class DrawingAreaImpl : publicDrawingArea {40 class DrawingAreaImpl final : public AcceleratedDrawingArea { 44 41 public: 45 42 DrawingAreaImpl(WebPage&, const WebPageCreationParameters&); … … 51 48 void setNeedsDisplayInRect(const WebCore::IntRect&) override; 52 49 void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override; 53 void pageBackgroundTransparencyChanged() override;54 void setLayerTreeStateIsFrozen(bool) override;55 bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; }56 LayerTreeHost* layerTreeHost() const override { return m_layerTreeHost.get(); }57 50 void forceRepaint() override; 58 bool forceRepaintAsync(uint64_t callbackID) override;59 51 60 void setPaintingEnabled(bool) override;61 52 void mainFrameContentSizeChanged(const WebCore::IntSize&) override; 62 53 void updatePreferences(const WebPreferencesStore&) override; 63 54 64 WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;65 55 void setRootCompositingLayer(WebCore::GraphicsLayer*) override; 66 void scheduleCompositingLayerFlush() override;67 void scheduleCompositingLayerFlushImmediately() override;68 69 void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;70 71 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK)72 void setNativeSurfaceHandleForCompositing(uint64_t) override;73 void destroyNativeSurfaceHandleForCompositing(bool&) override;74 #endif75 76 void layerHostDidFlushLayers() override;77 56 78 57 // IPC message handlers. 79 58 void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset) override; 80 59 void didUpdate() override; 81 virtual void suspendPainting();82 virtual void resumePainting();83 84 void sendDidUpdateBackingStoreState();85 60 86 void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*); 87 void exitAcceleratedCompositingModeSoon(); 88 bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); } 89 void exitAcceleratedCompositingMode(); 61 // AcceleratedDrawingArea 62 void suspendPainting() override; 63 void sendDidUpdateBackingStoreState() override; 64 void didUpdateBackingStoreState() override; 65 66 void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*) override; 67 void exitAcceleratedCompositingMode() override; 90 68 91 69 void scheduleDisplay(); … … 94 72 void display(UpdateInfo&); 95 73 96 uint64_t m_backingStoreStateID;97 98 74 WebCore::Region m_dirtyRegion; 99 75 WebCore::IntRect m_scrollRect; 100 76 WebCore::IntSize m_scrollOffset; 101 77 102 // Whether painting is enabled. If painting is disabled, any calls to setNeedsDisplay and scroll are ignored.103 bool m_isPaintingEnabled;104 105 // Whether we're currently processing an UpdateBackingStoreState message.106 bool m_inUpdateBackingStoreState;107 108 // When true, we should send an UpdateBackingStoreState message instead of any other messages109 // we normally send to the UI process.110 bool m_shouldSendDidUpdateBackingStoreState;111 112 78 // Whether we're waiting for a DidUpdate message. Used for throttling paints so that the 113 79 // web process won't paint more frequent than the UI process can handle. 114 bool m_isWaitingForDidUpdate; 115 116 // True between sending the 'enter compositing' messages, and the 'exit compositing' message. 117 bool m_compositingAccordingToProxyMessages; 80 bool m_isWaitingForDidUpdate { false }; 118 81 119 // When true, we maintain the layer tree in its current state by not leaving accelerated compositing mode 120 // and not scheduling layer flushes. 121 bool m_layerTreeStateIsFrozen; 122 123 // True when we were asked to exit accelerated compositing mode but couldn't because layer tree 124 // state was frozen. 125 bool m_wantsToExitAcceleratedCompositingMode; 126 127 // Whether painting is suspended. We'll still keep track of the dirty region but we 128 // won't paint until painting has resumed again. 129 bool m_isPaintingSuspended; 130 bool m_alwaysUseCompositing; 131 82 bool m_alwaysUseCompositing {false }; 132 83 bool m_forceRepaintAfterBackingStoreStateUpdate { false }; 133 84 134 85 RunLoop::Timer<DrawingAreaImpl> m_displayTimer; 135 RunLoop::Timer<DrawingAreaImpl> m_exitCompositingTimer;136 137 // The layer tree host that handles accelerated compositing.138 RefPtr<LayerTreeHost> m_layerTreeHost;139 86 }; 140 87 141 88 } // namespace WebKit 142 143 #endif // DrawingAreaImpl_h
Note: See TracChangeset
for help on using the changeset viewer.