Changeset 152074 in webkit
- Timestamp:
- Jun 26, 2013 7:50:11 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r151985 r152074 1979 1979 1980 1980 platform/graphics/texmap/coordinated/AreaAllocator.cpp 1981 platform/graphics/texmap/coordinated/CompositingCoordinator.cpp 1981 1982 platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp 1982 1983 platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp -
trunk/Source/WebCore/ChangeLog
r152070 r152074 1 2013-06-26 Gwang Yoon Hwang <ryumiel@company100.net> 2 3 Coordinated Graphics: Separate CoordinatedLayerTreeHost into CoordinatedLayerTreeHost and CompositingCoordinator 4 https://bugs.webkit.org/show_bug.cgi?id=104360 5 6 Reviewed by Noam Rosenthal. 7 8 The CoordinatedLayerTreeHost has too many responsibilities. It 9 implements LayerTreeHost, GraphicsLayerClient, 10 CoordinatedGraphicsLayerClient, CoordinatedImageBacking::Client, 11 UpdateAtlas::Client, GraphicsLayerFactory and 12 WebCustomFilterProgramProxyClient. 13 14 This refactoring reduces the responsibilities of CoordinatedLayerTreeHost. 15 16 This patch introduces a new class called CompositingCoordinator, which 17 takes the responsibility of managing compositing resources in 18 WebProcess. 19 20 CoordinatedLayerTreeHost is responsible only for the scheduling and 21 IPC-specific stuff, which are relevant only for WebKit2. 22 23 No new tests, covered by existing tests. 24 25 * CMakeLists.txt: 26 * Target.pri: 27 * platform/graphics/texmap/coordinated/CompositingCoordinator.cpp: Added. 28 (WebCore::CompositingCoordinator::create): 29 (WebCore::CompositingCoordinator::~CompositingCoordinator): 30 (WebCore::CompositingCoordinator::CompositingCoordinator): 31 (WebCore::CompositingCoordinator::setRootCompositingLayer): 32 (WebCore::CompositingCoordinator::sizeDidChange): 33 (WebCore::CompositingCoordinator::flushPendingLayerChanges): 34 (WebCore::CompositingCoordinator::syncDisplayState): 35 (WebCore::CompositingCoordinator::nextAnimationServiceTime): 36 (WebCore::CompositingCoordinator::clearPendingStateChanges): 37 (WebCore::CompositingCoordinator::initializeRootCompositingLayerIfNeeded): 38 (WebCore::CompositingCoordinator::createRootLayer): 39 (WebCore::CompositingCoordinator::syncLayerState): 40 (WebCore::CompositingCoordinator::createImageBackingIfNeeded): 41 (WebCore::CompositingCoordinator::createImageBacking): 42 (WebCore::CompositingCoordinator::updateImageBacking): 43 (WebCore::CompositingCoordinator::clearImageBackingContents): 44 (WebCore::CompositingCoordinator::removeImageBacking): 45 (WebCore::CompositingCoordinator::flushPendingImageBackingChanges): 46 (WebCore::CompositingCoordinator::notifyAnimationStarted): 47 (WebCore::CompositingCoordinator::notifyFlushRequired): 48 (WebCore::CompositingCoordinator::paintContents): 49 (WebCore::CompositingCoordinator::createGraphicsLayer): 50 (WebCore::CompositingCoordinator::deviceScaleFactor): 51 (WebCore::CompositingCoordinator::pageScaleFactor): 52 (WebCore::CompositingCoordinator::createUpdateAtlas): 53 (WebCore::CompositingCoordinator::removeUpdateAtlas): 54 (WebCore::CompositingCoordinator::visibleContentsRect): 55 (WebCore::CompositingCoordinator::mainContentsLayer): 56 (WebCore::CompositingCoordinator::setVisibleContentsRect): 57 (WebCore::CompositingCoordinator::deviceOrPageScaleFactorChanged): 58 (WebCore::CompositingCoordinator::detachLayer): 59 (WebCore::CompositingCoordinator::commitScrollOffset): 60 (WebCore::CompositingCoordinator::renderNextFrame): 61 (WebCore::CompositingCoordinator::purgeBackingStores): 62 (WebCore::CompositingCoordinator::paintToSurface): 63 (WebCore::CompositingCoordinator::scheduleReleaseInactiveAtlases): 64 (WebCore::CompositingCoordinator::releaseInactiveAtlasesTimerFired): 65 * platform/graphics/texmap/coordinated/CompositingCoordinator.h: Added. 66 (WebCore::CompositingCoordinator::clearRootLayer): 67 (WebCore::CompositingCoordinator::rootLayer): 68 (WebCore::CompositingCoordinator::state): 69 1 70 2013-06-26 Kihong Kwon <kihong.kwon@samsung.com> 2 71 -
trunk/Source/WebCore/Target.pri
r151914 r152074 4090 4090 platform/graphics/texmap/TextureMapperShaderProgram.h \ 4091 4091 platform/graphics/texmap/coordinated/AreaAllocator.h \ 4092 platform/graphics/texmap/coordinated/CompositingCoordinator.h \ 4092 4093 platform/graphics/texmap/coordinated/CoordinatedBackingStore.h \ 4093 4094 platform/graphics/texmap/coordinated/CoordinatedCustomFilterOperation.h \ … … 4125 4126 platform/graphics/texmap/TextureMapperShaderProgram.cpp \ 4126 4127 platform/graphics/texmap/coordinated/AreaAllocator.cpp \ 4128 platform/graphics/texmap/coordinated/CompositingCoordinator.cpp \ 4127 4129 platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp \ 4128 4130 platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp \ -
trunk/Source/WebKit2/ChangeLog
r152073 r152074 1 2013-06-26 Gwang Yoon Hwang <ryumiel@company100.net> 2 3 Coordinated Graphics: Separate CoordinatedLayerTreeHost into CoordinatedLayerTreeHost and CompositingCoordinator 4 https://bugs.webkit.org/show_bug.cgi?id=104360 5 6 Reviewed by Noam Rosenthal. 7 8 The CoordinatedLayerTreeHost has too many responsibilities. It 9 implements LayerTreeHost, GraphicsLayerClient, 10 CoordinatedGraphicsLayerClient, CoordinatedImageBacking::Client, 11 UpdateAtlas::Client, GraphicsLayerFactory and 12 WebCustomFilterProgramProxyClient. 13 14 This refactoring reduces the responsibilities of CoordinatedLayerTreeHost. 15 16 This patch introduces a new class called CompositingCoordinator, which 17 takes the responsibility of managing compositing resources in 18 WebProcess. 19 20 CoordinatedLayerTreeHost is responsible only for the scheduling and 21 IPC-specific stuff, which are relevant only for WebKit2. 22 23 No new tests, covered by existing tests. 24 25 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp: 26 (WebKit::CoordinatedLayerTreeHost::~CoordinatedLayerTreeHost): 27 (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost): 28 (WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer): 29 (WebKit::CoordinatedLayerTreeHost::invalidate): 30 (WebKit::CoordinatedLayerTreeHost::forceRepaint): 31 (WebKit::CoordinatedLayerTreeHost::sizeDidChange): 32 (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect): 33 (WebKit::CoordinatedLayerTreeHost::renderNextFrame): 34 (WebKit::CoordinatedLayerTreeHost::purgeBackingStores): 35 (WebKit::CoordinatedLayerTreeHost::willSyncLayerState): 36 (WebKit::CoordinatedLayerTreeHost::prepareCustomFilterProxiesForAnimations): 37 (WebKit::CoordinatedLayerTreeHost::checkCustomFilterProgramProxies): 38 (WebKit::CoordinatedLayerTreeHost::removeCustomFilterProgramProxy): 39 (WebKit::CoordinatedLayerTreeHost::didFlushRootLayer): 40 (WebKit::CoordinatedLayerTreeHost::performScheduledLayerFlush): 41 (WebKit::CoordinatedLayerTreeHost::createPageOverlayLayer): 42 (WebKit::CoordinatedLayerTreeHost::paintLayerContents): 43 (WebKit::CoordinatedLayerTreeHost::commitSceneState): 44 (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): 45 (WebKit::CoordinatedLayerTreeHost::graphicsLayerFactory): 46 (WebKit::CoordinatedLayerTreeHost::scheduleAnimation): 47 (WebKit::CoordinatedLayerTreeHost::commitScrollOffset): 48 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h: 49 * WebProcess/WebPage/LayerTreeHost.h: 50 1 51 2013-06-26 Simon Cooper <scooper@apple.com> 2 52 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
r151423 r152074 41 41 #include <WebCore/Frame.h> 42 42 #include <WebCore/FrameView.h> 43 #include <WebCore/GraphicsSurface.h>44 #include <WebCore/InspectorController.h>45 #include <WebCore/Page.h>46 #include <WebCore/RenderLayer.h>47 #include <WebCore/RenderLayerBacking.h>48 #include <WebCore/RenderLayerCompositor.h>49 #include <WebCore/RenderView.h>50 43 #include <WebCore/Settings.h> 51 #include <WebCore/SurfaceUpdateInfo.h>52 #include <WebCore/TextureMapperPlatformLayer.h>53 44 #include <wtf/CurrentTime.h> 54 #include <wtf/TemporaryChange.h>55 45 56 46 #if ENABLE(CSS_SHADERS) … … 73 63 disconnectCustomFilterPrograms(); 74 64 #endif 75 purgeBackingStores();76 77 LayerMap::iterator end = m_registeredLayers.end();78 for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)79 it->value->setCoordinator(0);80 65 } 81 66 82 67 CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage) 83 68 : LayerTreeHost(webPage) 84 , m_rootCompositingLayer(0)85 69 , m_notifyAfterScheduledLayerFlush(false) 86 70 , m_isValid(true) 87 , m_isPurging(false)88 , m_isFlushingLayerChanges(false)89 , m_waitingForUIProcess(true)90 71 , m_isSuspended(false) 91 , m_shouldSyncFrame(false) 92 , m_didInitializeRootCompositingLayer(false) 72 , m_isWaitingForRenderer(true) 93 73 , m_layerFlushTimer(this, &CoordinatedLayerTreeHost::layerFlushTimerFired) 94 , m_releaseInactiveAtlasesTimer(this, &CoordinatedLayerTreeHost::releaseInactiveAtlasesTimerFired)95 74 , m_layerFlushSchedulingEnabled(true) 96 75 , m_forceRepaintAsyncCallbackID(0) 97 , m_animationsLocked(false) 98 #if ENABLE(REQUEST_ANIMATION_FRAME) 99 , m_lastAnimationServiceTime(0) 100 #endif 101 { 102 m_webPage->corePage()->settings()->setApplyDeviceScaleFactorInCompositor(true); 103 104 // Create a root layer. 105 m_rootLayer = GraphicsLayer::create(this, this); 106 #ifndef NDEBUG 107 m_rootLayer->setName("CoordinatedLayerTreeHost root layer"); 108 #endif 109 m_rootLayer->setDrawsContent(false); 110 m_rootLayer->setSize(m_webPage->size()); 111 m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_rootLayer.get())->id(); 76 { 77 m_coordinator = CompositingCoordinator::create(webPage->corePage(), this); 78 79 m_coordinator->createRootLayer(webPage->size()); 80 m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id(); 112 81 113 82 CoordinatedSurface::setFactory(createCoordinatedSurface); 114 83 115 // This is a temporary way to enable this only in the GL case, until TextureMapperImageBuffer is removed. 116 // See https://bugs.webkit.org/show_bug.cgi?id=114869 117 CoordinatedGraphicsLayer::setShouldSupportContentsTiling(true); 118 119 if (m_webPage->hasPageOverlay()) 84 if (webPage->hasPageOverlay()) 120 85 createPageOverlayLayer(); 121 86 … … 159 124 void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer) 160 125 { 161 if (m_rootCompositingLayer) 162 m_rootCompositingLayer->removeFromParent(); 163 164 m_rootCompositingLayer = graphicsLayer; 165 if (m_rootCompositingLayer) 166 m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0); 126 m_coordinator->setRootCompositingLayer(graphicsLayer); 167 127 } 168 128 … … 172 132 173 133 ASSERT(m_isValid); 174 m_ rootLayer = nullptr;134 m_coordinator->clearRootLayer(); 175 135 m_isValid = false; 176 136 } … … 180 140 // This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely. 181 141 // Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed. 182 syncDisplayState();142 m_coordinator->syncDisplayState(); 183 143 184 144 // We need to schedule another flush, otherwise the forced paint might cancel a later expected flush. 185 145 // This is aligned with LayerTreeHostCA. 186 146 scheduleLayerFlush(); 187 flushPendingLayerChanges();147 m_coordinator->flushPendingLayerChanges(); 188 148 } 189 149 … … 199 159 void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize) 200 160 { 201 m_ rootLayer->setSize(newSize);161 m_coordinator->sizeDidChange(newSize); 202 162 scheduleLayerFlush(); 203 163 } … … 234 194 } 235 195 236 bool CoordinatedLayerTreeHost::flushPendingLayerChanges() 237 { 238 if (m_waitingForUIProcess) 239 return false; 240 241 TemporaryChange<bool> protector(m_isFlushingLayerChanges, true); 242 243 initializeRootCompositingLayerIfNeeded(); 244 245 m_rootLayer->flushCompositingStateForThisLayerOnly(); 246 if (m_pageOverlayLayer) 247 m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); 248 249 bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); 250 251 toCoordinatedGraphicsLayer(m_rootLayer.get())->updateContentBuffersIncludingSubLayers(); 252 toCoordinatedGraphicsLayer(m_rootLayer.get())->syncPendingStateChangesIncludingSubLayers(); 253 254 flushPendingImageBackingChanges(); 255 256 if (m_shouldSyncFrame) { 257 didSync = true; 258 259 if (m_rootCompositingLayer) { 260 m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size()); 261 if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer()) 262 m_state.coveredRect = contentsLayer->coverRect(); 263 } 264 265 m_state.scrollPosition = m_visibleContentsRect.location(); 266 267 m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(m_state)); 268 269 clearPendingStateChanges(); 270 m_waitingForUIProcess = true; 271 m_shouldSyncFrame = false; 272 } 273 274 if (m_forceRepaintAsyncCallbackID) { 275 m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID)); 276 m_forceRepaintAsyncCallbackID = 0; 277 } 278 279 return didSync; 280 } 281 282 void CoordinatedLayerTreeHost::clearPendingStateChanges() 283 { 284 m_state.layersToCreate.clear(); 285 m_state.layersToUpdate.clear(); 286 m_state.layersToRemove.clear(); 287 288 m_state.imagesToCreate.clear(); 289 m_state.imagesToRemove.clear(); 290 m_state.imagesToUpdate.clear(); 291 m_state.imagesToClear.clear(); 292 293 m_state.updateAtlasesToCreate.clear(); 294 m_state.updateAtlasesToRemove.clear(); 295 196 void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector) 197 { 198 m_coordinator->setVisibleContentsRect(rect, trajectoryVector); 199 scheduleLayerFlush(); 200 } 201 202 void CoordinatedLayerTreeHost::renderNextFrame() 203 { 204 m_coordinator->renderNextFrame(); 205 m_isWaitingForRenderer = false; 206 scheduleLayerFlush(); 207 } 208 209 void CoordinatedLayerTreeHost::purgeBackingStores() 210 { 211 m_coordinator->purgeBackingStores(); 212 } 213 214 void CoordinatedLayerTreeHost::willSyncLayerState(CoordinatedGraphicsLayerState& state) 215 { 296 216 #if ENABLE(CSS_SHADERS) 297 m_state.customFiltersToCreate.clear(); 298 m_state.customFiltersToRemove.clear(); 299 #endif 300 } 301 302 void CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded() 303 { 304 if (m_didInitializeRootCompositingLayer) 305 return; 306 307 m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())->id(); 308 m_didInitializeRootCompositingLayer = true; 309 m_shouldSyncFrame = true; 310 } 311 312 void CoordinatedLayerTreeHost::syncLayerState(CoordinatedLayerID id, CoordinatedGraphicsLayerState& state) 313 { 314 m_shouldSyncFrame = true; 315 316 #if ENABLE(CSS_SHADERS) 317 prepareCustomFilterProxiesIfNeeded(state); 318 #endif 319 320 m_state.layersToUpdate.append(std::make_pair(id, state)); 321 } 322 323 #if ENABLE(CSS_SHADERS) 324 void CoordinatedLayerTreeHost::prepareCustomFilterProxiesIfNeeded(CoordinatedGraphicsLayerState& state) 325 { 326 if (state.animationsChanged) { 327 GraphicsLayerAnimations& activeAnimations = state.animations; 328 for (size_t i = 0; i < activeAnimations.animations().size(); ++i) { 329 const KeyframeValueList& keyframes = activeAnimations.animations().at(i).keyframes(); 330 if (keyframes.property() != AnimatedPropertyWebkitFilter) 331 continue; 332 for (size_t j = 0; j < keyframes.size(); ++j) { 333 const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(j)); 334 checkCustomFilterProgramProxies(filterValue.value()); 335 } 336 } 337 } 217 if (state.animationsChanged) 218 prepareCustomFilterProxiesForAnimations(state.animations); 338 219 339 220 if (state.filtersChanged) 340 221 checkCustomFilterProgramProxies(state.filters); 222 #else 223 UNUSED_PARAM(state); 224 #endif 225 } 226 227 #if ENABLE(CSS_SHADERS) 228 void CoordinatedLayerTreeHost::prepareCustomFilterProxiesForAnimations(GraphicsLayerAnimations& activeAnimations) 229 { 230 for (size_t i = 0; i < activeAnimations.animations().size(); ++i) { 231 const KeyframeValueList& keyframes = activeAnimations.animations().at(i).keyframes(); 232 if (keyframes.property() != AnimatedPropertyWebkitFilter) 233 continue; 234 for (size_t j = 0; j < keyframes.size(); ++j) { 235 const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(j)); 236 checkCustomFilterProgramProxies(filterValue.value()); 237 } 238 } 341 239 } 342 240 … … 368 266 customFilterProgramProxy->setClient(this); 369 267 m_customFilterPrograms.add(customFilterProgramProxy.get()); 370 m_ state.customFiltersToCreate.append(std::make_pair(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo()));268 m_coordinator->state().customFiltersToCreate.append(std::make_pair(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo())); 371 269 } else { 372 270 // If the client was not disconnected then this coordinator must be the client for it. … … 381 279 // send a message to the other process to delete it. 382 280 m_customFilterPrograms.remove(customFilterProgramProxy); 383 m_ state.customFiltersToRemove.append(customFilterProgramProxy->id());281 m_coordinator->state().customFiltersToRemove.append(customFilterProgramProxy->id()); 384 282 } 385 283 … … 393 291 #endif // ENABLE(CSS_SHADERS) 394 292 395 void CoordinatedLayerTreeHost::detachLayer(CoordinatedGraphicsLayer* layer) 396 { 397 m_registeredLayers.remove(layer->id()); 398 399 size_t index = m_state.layersToCreate.find(layer->id()); 400 if (index != notFound) { 401 m_state.layersToCreate.remove(index); 402 return; 403 } 404 405 m_state.layersToRemove.append(layer->id()); 406 scheduleLayerFlush(); 293 void CoordinatedLayerTreeHost::didFlushRootLayer() 294 { 295 if (m_pageOverlayLayer) 296 m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); 407 297 } 408 298 409 299 void CoordinatedLayerTreeHost::performScheduledLayerFlush() 410 300 { 411 if (m_isSuspended || m_ waitingForUIProcess)412 return; 413 414 syncDisplayState();301 if (m_isSuspended || m_isWaitingForRenderer) 302 return; 303 304 m_coordinator->syncDisplayState(); 415 305 416 306 if (!m_isValid) 417 307 return; 418 308 419 if (flushPendingLayerChanges()) 420 didPerformScheduledLayerFlush(); 421 } 422 423 void CoordinatedLayerTreeHost::syncDisplayState() 424 { 425 #if ENABLE(INSPECTOR) 426 m_webPage->corePage()->inspectorController()->didBeginFrame(); 427 #endif 428 429 #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 430 // Make sure that any previously registered animation callbacks are being executed before we flush the layers. 431 m_lastAnimationServiceTime = WTF::monotonicallyIncreasingTime(); 432 m_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(m_lastAnimationServiceTime); 433 #endif 434 435 m_webPage->layoutIfNeeded(); 436 } 437 438 void CoordinatedLayerTreeHost::didPerformScheduledLayerFlush() 439 { 440 if (m_notifyAfterScheduledLayerFlush) { 309 bool didSync = m_coordinator->flushPendingLayerChanges(); 310 311 if (m_forceRepaintAsyncCallbackID) { 312 m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID)); 313 m_forceRepaintAsyncCallbackID = 0; 314 } 315 316 if (m_notifyAfterScheduledLayerFlush && didSync) { 441 317 static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers(); 442 318 m_notifyAfterScheduledLayerFlush = false; … … 453 329 ASSERT(!m_pageOverlayLayer); 454 330 455 m_pageOverlayLayer = GraphicsLayer::create( this, this);331 m_pageOverlayLayer = GraphicsLayer::create(graphicsLayerFactory(), m_coordinator.get()); 456 332 #ifndef NDEBUG 457 m_pageOverlayLayer->setName("Co ordinatedLayerTreeHostpage overlay content");333 m_pageOverlayLayer->setName("CompositingCoordinator page overlay content"); 458 334 #endif 459 335 460 336 m_pageOverlayLayer->setDrawsContent(true); 461 m_pageOverlayLayer->setSize(m_ webPage->size());462 463 m_ rootLayer->addChild(m_pageOverlayLayer.get());337 m_pageOverlayLayer->setSize(m_coordinator->rootLayer()->size()); 338 339 m_coordinator->rootLayer()->addChild(m_pageOverlayLayer.get()); 464 340 } 465 341 … … 471 347 } 472 348 473 PassRefPtr<CoordinatedImageBacking> CoordinatedLayerTreeHost::createImageBackingIfNeeded(Image* image) 474 { 475 CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image); 476 ImageBackingMap::iterator it = m_imageBackings.find(imageID); 477 RefPtr<CoordinatedImageBacking> imageBacking; 478 if (it == m_imageBackings.end()) { 479 imageBacking = CoordinatedImageBacking::create(this, image); 480 m_imageBackings.add(imageID, imageBacking); 481 } else 482 imageBacking = it->value; 483 484 return imageBacking; 485 } 486 487 void CoordinatedLayerTreeHost::createImageBacking(CoordinatedImageBackingID imageID) 488 { 489 m_state.imagesToCreate.append(imageID); 490 } 491 492 void CoordinatedLayerTreeHost::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<CoordinatedSurface> coordinatedSurface) 493 { 494 m_shouldSyncFrame = true; 495 m_state.imagesToUpdate.append(std::make_pair(imageID, coordinatedSurface)); 496 } 497 498 void CoordinatedLayerTreeHost::clearImageBackingContents(CoordinatedImageBackingID imageID) 499 { 500 m_shouldSyncFrame = true; 501 m_state.imagesToClear.append(imageID); 502 } 503 504 void CoordinatedLayerTreeHost::removeImageBacking(CoordinatedImageBackingID imageID) 505 { 506 if (m_isPurging) 507 return; 508 509 ASSERT(m_imageBackings.contains(imageID)); 510 m_imageBackings.remove(imageID); 511 512 m_state.imagesToRemove.append(imageID); 513 } 514 515 void CoordinatedLayerTreeHost::flushPendingImageBackingChanges() 516 { 517 ImageBackingMap::iterator end = m_imageBackings.end(); 518 for (ImageBackingMap::iterator iter = m_imageBackings.begin(); iter != end; ++iter) 519 iter->value->update(); 520 } 521 522 void CoordinatedLayerTreeHost::notifyAnimationStarted(const WebCore::GraphicsLayer*, double /* time */) 523 { 524 } 525 526 void CoordinatedLayerTreeHost::notifyFlushRequired(const WebCore::GraphicsLayer*) 527 { 528 scheduleLayerFlush(); 529 } 530 531 void CoordinatedLayerTreeHost::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect) 349 void CoordinatedLayerTreeHost::paintLayerContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, const IntRect& clipRect) 532 350 { 533 351 if (graphicsLayer == m_pageOverlayLayer) { … … 539 357 } 540 358 541 PassOwnPtr<GraphicsLayer> CoordinatedLayerTreeHost::createGraphicsLayer(GraphicsLayerClient* client) 542 { 543 CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client); 544 layer->setCoordinator(this); 545 m_registeredLayers.add(layer->id(), layer); 546 m_state.layersToCreate.append(layer->id()); 547 layer->setNeedsVisibleRectAdjustment(); 548 scheduleLayerFlush(); 549 return adoptPtr(layer); 359 void CoordinatedLayerTreeHost::commitSceneState(WebCore::CoordinatedGraphicsState& state) 360 { 361 m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(state)); 362 m_isWaitingForRenderer = true; 550 363 } 551 364 … … 555 368 } 556 369 557 float CoordinatedLayerTreeHost::deviceScaleFactor() const558 {559 return m_webPage->deviceScaleFactor();560 }561 562 float CoordinatedLayerTreeHost::pageScaleFactor() const563 {564 return m_webPage->pageScaleFactor();565 }566 567 370 bool LayerTreeHost::supportsAcceleratedCompositing() 568 371 { … … 570 373 } 571 374 572 void CoordinatedLayerTreeHost::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> coordinatedSurface)573 {574 m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, coordinatedSurface));575 }576 577 void CoordinatedLayerTreeHost::removeUpdateAtlas(uint32_t atlasID)578 {579 if (m_isPurging)580 return;581 m_state.updateAtlasesToRemove.append(atlasID);582 }583 584 WebCore::FloatRect CoordinatedLayerTreeHost::visibleContentsRect() const585 {586 return m_visibleContentsRect;587 }588 589 CoordinatedGraphicsLayer* CoordinatedLayerTreeHost::mainContentsLayer()590 {591 if (!m_rootCompositingLayer)592 return 0;593 594 return toCoordinatedGraphicsLayer(m_rootCompositingLayer)->findFirstDescendantWithContentsRecursively();595 }596 597 void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)598 {599 // A zero trajectoryVector indicates that tiles all around the viewport are requested.600 if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())601 contentsLayer->setVisibleContentRectTrajectoryVector(trajectoryVector);602 603 bool contentsRectDidChange = rect != m_visibleContentsRect;604 if (contentsRectDidChange) {605 m_visibleContentsRect = rect;606 607 LayerMap::iterator end = m_registeredLayers.end();608 for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it) {609 it->value->setNeedsVisibleRectAdjustment();610 }611 }612 613 scheduleLayerFlush();614 if (m_webPage->useFixedLayout()) {615 // Round the rect instead of enclosing it to make sure that its size stays616 // the same while panning. This can have nasty effects on layout.617 m_webPage->setFixedVisibleContentRect(roundedIntRect(rect));618 }619 }620 621 375 void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged() 622 376 { 623 m_ rootLayer->deviceOrPageScaleFactorChanged();377 m_coordinator->deviceOrPageScaleFactorChanged(); 624 378 if (m_pageOverlayLayer) 625 379 m_pageOverlayLayer->deviceOrPageScaleFactorChanged(); … … 632 386 GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory() 633 387 { 634 return this;388 return m_coordinator.get(); 635 389 } 636 390 … … 638 392 void CoordinatedLayerTreeHost::scheduleAnimation() 639 393 { 640 if (m_ waitingForUIProcess)394 if (m_isWaitingForRenderer) 641 395 return; 642 396 … … 644 398 return; 645 399 646 // According to the requestAnimationFrame spec, rAF callbacks should not be faster than 60FPS. 647 static const double MinimalTimeoutForAnimations = 1. / 60.; 648 m_layerFlushTimer.startOneShot(std::max<double>(0., MinimalTimeoutForAnimations - WTF::monotonicallyIncreasingTime() + m_lastAnimationServiceTime)); 400 m_layerFlushTimer.startOneShot(m_coordinator->nextAnimationServiceTime()); 649 401 scheduleLayerFlush(); 650 402 } 651 403 #endif 652 404 653 void CoordinatedLayerTreeHost::renderNextFrame()654 {655 m_waitingForUIProcess = false;656 scheduleLayerFlush();657 for (unsigned i = 0; i < m_updateAtlases.size(); ++i)658 m_updateAtlases[i]->didSwapBuffers();659 }660 661 void CoordinatedLayerTreeHost::purgeBackingStores()662 {663 TemporaryChange<bool> purgingToggle(m_isPurging, true);664 665 LayerMap::iterator end = m_registeredLayers.end();666 for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)667 it->value->purgeBackingStores();668 669 m_imageBackings.clear();670 m_updateAtlases.clear();671 }672 673 bool CoordinatedLayerTreeHost::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client)674 {675 for (unsigned i = 0; i < m_updateAtlases.size(); ++i) {676 UpdateAtlas* atlas = m_updateAtlases[i].get();677 if (atlas->supportsAlpha() == (flags & CoordinatedSurface::SupportsAlpha)) {678 // This will false if there is no available buffer space.679 if (atlas->paintOnAvailableBuffer(size, atlasID, offset, client))680 return true;681 }682 }683 684 static const int ScratchBufferDimension = 1024; // Should be a power of two.685 m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags)));686 scheduleReleaseInactiveAtlases();687 return m_updateAtlases.last()->paintOnAvailableBuffer(size, atlasID, offset, client);688 }689 690 const double ReleaseInactiveAtlasesTimerInterval = 0.5;691 692 void CoordinatedLayerTreeHost::scheduleReleaseInactiveAtlases()693 {694 if (!m_releaseInactiveAtlasesTimer.isActive())695 m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval);696 }697 698 void CoordinatedLayerTreeHost::releaseInactiveAtlasesTimerFired(Timer<CoordinatedLayerTreeHost>*)699 {700 // We always want to keep one atlas for non-composited content.701 OwnPtr<UpdateAtlas> atlasToKeepAnyway;702 bool foundActiveAtlasForNonCompositedContent = false;703 for (int i = m_updateAtlases.size() - 1; i >= 0; --i) {704 UpdateAtlas* atlas = m_updateAtlases[i].get();705 if (!atlas->isInUse())706 atlas->addTimeInactive(ReleaseInactiveAtlasesTimerInterval);707 bool usableForNonCompositedContent = !atlas->supportsAlpha();708 if (atlas->isInactive()) {709 if (!foundActiveAtlasForNonCompositedContent && !atlasToKeepAnyway && usableForNonCompositedContent)710 atlasToKeepAnyway = m_updateAtlases[i].release();711 m_updateAtlases.remove(i);712 } else if (usableForNonCompositedContent)713 foundActiveAtlasForNonCompositedContent = true;714 }715 716 if (!foundActiveAtlasForNonCompositedContent && atlasToKeepAnyway)717 m_updateAtlases.append(atlasToKeepAnyway.release());718 719 if (m_updateAtlases.size() <= 1)720 m_releaseInactiveAtlasesTimer.stop();721 }722 723 405 void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color) 724 406 { … … 728 410 void CoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) 729 411 { 730 LayerMap::iterator i = m_registeredLayers.find(layerID); 731 if (i == m_registeredLayers.end()) 732 return; 733 734 i->value->commitScrollOffset(offset); 412 m_coordinator->commitScrollOffset(layerID, offset); 735 413 } 736 414 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h
r151262 r152074 26 26 #include "LayerTreeContext.h" 27 27 #include "LayerTreeHost.h" 28 #include "Timer.h" 29 #include <WebCore/CoordinatedGraphicsLayer.h> 30 #include <WebCore/CoordinatedGraphicsState.h> 31 #include <WebCore/CoordinatedImageBacking.h> 32 #include <WebCore/GraphicsLayerClient.h> 28 #include <WebCore/CompositingCoordinator.h> 33 29 #include <WebCore/GraphicsLayerFactory.h> 34 #include <WebCore/UpdateAtlas.h>35 30 #include <wtf/OwnPtr.h> 36 31 … … 47 42 class WebPage; 48 43 49 class CoordinatedLayerTreeHost : public LayerTreeHost, WebCore::GraphicsLayerClient 50 , public WebCore::CoordinatedGraphicsLayerClient 51 , public WebCore::CoordinatedImageBacking::Client 52 , public WebCore::UpdateAtlas::Client 53 , public WebCore::GraphicsLayerFactory 44 class CoordinatedLayerTreeHost : public LayerTreeHost, public WebCore::CompositingCoordinator::Client 54 45 #if ENABLE(CSS_SHADERS) 55 46 , WebCustomFilterProgramProxyClient … … 85 76 virtual void pageBackgroundTransparencyChanged() OVERRIDE; 86 77 87 virtual void renderNextFrame();88 virtual void purgeBackingStores();89 virtual void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);90 78 virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&); 91 79 virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE; … … 99 87 static PassRefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags); 100 88 101 void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset);102 103 89 protected: 104 90 explicit CoordinatedLayerTreeHost(WebPage*); 105 91 106 92 private: 107 // GraphicsLayerClient108 virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time);109 virtual void notifyFlushRequired(const WebCore::GraphicsLayer*);110 virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect);111 virtual float deviceScaleFactor() const OVERRIDE;112 virtual float pageScaleFactor() const OVERRIDE;113 114 // CoordinatedImageBacking::Client115 virtual void createImageBacking(WebCore::CoordinatedImageBackingID) OVERRIDE;116 virtual void updateImageBacking(WebCore::CoordinatedImageBackingID, PassRefPtr<WebCore::CoordinatedSurface>) OVERRIDE;117 virtual void clearImageBackingContents(WebCore::CoordinatedImageBackingID) OVERRIDE;118 virtual void removeImageBacking(WebCore::CoordinatedImageBackingID) OVERRIDE;119 120 void flushPendingImageBackingChanges();121 122 // CoordinatedGraphicsLayerClient123 virtual bool isFlushingLayerChanges() const OVERRIDE { return m_isFlushingLayerChanges; }124 virtual WebCore::FloatRect visibleContentsRect() const;125 virtual PassRefPtr<WebCore::CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) OVERRIDE;126 virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*);127 virtual bool paintToSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& /* atlasID */, WebCore::IntPoint&, WebCore::CoordinatedSurface::Client*) OVERRIDE;128 virtual void syncLayerState(WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayerState&);129 130 // UpdateAtlas::Client131 virtual void createUpdateAtlas(uint32_t atlasID, PassRefPtr<WebCore::CoordinatedSurface>) OVERRIDE;132 virtual void removeUpdateAtlas(uint32_t atlasID) OVERRIDE;133 134 // GraphicsLayerFactory135 virtual PassOwnPtr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE;136 137 93 // CoordinatedLayerTreeHost 138 void initializeRootCompositingLayerIfNeeded();139 94 void createPageOverlayLayer(); 140 95 void destroyPageOverlayLayer(); 141 bool flushPendingLayerChanges();142 void clearPendingStateChanges();143 96 void cancelPendingLayerFlush(); 144 97 void performScheduledLayerFlush(); 145 void didPerformScheduledLayerFlush(); 146 void syncDisplayState(); 98 void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&); 99 void renderNextFrame(); 100 void purgeBackingStores(); 101 void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset); 102 147 103 void layerFlushTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*); 148 104 149 void scheduleReleaseInactiveAtlases(); 150 151 void releaseInactiveAtlasesTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*); 105 // CompositingCoordinator::Client 106 virtual void didFlushRootLayer() OVERRIDE; 107 virtual void willSyncLayerState(WebCore::CoordinatedGraphicsLayerState&) OVERRIDE; 108 virtual void notifyFlushRequired() OVERRIDE { scheduleLayerFlush(); }; 109 virtual void commitSceneState(WebCore::CoordinatedGraphicsState&) OVERRIDE; 110 virtual void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) OVERRIDE; 152 111 153 112 #if ENABLE(CSS_SHADERS) 154 void prepareCustomFilterProxies IfNeeded(WebCore::CoordinatedGraphicsLayerState&);113 void prepareCustomFilterProxiesForAnimations(WebCore::GraphicsLayerAnimations&); 155 114 156 115 // WebCustomFilterProgramProxyClient … … 161 120 #endif 162 121 163 OwnPtr<WebCore::GraphicsLayer> m_rootLayer; 164 WebCore::GraphicsLayer* m_rootCompositingLayer; 122 OwnPtr<WebCore::CompositingCoordinator> m_coordinator; 165 123 166 124 // The page overlay layer. Will be null if there's no page overlay. 167 125 OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer; 168 126 RefPtr<PageOverlay> m_pageOverlay; 169 170 WebCore::CoordinatedGraphicsState m_state;171 172 typedef HashMap<WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayer*> LayerMap;173 LayerMap m_registeredLayers;174 typedef HashMap<WebCore::CoordinatedImageBackingID, RefPtr<WebCore::CoordinatedImageBacking> > ImageBackingMap;175 ImageBackingMap m_imageBackings;176 Vector<OwnPtr<WebCore::UpdateAtlas> > m_updateAtlases;177 127 178 128 #if ENABLE(CSS_SHADERS) … … 182 132 bool m_notifyAfterScheduledLayerFlush; 183 133 bool m_isValid; 184 // We don't send the messages related to releasing resources to UI Process during purging, because UI Process already had removed all resources.185 bool m_isPurging;186 bool m_isFlushingLayerChanges;187 188 bool m_waitingForUIProcess;189 134 bool m_isSuspended; 190 WebCore::FloatRect m_visibleContentsRect;135 bool m_isWaitingForRenderer; 191 136 192 137 LayerTreeContext m_layerTreeContext; 193 bool m_shouldSyncFrame; 194 bool m_didInitializeRootCompositingLayer; 138 195 139 WebCore::Timer<CoordinatedLayerTreeHost> m_layerFlushTimer; 196 WebCore::Timer<CoordinatedLayerTreeHost> m_releaseInactiveAtlasesTimer;197 140 bool m_layerFlushSchedulingEnabled; 198 141 uint64_t m_forceRepaintAsyncCallbackID; 199 bool m_animationsLocked;200 201 #if ENABLE(REQUEST_ANIMATION_FRAME)202 double m_lastAnimationServiceTime;203 #endif204 142 }; 205 143 -
trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
r149004 r152074 88 88 89 89 #if USE(COORDINATED_GRAPHICS) 90 virtual void setVisibleContentsRect(const WebCore::FloatRect&, float /* scale */, const WebCore::FloatPoint&) { }91 virtual void renderNextFrame() { }92 virtual void purgeBackingStores() { }93 90 virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) = 0; 94 91 #endif
Note: See TracChangeset
for help on using the changeset viewer.