Changeset 291733 in webkit
- Timestamp:
- Mar 22, 2022, 7:06:04 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 1 added
- 14 edited
-
ChangeLog (modified) (1 diff)
-
GPUProcess/graphics/RemoteRenderingBackend.cpp (modified) (5 diffs)
-
GPUProcess/graphics/RemoteRenderingBackend.h (modified) (3 diffs)
-
GPUProcess/graphics/RemoteRenderingBackend.messages.in (modified) (1 diff)
-
Scripts/webkit/messages.py (modified) (1 diff)
-
Shared/RemoteLayerTree/RemoteLayerBackingStore.h (modified) (3 diffs)
-
Shared/RemoteLayerTree/RemoteLayerBackingStore.mm (modified) (4 diffs)
-
Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h (modified) (1 diff)
-
Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm (modified) (1 diff)
-
Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.h (modified) (1 diff)
-
Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.mm (modified) (1 diff)
-
WebKit.xcodeproj/project.pbxproj (modified) (2 diffs)
-
WebProcess/GPU/graphics/PrepareBackingStoreBuffersData.h (added)
-
WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp (modified) (3 diffs)
-
WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r291732 r291733 1 2022-03-22 Simon Fraser <simon.fraser@apple.com> 2 3 Swap all RemoteLayerBackingStore buffers in a single IPC 4 https://bugs.webkit.org/show_bug.cgi?id=238210 5 6 Reviewed by Tim Horton. 7 8 PrepareBuffersForDisplay is a sync IPC (since we need the result before painting), and sync 9 IPC per-layer has performance impact. So group all the swapping into a single IPC with the 10 GPU Process. 11 12 The PrepareBuffersForDisplay message now takes a vector of 13 PrepareBackingStoreBuffersInputData, and returns a vector of 14 PrepareBackingStoreBuffersOutputData. Swapped buffers are applied to the 15 RemoteLayerBackingStore as before, with a minor change in the place that setNeedsDisplay() 16 is called in the case where we need a full display. 17 18 * GPUProcess/graphics/RemoteRenderingBackend.cpp: 19 (WebKit::RemoteRenderingBackend::prepareBuffersForDisplay): 20 (WebKit::RemoteRenderingBackend::prepareLayerBuffersForDisplay): 21 * GPUProcess/graphics/RemoteRenderingBackend.h: 22 * GPUProcess/graphics/RemoteRenderingBackend.messages.in: 23 * Scripts/webkit/messages.py: 24 (headers_for_type): 25 * Shared/RemoteLayerTree/RemoteLayerBackingStore.h: 26 * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm: 27 (WebKit::RemoteLayerBackingStore::applySwappedBuffers): 28 (WebKit::RemoteLayerBackingStore::performDelegatedLayerDisplay): 29 (WebKit::RemoteLayerBackingStore::prepareToDisplay): 30 (WebKit::RemoteLayerBackingStore::ensureFrontBuffer): 31 (WebKit::RemoteLayerBackingStore::prepareBuffers): 32 (WebKit::operator<<): Deleted. 33 * Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h: 34 * Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm: 35 (WebKit::RemoteLayerBackingStoreCollection::prepareBackingStoreBuffers): Deleted. 36 * Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.h: 37 * Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.mm: 38 (WebKit::RemoteLayerWithRemoteRenderingBackingStoreCollection::prepareBackingStoresForDisplay): 39 (WebKit::RemoteLayerWithRemoteRenderingBackingStoreCollection::prepareBackingStoreBuffers): Deleted. 40 * WebKit.xcodeproj/project.pbxproj: 41 * WebProcess/GPU/graphics/PrepareBackingStoreBuffersData.h: Added. 42 (WebKit::PrepareBackingStoreBuffersInputData::encode const): 43 (WebKit::PrepareBackingStoreBuffersInputData::decode): 44 (WebKit::PrepareBackingStoreBuffersOutputData::encode const): 45 (WebKit::PrepareBackingStoreBuffersOutputData::decode): 46 * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp: 47 (WebKit::RemoteRenderingBackendProxy::prepareBuffersForDisplay): 48 * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h: 49 1 50 2022-03-22 Sihui Liu <sihui_liu@apple.com> 2 51 -
trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp
r291243 r291733 400 400 } 401 401 402 void RemoteRenderingBackend::prepareBuffersForDisplay(Vector<PrepareBackingStoreBuffersInputData> swapBuffersInput, CompletionHandler<void(const Vector<PrepareBackingStoreBuffersOutputData>&)>&& completionHandler) 403 { 404 Vector<PrepareBackingStoreBuffersOutputData> outputData; 405 outputData.resizeToFit(swapBuffersInput.size()); 406 407 for (unsigned i = 0; i < swapBuffersInput.size(); ++i) 408 prepareLayerBuffersForDisplay(swapBuffersInput[i], outputData[i]); 409 410 completionHandler(outputData); 411 } 412 402 413 // This is the GPU Process version of RemoteLayerBackingStore::prepareBuffers(). 403 void RemoteRenderingBackend::prepare BuffersForDisplay(const BufferIdentifierSet& bufferSet, bool supportsPartialRepaint, bool hasEmptyDirtyRegion, CompletionHandler<void(const BufferIdentifierSet& swappedBufferSet, std::optional<ImageBufferBackendHandle>&& frontBufferHandle, SwapBuffersDisplayRequirement prepareResult)>&& completionHandler)414 void RemoteRenderingBackend::prepareLayerBuffersForDisplay(const PrepareBackingStoreBuffersInputData& inputData, PrepareBackingStoreBuffersOutputData& outputData) 404 415 { 405 416 auto fetchBuffer = [&](std::optional<RenderingResourceIdentifier> identifier) -> ImageBuffer* { … … 413 424 }; 414 425 415 auto frontBuffer = fetchBuffer( bufferSet.front);416 auto backBuffer = fetchBuffer( bufferSet.back);417 auto secondaryBackBuffer = fetchBuffer( bufferSet.secondaryBack);426 auto frontBuffer = fetchBuffer(inputData.bufferSet.front); 427 auto backBuffer = fetchBuffer(inputData.bufferSet.back); 428 auto secondaryBackBuffer = fetchBuffer(inputData.bufferSet.secondaryBack); 418 429 419 430 LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << "GPU Process: RemoteRenderingBackend::prepareBuffersForDisplay - front " 420 << bufferSet.front << " (in-use " << (frontBuffer && frontBuffer->isInUse()) << ") "421 << bufferSet.back << " (in-use " << (backBuffer && backBuffer->isInUse()) << ") "422 << bufferSet.secondaryBack << " (in-use " << (secondaryBackBuffer && secondaryBackBuffer->isInUse()) << ") ");431 << inputData.bufferSet.front << " (in-use " << (frontBuffer && frontBuffer->isInUse()) << ") " 432 << inputData.bufferSet.back << " (in-use " << (backBuffer && backBuffer->isInUse()) << ") " 433 << inputData.bufferSet.secondaryBack << " (in-use " << (secondaryBackBuffer && secondaryBackBuffer->isInUse()) << ") "); 423 434 424 435 bool needsFullDisplay = false; … … 430 441 } 431 442 432 if (frontBuffer && !needsFullDisplay && hasEmptyDirtyRegion) {443 if (frontBuffer && !needsFullDisplay && inputData.hasEmptyDirtyRegion) { 433 444 // No swap necessary, but we do need to return the front buffer handle. 434 autofrontBufferHandle = handleFromBuffer(*frontBuffer);435 auto resultBufferSet = BufferIdentifierSet { bufferIdentifer(frontBuffer), bufferIdentifer(backBuffer), bufferIdentifer(secondaryBackBuffer) };436 completionHandler(resultBufferSet, WTFMove(frontBufferHandle), SwapBuffersDisplayRequirement::NeedsNoDisplay);445 outputData.frontBufferHandle = handleFromBuffer(*frontBuffer); 446 outputData.bufferSet = BufferIdentifierSet { bufferIdentifer(frontBuffer), bufferIdentifer(backBuffer), bufferIdentifer(secondaryBackBuffer) }; 447 outputData.displayRequirement = SwapBuffersDisplayRequirement::NeedsNoDisplay; 437 448 return; 438 449 } 439 450 440 if (!frontBuffer || ! supportsPartialRepaint)451 if (!frontBuffer || !inputData.supportsPartialRepaint) 441 452 needsFullDisplay = true; 442 453 … … 453 464 std::swap(frontBuffer, backBuffer); 454 465 455 std::optional<ImageBufferBackendHandle> frontBufferHandle;466 outputData.bufferSet = BufferIdentifierSet { bufferIdentifer(frontBuffer), bufferIdentifer(backBuffer), bufferIdentifer(secondaryBackBuffer) }; 456 467 if (frontBuffer) { 457 468 auto previousState = frontBuffer->setNonVolatile(); … … 459 470 needsFullDisplay = true; 460 471 461 frontBufferHandle = handleFromBuffer(*frontBuffer); 462 } 463 464 auto resultBufferSet = BufferIdentifierSet { bufferIdentifer(frontBuffer), bufferIdentifer(backBuffer), bufferIdentifer(secondaryBackBuffer) }; 472 outputData.frontBufferHandle = handleFromBuffer(*frontBuffer); 473 } else 474 needsFullDisplay = true; 465 475 466 476 LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << "GPU Process: prepareBuffersForDisplay - swapped from [" 467 << bufferSet.front << ", " << bufferSet.back << ", " << bufferSet.secondaryBack << "] to [" 468 << resultBufferSet.front << ", " << resultBufferSet.back << ", " << resultBufferSet.secondaryBack << "]"); 469 470 auto displayRequirement = needsFullDisplay ? SwapBuffersDisplayRequirement::NeedsFullDisplay : SwapBuffersDisplayRequirement::NeedsNormalDisplay; 471 completionHandler(resultBufferSet, WTFMove(frontBufferHandle), displayRequirement); 477 << inputData.bufferSet.front << ", " << inputData.bufferSet.back << ", " << inputData.bufferSet.secondaryBack << "] to [" 478 << outputData.bufferSet.front << ", " << outputData.bufferSet.back << ", " << outputData.bufferSet.secondaryBack << "]"); 479 480 outputData.displayRequirement = needsFullDisplay ? SwapBuffersDisplayRequirement::NeedsFullDisplay : SwapBuffersDisplayRequirement::NeedsNormalDisplay; 472 481 } 473 482 -
trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h
r291243 r291733 69 69 class RemoteDisplayListRecorder; 70 70 struct BufferIdentifierSet; 71 struct PrepareBackingStoreBuffersInputData; 72 struct PrepareBackingStoreBuffersOutputData; 71 73 struct RemoteRenderingBackendCreationParameters; 72 74 enum class SwapBuffersDisplayRequirement : uint8_t; … … 121 123 void finalizeRenderingUpdate(RenderingUpdateID); 122 124 void markSurfacesVolatile(const Vector<WebCore::RenderingResourceIdentifier>&, CompletionHandler<void(const Vector<WebCore::RenderingResourceIdentifier>& markedVolatileBufferIdentifiers)>&&); 123 124 void prepareBuffersForDisplay(const BufferIdentifierSet& bufferSet, bool supportsPartialRepaint, bool hasEmptyDirtyRegion, CompletionHandler<void(const BufferIdentifierSet& swappedBufferSet, std::optional<ImageBufferBackendHandle>&& frontBufferHandle, SwapBuffersDisplayRequirement prepareResult)>&&); 125 void prepareBuffersForDisplay(Vector<PrepareBackingStoreBuffersInputData> swapBuffersInput, CompletionHandler<void(const Vector<PrepareBackingStoreBuffersOutputData>&)>&&); 125 126 126 127 // Received messages translated to use QualifiedRenderingResourceIdentifier. … … 133 134 void releaseRemoteResourceWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier); 134 135 void cacheFontWithQualifiedIdentifier(Ref<WebCore::Font>&&, QualifiedRenderingResourceIdentifier); 136 137 void prepareLayerBuffersForDisplay(const PrepareBackingStoreBuffersInputData&, PrepareBackingStoreBuffersOutputData&); 135 138 136 139 Ref<IPC::StreamConnectionWorkQueue> m_workQueue; -
trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in
r291243 r291733 38 38 ReleaseRemoteResource(WebCore::RenderingResourceIdentifier renderingResourceIdentifier) 39 39 40 PrepareBuffersForDisplay( struct WebKit::BufferIdentifierSet bufferSet, bool supportsPartialRepaint, bool hasEmptyDirtyRegion) -> (struct WebKit::BufferIdentifierSet swappedBufferSet, std::optional<WebKit::ImageBufferBackendHandle> frontBufferHandle, enum:uint8_t WebKit::SwapBuffersDisplayRequirement prepareResult) Synchronous NotStreamEncodable NotStreamEncodableReply40 PrepareBuffersForDisplay(Vector<WebKit::PrepareBackingStoreBuffersInputData> swapBuffersInput) -> (Vector<WebKit::PrepareBackingStoreBuffersOutputData> swapBuffersOutput) Synchronous NotStreamEncodable NotStreamEncodableReply 41 41 42 42 MarkSurfacesVolatile(Vector<WebCore::RenderingResourceIdentifier> renderingResourceIdentifiers) -> (Vector<WebCore::RenderingResourceIdentifier> markedVolatileBufferIdentifiers) Synchronous -
trunk/Source/WebKit/Scripts/webkit/messages.py
r291136 r291733 890 890 'WebKit::PaymentSetupConfiguration': ['"PaymentSetupConfigurationWebKit.h"'], 891 891 'WebKit::PaymentSetupFeatures': ['"ApplePayPaymentSetupFeaturesWebKit.h"'], 892 'WebKit::PrepareBackingStoreBuffersInputData': ['"PrepareBackingStoreBuffersData.h"'], 893 'WebKit::PrepareBackingStoreBuffersOutputData': ['"PrepareBackingStoreBuffersData.h"'], 892 894 'WebKit::RespectSelectionAnchor': ['"GestureTypes.h"'], 893 895 'WebKit::RemoteVideoFrameReadReference': ['"RemoteVideoFrameIdentifier.h"'], -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h
r291599 r291733 68 68 void setContents(WTF::MachSendRight&& surfaceHandle); 69 69 70 SwapBuffersDisplayRequirement prepareBuffers(bool hasEmptyDirtyRegion);71 72 70 // Returns true if we need encode the buffer. 73 71 bool layerWillBeDisplayed(); 74 72 bool needsDisplay() const; 75 73 74 bool performDelegatedLayerDisplay(); 76 75 void prepareToDisplay(); 77 76 void paintContents(); … … 100 99 101 100 // Just for RemoteBackingStoreCollection. 102 void applySwappedBuffers(RefPtr<WebCore::ImageBuffer>&& front, RefPtr<WebCore::ImageBuffer>&& back, RefPtr<WebCore::ImageBuffer>&& secondaryBack );101 void applySwappedBuffers(RefPtr<WebCore::ImageBuffer>&& front, RefPtr<WebCore::ImageBuffer>&& back, RefPtr<WebCore::ImageBuffer>&& secondaryBack, SwapBuffersDisplayRequirement); 103 102 WebCore::SetNonVolatileResult swapToValidFrontBuffer(); 104 103 … … 144 143 bool setBufferVolatile(Buffer&); 145 144 WebCore::SetNonVolatileResult setBufferNonVolatile(Buffer&); 145 146 SwapBuffersDisplayRequirement prepareBuffers(); 147 void ensureFrontBuffer(); 148 void dirtyRepaintCounterIfNecessary(); 146 149 147 150 PlatformCALayerRemote* m_layer; -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm
r291599 r291733 250 250 251 251 // Called after buffer swapping in the GPU process. 252 void RemoteLayerBackingStore::applySwappedBuffers(RefPtr<WebCore::ImageBuffer>&& front, RefPtr<WebCore::ImageBuffer>&& back, RefPtr<WebCore::ImageBuffer>&& secondaryBack )252 void RemoteLayerBackingStore::applySwappedBuffers(RefPtr<WebCore::ImageBuffer>&& front, RefPtr<WebCore::ImageBuffer>&& back, RefPtr<WebCore::ImageBuffer>&& secondaryBack, SwapBuffersDisplayRequirement displayRequirement) 253 253 { 254 254 ASSERT(WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM)); 255 m_contentsBufferHandle = std::nullopt; 255 256 256 257 m_frontBuffer.imageBuffer = WTFMove(front); 257 258 m_backBuffer.imageBuffer = WTFMove(back); 258 259 m_secondaryBackBuffer.imageBuffer = WTFMove(secondaryBack); 260 261 if (displayRequirement == SwapBuffersDisplayRequirement::NeedsNoDisplay) 262 return; 263 264 if (displayRequirement == SwapBuffersDisplayRequirement::NeedsFullDisplay) 265 setNeedsDisplay(); 266 267 dirtyRepaintCounterIfNecessary(); 268 ensureFrontBuffer(); 259 269 } 260 270 … … 273 283 } 274 284 275 #if !LOG_DISABLED276 static TextStream& operator<<(TextStream& ts, SwapBuffersDisplayRequirement result)277 {278 switch (result) {279 case SwapBuffersDisplayRequirement::NeedsFullDisplay: ts << "full display"; break;280 case SwapBuffersDisplayRequirement::NeedsNormalDisplay: ts << "normal display"; break;281 case SwapBuffersDisplayRequirement::NeedsNoDisplay: ts << "no display"; break;282 }283 return ts;284 }285 #endif286 287 285 bool RemoteLayerBackingStore::needsDisplay() const 288 286 { … … 303 301 } 304 302 305 void RemoteLayerBackingStore::prepareToDisplay() 306 { 307 ASSERT(!m_frontBufferFlushers.size()); 308 309 auto* collection = backingStoreCollection(); 310 if (!collection) { 311 ASSERT_NOT_REACHED(); 312 return; 313 } 314 315 ASSERT(collection->backingStoreNeedsDisplay(*this)); 316 317 LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << "RemoteLayerBackingStore " << m_layer->layerID() << " prepareToDisplay()"); 318 303 bool RemoteLayerBackingStore::performDelegatedLayerDisplay() 304 { 319 305 auto& layerOwner = *m_layer->owner(); 320 306 if (layerOwner.platformCALayerDelegatesDisplay(m_layer)) { … … 322 308 layerOwner.platformCALayerLayerDisplay(m_layer); 323 309 layerOwner.platformCALayerLayerDidDisplay(m_layer); 324 return; 325 } 326 327 m_contentsBufferHandle = std::nullopt; 328 329 auto displayRequirement = collection->prepareBackingStoreBuffers(*this); 330 331 LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << "RemoteLayerBackingStore " << m_layer->layerID() << " prepareToDisplay() - " << displayRequirement); 332 333 ASSERT(displayRequirement != SwapBuffersDisplayRequirement::NeedsNoDisplay); 310 return true; 311 } 312 313 return false; 314 } 315 316 void RemoteLayerBackingStore::prepareToDisplay() 317 { 318 ASSERT(!WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM)); 319 ASSERT(!m_frontBufferFlushers.size()); 320 321 auto* collection = backingStoreCollection(); 322 if (!collection) { 323 ASSERT_NOT_REACHED(); 324 return; 325 } 326 327 ASSERT(collection->backingStoreNeedsDisplay(*this)); 328 329 LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << "RemoteLayerBackingStore " << m_layer->layerID() << " prepareToDisplay()"); 330 331 if (performDelegatedLayerDisplay()) 332 return; 333 334 auto displayRequirement = prepareBuffers(); 335 if (displayRequirement == SwapBuffersDisplayRequirement::NeedsNoDisplay) 336 return; 334 337 335 338 if (displayRequirement == SwapBuffersDisplayRequirement::NeedsFullDisplay) 336 339 setNeedsDisplay(); 337 340 338 if (layerOwner.platformCALayerShowRepaintCounter(m_layer)) { 341 dirtyRepaintCounterIfNecessary(); 342 ensureFrontBuffer(); 343 } 344 345 void RemoteLayerBackingStore::dirtyRepaintCounterIfNecessary() 346 { 347 if (m_layer->owner()->platformCALayerShowRepaintCounter(m_layer)) { 339 348 WebCore::IntRect indicatorRect(0, 0, 52, 27); 340 349 m_dirtyRegion.unite(indicatorRect); 341 350 } 342 351 } 352 353 void RemoteLayerBackingStore::ensureFrontBuffer() 354 { 355 if (m_frontBuffer.imageBuffer) 356 return; 357 358 auto* collection = backingStoreCollection(); 359 if (!collection) { 360 ASSERT_NOT_REACHED(); 361 return; 362 } 363 364 m_frontBuffer.imageBuffer = collection->allocateBufferForBackingStore(*this); 365 366 #if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER) 367 if (m_includeDisplayList == IncludeDisplayList::Yes) 368 m_frontBuffer.displayListImageBuffer = WebCore::ConcreteImageBuffer<CGDisplayListImageBufferBackend>::create(m_size, m_scale, WebCore::DestinationColorSpace::SRGB(), pixelFormat(), nullptr); 369 #endif 370 } 371 372 #if !LOG_DISABLED 373 static TextStream& operator<<(TextStream& ts, SwapBuffersDisplayRequirement result) 374 { 375 switch (result) { 376 case SwapBuffersDisplayRequirement::NeedsFullDisplay: ts << "full display"; break; 377 case SwapBuffersDisplayRequirement::NeedsNormalDisplay: ts << "normal display"; break; 378 case SwapBuffersDisplayRequirement::NeedsNoDisplay: ts << "no display"; break; 379 } 380 return ts; 381 } 382 #endif 383 384 SwapBuffersDisplayRequirement RemoteLayerBackingStore::prepareBuffers() 385 { 386 ASSERT(!WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM)); 387 m_contentsBufferHandle = std::nullopt; 388 389 auto displayRequirement = SwapBuffersDisplayRequirement::NeedsNoDisplay; 390 391 // Make the previous front buffer non-volatile early, so that we can dirty the whole layer if it comes back empty. 392 if (!hasFrontBuffer() || setFrontBufferNonVolatile() == WebCore::SetNonVolatileResult::Empty) 393 displayRequirement = SwapBuffersDisplayRequirement::NeedsFullDisplay; 394 else if (!hasEmptyDirtyRegion()) 395 displayRequirement = SwapBuffersDisplayRequirement::NeedsNormalDisplay; 396 397 if (displayRequirement == SwapBuffersDisplayRequirement::NeedsNoDisplay) 398 return displayRequirement; 399 400 if (!supportsPartialRepaint()) 401 displayRequirement = SwapBuffersDisplayRequirement::NeedsFullDisplay; 402 403 auto result = swapToValidFrontBuffer(); 404 if (!hasFrontBuffer() || result == WebCore::SetNonVolatileResult::Empty) 405 displayRequirement = SwapBuffersDisplayRequirement::NeedsFullDisplay; 406 407 LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << "RemoteLayerBackingStore " << m_layer->layerID() << " prepareBuffers() - " << displayRequirement); 408 return displayRequirement; 409 } 410 411 void RemoteLayerBackingStore::paintContents() 412 { 343 413 if (!m_frontBuffer.imageBuffer) { 344 m_frontBuffer.imageBuffer = collection->allocateBufferForBackingStore(*this); 345 346 #if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER) 347 if (m_includeDisplayList == IncludeDisplayList::Yes) 348 m_frontBuffer.displayListImageBuffer = WebCore::ConcreteImageBuffer<CGDisplayListImageBufferBackend>::create(m_size, m_scale, WebCore::DestinationColorSpace::SRGB(), pixelFormat(), nullptr); 349 #endif 350 } 351 } 352 353 SwapBuffersDisplayRequirement RemoteLayerBackingStore::prepareBuffers(bool hasEmptyDirtyRegion) 354 { 355 ASSERT(!WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM)); 356 357 bool needsFullDisplay = false; 358 359 // Make the previous front buffer non-volatile early, so that we can dirty the whole layer if it comes back empty. 360 if (setFrontBufferNonVolatile() == WebCore::SetNonVolatileResult::Empty) 361 needsFullDisplay = true; 362 363 if (!needsFullDisplay && hasEmptyDirtyRegion) 364 return SwapBuffersDisplayRequirement::NeedsNoDisplay; 365 366 if (!hasFrontBuffer() || !supportsPartialRepaint()) 367 needsFullDisplay = true; 368 369 auto result = swapToValidFrontBuffer(); 370 if (result == WebCore::SetNonVolatileResult::Empty) 371 needsFullDisplay = true; 372 373 return needsFullDisplay ? SwapBuffersDisplayRequirement::NeedsFullDisplay : SwapBuffersDisplayRequirement::NeedsNormalDisplay; 374 } 375 376 void RemoteLayerBackingStore::paintContents() 377 { 378 if (!m_frontBuffer.imageBuffer) 379 return; 414 ASSERT(m_layer->owner()->platformCALayerDelegatesDisplay(m_layer)); 415 return; 416 } 380 417 381 418 LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << "RemoteLayerBackingStore " << m_layer->layerID() << " paintContents() - has dirty region " << !hasEmptyDirtyRegion()); -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h
r291599 r291733 62 62 virtual bool backingStoreNeedsDisplay(const RemoteLayerBackingStore&); 63 63 64 virtual SwapBuffersDisplayRequirement prepareBackingStoreBuffers(RemoteLayerBackingStore&); 65 66 void prepareBackingStoresForDisplay(RemoteLayerTreeTransaction&); 64 virtual void prepareBackingStoresForDisplay(RemoteLayerTreeTransaction&); 67 65 void paintReachableBackingStoreContents(); 68 66 -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm
r291599 r291733 164 164 } 165 165 166 SwapBuffersDisplayRequirement RemoteLayerBackingStoreCollection::prepareBackingStoreBuffers(RemoteLayerBackingStore& backingStore)167 {168 return backingStore.prepareBuffers(backingStore.hasEmptyDirtyRegion());169 }170 171 166 bool RemoteLayerBackingStoreCollection::markBackingStoreVolatile(RemoteLayerBackingStore& backingStore, OptionSet<VolatilityMarkingBehavior> markingBehavior, MonotonicTime now) 172 167 { -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.h
r291599 r291733 45 45 46 46 bool backingStoreNeedsDisplay(const RemoteLayerBackingStore&) final; 47 SwapBuffersDisplayRequirement prepareBackingStoreBuffers(RemoteLayerBackingStore&) final;47 void prepareBackingStoresForDisplay(RemoteLayerTreeTransaction&) final; 48 48 49 49 bool collectBackingStoreBufferIdentifiersToMarkVolatile(RemoteLayerBackingStore&, OptionSet<VolatilityMarkingBehavior>, MonotonicTime now, Vector<WebCore::RenderingResourceIdentifier>&); -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStoreCollection.mm
r291599 r291733 65 65 } 66 66 67 SwapBuffersDisplayRequirement RemoteLayerWithRemoteRenderingBackingStoreCollection::prepareBackingStoreBuffers(RemoteLayerBackingStore& backingStore) 68 { 67 void RemoteLayerWithRemoteRenderingBackingStoreCollection::prepareBackingStoresForDisplay(RemoteLayerTreeTransaction& transaction) 68 { 69 Vector<RemoteRenderingBackendProxy::LayerPrepareBuffersData> prepareBuffersData; 70 prepareBuffersData.reserveInitialCapacity(m_backingStoresNeedingDisplay.size()); 71 72 Vector<RemoteLayerBackingStore*> backingStoreList; 73 backingStoreList.reserveInitialCapacity(m_backingStoresNeedingDisplay.size()); 74 75 for (auto* backingStore : m_backingStoresNeedingDisplay) { 76 backingStore->layer()->properties().notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreChanged); 77 transaction.layerPropertiesChanged(*backingStore->layer()); 78 79 if (backingStore->performDelegatedLayerDisplay()) 80 continue; 81 82 prepareBuffersData.uncheckedAppend({ 83 { 84 backingStore->bufferForType(RemoteLayerBackingStore::BufferType::Front), 85 backingStore->bufferForType(RemoteLayerBackingStore::BufferType::Back), 86 backingStore->bufferForType(RemoteLayerBackingStore::BufferType::SecondaryBack) 87 }, 88 backingStore->supportsPartialRepaint(), 89 backingStore->hasEmptyDirtyRegion(), 90 }); 91 92 backingStoreList.uncheckedAppend(backingStore); 93 } 94 69 95 auto& remoteRenderingBackend = layerTreeContext().ensureRemoteRenderingBackendProxy(); 70 71 auto identifiers = RemoteRenderingBackendProxy::BufferSet { 72 backingStore.bufferForType(RemoteLayerBackingStore::BufferType::Front), 73 backingStore.bufferForType(RemoteLayerBackingStore::BufferType::Back), 74 backingStore.bufferForType(RemoteLayerBackingStore::BufferType::SecondaryBack) 75 }; 76 77 auto swapResult = remoteRenderingBackend.prepareBuffersForDisplay(WTFMove(identifiers), backingStore.supportsPartialRepaint(), backingStore.hasEmptyDirtyRegion()); 78 79 backingStore.applySwappedBuffers(WTFMove(swapResult.buffers.front), WTFMove(swapResult.buffers.back), WTFMove(swapResult.buffers.secondaryBack)); 80 return swapResult.displayRequirement; 96 auto swapResult = remoteRenderingBackend.prepareBuffersForDisplay(WTFMove(prepareBuffersData)); 97 98 RELEASE_ASSERT(swapResult.size() == backingStoreList.size()); 99 for (unsigned i = 0; i < swapResult.size(); ++i) { 100 auto& backingStoreSwapResult = swapResult[i]; 101 auto* backingStore = backingStoreList[i]; 102 backingStore->applySwappedBuffers(WTFMove(backingStoreSwapResult.buffers.front), WTFMove(backingStoreSwapResult.buffers.back), WTFMove(backingStoreSwapResult.buffers.secondaryBack), backingStoreSwapResult.displayRequirement); 103 } 81 104 } 82 105 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r291684 r291733 2622 2622 0F5E200218E77051003EC3E5 /* PlatformCAAnimationRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCAAnimationRemote.h; sourceTree = "<group>"; }; 2623 2623 0F65956727DB1D5800EE874B /* SwapBuffersDisplayRequirement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwapBuffersDisplayRequirement.h; sourceTree = "<group>"; }; 2624 0F65956C27E10C2C00EE874B /* PrepareBackingStoreBuffersData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrepareBackingStoreBuffersData.h; sourceTree = "<group>"; }; 2624 2625 0F707C771A1FEE8300DA7A45 /* RemoteLayerTreeScrollingPerformanceData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerTreeScrollingPerformanceData.mm; sourceTree = "<group>"; }; 2625 2626 0F707C791A1FEEA300DA7A45 /* RemoteLayerTreeScrollingPerformanceData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerTreeScrollingPerformanceData.h; sourceTree = "<group>"; }; … … 9901 9902 727A7F38240788F0004D2931 /* PlatformImageBufferShareableBackend.h */, 9902 9903 7227800B2408BD7D007D376B /* PlatformRemoteImageBufferProxy.h */, 9904 0F65956C27E10C2C00EE874B /* PrepareBackingStoreBuffersData.h */, 9903 9905 F48BB8DE26F9635D001C1C40 /* RemoteDisplayListRecorderProxy.cpp */, 9904 9906 F48BB8DD26F9635D001C1C40 /* RemoteDisplayListRecorderProxy.h */, -
trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp
r291243 r291733 268 268 } 269 269 270 auto RemoteRenderingBackendProxy::prepareBuffersForDisplay(const BufferSet& buffers, bool supportsPartialRepaint, bool hasEmptyDirtyRegion) -> SwapBuffersResult270 auto RemoteRenderingBackendProxy::prepareBuffersForDisplay(const Vector<LayerPrepareBuffersData>& prepareBuffersInput) -> Vector<SwapBuffersResult> 271 271 { 272 272 auto bufferIdentifier = [](ImageBuffer* buffer) -> std::optional<RenderingResourceIdentifier> { … … 287 287 }; 288 288 289 // Clear all the buffer's MachSendRights to avoid all the surfaces appearing to be in-use. 290 // We get back the new front buffer's MachSendRight in the reply. 291 clearBackendHandle(buffers.front.get()); 292 clearBackendHandle(buffers.back.get()); 293 clearBackendHandle(buffers.secondaryBack.get()); 294 295 auto bufferSet = BufferIdentifierSet { 296 bufferIdentifier(buffers.front.get()), 297 bufferIdentifier(buffers.back.get()), 298 bufferIdentifier(buffers.secondaryBack.get()) 299 }; 300 301 BufferIdentifierSet swappedBufferSet; 302 std::optional<ImageBufferBackendHandle> frontBufferHandle; 303 auto displayRequirement = SwapBuffersDisplayRequirement::NeedsNoDisplay; 304 305 sendSyncToStream(Messages::RemoteRenderingBackend::PrepareBuffersForDisplay(bufferSet, supportsPartialRepaint, hasEmptyDirtyRegion), 306 Messages::RemoteRenderingBackend::PrepareBuffersForDisplay::Reply(swappedBufferSet, frontBufferHandle, displayRequirement)); 307 308 LOG_WITH_STREAM(RemoteRenderingBufferVolatility, stream << "RemoteRenderingBackendProxy::prepareBuffersForDisplay swapped to " << swappedBufferSet.front << " " << swappedBufferSet.back << " " << swappedBufferSet.secondaryBack); 289 Vector<PrepareBackingStoreBuffersInputData> inputData; 290 inputData.reserveInitialCapacity(prepareBuffersInput.size()); 291 292 for (const auto& perLayerData : prepareBuffersInput) { 293 // Clear all the buffer's MachSendRights to avoid all the surfaces appearing to be in-use. 294 // We get back the new front buffer's MachSendRight in the reply. 295 clearBackendHandle(perLayerData.buffers.front.get()); 296 clearBackendHandle(perLayerData.buffers.back.get()); 297 clearBackendHandle(perLayerData.buffers.secondaryBack.get()); 298 299 inputData.uncheckedAppend({ 300 { 301 bufferIdentifier(perLayerData.buffers.front.get()), 302 bufferIdentifier(perLayerData.buffers.back.get()), 303 bufferIdentifier(perLayerData.buffers.secondaryBack.get()) 304 }, 305 perLayerData.supportsPartialRepaint, 306 perLayerData.hasEmptyDirtyRegion 307 }); 308 } 309 310 Vector<PrepareBackingStoreBuffersOutputData> outputData; 311 sendSyncToStream(Messages::RemoteRenderingBackend::PrepareBuffersForDisplay(inputData), Messages::RemoteRenderingBackend::PrepareBuffersForDisplay::Reply(outputData)); 312 RELEASE_ASSERT(inputData.size() == outputData.size()); 309 313 310 314 auto fetchBufferWithIdentifier = [&](std::optional<RenderingResourceIdentifier> identifier, std::optional<ImageBufferBackendHandle>&& handle = std::nullopt, bool isFrontBuffer = false) -> RefPtr<ImageBuffer> { … … 332 336 }; 333 337 334 return { 335 { 336 fetchBufferWithIdentifier(swappedBufferSet.front, WTFMove(frontBufferHandle), true), 337 fetchBufferWithIdentifier(swappedBufferSet.back), 338 fetchBufferWithIdentifier(swappedBufferSet.secondaryBack) 339 }, 340 displayRequirement 341 }; 338 Vector<SwapBuffersResult> result; 339 result.reserveInitialCapacity(outputData.size()); 340 341 for (auto& perLayerOutputData : outputData) { 342 result.uncheckedAppend({ 343 { 344 fetchBufferWithIdentifier(perLayerOutputData.bufferSet.front, WTFMove(perLayerOutputData.frontBufferHandle), true), 345 fetchBufferWithIdentifier(perLayerOutputData.bufferSet.back), 346 fetchBufferWithIdentifier(perLayerOutputData.bufferSet.secondaryBack) 347 }, 348 perLayerOutputData.displayRequirement 349 }); 350 } 351 352 return result; 342 353 } 343 354 -
trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h
r291243 r291733 102 102 }; 103 103 104 struct LayerPrepareBuffersData { 105 BufferSet buffers; 106 bool supportsPartialRepaint { true }; 107 bool hasEmptyDirtyRegion { false }; 108 }; 109 104 110 struct SwapBuffersResult { 105 111 BufferSet buffers; 106 112 SwapBuffersDisplayRequirement displayRequirement; 107 113 }; 108 SwapBuffersResult prepareBuffersForDisplay(const BufferSet&, bool supportsPartialRepaint, bool hasEmptyDirtyRegion); 114 115 Vector<SwapBuffersResult> prepareBuffersForDisplay(const Vector<LayerPrepareBuffersData>&); 109 116 110 117 void finalizeRenderingUpdate();
Note:
See TracChangeset
for help on using the changeset viewer.