1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_layers_WebRenderBridgeParent_h 8 #define mozilla_layers_WebRenderBridgeParent_h 9 10 #include <unordered_map> 11 #include <unordered_set> 12 13 #include "CompositableHost.h" // for CompositableHost, ImageCompositeNotificationInfo 14 #include "GLContextProvider.h" 15 #include "mozilla/DataMutex.h" 16 #include "mozilla/layers/CompositableTransactionParent.h" 17 #include "mozilla/layers/CompositorVsyncSchedulerOwner.h" 18 #include "mozilla/layers/LayerManager.h" 19 #include "mozilla/layers/PWebRenderBridgeParent.h" 20 #include "mozilla/HashTable.h" 21 #include "mozilla/Maybe.h" 22 #include "mozilla/Result.h" 23 #include "mozilla/UniquePtr.h" 24 #include "mozilla/webrender/WebRenderTypes.h" 25 #include "mozilla/webrender/WebRenderAPI.h" 26 #include "nsTArrayForwardDeclare.h" 27 28 namespace mozilla { 29 30 namespace gl { 31 class GLContext; 32 } 33 34 namespace widget { 35 class CompositorWidget; 36 } 37 38 namespace wr { 39 class WebRenderAPI; 40 class WebRenderPipelineInfo; 41 } // namespace wr 42 43 namespace layers { 44 45 class AsyncImagePipelineManager; 46 class Compositor; 47 class CompositorBridgeParentBase; 48 class CompositorVsyncScheduler; 49 class OMTASampler; 50 class UiCompositorControllerParent; 51 class WebRenderBridgeParentRef; 52 class WebRenderImageHost; 53 struct WrAnimations; 54 55 struct CompositorAnimationIdsForEpoch { CompositorAnimationIdsForEpochCompositorAnimationIdsForEpoch56 CompositorAnimationIdsForEpoch(const wr::Epoch& aEpoch, 57 nsTArray<uint64_t>&& aIds) 58 : mEpoch(aEpoch), mIds(std::move(aIds)) {} 59 60 wr::Epoch mEpoch; 61 nsTArray<uint64_t> mIds; 62 }; 63 64 class WebRenderBridgeParent final : public PWebRenderBridgeParent, 65 public CompositorVsyncSchedulerOwner, 66 public CompositableParentManager, 67 public layers::FrameRecorder { 68 public: 69 WebRenderBridgeParent(CompositorBridgeParentBase* aCompositorBridge, 70 const wr::PipelineId& aPipelineId, 71 widget::CompositorWidget* aWidget, 72 CompositorVsyncScheduler* aScheduler, 73 RefPtr<wr::WebRenderAPI>&& aApi, 74 RefPtr<AsyncImagePipelineManager>&& aImageMgr, 75 TimeDuration aVsyncRate); 76 77 static WebRenderBridgeParent* CreateDestroyed( 78 const wr::PipelineId& aPipelineId, nsCString&& aError); 79 PipelineId()80 wr::PipelineId PipelineId() { return mPipelineId; } GetWebRenderAPI()81 already_AddRefed<wr::WebRenderAPI> GetWebRenderAPI() { 82 return do_AddRef(mApi); 83 } AsyncImageManager()84 AsyncImagePipelineManager* AsyncImageManager() { return mAsyncImageManager; } CompositorScheduler()85 CompositorVsyncScheduler* CompositorScheduler() { 86 return mCompositorScheduler.get(); 87 } GetCompositorBridge()88 CompositorBridgeParentBase* GetCompositorBridge() { 89 return mCompositorBridge; 90 } 91 92 void UpdateQualitySettings(); 93 void UpdateDebugFlags(); 94 void UpdateMultithreading(); 95 void UpdateBatchingParameters(); 96 void UpdateProfilerUI(); 97 98 mozilla::ipc::IPCResult RecvEnsureConnected( 99 TextureFactoryIdentifier* aTextureFactoryIdentifier, 100 MaybeIdNamespace* aMaybeIdNamespace, nsCString* aError) override; 101 102 mozilla::ipc::IPCResult RecvNewCompositable( 103 const CompositableHandle& aHandle, const TextureInfo& aInfo) override; 104 mozilla::ipc::IPCResult RecvReleaseCompositable( 105 const CompositableHandle& aHandle) override; 106 107 mozilla::ipc::IPCResult RecvShutdown() override; 108 mozilla::ipc::IPCResult RecvShutdownSync() override; 109 mozilla::ipc::IPCResult RecvDeleteCompositorAnimations( 110 nsTArray<uint64_t>&& aIds) override; 111 mozilla::ipc::IPCResult RecvUpdateResources( 112 const wr::IdNamespace& aIdNamespace, 113 nsTArray<OpUpdateResource>&& aUpdates, 114 nsTArray<RefCountedShmem>&& aSmallShmems, 115 nsTArray<ipc::Shmem>&& aLargeShmems) override; 116 mozilla::ipc::IPCResult RecvSetDisplayList( 117 DisplayListData&& aDisplayList, nsTArray<OpDestroy>&& aToDestroy, 118 const uint64_t& aFwdTransactionId, const TransactionId& aTransactionId, 119 const bool& aContainsSVGGroup, const VsyncId& aVsyncId, 120 const TimeStamp& aVsyncStartTime, const TimeStamp& aRefreshStartTime, 121 const TimeStamp& aTxnStartTime, const nsCString& aTxnURL, 122 const TimeStamp& aFwdTime, 123 nsTArray<CompositionPayload>&& aPayloads) override; 124 mozilla::ipc::IPCResult RecvEmptyTransaction( 125 const FocusTarget& aFocusTarget, 126 Maybe<TransactionData>&& aTransactionData, 127 nsTArray<OpDestroy>&& aToDestroy, const uint64_t& aFwdTransactionId, 128 const TransactionId& aTransactionId, const VsyncId& aVsyncId, 129 const TimeStamp& aVsyncStartTime, const TimeStamp& aRefreshStartTime, 130 const TimeStamp& aTxnStartTime, const nsCString& aTxnURL, 131 const TimeStamp& aFwdTime, 132 nsTArray<CompositionPayload>&& aPayloads) override; 133 mozilla::ipc::IPCResult RecvSetFocusTarget( 134 const FocusTarget& aFocusTarget) override; 135 mozilla::ipc::IPCResult RecvParentCommands( 136 nsTArray<WebRenderParentCommand>&& commands) override; 137 mozilla::ipc::IPCResult RecvGetSnapshot(PTextureParent* aTexture, 138 bool* aNeedsYFlip) override; 139 140 mozilla::ipc::IPCResult RecvSetLayersObserverEpoch( 141 const LayersObserverEpoch& aChildEpoch) override; 142 143 mozilla::ipc::IPCResult RecvClearCachedResources() override; 144 mozilla::ipc::IPCResult RecvInvalidateRenderedFrame() override; 145 mozilla::ipc::IPCResult RecvScheduleComposite() override; 146 mozilla::ipc::IPCResult RecvCapture() override; 147 mozilla::ipc::IPCResult RecvStartCaptureSequence( 148 const nsCString& path, const uint32_t& aFlags) override; 149 mozilla::ipc::IPCResult RecvStopCaptureSequence() override; 150 mozilla::ipc::IPCResult RecvSyncWithCompositor() override; 151 152 mozilla::ipc::IPCResult RecvSetConfirmedTargetAPZC( 153 const uint64_t& aBlockId, 154 nsTArray<ScrollableLayerGuid>&& aTargets) override; 155 156 mozilla::ipc::IPCResult RecvSetTestSampleTime( 157 const TimeStamp& aTime) override; 158 mozilla::ipc::IPCResult RecvLeaveTestMode() override; 159 mozilla::ipc::IPCResult RecvGetAnimationValue( 160 const uint64_t& aCompositorAnimationsId, OMTAValue* aValue) override; 161 mozilla::ipc::IPCResult RecvSetAsyncScrollOffset( 162 const ScrollableLayerGuid::ViewID& aScrollId, const float& aX, 163 const float& aY) override; 164 mozilla::ipc::IPCResult RecvSetAsyncZoom( 165 const ScrollableLayerGuid::ViewID& aScrollId, 166 const float& aZoom) override; 167 mozilla::ipc::IPCResult RecvFlushApzRepaints() override; 168 mozilla::ipc::IPCResult RecvGetAPZTestData(APZTestData* data) override; 169 mozilla::ipc::IPCResult RecvGetFrameUniformity( 170 FrameUniformityData* aOutData) override; 171 172 void ActorDestroy(ActorDestroyReason aWhy) override; 173 174 void SetClearColor(const gfx::DeviceColor& aColor); 175 176 void Pause(); 177 bool Resume(); 178 179 void Destroy(); 180 181 // CompositorVsyncSchedulerOwner IsPendingComposite()182 bool IsPendingComposite() override { return false; } FinishPendingComposite()183 void FinishPendingComposite() override {} 184 void CompositeToTarget(VsyncId aId, gfx::DrawTarget* aTarget, 185 const gfx::IntRect* aRect = nullptr) override; 186 TimeDuration GetVsyncInterval() const override; 187 188 // CompositableParentManager 189 bool IsSameProcess() const override; 190 base::ProcessId GetChildProcessId() override; 191 void NotifyNotUsed(PTextureParent* aTexture, 192 uint64_t aTransactionId) override; 193 void SendAsyncMessage( 194 const nsTArray<AsyncParentMessageData>& aMessage) override; 195 void SendPendingAsyncMessages() override; 196 void SetAboutToSendAsyncMessages() override; 197 198 void HoldPendingTransactionId( 199 const wr::Epoch& aWrEpoch, TransactionId aTransactionId, 200 bool aContainsSVGGroup, const VsyncId& aVsyncId, 201 const TimeStamp& aVsyncStartTime, const TimeStamp& aRefreshStartTime, 202 const TimeStamp& aTxnStartTime, const nsCString& aTxnURL, 203 const TimeStamp& aFwdTime, const bool aIsFirstPaint, 204 nsTArray<CompositionPayload>&& aPayloads, 205 const bool aUseForTelemetry = true); 206 TransactionId LastPendingTransactionId(); 207 void FlushTransactionIdsForEpoch( 208 const wr::Epoch& aEpoch, const VsyncId& aCompositeStartId, 209 const TimeStamp& aCompositeStartTime, const TimeStamp& aRenderStartTime, 210 const TimeStamp& aEndTime, UiCompositorControllerParent* aUiController, 211 wr::RendererStats* aStats, nsTArray<FrameStats>& aOutputStats, 212 nsTArray<TransactionId>& aOutputTransactions); 213 void NotifySceneBuiltForEpoch(const wr::Epoch& aEpoch, 214 const TimeStamp& aEndTime); 215 216 void CompositeIfNeeded(); 217 218 TextureFactoryIdentifier GetTextureFactoryIdentifier(); 219 220 void ExtractImageCompositeNotifications( 221 nsTArray<ImageCompositeNotificationInfo>* aNotifications); 222 GetCurrentEpoch()223 wr::Epoch GetCurrentEpoch() const { return mWrEpoch; } GetIdNamespace()224 wr::IdNamespace GetIdNamespace() { return mIdNamespace; } 225 MatchesNamespace(const wr::ImageKey & aImageKey)226 bool MatchesNamespace(const wr::ImageKey& aImageKey) const { 227 return aImageKey.mNamespace == mIdNamespace; 228 } 229 MatchesNamespace(const wr::BlobImageKey & aBlobKey)230 bool MatchesNamespace(const wr::BlobImageKey& aBlobKey) const { 231 return MatchesNamespace(wr::AsImageKey(aBlobKey)); 232 } 233 MatchesNamespace(const wr::FontKey & aFontKey)234 bool MatchesNamespace(const wr::FontKey& aFontKey) const { 235 return aFontKey.mNamespace == mIdNamespace; 236 } 237 MatchesNamespace(const wr::FontInstanceKey & aFontKey)238 bool MatchesNamespace(const wr::FontInstanceKey& aFontKey) const { 239 return aFontKey.mNamespace == mIdNamespace; 240 } 241 242 void FlushRendering(bool aWaitForPresent = true); 243 244 /** 245 * Schedule generating WebRender frame definitely at next composite timing. 246 * 247 * WebRenderBridgeParent uses composite timing to check if there is an update 248 * to AsyncImagePipelines. If there is no update, WebRenderBridgeParent skips 249 * to generate frame. If we need to generate new frame at next composite 250 * timing, call this method. 251 * 252 * Call CompositorVsyncScheduler::ScheduleComposition() directly, if we just 253 * want to trigger AsyncImagePipelines update checks. 254 */ 255 void ScheduleGenerateFrame(); 256 257 /** 258 * Invalidate rendered frame. 259 * 260 * WebRender could skip frame rendering if there is no update. 261 * This function is used to force invalidating even when there is no update. 262 */ 263 void InvalidateRenderedFrame(); 264 265 /** 266 * Schedule forced frame rendering at next composite timing. 267 * 268 * WebRender could skip frame rendering if there is no update. 269 * This function is used to force rendering even when there is no update. 270 */ 271 void ScheduleForcedGenerateFrame(); 272 273 void NotifyDidSceneBuild(RefPtr<const wr::WebRenderPipelineInfo> aInfo); 274 275 wr::Epoch UpdateWebRender( 276 CompositorVsyncScheduler* aScheduler, RefPtr<wr::WebRenderAPI>&& aApi, 277 AsyncImagePipelineManager* aImageMgr, 278 const TextureFactoryIdentifier& aTextureFactoryIdentifier); 279 280 void RemoveEpochDataPriorTo(const wr::Epoch& aRenderedEpoch); 281 282 bool IsRootWebRenderBridgeParent() const; 283 LayersId GetLayersId() const; 284 285 void BeginRecording(const TimeStamp& aRecordingStart); 286 287 /** 288 * Write the frames collected since the call to BeginRecording to disk. 289 * 290 * If there is not currently a recorder, this is a no-op. 291 */ 292 RefPtr<wr::WebRenderAPI::WriteCollectedFramesPromise> WriteCollectedFrames(); 293 294 #if defined(MOZ_WIDGET_ANDROID) 295 /** 296 * Request a screengrab for android 297 */ 298 void RequestScreenPixels(UiCompositorControllerParent* aController); 299 void MaybeCaptureScreenPixels(); 300 #endif 301 /** 302 * Return the frames collected since the call to BeginRecording encoded 303 * as data URIs. 304 * 305 * If there is not currently a recorder, this is a no-op and the promise will 306 * be rejected. 307 */ 308 RefPtr<wr::WebRenderAPI::GetCollectedFramesPromise> GetCollectedFrames(); 309 310 void DisableNativeCompositor(); 311 void AddPendingScrollPayload(CompositionPayload& aPayload, 312 const VsyncId& aCompositeStartId); 313 314 nsTArray<CompositionPayload> TakePendingScrollPayload( 315 const VsyncId& aCompositeStartId); 316 317 RefPtr<WebRenderBridgeParentRef> GetWebRenderBridgeParentRef(); 318 319 private: 320 class ScheduleSharedSurfaceRelease; 321 322 WebRenderBridgeParent(const wr::PipelineId& aPipelineId, nsCString&& aError); 323 virtual ~WebRenderBridgeParent(); 324 325 bool ProcessEmptyTransactionUpdates(TransactionData& aData, 326 bool* aScheduleComposite); 327 328 bool ProcessDisplayListData(DisplayListData& aDisplayList, wr::Epoch aWrEpoch, 329 const TimeStamp& aTxnStartTime, 330 bool aValidTransaction, 331 bool aObserveLayersUpdate); 332 333 bool SetDisplayList(const LayoutDeviceRect& aRect, ipc::ByteBuf&& aDL, 334 const wr::BuiltDisplayListDescriptor& aDLDesc, 335 const nsTArray<OpUpdateResource>& aResourceUpdates, 336 const nsTArray<RefCountedShmem>& aSmallShmems, 337 const nsTArray<ipc::Shmem>& aLargeShmems, 338 const TimeStamp& aTxnStartTime, 339 wr::TransactionBuilder& aTxn, wr::Epoch aWrEpoch, 340 bool aObserveLayersUpdate); 341 342 void UpdateAPZFocusState(const FocusTarget& aFocus); 343 void UpdateAPZScrollData(const wr::Epoch& aEpoch, 344 WebRenderScrollData&& aData); 345 void UpdateAPZScrollOffsets(ScrollUpdatesMap&& aUpdates, 346 uint32_t aPaintSequenceNumber); 347 348 bool UpdateResources(const nsTArray<OpUpdateResource>& aResourceUpdates, 349 const nsTArray<RefCountedShmem>& aSmallShmems, 350 const nsTArray<ipc::Shmem>& aLargeShmems, 351 wr::TransactionBuilder& aUpdates); 352 void AddPrivateExternalImage(wr::ExternalImageId aExtId, wr::ImageKey aKey, 353 wr::ImageDescriptor aDesc, 354 wr::TransactionBuilder& aResources); 355 void UpdatePrivateExternalImage(wr::ExternalImageId aExtId, wr::ImageKey aKey, 356 const wr::ImageDescriptor& aDesc, 357 const ImageIntRect& aDirtyRect, 358 wr::TransactionBuilder& aResources); 359 bool AddSharedExternalImage(wr::ExternalImageId aExtId, wr::ImageKey aKey, 360 wr::TransactionBuilder& aResources); 361 bool UpdateSharedExternalImage( 362 wr::ExternalImageId aExtId, wr::ImageKey aKey, 363 const ImageIntRect& aDirtyRect, wr::TransactionBuilder& aResources, 364 UniquePtr<ScheduleSharedSurfaceRelease>& aScheduleRelease); 365 void ObserveSharedSurfaceRelease( 366 const nsTArray<wr::ExternalImageKeyPair>& aPairs); 367 368 bool PushExternalImageForTexture(wr::ExternalImageId aExtId, 369 wr::ImageKey aKey, TextureHost* aTexture, 370 bool aIsUpdate, 371 wr::TransactionBuilder& aResources); 372 373 void AddPipelineIdForCompositable(const wr::PipelineId& aPipelineIds, 374 const CompositableHandle& aHandle, 375 const bool& aAsync, 376 wr::TransactionBuilder& aTxn, 377 wr::TransactionBuilder& aTxnForImageBridge); 378 void RemovePipelineIdForCompositable(const wr::PipelineId& aPipelineId, 379 wr::TransactionBuilder& aTxn); 380 381 void DeleteImage(const wr::ImageKey& aKey, wr::TransactionBuilder& aUpdates); 382 void ReleaseTextureOfImage(const wr::ImageKey& aKey); 383 384 bool ProcessWebRenderParentCommands( 385 const nsTArray<WebRenderParentCommand>& aCommands, 386 wr::TransactionBuilder& aTxn); 387 388 void ClearResources(); 389 void ClearAnimationResources(); 390 bool ShouldParentObserveEpoch(); 391 mozilla::ipc::IPCResult HandleShutdown(); 392 393 void ResetPreviousSampleTime(); 394 395 void SetOMTASampleTime(); 396 RefPtr<OMTASampler> GetOMTASampler() const; 397 398 CompositorBridgeParent* GetRootCompositorBridgeParent() const; 399 400 RefPtr<WebRenderBridgeParent> GetRootWebRenderBridgeParent() const; 401 402 // Tell APZ what the subsequent sampling's timestamp should be. 403 void SetAPZSampleTime(); 404 405 wr::Epoch GetNextWrEpoch(); 406 // This function is expected to be used when GetNextWrEpoch() is called, 407 // but TransactionBuilder does not have resource updates nor display list. 408 // In this case, ScheduleGenerateFrame is not triggered via SceneBuilder. 409 // Then we want to rollback WrEpoch. See Bug 1490117. 410 void RollbackWrEpoch(); 411 412 void FlushSceneBuilds(); 413 void FlushFrameGeneration(); 414 void FlushFramePresentation(); 415 416 void MaybeGenerateFrame(VsyncId aId, bool aForceGenerateFrame); 417 GetVsyncIdForEpoch(const wr::Epoch & aEpoch)418 VsyncId GetVsyncIdForEpoch(const wr::Epoch& aEpoch) { 419 for (auto& id : mPendingTransactionIds) { 420 if (id.mEpoch.mHandle == aEpoch.mHandle) { 421 return id.mVsyncId; 422 } 423 } 424 return VsyncId(); 425 } 426 427 private: 428 struct PendingTransactionId { PendingTransactionIdPendingTransactionId429 PendingTransactionId(const wr::Epoch& aEpoch, TransactionId aId, 430 bool aContainsSVGGroup, const VsyncId& aVsyncId, 431 const TimeStamp& aVsyncStartTime, 432 const TimeStamp& aRefreshStartTime, 433 const TimeStamp& aTxnStartTime, 434 const nsCString& aTxnURL, const TimeStamp& aFwdTime, 435 const bool aIsFirstPaint, const bool aUseForTelemetry, 436 nsTArray<CompositionPayload>&& aPayloads) 437 : mEpoch(aEpoch), 438 mId(aId), 439 mVsyncId(aVsyncId), 440 mVsyncStartTime(aVsyncStartTime), 441 mRefreshStartTime(aRefreshStartTime), 442 mTxnStartTime(aTxnStartTime), 443 mTxnURL(aTxnURL), 444 mFwdTime(aFwdTime), 445 mSkippedComposites(0), 446 mContainsSVGGroup(aContainsSVGGroup), 447 mIsFirstPaint(aIsFirstPaint), 448 mUseForTelemetry(aUseForTelemetry), 449 mPayloads(std::move(aPayloads)) {} 450 wr::Epoch mEpoch; 451 TransactionId mId; 452 VsyncId mVsyncId; 453 TimeStamp mVsyncStartTime; 454 TimeStamp mRefreshStartTime; 455 TimeStamp mTxnStartTime; 456 nsCString mTxnURL; 457 TimeStamp mFwdTime; 458 TimeStamp mSceneBuiltTime; 459 uint32_t mSkippedComposites; 460 bool mContainsSVGGroup; 461 bool mIsFirstPaint; 462 bool mUseForTelemetry; 463 nsTArray<CompositionPayload> mPayloads; 464 }; 465 466 CompositorBridgeParentBase* MOZ_NON_OWNING_REF mCompositorBridge; 467 wr::PipelineId mPipelineId; 468 RefPtr<widget::CompositorWidget> mWidget; 469 RefPtr<wr::WebRenderAPI> mApi; 470 RefPtr<AsyncImagePipelineManager> mAsyncImageManager; 471 RefPtr<CompositorVsyncScheduler> mCompositorScheduler; 472 // mActiveAnimations is used to avoid leaking animations when 473 // WebRenderBridgeParent is destroyed abnormally and Tab move between 474 // different windows. 475 std::unordered_map<uint64_t, wr::Epoch> mActiveAnimations; 476 std::unordered_map<uint64_t, RefPtr<WebRenderImageHost>> mAsyncCompositables; 477 std::unordered_map<uint64_t, CompositableTextureHostRef> mTextureHosts; 478 std::unordered_map<uint64_t, wr::ExternalImageId> mSharedSurfaceIds; 479 480 TimeDuration mVsyncRate; 481 TimeStamp mPreviousFrameTimeStamp; 482 // These fields keep track of the latest layer observer epoch values in the 483 // child and the parent. mChildLayersObserverEpoch is the latest epoch value 484 // received from the child. mParentLayersObserverEpoch is the latest epoch 485 // value that we have told BrowserParent about (via ObserveLayerUpdate). 486 LayersObserverEpoch mChildLayersObserverEpoch; 487 LayersObserverEpoch mParentLayersObserverEpoch; 488 489 std::deque<PendingTransactionId> mPendingTransactionIds; 490 std::queue<CompositorAnimationIdsForEpoch> mCompositorAnimationsToDelete; 491 wr::Epoch mWrEpoch; 492 wr::IdNamespace mIdNamespace; 493 CompositionOpportunityId mCompositionOpportunityId; 494 nsCString mInitError; 495 496 TimeStamp mMostRecentComposite; 497 498 RefPtr<WebRenderBridgeParentRef> mWebRenderBridgeRef; 499 500 #if defined(MOZ_WIDGET_ANDROID) 501 UiCompositorControllerParent* mScreenPixelsTarget; 502 #endif 503 bool mDestroyed; 504 bool mReceivedDisplayList; 505 bool mIsFirstPaint; 506 bool mSkippedComposite; 507 bool mDisablingNativeCompositor; 508 // These payloads are being used for SCROLL_PRESENT_LATENCY telemetry 509 DataMutex<nsClassHashtable<nsUint64HashKey, nsTArray<CompositionPayload>>> 510 mPendingScrollPayloads; 511 }; 512 513 // Use this class, since WebRenderBridgeParent could not supports 514 // ThreadSafeWeakPtr. 515 // This class provides a ref of WebRenderBridgeParent when 516 // the WebRenderBridgeParent is not destroyed. Then it works similar to 517 // weak pointer. 518 class WebRenderBridgeParentRef final { 519 public: 520 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebRenderBridgeParentRef) 521 522 explicit WebRenderBridgeParentRef(WebRenderBridgeParent* aWebRenderBridge); 523 524 RefPtr<WebRenderBridgeParent> WrBridge(); 525 void Clear(); 526 527 protected: 528 ~WebRenderBridgeParentRef(); 529 530 RefPtr<WebRenderBridgeParent> mWebRenderBridge; 531 }; 532 533 } // namespace layers 534 } // namespace mozilla 535 536 #endif // mozilla_layers_WebRenderBridgeParent_h 537