diff --git a/gfx/2d/InlineTranslator.cpp b/gfx/2d/InlineTranslator.cpp index e31c50c39ccc4..b6f393fe9c456 100644 --- a/gfx/2d/InlineTranslator.cpp +++ b/gfx/2d/InlineTranslator.cpp @@ -85,6 +85,121 @@ size_t aLen ) { +struct +MemReader +{ +MemReader +( +char +* +aData +size_t +aLen +) +: +mData +( +aData +) +mEnd +( +aData ++ +aLen +) +{ +} +void +read +( +char +* +s +std +: +: +streamsize +n +) +{ +if +( +n +< += +( +mEnd +- +mData +) +) +{ +memcpy +( +s +mData +n +) +; +mData ++ += +n +; +} +else +{ +SetIsBad +( +) +; +} +} +bool +eof +( +) +{ +return +mData +> +mEnd +; +} +bool +good +( +) +{ +return +! +eof +( +) +; +} +void +SetIsBad +( +) +{ +mData += +mEnd ++ +1 +; +} +char +* +mData +; +char +* +mEnd +; +} +; MemReader reader ( diff --git a/gfx/2d/InlineTranslator.h b/gfx/2d/InlineTranslator.h index 426dba6278d9a..c83821f1d90cf 100644 --- a/gfx/2d/InlineTranslator.h +++ b/gfx/2d/InlineTranslator.h @@ -785,122 +785,6 @@ mError } protected : -struct -MemReader -{ -constexpr -MemReader -( -char -* -aData -size_t -aLen -) -: -mData -( -aData -) -mEnd -( -aData -+ -aLen -) -{ -} -void -read -( -char -* -s -std -: -: -streamsize -n -) -{ -if -( -n -< -= -( -mEnd -- -mData -) -) -{ -memcpy -( -s -mData -n -) -; -mData -+ -= -n -; -} -else -{ -SetIsBad -( -) -; -} -} -bool -eof -( -) -{ -return -mData -> -mEnd -; -} -bool -good -( -) -{ -return -! -eof -( -) -; -} -void -SetIsBad -( -) -{ -mData -= -mEnd -+ -1 -; -} -char -* -mData -; -char -* -mEnd -; -} -; RefPtr < DrawTarget diff --git a/gfx/2d/RecordedEvent.cpp b/gfx/2d/RecordedEvent.cpp index 35e0b7da33e02..bead34c905100 100644 --- a/gfx/2d/RecordedEvent.cpp +++ b/gfx/2d/RecordedEvent.cpp @@ -103,6 +103,42 @@ aAction ) ; } +bool +RecordedEvent +: +: +DoWithEventFromStream +( +EventRingBuffer +& +aStream +EventType +aType +const +std +: +: +function +< +bool +( +RecordedEvent +* +) +> +& +aAction +) +{ +return +DoWithEvent +( +aStream +aType +aAction +) +; +} std : : diff --git a/gfx/2d/RecordedEvent.h b/gfx/2d/RecordedEvent.h index 32d68be3d18e6..1d763d45d9696 100644 --- a/gfx/2d/RecordedEvent.h +++ b/gfx/2d/RecordedEvent.h @@ -968,7 +968,6 @@ mTotalSize struct MemWriter { -constexpr explicit MemWriter ( @@ -1014,104 +1013,7 @@ mPtr } ; class -ContiguousBuffer -{ -public -: -ContiguousBuffer -( -char -* -aStart -size_t -aSize -) -: -mWriter -( -aStart -) -mEnd -( -aStart -+ -aSize -) -{ -} -constexpr -MOZ_IMPLICIT -ContiguousBuffer -( -std -: -: -nullptr_t -) -: -mWriter -( -nullptr -) -{ -} -MemWriter -& -Writer -( -) -{ -return -mWriter -; -} -size_t -SizeRemaining -( -) -{ -return -mWriter -. -mPtr -? -mEnd -- -mWriter -. -mPtr -: -0 -; -} -bool -IsValid -( -) -{ -return -! -! -mWriter -. -mPtr -; -} -private -: -MemWriter -mWriter -; -char -* -mEnd -= -nullptr -; -} -; -class -ContiguousBufferStream +EventRingBuffer { public : @@ -1151,51 +1053,39 @@ Record size ) ; -auto -& -buffer -= -GetContiguousBuffer +if ( size . mTotalSize +> +mAvailable ) -; -if -( -! -buffer -. -IsValid +{ +WaitForAndRecalculateAvailableSpace ( ) -) -{ -return ; } -MOZ_ASSERT +if ( size . mTotalSize < = -buffer -. -SizeRemaining -( +mAvailable ) +{ +MemWriter +writer +( +mBufPos ) ; WriteElement ( -buffer -. -Writer -( -) +writer aRecordedEvent - > @@ -1209,25 +1099,67 @@ aRecordedEvent > Record ( -buffer +writer +) +; +UpdateWriteTotalsBy +( +size . -Writer +mTotalSize +) +; +} +else +{ +WriteElement +( +* +this +aRecordedEvent +- +> +GetType ( ) ) ; -IncrementEventCount +aRecordedEvent +- +> +Record ( +* +this ) ; } -protected -: +} virtual -ContiguousBuffer -& -GetContiguousBuffer +void +write ( +const +char +* +const +aData +const +size_t +aSize +) += +0 +; +virtual +void +read +( +char +* +const +aOut +const size_t aSize ) @@ -1235,13 +1167,53 @@ aSize 0 ; virtual +bool +good +( +) +const += +0 +; +virtual void -IncrementEventCount +SetIsBad +( +) += +0 +; +protected +: +virtual +bool +WaitForAndRecalculateAvailableSpace ( ) = 0 ; +virtual +void +UpdateWriteTotalsBy +( +uint32_t +aCount +) += +0 +; +char +* +mBufPos += +nullptr +; +uint32_t +mAvailable += +0 +; } ; struct @@ -1692,7 +1664,7 @@ virtual void RecordToStream ( -ContiguousBufferStream +EventRingBuffer & aStream ) @@ -1901,6 +1873,31 @@ RecordedEvent aAction ) ; +static +bool +DoWithEventFromStream +( +EventRingBuffer +& +aStream +EventType +aType +const +std +: +: +function +< +bool +( +RecordedEvent +* +) +> +& +aAction +) +; EventType GetType ( @@ -2092,7 +2089,7 @@ aStream void RecordToStream ( -ContiguousBufferStream +EventRingBuffer & aStream ) diff --git a/gfx/ipc/CanvasManagerChild.cpp b/gfx/ipc/CanvasManagerChild.cpp index 568e88fce7cbb..f06d0127738f9 100644 --- a/gfx/ipc/CanvasManagerChild.cpp +++ b/gfx/ipc/CanvasManagerChild.cpp @@ -729,28 +729,6 @@ void CanvasManagerChild : : -ClearCachedResources -( -) -{ -if -( -mCanvasChild -) -{ -mCanvasChild -- -> -ClearCachedResources -( -) -; -} -} -void -CanvasManagerChild -: -: DeactivateCanvas ( ) diff --git a/gfx/ipc/CanvasManagerChild.h b/gfx/ipc/CanvasManagerChild.h index fcf8b8ac5ad33..675a402ecae13 100644 --- a/gfx/ipc/CanvasManagerChild.h +++ b/gfx/ipc/CanvasManagerChild.h @@ -189,11 +189,6 @@ EndCanvasTransaction ) ; void -ClearCachedResources -( -) -; -void DeactivateCanvas ( ) diff --git a/gfx/layers/CanvasDrawEventRecorder.cpp b/gfx/layers/CanvasDrawEventRecorder.cpp index e9af848ca2c72..2f2b7d82995f3 100644 --- a/gfx/layers/CanvasDrawEventRecorder.cpp +++ b/gfx/layers/CanvasDrawEventRecorder.cpp @@ -26,16 +26,7 @@ h # include " -mozilla -/ -StaticPrefs_gfx -. -h -" -# -include -" -RecordedCanvasEventImpl +nsThreadUtils . h " @@ -45,38 +36,172 @@ mozilla namespace layers { -struct -ShmemAndHandle -{ -RefPtr -< -ipc +static +const +uint32_t +kMaxSpinCount += +200 +; +static +const +TimeDuration +kTimeout += +TimeDuration : : -SharedMemoryBasic -> -shmem +FromMilliseconds +( +100 +) ; -Handle -handle +static +const +int32_t +kTimeoutRetryCount += +50 ; -} +static +const +uint32_t +kCacheLineSize += +64 +; +static +const +uint32_t +kSmallStreamSize += +64 +* +1024 ; static -Maybe +const +uint32_t +kLargeStreamSize += +2048 +* +1024 +; +static_assert +( +( +static_cast < -ShmemAndHandle +uint64_t > -CreateAndMapShmem ( -size_t -aSize +UINT32_MAX +) ++ +1 +) +% +kSmallStreamSize += += +0 +" +kSmallStreamSize +must +be +a +power +of +two +. +" +) +; +static_assert +( +( +static_cast +< +uint64_t +> +( +UINT32_MAX +) ++ +1 +) +% +kLargeStreamSize += += +0 +" +kLargeStreamSize +must +be +a +power +of +two +. +" +) +; +uint32_t +CanvasEventRingBuffer +: +: +StreamSize +( +) +{ +return +mLargeStream +? +kLargeStreamSize +: +kSmallStreamSize +; +} +bool +CanvasEventRingBuffer +: +: +InitBuffer +( +base +: +: +ProcessId +aOtherPid +ipc +: +: +SharedMemoryBasic +: +: +Handle +* +aReadHandle ) { -auto -shmem +size_t +shmemSize += +StreamSize +( +) ++ +( +2 +* +kCacheLineSize +) +; +mSharedMemory = -MakeRefPtr +MakeAndAddRef < ipc : @@ -88,36 +213,44 @@ SharedMemoryBasic ; if ( +NS_WARN_IF +( ! -shmem +mSharedMemory - > Create ( -aSize +shmemSize +) ) | | +NS_WARN_IF +( ! -shmem +mSharedMemory - > Map ( -aSize +shmemSize +) ) ) { +mGood += +false +; return -Nothing -( -) +false ; } -auto -shmemHandle +* +aReadHandle = -shmem +mSharedMemory - > TakeHandle @@ -126,287 +259,221 @@ TakeHandle ; if ( +NS_WARN_IF +( ! -shmemHandle +* +aReadHandle +) ) { +mGood += +false +; return -Nothing -( -) +false ; } -return -Some -( -ShmemAndHandle -{ -shmem -. -forget +mBuf += +static_cast +< +char +* +> ( -) -std -: -: -move +mSharedMemory +- +> +memory ( -shmemHandle ) -} ) ; -} -CanvasDrawEventRecorder -: -: -CanvasDrawEventRecorder +mBufPos += +mBuf +; +mAvailable += +StreamSize ( ) -{ -mDefaultBufferSize -= -ipc -: -: -SharedMemory -: -: -PageAlignedSize +; +static_assert ( -StaticPrefs -: -: -gfx_canvas_remote_default_buffer_size +sizeof ( +ReadFooter ) -) -; -mMaxSpinCount +< = -StaticPrefs -: -: -gfx_canvas_remote_max_spin_count -( +kCacheLineSize +" +ReadFooter +must +fit +in +kCacheLineSize +. +" ) ; -mDropBufferLimit +mRead = -StaticPrefs -: -: -gfx_canvas_remote_drop_buffer_limit +reinterpret_cast +< +ReadFooter +* +> +( +mBuf ++ +StreamSize ( ) +) ; -mDropBufferOnZero +mRead +- +> +count = -mDropBufferLimit +0 ; -} -bool -CanvasDrawEventRecorder -: -: -Init -( -TextureType -aTextureType -UniquePtr -< -Helpers +mRead +- > -aHelpers -) -{ -mHelpers +returnCount = -std -: -: -move -( -aHelpers -) +0 ; -MOZ_ASSERT -( -mTextureType -= +mRead +- +> +state = -TextureType +State : : -Unknown -) +Processing ; -auto -header -= -CreateAndMapShmem +static_assert ( sizeof ( -Header -) +WriteFooter ) -; -if -( -NS_WARN_IF -( -header +< += +kCacheLineSize +" +WriteFooter +must +fit +in +kCacheLineSize . -isNothing -( -) -) +" ) -{ -return -false ; -} -mHeader +mWrite = -static_cast +reinterpret_cast < -Header +WriteFooter * > ( -header -- -> -shmem -- -> -memory +mBuf ++ +StreamSize ( ) ++ +kCacheLineSize ) ; -mHeader +mWrite - > -eventCount +count = 0 ; -mHeader +mWrite - > -writerWaitCount +returnCount = 0 ; -mHeader +mWrite - > -writerState -= -State -: -: -Processing -; -mHeader -- -> -processedCount +requiredDifference = 0 ; -mHeader +mWrite - > -readerState +state = State : : Processing ; -AutoTArray -< -Handle -2 -> -bufferHandles -; -auto -buffer +mOurCount = -CreateAndMapShmem -( -mDefaultBufferSize -) +0 ; -if -( -NS_WARN_IF -( -buffer -. -isNothing -( -) -) -) -{ return -false +true ; } -mCurrentBuffer -= -CanvasBuffer -( -std +bool +CanvasEventRingBuffer : : -move -( -buffer -- -> -shmem -) -) -; -bufferHandles -. -AppendElement +InitWriter ( -std +base : : -move -( -buffer -- +ProcessId +aOtherPid +ipc +: +: +SharedMemoryBasic +: +: +Handle +* +aReadHandle +CrossProcessSemaphoreHandle +* +aReaderSem +CrossProcessSemaphoreHandle +* +aWriterSem +UniquePtr +< +WriterServices > -handle -) -) -; -buffer -= -CreateAndMapShmem -( -mDefaultBufferSize +aWriterServices ) -; +{ if ( -NS_WARN_IF -( -buffer -. -isNothing +! +InitBuffer ( -) +aOtherPid +aReadHandle ) ) { @@ -414,38 +481,7 @@ return false ; } -mRecycledBuffers -. -emplace -( -buffer -- -> -shmem -. -forget -( -) -0 -) -; -bufferHandles -. -AppendElement -( -std -: -: -move -( -buffer -- -> -handle -) -) -; -mWriterSemaphore +mReaderSemaphore . reset ( @@ -455,23 +491,23 @@ CrossProcessSemaphore Create ( " -CanvasRecorder +SharedMemoryStreamParent " 0 ) ) ; -auto -writerSem +* +aReaderSem = -mWriterSemaphore +mReaderSemaphore - > CloneHandle ( ) ; -mWriterSemaphore +mReaderSemaphore - > CloseHandle @@ -483,7 +519,8 @@ if ! IsHandleValid ( -writerSem +* +aReaderSem ) ) { @@ -491,7 +528,7 @@ return false ; } -mReaderSemaphore +mWriterSemaphore . reset ( @@ -501,23 +538,23 @@ CrossProcessSemaphore Create ( " -CanvasTranslator +SharedMemoryStreamChild " 0 ) ) ; -auto -readerSem +* +aWriterSem = -mReaderSemaphore +mWriterSemaphore - > CloneHandle ( ) ; -mReaderSemaphore +mWriterSemaphore - > CloseHandle @@ -529,7 +566,8 @@ if ! IsHandleValid ( -readerSem +* +aWriterSem ) ) { @@ -537,48 +575,61 @@ return false ; } -if -( -! -mHelpers -- -> -InitTranslator -( -aTextureType +mWriterServices += std : : move ( -header -- -> -handle +aWriterServices ) -std +; +mGood += +true +; +return +true +; +} +bool +CanvasEventRingBuffer : : -move +InitReader ( -bufferHandles -) -mDefaultBufferSize -std +ipc : : -move -( -readerSem +SharedMemoryBasic +: +: +Handle +aReadHandle +CrossProcessSemaphoreHandle +aReaderSem +CrossProcessSemaphoreHandle +aWriterSem +UniquePtr +< +ReaderServices +> +aReaderServices ) +{ +if +( +! +SetNewBuffer +( std : : move ( -writerSem +aReadHandle ) -false ) ) { @@ -586,741 +637,794 @@ return false ; } -mTextureType -= -aTextureType -; -mHeaderShmem -= -header -- -> -shmem -; -return -true -; -} -void -CanvasDrawEventRecorder +mReaderSemaphore +. +reset +( +CrossProcessSemaphore : : -RecordEvent +Create ( -const -gfx +std : : -RecordedEvent -& -aEvent +move +( +aReaderSem ) -{ -aEvent -. -RecordToStream +) +) +; +mReaderSemaphore +- +> +CloseHandle ( -* -this ) ; -} -int64_t -CanvasDrawEventRecorder +mWriterSemaphore +. +reset +( +CrossProcessSemaphore : : -CreateCheckpoint +Create +( +std +: +: +move ( +aWriterSem ) -{ -int64_t -checkpoint -= -mHeader +) +) +; +mWriterSemaphore - > -eventCount -; -RecordEvent -( -RecordedCheckpoint +CloseHandle ( ) +; +mReaderServices += +std +: +: +move +( +aReaderServices ) ; +mGood += +true +; return -checkpoint +true ; } bool -CanvasDrawEventRecorder +CanvasEventRingBuffer : : -WaitForCheckpoint +SetNewBuffer ( -int64_t -aCheckpoint +ipc +: +: +SharedMemoryBasic +: +: +Handle +aReadHandle ) { -uint32_t -spinCount -= -mMaxSpinCount -; -do -{ -if +MOZ_RELEASE_ASSERT ( -mHeader -- -> -processedCount -> -= -aCheckpoint +! +mSharedMemory +" +Shared +memory +should +have +been +dropped +before +new +buffer +is +sent +. +" ) -{ -return -true ; -} -} -while +size_t +shmemSize += +StreamSize ( -- -- -spinCount -! -= -0 +) ++ +( +2 +* +kCacheLineSize ) ; -mHeader -- -> -writerState +mSharedMemory = -State +MakeAndAddRef +< +ipc : : -AboutToWait +SharedMemoryBasic +> +( +) ; if ( -mHeader +NS_WARN_IF +( +! +mSharedMemory - > -processedCount -> -= -aCheckpoint +SetHandle +( +std +: +: +move +( +aReadHandle ) -{ -mHeader +ipc +: +: +SharedMemory +: +: +RightsReadWrite +) +) +| +| +NS_WARN_IF +( +! +mSharedMemory - > -writerState +Map +( +shmemSize +) +) +) +{ +mGood = -State -: -: -Processing +false ; return -true +false ; } -mHeader +mSharedMemory - > -writerWaitCount -= -aCheckpoint +CloseHandle +( +) ; -mHeader -- -> -writerState +mBuf = -State -: -: -Waiting -; -while +static_cast +< +char +* +> ( -! -mHelpers +mSharedMemory - > -ReaderClosed +memory ( ) -& -& -mHeader -- -> -readerState -! -= -State -: -: -Failed ) -{ -if -( -mWriterSemaphore -- +; +mRead += +reinterpret_cast +< +ReadFooter +* > -Wait -( -Some ( -TimeDuration -: -: -FromMilliseconds +mBuf ++ +StreamSize ( -100 ) ) +; +mWrite += +reinterpret_cast +< +WriteFooter +* +> +( +mBuf ++ +StreamSize +( ) ++ +kCacheLineSize ) -{ -MOZ_ASSERT -( -mHeader -- -> -processedCount -> +; +mOurCount = -aCheckpoint -) +0 ; return true ; } -} -mHeader -- -> -writerState -= -State +bool +CanvasEventRingBuffer : : -Failed -; +WaitForAndRecalculateAvailableSpace +( +) +{ +if +( +! +good +( +) +) +{ return false ; } -void -CanvasDrawEventRecorder -: -: -WriteInternalEvent +uint32_t +bufPos += +mOurCount +% +StreamSize ( -EventType -aEventType ) -{ -MOZ_ASSERT -( -mCurrentBuffer -. -SizeRemaining +; +uint32_t +maxToWrite += +StreamSize ( ) -> -0 -) +- +bufPos ; -WriteElement +mAvailable += +std +: +: +min ( -mCurrentBuffer -. -Writer +maxToWrite +WaitForBytesToWrite ( ) -aEventType ) ; -IncrementEventCount +if ( +! +mAvailable ) +{ +mBufPos += +nullptr +; +return +false ; } -gfx -: -: -ContiguousBuffer -& -CanvasDrawEventRecorder +mBufPos += +mBuf ++ +bufPos +; +return +true +; +} +void +CanvasEventRingBuffer : : -GetContiguousBuffer +write ( +const +char +* +const +aData +const size_t aSize ) { +const +char +* +curDestPtr += +aData +; +size_t +remainingToWrite += +aSize +; if ( -mCurrentBuffer -. -SizeRemaining +remainingToWrite +> +mAvailable +) +{ +if +( +! +WaitForAndRecalculateAvailableSpace ( ) -> -aSize ) { return -mCurrentBuffer ; } +} if ( -mRecycledBuffers -. -front +remainingToWrite +< += +mAvailable +) +{ +memcpy ( +mBufPos +curDestPtr +remainingToWrite ) -. -Capacity +; +UpdateWriteTotalsBy ( +remainingToWrite ) -> -aSize -& -& -mRecycledBuffers -. -front +; +return +; +} +do +{ +memcpy ( +mBufPos +curDestPtr +mAvailable ) -. -eventCount -< +; +IncrementWriteCountBy +( +mAvailable +) +; +curDestPtr ++ = -mHeader +mAvailable +; +remainingToWrite - -> -processedCount -) -{ += +mAvailable +; if ( -mCurrentBuffer -. -Capacity +! +WaitForAndRecalculateAvailableSpace ( ) -= -= -mDefaultBufferSize ) { -WriteInternalEvent +return +; +} +} +while ( -RECYCLE_BUFFER +remainingToWrite +> +mAvailable ) ; -mRecycledBuffers -. -emplace +memcpy ( -std +mBufPos +curDestPtr +remainingToWrite +) +; +UpdateWriteTotalsBy +( +remainingToWrite +) +; +} +void +CanvasEventRingBuffer : : -move +IncrementWriteCountBy ( -mCurrentBuffer -. -shmem +uint32_t +aCount ) -mHeader +{ +mOurCount ++ += +aCount +; +mWrite - > -eventCount -) +count += +mOurCount ; -} -else +if +( +mRead +- +> +state +! += +State +: +: +Processing +) { -WriteInternalEvent +CheckAndSignalReader ( -DROP_BUFFER ) ; } -mCurrentBuffer -= -CanvasBuffer -( -std +} +void +CanvasEventRingBuffer : : -move -( -mRecycledBuffers -. -front +UpdateWriteTotalsBy ( +uint32_t +aCount ) -. -shmem -) +{ +IncrementWriteCountBy +( +aCount ) ; -mRecycledBuffers -. -pop +mBufPos ++ += +aCount +; +mAvailable +- += +aCount +; +} +bool +CanvasEventRingBuffer +: +: +WaitForAndRecalculateAvailableData ( ) -; +{ if ( -mRecycledBuffers -. -size -( -) -> -1 -& -& -mRecycledBuffers -. -front +! +good ( ) -. -eventCount -< -mHeader -- -> -processedCount ) { -if -( -- -- -mDropBufferOnZero -= +return +false +; +} +uint32_t +bufPos = -0 -) -{ -WriteInternalEvent +mOurCount +% +StreamSize ( -DROP_BUFFER ) ; -mCurrentBuffer +uint32_t +maxToRead = -CanvasBuffer +StreamSize ( +) +- +bufPos +; +mAvailable += std : : -move +min ( -mRecycledBuffers -. -front +maxToRead +WaitForBytesToRead ( ) -. -shmem -) ) ; -mRecycledBuffers -. -pop +if +( +! +mAvailable +) +{ +SetIsBad ( ) ; -mDropBufferOnZero +mBufPos = -1 +nullptr +; +return +false ; } -} -else -{ -mDropBufferOnZero +mBufPos = -mDropBufferLimit +mBuf ++ +bufPos ; -} return -mCurrentBuffer +true ; } -WriteInternalEvent +void +CanvasEventRingBuffer +: +: +read ( -PAUSE_TRANSLATION +char +* +const +aOut +const +size_t +aSize ) +{ +char +* +curSrcPtr += +aOut +; +size_t +remainingToRead += +aSize ; if ( -mCurrentBuffer -. -Capacity -( -) -= -= -mDefaultBufferSize +remainingToRead +> +mAvailable ) { -mRecycledBuffers -. -emplace +if ( -std -: -: -move +! +WaitForAndRecalculateAvailableData ( -mCurrentBuffer -. -shmem ) -mHeader -- -> -eventCount ) +{ +return ; } -size_t -bufferSize +} +if +( +remainingToRead +< = -std -: -: -max +mAvailable +) +{ +memcpy ( -mDefaultBufferSize -ipc -: -: -SharedMemory -: -: -PageAlignedSize +curSrcPtr +mBufPos +remainingToRead +) +; +UpdateReadTotalsBy ( -aSize -+ -1 +remainingToRead ) +; +return +; +} +do +{ +memcpy +( +curSrcPtr +mBufPos +mAvailable ) ; -auto -newBuffer -= -CreateAndMapShmem +IncrementReadCountBy ( -bufferSize +mAvailable ) ; +curSrcPtr ++ += +mAvailable +; +remainingToRead +- += +mAvailable +; if ( -NS_WARN_IF -( -newBuffer -. -isNothing +! +WaitForAndRecalculateAvailableData ( ) ) -) { -mHeader -- +return +; +} +} +while +( +remainingToRead > -writerState -= -State -: -: -Failed +mAvailable +) ; -mCurrentBuffer -= -CanvasBuffer +memcpy ( -nullptr +curSrcPtr +mBufPos +remainingToRead ) ; -return -mCurrentBuffer +UpdateReadTotalsBy +( +remainingToRead +) ; } -if -( -! -mHelpers -- -> -AddBuffer -( -std +void +CanvasEventRingBuffer : : -move +IncrementReadCountBy ( -newBuffer -- -> -handle -) -bufferSize -) +uint32_t +aCount ) { -mHeader +mOurCount ++ += +aCount +; +mRead +- +> +count += +mOurCount +; +if +( +mWrite - > -writerState +state +! = State : : -Failed -; -mCurrentBuffer -= -CanvasBuffer +Processing +) +{ +CheckAndSignalWriter ( -nullptr ) ; -return -mCurrentBuffer -; } -mCurrentBuffer -= -CanvasBuffer -( -std +} +void +CanvasEventRingBuffer : : -move +UpdateReadTotalsBy ( -newBuffer -- -> -shmem +uint32_t +aCount ) +{ +IncrementReadCountBy +( +aCount ) ; -return -mCurrentBuffer +mBufPos ++ += +aCount +; +mAvailable +- += +aCount ; } void -CanvasDrawEventRecorder +CanvasEventRingBuffer : : -DropFreeBuffers -( -) -{ -while -( -mRecycledBuffers -. -size -( -) -> -1 -& -& -mRecycledBuffers -. -front -( -) -. -eventCount -< -mHeader -- -> -processedCount -) -{ -WriteInternalEvent -( -DROP_BUFFER -) -; -mCurrentBuffer -= -CanvasBuffer -( -std -: -: -move -( -mRecycledBuffers -. -front -( -) -. -shmem -) -) -; -mRecycledBuffers -. -pop -( -) -; -} -} -void -CanvasDrawEventRecorder -: -: -IncrementEventCount -( -) -{ -mHeader -- -> -eventCount -+ -+ -; -CheckAndSignalReader -( -) -; -} -void -CanvasDrawEventRecorder -: -: -CheckAndSignalReader +CheckAndSignalReader ( ) { @@ -1328,10 +1432,10 @@ do { switch ( -mHeader +mRead - > -readerState +state ) { case @@ -1344,12 +1448,6 @@ case State : : -Paused -: -case -State -: -: Failed : return @@ -1362,7 +1460,7 @@ AboutToWait : if ( -mHelpers +mWriterServices - > ReaderClosed @@ -1383,23 +1481,21 @@ Waiting : if ( -mHeader +mRead - > -processedCount -< -mHeader -- -> -eventCount +count +! += +mOurCount ) { if ( -mHeader +mRead - > -readerState +state . compareExchange ( @@ -1426,10 +1522,10 @@ return } MOZ_ASSERT ( -mHeader +mRead - > -readerState +state = = State @@ -1451,72 +1547,1293 @@ Stopped : if ( -mHeader -- -> -processedCount -< -mHeader +mRead - > -eventCount +count +! += +mOurCount ) { -mHeader +mRead - > -readerState +state = State : : Processing ; -if +mWriterServices +- +> +ResumeReader +( +) +; +} +return +; +default +: +MOZ_ASSERT_UNREACHABLE +( +" +Invalid +waiting +state +. +" +) +; +return +; +} +} +while +( +true +) +; +} +bool +CanvasEventRingBuffer +: +: +HasDataToRead +( +) +{ +return ( +mWrite +- +> +count ! -mHelpers += +mOurCount +) +; +} +bool +CanvasEventRingBuffer +: +: +StopIfEmpty +( +) +{ +CheckAndSignalWriter +( +) +; +mRead - > -RestartReader +state += +State +: +: +AboutToWait +; +if +( +HasDataToRead ( ) ) { -mHeader +mRead - > -writerState +state = State : : -Failed +Processing +; +return +false ; } -} +mRead +- +> +state += +State +: +: +Stopped +; return +true ; -default +} +bool +CanvasEventRingBuffer : -MOZ_ASSERT_UNREACHABLE +: +WaitForDataToRead ( -" -Invalid -waiting -state -. -" +TimeDuration +aTimeout +int32_t +aRetryCount ) +{ +uint32_t +spinCount += +kMaxSpinCount ; +do +{ +if +( +HasDataToRead +( +) +) +{ return +true ; } } while ( +- +- +spinCount +! += +0 +) +; +CheckAndSignalWriter +( +) +; +mRead +- +> +state += +State +: +: +AboutToWait +; +if +( +HasDataToRead +( +) +) +{ +mRead +- +> +state += +State +: +: +Processing +; +return true +; +} +mRead +- +> +state += +State +: +: +Waiting +; +do +{ +if +( +mReaderSemaphore +- +> +Wait +( +Some +( +aTimeout +) ) +) +{ +MOZ_RELEASE_ASSERT +( +HasDataToRead +( +) +) +; +return +true +; +} +if +( +mReaderServices +- +> +WriterClosed +( +) +) +{ +return +false +; +} +} +while +( +aRetryCount +- +- +> +0 +) +; +if +( +! +mRead +- +> +state +. +compareExchange +( +State +: +: +Waiting +State +: +: +Stopped +) +) +{ +MOZ_RELEASE_ASSERT +( +HasDataToRead +( +) +) +; +MOZ_RELEASE_ASSERT +( +mRead +- +> +state += += +State +: +: +Processing +) +; +MOZ_ALWAYS_TRUE +( +mReaderSemaphore +- +> +Wait +( +) +) +; +return +true +; +} +return +false +; +} +uint8_t +CanvasEventRingBuffer +: +: +ReadNextEvent +( +) +{ +uint8_t +nextEvent +; +ReadElement +( +* +this +nextEvent +) +; +while +( +nextEvent += += +kCheckpointEventType +& +& +good +( +) +) +{ +ReadElement +( +* +this +nextEvent +) +; +} +if +( +nextEvent += += +kDropBufferEventType +) +{ +mBuf += +nullptr +; +mBufPos += +nullptr +; +mRead += +nullptr +; +mWrite += +nullptr +; +mAvailable += +0 +; +mSharedMemory += +nullptr +; +mLargeStream += +! +mLargeStream +; +} +return +nextEvent +; +} +uint32_t +CanvasEventRingBuffer +: +: +CreateCheckpoint +( +) +{ +WriteElement +( +* +this +kCheckpointEventType +) +; +return +mOurCount +; +} +bool +CanvasEventRingBuffer +: +: +WaitForCheckpoint +( +uint32_t +aCheckpoint +) +{ +return +WaitForReadCount +( +aCheckpoint +kTimeout +) +; +} +bool +CanvasEventRingBuffer +: +: +SwitchBuffer +( +base +: +: +ProcessId +aOtherPid +ipc +: +: +SharedMemoryBasic +: +: +Handle +* +aReadHandle +) +{ +WriteElement +( +* +this +kDropBufferEventType +) +; +if +( +! +WaitForCheckpoint +( +mOurCount +) +) +{ +return +false +; +} +mBuf += +nullptr +; +mBufPos += +nullptr +; +mRead += +nullptr +; +mWrite += +nullptr +; +mAvailable += +0 +; +mSharedMemory += +nullptr +; +mLargeStream += +! +mLargeStream +; +return +InitBuffer +( +aOtherPid +aReadHandle +) +; +} +void +CanvasEventRingBuffer +: +: +CheckAndSignalWriter +( +) +{ +do +{ +switch +( +mWrite +- +> +state +) +{ +case +State +: +: +Processing +: +return +; +case +State +: +: +AboutToWait +: +if +( +mReaderServices +- +> +WriterClosed +( +) +) +{ +return +; +} +continue +; +case +State +: +: +Waiting +: +if +( +mWrite +- +> +count +- +mOurCount +< += +mWrite +- +> +requiredDifference +) +{ +mWrite +- +> +state += +State +: +: +Processing +; +mWriterSemaphore +- +> +Signal +( +) +; +} +return +; +default +: +MOZ_ASSERT_UNREACHABLE +( +" +Invalid +waiting +state +. +" +) +; +return +; +} +} +while +( +true +) +; +} +bool +CanvasEventRingBuffer +: +: +WaitForReadCount +( +uint32_t +aReadCount +TimeDuration +aTimeout +) +{ +uint32_t +requiredDifference += +mOurCount +- +aReadCount +; +uint32_t +spinCount += +kMaxSpinCount +; +do +{ +if +( +mOurCount +- +mRead +- +> +count +< += +requiredDifference +) +{ +return +true +; +} +} +while +( +- +- +spinCount +! += +0 +) +; +CheckAndSignalReader +( +) +; +mWrite +- +> +state += +State +: +: +AboutToWait +; +if +( +mOurCount +- +mRead +- +> +count +< += +requiredDifference +) +{ +mWrite +- +> +state += +State +: +: +Processing +; +return +true +; +} +mWrite +- +> +requiredDifference += +requiredDifference +; +mWrite +- +> +state += +State +: +: +Waiting +; +while +( +! +mWriterServices +- +> +ReaderClosed +( +) +& +& +mRead +- +> +state +! += +State +: +: +Failed +) +{ +if +( +mWriterSemaphore +- +> +Wait +( +Some +( +aTimeout +) +) +) +{ +MOZ_ASSERT +( +mOurCount +- +mRead +- +> +count +< += +requiredDifference +) +; +return +true +; +} +} +mWrite +- +> +state += +State +: +: +Failed +; +mGood += +false +; +return +false +; +} +uint32_t +CanvasEventRingBuffer +: +: +WaitForBytesToWrite +( +) +{ +uint32_t +streamFullReadCount += +mOurCount +- +StreamSize +( +) +; +if +( +! +WaitForReadCount +( +streamFullReadCount ++ +1 +kTimeout +) +) +{ +return +0 +; +} +return +mRead +- +> +count +- +streamFullReadCount +; +} +uint32_t +CanvasEventRingBuffer +: +: +WaitForBytesToRead +( +) +{ +if +( +! +WaitForDataToRead +( +kTimeout +kTimeoutRetryCount +) +) +{ +return +0 +; +} +return +mWrite +- +> +count +- +mOurCount +; +} +void +CanvasEventRingBuffer +: +: +ReturnWrite +( +const +char +* +aData +size_t +aSize +) +{ +uint32_t +writeCount += +mRead +- +> +returnCount +; +uint32_t +bufPos += +writeCount +% +StreamSize +( +) +; +uint32_t +bufRemaining += +StreamSize +( +) +- +bufPos +; +uint32_t +availableToWrite += +std +: +: +min +( +bufRemaining +( +mWrite +- +> +returnCount ++ +StreamSize +( +) +- +writeCount +) +) +; +while +( +availableToWrite +< +aSize +) +{ +if +( +availableToWrite +) +{ +memcpy +( +mBuf ++ +bufPos +aData +availableToWrite +) +; +writeCount ++ += +availableToWrite +; +mRead +- +> +returnCount += +writeCount +; +bufPos += +writeCount +% +StreamSize +( +) +; +bufRemaining += +StreamSize +( +) +- +bufPos +; +aData ++ += +availableToWrite +; +aSize +- += +availableToWrite +; +} +else +if +( +mReaderServices +- +> +WriterClosed +( +) +) +{ +return +; +} +availableToWrite += +std +: +: +min +( +bufRemaining +( +mWrite +- +> +returnCount ++ +StreamSize +( +) +- +writeCount +) +) +; +} +memcpy +( +mBuf ++ +bufPos +aData +aSize +) +; +writeCount ++ += +aSize +; +mRead +- +> +returnCount += +writeCount +; +} +void +CanvasEventRingBuffer +: +: +ReturnRead +( +char +* +aOut +size_t +aSize +) +{ +WaitForCheckpoint +( +mOurCount +) +; +uint32_t +readCount += +mWrite +- +> +returnCount +; +while +( +readCount += += +mRead +- +> +returnCount +) +{ +if +( +mRead +- +> +state +! += +State +: +: +Processing +& +& +readCount += += +mRead +- +> +returnCount +) +{ +return +; +} +} +uint32_t +bufPos += +readCount +% +StreamSize +( +) +; +uint32_t +bufRemaining += +StreamSize +( +) +- +bufPos +; +uint32_t +availableToRead += +std +: +: +min +( +bufRemaining +( +mRead +- +> +returnCount +- +readCount +) +) +; +while +( +availableToRead +< +aSize +) +{ +if +( +availableToRead +) +{ +memcpy +( +aOut +mBuf ++ +bufPos +availableToRead +) +; +readCount ++ += +availableToRead +; +mWrite +- +> +returnCount += +readCount +; +bufPos += +readCount +% +StreamSize +( +) +; +bufRemaining += +StreamSize +( +) +- +bufPos +; +aOut ++ += +availableToRead +; +aSize +- += +availableToRead +; +} +else +if +( +mWriterServices +- +> +ReaderClosed +( +) +) +{ +return +; +} +availableToRead += +std +: +: +min +( +bufRemaining +( +mRead +- +> +returnCount +- +readCount +) +) +; +} +memcpy +( +aOut +mBuf ++ +bufPos +aSize +) +; +readCount ++ += +aSize +; +mWrite +- +> +returnCount += +readCount ; } void diff --git a/gfx/layers/CanvasDrawEventRecorder.h b/gfx/layers/CanvasDrawEventRecorder.h index efa8c4861375b..f22e1e8d3d68b 100644 --- a/gfx/layers/CanvasDrawEventRecorder.h +++ b/gfx/layers/CanvasDrawEventRecorder.h @@ -6,20 +6,6 @@ define mozilla_layers_CanvasDrawEventRecorder_h # include -< -queue -> -# -include -" -mozilla -/ -Atomics -. -h -" -# -include " mozilla / @@ -51,161 +37,48 @@ SharedMemoryBasic . h " -# -include -" -mozilla -/ -layers -/ -LayersTypes -. -h -" -# -include -" -mozilla -/ -RefPtr -. -h -" -# -include -" -mozilla -/ -UniquePtr -. -h -" namespace mozilla { -using -EventType -= -gfx -: -: -RecordedEvent -: -: -EventType -; namespace layers { -typedef -mozilla -: -: -ipc -: -: -SharedMemoryBasic -: -: -Handle -Handle +static +const +uint8_t +kCheckpointEventType += +- +1 ; -typedef -mozilla -: -: -CrossProcessSemaphoreHandle -CrossProcessSemaphoreHandle +static +const +uint8_t +kDropBufferEventType += +- +2 ; class -CanvasDrawEventRecorder +CanvasEventRingBuffer final : public gfx : : -DrawEventRecorderPrivate -public -gfx -: -: -ContiguousBufferStream +EventRingBuffer { public : -MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME -( -CanvasDrawEventRecorder -final -) -CanvasDrawEventRecorder -( -) -; -enum -class -State -: -uint32_t -{ -Processing -AboutToWait -Waiting -Paused -Stopped -Failed -} -; -struct -Header -{ -Atomic -< -int64_t -> -eventCount -; -Atomic -< -int64_t -> -writerWaitCount -; -Atomic -< -State -> -writerState -; -uint8_t -padding1 -[ -44 -] -; -Atomic -< -int64_t -> -processedCount -; -Atomic -< -State -> -readerState -; -} -; class -Helpers +WriterServices { public : virtual ~ -Helpers +WriterServices ( ) = @@ -213,70 +86,38 @@ default ; virtual bool -InitTranslator +ReaderClosed ( -const -TextureType -& -aTextureType -Handle -& -& -aReadHandle -nsTArray -< -Handle -> -& -& -aBufferHandles -const -uint64_t -& -aBufferSize -CrossProcessSemaphoreHandle -& -& -aReaderSem -CrossProcessSemaphoreHandle -& -& -aWriterSem -const -bool -& -aUseIPDLThread ) = 0 ; virtual -bool -AddBuffer +void +ResumeReader ( -Handle -& -& -aBufferHandle -const -uint64_t -& -aBufferSize ) = 0 ; +} +; +class +ReaderServices +{ +public +: virtual -bool -ReaderClosed +~ +ReaderServices ( ) = -0 +default ; virtual bool -RestartReader +WriterClosed ( ) = @@ -284,139 +125,433 @@ RestartReader ; } ; -bool -Init +CanvasEventRingBuffer ( -TextureType -aTextureType -UniquePtr -< -Helpers -> -aHelpers ) -; -void -RecordEvent +{ +} +bool +InitBuffer ( -const -gfx +base : : -RecordedEvent -& -aEvent +ProcessId +aOtherPid +ipc +: +: +SharedMemoryBasic +: +: +Handle +* +aReadHandle ) -final ; -void -StoreSourceSurfaceRecording +bool +InitWriter ( -gfx +base : : -SourceSurface +ProcessId +aOtherPid +ipc +: +: +SharedMemoryBasic +: +: +Handle * -aSurface -const -char +aReadHandle +CrossProcessSemaphoreHandle * -aReason +aReaderSem +CrossProcessSemaphoreHandle +* +aWriterSem +UniquePtr +< +WriterServices +> +aWriterServices ) -final ; -void -Flush +bool +InitReader ( +ipc +: +: +SharedMemoryBasic +: +: +Handle +aReadHandle +CrossProcessSemaphoreHandle +aReaderSem +CrossProcessSemaphoreHandle +aWriterSem +UniquePtr +< +ReaderServices +> +aReaderServices ) -final -{ -} -int64_t -CreateCheckpoint +; +bool +SetNewBuffer ( +ipc +: +: +SharedMemoryBasic +: +: +Handle +aReadHandle ) ; bool -WaitForCheckpoint +IsValid ( -int64_t -aCheckpoint ) +const +{ +return +mSharedMemory ; -TextureType -GetTextureType +} +bool +good +( +) +const +final +{ +return +mGood +; +} +bool +WriterFailed ( ) +const { return -mTextureType +mWrite +& +& +mWrite +- +> +state += += +State +: +: +Failed ; } void -DropFreeBuffers +SetIsBad ( ) +final +{ +mGood += +false ; -protected -: -gfx +mRead +- +> +state += +State : : -ContiguousBuffer -& -GetContiguousBuffer +Failed +; +} +void +write ( +const +char +* +const +aData +const size_t aSize ) final ; +bool +HasDataToRead +( +) +; +bool +StopIfEmpty +( +) +; +bool +WaitForDataToRead +( +TimeDuration +aTimeout +int32_t +aRetryCount +) +; +uint8_t +ReadNextEvent +( +) +; void -IncrementEventCount +read ( +char +* +const +aOut +const +size_t +aSize ) final ; -private +uint32_t +CreateCheckpoint +( +) +; +bool +WaitForCheckpoint +( +uint32_t +aCheckpoint +) +; +bool +SwitchBuffer +( +base +: +: +ProcessId +aOtherPid +ipc +: +: +SharedMemoryBasic +: : +Handle +* +aHandle +) +; void -WriteInternalEvent +ReturnWrite ( -EventType -aEventType +const +char +* +aData +size_t +aSize ) ; void -CheckAndSignalReader +ReturnRead ( +char +* +aOut +size_t +aSize ) ; -size_t -mDefaultBufferSize +bool +UsingLargeStream +( +) +{ +return +mLargeStream +; +} +protected +: +bool +WaitForAndRecalculateAvailableSpace +( +) +final +; +void +UpdateWriteTotalsBy +( +uint32_t +aCount +) +final ; +private +: +enum +class +State +: uint32_t -mMaxSpinCount +{ +Processing +AboutToWait +Waiting +Stopped +Failed +} ; +struct +ReadFooter +{ +Atomic +< uint32_t -mDropBufferLimit +> +count ; +Atomic +< uint32_t -mDropBufferOnZero +> +returnCount ; -UniquePtr +Atomic +< +State +> +state +; +} +; +struct +WriteFooter +{ +Atomic +< +uint32_t +> +count +; +Atomic +< +uint32_t +> +returnCount +; +Atomic +< +uint32_t +> +requiredDifference +; +Atomic < -Helpers +State > -mHelpers +state ; -TextureType -mTextureType +} +; +CanvasEventRingBuffer +( +const +CanvasEventRingBuffer +& +) = -TextureType -: -: -Unknown +delete +; +void +operator += +( +const +CanvasEventRingBuffer +& +) += +delete +; +void +IncrementWriteCountBy +( +uint32_t +aCount +) +; +bool +WaitForReadCount +( +uint32_t +aReadCount +TimeDuration +aTimeout +) +; +bool +WaitForAndRecalculateAvailableData +( +) +; +void +UpdateReadTotalsBy +( +uint32_t +aCount +) +; +void +IncrementReadCountBy +( +uint32_t +aCount +) +; +void +CheckAndSignalReader +( +) +; +void +CheckAndSignalWriter +( +) +; +uint32_t +WaitForBytesToWrite +( +) +; +uint32_t +WaitForBytesToRead +( +) +; +uint32_t +StreamSize +( +) ; RefPtr < @@ -425,196 +560,294 @@ ipc : SharedMemoryBasic > -mHeaderShmem +mSharedMemory +; +UniquePtr +< +CrossProcessSemaphore +> +mReaderSemaphore +; +UniquePtr +< +CrossProcessSemaphore +> +mWriterSemaphore ; -Header +UniquePtr +< +WriterServices +> +mWriterServices +; +UniquePtr +< +ReaderServices +> +mReaderServices +; +char * -mHeader +mBuf = nullptr ; -struct -CanvasBuffer +uint32_t +mOurCount += +0 +; +WriteFooter +* +mWrite += +nullptr +; +ReadFooter +* +mRead += +nullptr +; +bool +mGood += +false +; +bool +mLargeStream += +true +; +} +; +class +CanvasDrawEventRecorder +final : public gfx : : -ContiguousBuffer +DrawEventRecorderPrivate { -RefPtr -< -ipc -: +public : -SharedMemoryBasic -> -shmem -; -CanvasBuffer +MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME ( +CanvasDrawEventRecorder +final ) -: -ContiguousBuffer +explicit +CanvasDrawEventRecorder ( -nullptr ) { } -explicit -CanvasBuffer +; +bool +Init ( -RefPtr -< +base +: +: +ProcessId +aOtherPid ipc : : SharedMemoryBasic -> -& -& -aShmem -) : -ContiguousBuffer -( -static_cast -< -char +: +Handle * +aHandle +CrossProcessSemaphoreHandle +* +aReaderSem +CrossProcessSemaphoreHandle +* +aWriterSem +UniquePtr +< +CanvasEventRingBuffer +: +: +WriterServices > -( -aShmem -- -> -memory -( -) -) -aShmem -- -> -Size -( +aWriterServices ) -) -shmem +{ +return +mOutputStream +. +InitWriter ( +aOtherPid +aHandle +aReaderSem +aWriterSem std : : move ( -aShmem +aWriterServices ) ) -{ +; } -size_t -Capacity +void +RecordEvent ( +const +gfx +: +: +RecordedEvent +& +aEvent ) +final { -return -shmem -- -> -Size +if +( +! +mOutputStream +. +good ( ) -; -} -} -; -struct -RecycledBuffer +) { -RefPtr -< -ipc -: -: -SharedMemoryBasic -> -shmem +return ; -int64_t -eventCount -= -0 +} +aEvent +. +RecordToStream +( +mOutputStream +) ; -explicit -RecycledBuffer +} +void +StoreSourceSurfaceRecording ( -RefPtr -< -ipc +gfx : : -SharedMemoryBasic -> -& -& -aShmem -int64_t -aEventCount +SourceSurface +* +aSurface +const +char +* +aReason ) -: -shmem +final +; +void +Flush ( -std -: -: -move +) +final +{ +} +void +ReturnRead ( -aShmem +char +* +aOut +size_t +aSize ) +{ +mOutputStream +. +ReturnRead +( +aOut +aSize ) -eventCount +; +} +uint32_t +CreateCheckpoint ( -aEventCount ) { +return +mOutputStream +. +CreateCheckpoint +( +) +; } -size_t -Capacity +bool +WaitForCheckpoint ( +uint32_t +aCheckpoint ) { return -shmem -- -> -Size +mOutputStream +. +WaitForCheckpoint ( +aCheckpoint ) ; } -} -; -CanvasBuffer -mCurrentBuffer +bool +UsingLargeStream +( +) +{ +return +mOutputStream +. +UsingLargeStream +( +) ; -std +} +bool +SwitchBuffer +( +base : : -queue -< -RecycledBuffer -> -mRecycledBuffers -; -UniquePtr -< -CrossProcessSemaphore -> -mWriterSemaphore +ProcessId +aOtherPid +ipc +: +: +SharedMemoryBasic +: +: +Handle +* +aHandle +) +{ +return +mOutputStream +. +SwitchBuffer +( +aOtherPid +aHandle +) ; -UniquePtr -< -CrossProcessSemaphore -> -mReaderSemaphore +} +private +: +CanvasEventRingBuffer +mOutputStream ; } ; diff --git a/gfx/layers/RecordedCanvasEventImpl.h b/gfx/layers/RecordedCanvasEventImpl.h index 2b87d280c1ec7..5f66800a225da 100644 --- a/gfx/layers/RecordedCanvasEventImpl.h +++ b/gfx/layers/RecordedCanvasEventImpl.h @@ -307,68 +307,6 @@ LAST 12 ) ; -const -EventType -CHECKPOINT -= -EventType -( -EventType -: -: -LAST -+ -13 -) -; -const -EventType -PAUSE_TRANSLATION -= -EventType -( -EventType -: -: -LAST -+ -14 -) -; -const -EventType -RECYCLE_BUFFER -= -EventType -( -EventType -: -: -LAST -+ -15 -) -; -const -EventType -DROP_BUFFER -= -EventType -( -EventType -: -: -LAST -+ -16 -) -; -const -EventType -LAST_CANVAS_EVENT_TYPE -= -DROP_BUFFER -; class RecordedCanvasBeginTransaction final @@ -1791,16 +1729,168 @@ aTranslator ) const { +gfx +: +: +SourceSurface +* +surface += aTranslator - > -GetDataSurface +LookupSourceSurface +( +mSurface +) +; +if +( +! +surface +) +{ +return +false +; +} +UniquePtr +< +gfx +: +: +DataSourceSurface +: +: +ScopedMap +> +map += +aTranslator +- +> +GetPreparedMap ( mSurface +) +; +if +( +! +map +) +{ +return +false +; +} +int32_t +dataFormatWidth += +surface +- +> +GetSize +( +) +. +width +* +BytesPerPixel +( +surface +- +> +GetFormat +( +) +) +; +int32_t +srcStride += +map +- +> +GetStride +( +) +; +if +( +dataFormatWidth +> +srcStride +) +{ +return +false +; +} +char +* +src += +reinterpret_cast +< +char +* +> +( +map +- +> +GetData +( +) +) +; +char +* +endSrc += +src ++ +( +map +- +> +GetSurface +( +) +- +> +GetSize +( +) . -mLongPtr +height +* +srcStride +) +; +while +( +src +< +endSrc +) +{ +aTranslator +- +> +ReturnWrite +( +src +dataFormatWidth ) ; +src ++ += +srcStride +; +} return true ; @@ -2707,428 +2797,52 @@ mTextureId ) ; } -class -RecordedCheckpoint -final -: -public -RecordedEventDerived -< -RecordedCheckpoint -> -{ -public -: -RecordedCheckpoint +# +define +FOR_EACH_CANVAS_EVENT ( +f ) -: -RecordedEventDerived +\ +f ( -CHECKPOINT +CANVAS_BEGIN_TRANSACTION +RecordedCanvasBeginTransaction ) -{ -} -template -< -class -S -> -MOZ_IMPLICIT -RecordedCheckpoint +; +\ +f ( -S -& -aStream +CANVAS_END_TRANSACTION +RecordedCanvasEndTransaction ) -: -RecordedEventDerived +; +\ +f ( -CHECKPOINT +CANVAS_FLUSH +RecordedCanvasFlush ) -{ -} -bool -PlayCanvasEvent +; +\ +f ( -CanvasTranslator -* -aTranslator +TEXTURE_LOCK +RecordedTextureLock ) -const -{ -aTranslator -- -> -CheckpointReached +; +\ +f ( +TEXTURE_UNLOCK +RecordedTextureUnlock ) ; -return -true -; -} -template -< -class -S -> -void -Record -( -S -& -aStream -) -const -{ -} -std -: -: -string -GetName -( -) -const -final -{ -return -" -RecordedCheckpoint -" -; -} -} -; -class -RecordedPauseTranslation -final -: -public -RecordedEventDerived -< -RecordedPauseTranslation -> -{ -public -: -RecordedPauseTranslation -( -) -: -RecordedEventDerived -( -PAUSE_TRANSLATION -) -{ -} -template -< -class -S -> -MOZ_IMPLICIT -RecordedPauseTranslation -( -S -& -aStream -) -: -RecordedEventDerived -( -PAUSE_TRANSLATION -) -{ -} -bool -PlayCanvasEvent -( -CanvasTranslator -* -aTranslator -) -const -{ -aTranslator -- -> -PauseTranslation +\ +f ( -) -; -return -true -; -} -template -< -class -S -> -void -Record -( -S -& -aStream -) -const -{ -} -std -: -: -string -GetName -( -) -const -final -{ -return -" -RecordedPauseTranslation -" -; -} -} -; -class -RecordedRecycleBuffer -final -: -public -RecordedEventDerived -< -RecordedRecycleBuffer -> -{ -public -: -RecordedRecycleBuffer -( -) -: -RecordedEventDerived -( -RECYCLE_BUFFER -) -{ -} -template -< -class -S -> -MOZ_IMPLICIT -RecordedRecycleBuffer -( -S -& -aStream -) -: -RecordedEventDerived -( -RECYCLE_BUFFER -) -{ -} -bool -PlayCanvasEvent -( -CanvasTranslator -* -aTranslator -) -const -{ -aTranslator -- -> -RecycleBuffer -( -) -; -return -true -; -} -template -< -class -S -> -void -Record -( -S -& -aStream -) -const -{ -} -std -: -: -string -GetName -( -) -const -final -{ -return -" -RecordedNextBuffer -" -; -} -} -; -class -RecordedDropBuffer -final -: -public -RecordedEventDerived -< -RecordedDropBuffer -> -{ -public -: -RecordedDropBuffer -( -) -: -RecordedEventDerived -( -DROP_BUFFER -) -{ -} -template -< -class -S -> -MOZ_IMPLICIT -RecordedDropBuffer -( -S -& -aStream -) -: -RecordedEventDerived -( -DROP_BUFFER -) -{ -} -bool -PlayCanvasEvent -( -CanvasTranslator -* -aTranslator -) -const -{ -aTranslator -- -> -NextBuffer -( -) -; -return -true -; -} -template -< -class -S -> -void -Record -( -S -& -aStream -) -const -{ -} -std -: -: -string -GetName -( -) -const -final -{ -return -" -RecordedDropAndMoveNextBuffer -" -; -} -} -; -# -define -FOR_EACH_CANVAS_EVENT -( -f -) -\ -f -( -CANVAS_BEGIN_TRANSACTION -RecordedCanvasBeginTransaction -) -; -\ -f -( -CANVAS_END_TRANSACTION -RecordedCanvasEndTransaction -) -; -\ -f -( -CANVAS_FLUSH -RecordedCanvasFlush -) -; -\ -f -( -TEXTURE_LOCK -RecordedTextureLock -) -; -\ -f -( -TEXTURE_UNLOCK -RecordedTextureUnlock -) -; -\ -f -( -CACHE_DATA_SURFACE -RecordedCacheDataSurface +CACHE_DATA_SURFACE +RecordedCacheDataSurface ) ; \ @@ -3180,34 +2894,6 @@ TEXTURE_DESTRUCTION RecordedTextureDestruction ) ; -\ -f -( -CHECKPOINT -RecordedCheckpoint -) -; -\ -f -( -PAUSE_TRANSLATION -RecordedPauseTranslation -) -; -\ -f -( -RECYCLE_BUFFER -RecordedRecycleBuffer -) -; -\ -f -( -DROP_BUFFER -RecordedDropBuffer -) -; } } # diff --git a/gfx/layers/client/TextureRecorded.cpp b/gfx/layers/client/TextureRecorded.cpp index 8d2dbb2fd0441..76b9c81f2dcfd 100644 --- a/gfx/layers/client/TextureRecorded.cpp +++ b/gfx/layers/client/TextureRecorded.cpp @@ -66,8 +66,6 @@ mCanvasChild > EnsureRecorder ( -aSize -aFormat aTextureType ) ; diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index 69caf5dec1e33..205fd4041d818 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -153,17 +153,6 @@ mozilla / layers / -LayersMessages -. -h -" -# -include -" -mozilla -/ -layers -/ LayersSurfaces . h diff --git a/gfx/layers/ipc/CanvasChild.cpp b/gfx/layers/ipc/CanvasChild.cpp index 3a8b2370c6772..5b93e0362b88f 100644 --- a/gfx/layers/ipc/CanvasChild.cpp +++ b/gfx/layers/ipc/CanvasChild.cpp @@ -103,26 +103,6 @@ h # include " -mozilla -/ -layers -/ -SourceSurfaceSharedData -. -h -" -# -include -" -mozilla -/ -Maybe -. -h -" -# -include -" nsIObserverService . h @@ -140,27 +120,33 @@ mozilla namespace layers { +bool +CanvasChild +: +: +mInForeground += +true +; class -RecorderHelpers +RingBufferWriterServices final : public -CanvasDrawEventRecorder +CanvasEventRingBuffer : : -Helpers +WriterServices { public : explicit -RecorderHelpers +RingBufferWriterServices ( -const RefPtr < CanvasChild > -& aCanvasChild ) : @@ -171,7 +157,7 @@ aCanvasChild { } ~ -RecorderHelpers +RingBufferWriterServices ( ) override @@ -179,134 +165,6 @@ override default ; bool -InitTranslator -( -const -TextureType -& -aTextureType -Handle -& -& -aReadHandle -nsTArray -< -Handle -> -& -& -aBufferHandles -const -uint64_t -& -aBufferSize -CrossProcessSemaphoreHandle -& -& -aReaderSem -CrossProcessSemaphoreHandle -& -& -aWriterSem -const -bool -& -aUseIPDLThread -) -override -{ -if -( -! -mCanvasChild -) -{ -return -false -; -} -return -mCanvasChild -- -> -SendInitTranslator -( -aTextureType -std -: -: -move -( -aReadHandle -) -std -: -: -move -( -aBufferHandles -) -aBufferSize -std -: -: -move -( -aReaderSem -) -std -: -: -move -( -aWriterSem -) -aUseIPDLThread -) -; -} -bool -AddBuffer -( -Handle -& -& -aBufferHandle -const -uint64_t -& -aBufferSize -) -override -{ -if -( -! -mCanvasChild -) -{ -return -false -; -} -return -mCanvasChild -- -> -SendAddBuffer -( -std -: -: -move -( -aBufferHandle -) -aBufferSize -) -; -} -bool ReaderClosed ( ) @@ -343,8 +201,8 @@ ExpectingShutdown ) ; } -bool -RestartReader +void +ResumeReader ( ) override @@ -356,14 +214,12 @@ mCanvasChild ) { return -false ; } -return mCanvasChild - > -SendRestartTranslation +ResumeTranslation ( ) ; @@ -944,16 +800,6 @@ CanvasChild : EnsureRecorder ( -gfx -: -: -IntSize -aSize -gfx -: -: -SurfaceFormat -aFormat TextureType aTextureType ) @@ -964,28 +810,62 @@ if mRecorder ) { -auto -recorder +MOZ_ASSERT +( +mTextureType += += +TextureType +: +: +Unknown +) +; +mTextureType += +aTextureType +; +mRecorder = -MakeRefPtr +MakeAndAddRef < CanvasDrawEventRecorder > ( ) ; +SharedMemoryBasic +: +: +Handle +handle +; +CrossProcessSemaphoreHandle +readerSem +; +CrossProcessSemaphoreHandle +writerSem +; if ( ! -recorder +mRecorder - > Init ( -aTextureType +OtherPid +( +) +& +handle +& +readerSem +& +writerSem MakeUnique < -RecorderHelpers +RingBufferWriterServices > ( this @@ -993,26 +873,55 @@ this ) ) { +mRecorder += +nullptr +; return ; } -mRecorder -= -recorder -. -forget +if +( +CanSend +( +) +) +{ +Unused +< +< +SendInitTranslator +( +mTextureType +std +: +: +move +( +handle +) +std +: +: +move +( +readerSem +) +std +: +: +move ( +writerSem +) +false ) ; } +} MOZ_RELEASE_ASSERT ( -mRecorder -- -> -GetTextureType -( -) +mTextureType = = aTextureType @@ -1028,12 +937,6 @@ currently " ) ; -EnsureDataSurfaceShmem -( -aSize -aFormat -) -; } void CanvasChild @@ -1045,12 +948,29 @@ ActorDestroyReason aWhy ) { +if +( +mRecorder +) +{ +mRecorder +- +> +DetachResources +( +) +; +mRecorder += +nullptr +; +} } void CanvasChild : : -Destroy +ResumeTranslation ( ) { @@ -1061,9 +981,8 @@ CanSend ) ) { -Send__delete__ +SendResumeTranslation ( -this ) ; } @@ -1072,15 +991,46 @@ void CanvasChild : : -OnTextureWriteLock +Destroy ( ) { -mHasOutstandingWriteLock -= -true -; -mLastWriteLockCheckpoint +if +( +CanSend +( +) +) +{ +Send__delete__ +( +this +) +; +} +} +void +CanvasChild +: +: +OnTextureWriteLock +( +) +{ +if +( +! +mRecorder +) +{ +return +; +} +mHasOutstandingWriteLock += +true +; +mLastWriteLockCheckpoint = mRecorder - @@ -1100,6 +1050,19 @@ OnTextureForwarded { if ( +! +mRecorder +) +{ +return +; +} +mInForeground += +true +; +if +( mHasOutstandingWriteLock ) { @@ -1170,119 +1133,136 @@ EnsureBeginTransaction if ( ! -mIsInTransaction +mRecorder ) { -RecordEvent -( -RecordedCanvasBeginTransaction -( -) -) -; -mIsInTransaction -= -true -; -} return -true +false ; } -void -CanvasChild -: -: -EndTransaction -( -) -{ if ( +! mIsInTransaction ) { -RecordEvent +if ( -RecordedCanvasEndTransaction +mInForeground +! += +mRecorder +- +> +UsingLargeStream ( ) ) -; -mIsInTransaction -= -false -; -mDormant -= -false -; -} -else { +SharedMemoryBasic +: +: +Handle +handle +; if ( ! -mDormant -) -{ -mDormant -= -true -; -NS_DelayedDispatchToCurrentThread +mRecorder +- +> +SwitchBuffer ( -NewRunnableMethod +OtherPid ( -" -CanvasChild -: -: -DropFreeBuffersWhenDormant -" -this +) & -CanvasChild -: -: -DropFreeBuffersWhenDormant +handle ) -StaticPrefs +| +| +! +SendNewBuffer +( +std : : -gfx_canvas_remote_drop_buffer_milliseconds +move ( +handle +) ) ) +{ +mRecorder += +nullptr +; +return +false ; } } -+ -+ -mTransactionsSinceGetDataSurface +mRecorder +- +> +RecordEvent +( +RecordedCanvasBeginTransaction +( +) +) +; +mIsInTransaction += +true +; +} +return +true ; } void CanvasChild : : -DropFreeBuffersWhenDormant +EndTransaction +( +) +{ +if ( +! +mRecorder ) { +return +; +} if ( -mDormant +mIsInTransaction ) { mRecorder - > -DropFreeBuffers +RecordEvent +( +RecordedCanvasEndTransaction ( ) +) +; +mIsInTransaction += +false ; } ++ ++ +mTransactionsSinceGetDataSurface +; } void CanvasChild @@ -1292,12 +1272,9 @@ ClearCachedResources ( ) { -mRecorder -- -> -DropFreeBuffers -( -) +mInForeground += +false ; } bool @@ -1321,6 +1298,10 @@ true ; } return +! +mRecorder +| +| mRecorder - > @@ -1353,6 +1334,16 @@ SurfaceFormat aFormat ) { +if +( +! +mRecorder +) +{ +return +nullptr +; +} RefPtr < gfx @@ -1432,231 +1423,42 @@ forget ) ; } -bool +void CanvasChild : : -EnsureDataSurfaceShmem +RecordEvent ( +const gfx : : -IntSize -aSize -gfx -: -: -SurfaceFormat -aFormat +RecordedEvent +& +aEvent ) { -size_t -dataFormatWidth -= -aSize -. -width -* -BytesPerPixel -( -aFormat -) -; -size_t -sizeRequired -= -ipc -: -: -SharedMemory -: -: -PageAlignedSize -( -dataFormatWidth -* -aSize -. -height -) -; if ( ! -mDataSurfaceShmemAvailable -| -| -mDataSurfaceShmem -- -> -Size -( -) -< -sizeRequired +mRecorder ) { +return +; +} +mRecorder +- +> RecordEvent ( -RecordedPauseTranslation -( -) +aEvent ) ; -auto -dataSurfaceShmem -= -MakeRefPtr +} +already_AddRefed < -ipc -: -: -SharedMemoryBasic -> -( -) -; -if -( -! -dataSurfaceShmem -- -> -Create -( -sizeRequired -) -| -| -! -dataSurfaceShmem -- -> -Map -( -sizeRequired -) -) -{ -return -false -; -} -auto -shmemHandle -= -dataSurfaceShmem -- -> -TakeHandle -( -) -; -if -( -! -shmemHandle -) -{ -return -false -; -} -if -( -! -SendSetDataSurfaceBuffer -( -std -: -: -move -( -shmemHandle -) -sizeRequired -) -) -{ -return -false -; -} -mDataSurfaceShmem -= -dataSurfaceShmem -. -forget -( -) -; -mDataSurfaceShmemAvailable -= -true -; -} -MOZ_ASSERT -( -mDataSurfaceShmemAvailable -) -; -return -true -; -} -void -CanvasChild -: -: -RecordEvent -( -const -gfx -: -: -RecordedEvent -& -aEvent -) -{ -if -( -! -mRecorder -) -{ -return -; -} -mRecorder -- -> -RecordEvent -( -aEvent -) -; -} -int64_t -CanvasChild -: -: -CreateCheckpoint -( -) -{ -return -mRecorder -- -> -CreateCheckpoint -( -) -; -} -already_AddRefed -< -gfx +gfx : : DataSourceSurface @@ -1690,6 +1492,16 @@ aSurface if ( ! +mRecorder +) +{ +return +nullptr +; +} +if +( +! mIsInTransaction ) { @@ -1710,6 +1522,9 @@ return nullptr ; } +mRecorder +- +> RecordEvent ( RecordedPrepareDataForSurface @@ -1718,6 +1533,16 @@ aSurface ) ) ; +uint32_t +checkpoint += +mRecorder +- +> +CreateCheckpoint +( +) +; gfx : : @@ -1744,92 +1569,7 @@ GetFormat ( ) ; -if -( -! -EnsureDataSurfaceShmem -( -ssSize -ssFormat -) -) -{ -return -nullptr -; -} -mDataSurfaceShmemAvailable -= -false -; -RecordEvent -( -RecordedGetDataForSurface -( -aSurface -) -) -; -auto -checkpoint -= -CreateCheckpoint -( -) -; -struct -DataShmemHolder -{ -RefPtr -< -ipc -: -: -SharedMemoryBasic -> -shmem -; -RefPtr -< -CanvasChild -> -canvasChild -; -} -; -auto -* -data -= -static_cast -< -uint8_t -* -> -( -mDataSurfaceShmem -- -> -memory -( -) -) -; -auto -* -closure -= -new -DataShmemHolder -{ -do_AddRef -( -mDataSurfaceShmem -) -this -} -; -auto +size_t dataFormatWidth = ssSize @@ -1856,64 +1596,129 @@ gfx Factory : : -CreateWrappingDataSourceSurface +CreateDataSourceSurfaceWithStride ( -data -dataFormatWidth ssSize ssFormat -[ -] +dataFormatWidth +) +; +if ( -void -* -aClosure +! +dataSurface ) { -auto +gfxWarning +( +) +< +< +" +Failed +to +create +DataSourceSurface +. +" +; +return +nullptr +; +} +gfx +: +: +DataSourceSurface +: +: +ScopedMap +map +( +dataSurface +gfx +: +: +DataSourceSurface +: +: +READ_WRITE +) +; +char * -shmemHolder +dest = -static_cast +reinterpret_cast < -DataShmemHolder +char * > ( -aClosure +map +. +GetData +( +) ) ; -shmemHolder -- -> -canvasChild -- -> -ReturnDataSurfaceShmem +if ( -shmemHolder +! +mRecorder - > -shmem -. -forget +WaitForCheckpoint ( +checkpoint +) ) +{ +gfxWarning +( ) +< +< +" +Timed +out +preparing +data +for +DataSourceSurface +. +" ; -delete -shmemHolder +return +dataSurface +. +forget +( +) ; } -closure +mRecorder +- +> +RecordEvent +( +RecordedGetDataForSurface +( +aSurface +) ) ; mRecorder - > -WaitForCheckpoint +ReturnRead ( -checkpoint +dest +ssSize +. +height +* +dataFormatWidth ) ; return @@ -1948,10 +1753,15 @@ SourceSurface aSurface ) { +MOZ_ASSERT +( +aSurface +) +; if ( ! -aSurface +mRecorder ) { return @@ -1970,52 +1780,5 @@ mRecorder ) ; } -void -CanvasChild -: -: -ReturnDataSurfaceShmem -( -already_AddRefed -< -ipc -: -: -SharedMemoryBasic -> -aDataSurfaceShmem -) -{ -RefPtr -< -ipc -: -: -SharedMemoryBasic -> -data -= -aDataSurfaceShmem -; -if -( -data -= -= -mDataSurfaceShmem -) -{ -MOZ_ASSERT -( -! -mDataSurfaceShmemAvailable -) -; -mDataSurfaceShmemAvailable -= -true -; -} -} } } diff --git a/gfx/layers/ipc/CanvasChild.h b/gfx/layers/ipc/CanvasChild.h index 27bb53e33b637..a5888a8ccb51a 100644 --- a/gfx/layers/ipc/CanvasChild.h +++ b/gfx/layers/ipc/CanvasChild.h @@ -57,6 +57,20 @@ WeakPtr . h " +# +include +" +nsRefPtrHashtable +. +h +" +# +include +" +nsTArray +. +h +" namespace mozilla { @@ -102,6 +116,7 @@ return mDeactivated ; } +static void ClearCachedResources ( @@ -126,21 +141,16 @@ RecvDeactivate void EnsureRecorder ( -gfx -: -: -IntSize -aSize -gfx -: -: -SurfaceFormat -aFormat TextureType aTextureType ) ; void +ResumeTranslation +( +) +; +void Destroy ( ) @@ -216,11 +226,6 @@ RecordedEvent aEvent ) ; -int64_t -CreateCheckpoint -( -) -; already_AddRefed < gfx @@ -283,39 +288,6 @@ CanvasChild ) final ; -bool -EnsureDataSurfaceShmem -( -gfx -: -: -IntSize -aSize -gfx -: -: -SurfaceFormat -aFormat -) -; -void -ReturnDataSurfaceShmem -( -already_AddRefed -< -ipc -: -: -SharedMemoryBasic -> -aDataSurfaceShmem -) -; -void -DropFreeBuffersWhenDormant -( -) -; static const uint32_t @@ -327,27 +299,25 @@ static bool mDeactivated ; +static +bool +mInForeground +; RefPtr < CanvasDrawEventRecorder > mRecorder ; -RefPtr -< -ipc +TextureType +mTextureType += +TextureType : : -SharedMemoryBasic -> -mDataSurfaceShmem +Unknown ; -bool -mDataSurfaceShmemAvailable -= -false -; -int64_t +uint32_t mLastWriteLockCheckpoint = 0 @@ -382,11 +352,6 @@ mHasOutstandingWriteLock = false ; -bool -mDormant -= -false -; } ; } diff --git a/gfx/layers/ipc/CanvasTranslator.cpp b/gfx/layers/ipc/CanvasTranslator.cpp index 1346d58eca9ba..e9f70df72cfa0 100644 --- a/gfx/layers/ipc/CanvasTranslator.cpp +++ b/gfx/layers/ipc/CanvasTranslator.cpp @@ -96,17 +96,6 @@ mozilla / layers / -CanvasTranslator -. -h -" -# -include -" -mozilla -/ -layers -/ SharedSurfacesParent . h @@ -127,15 +116,6 @@ include " mozilla / -StaticPrefs_gfx -. -h -" -# -include -" -mozilla -/ SyncRunnable . h @@ -201,6 +181,87 @@ mozilla namespace layers { +static +const +TimeDuration +kReadEventTimeout += +TimeDuration +: +: +FromMilliseconds +( +5 +) +; +class +RingBufferReaderServices +final +: +public +CanvasEventRingBuffer +: +: +ReaderServices +{ +public +: +explicit +RingBufferReaderServices +( +RefPtr +< +CanvasTranslator +> +aCanvasTranslator +) +: +mCanvasTranslator +( +std +: +: +move +( +aCanvasTranslator +) +) +{ +} +~ +RingBufferReaderServices +( +) +final += +default +; +bool +WriterClosed +( +) +final +{ +return +! +mCanvasTranslator +- +> +CanSend +( +) +; +} +private +: +RefPtr +< +CanvasTranslator +> +mCanvasTranslator +; +} +; TextureData * CanvasTranslator @@ -288,30 +349,6 @@ CanvasTranslator ( ) { -mMaxSpinCount -= -StaticPrefs -: -: -gfx_canvas_remote_max_spin_count -( -) -; -mNextEventTimeout -= -TimeDuration -: -: -FromMilliseconds -( -StaticPrefs -: -: -gfx_canvas_remote_event_timeout_ms -( -) -) -; Telemetry : : @@ -439,100 +476,6 @@ IsInCanvasRenderThread ) ; } -static -bool -CreateAndMapShmem -( -RefPtr -< -ipc -: -: -SharedMemoryBasic -> -& -aShmem -Handle -& -& -aHandle -ipc -: -: -SharedMemory -: -: -OpenRights -aOpenRights -size_t -aSize -) -{ -auto -shmem -= -MakeRefPtr -< -ipc -: -: -SharedMemoryBasic -> -( -) -; -if -( -! -shmem -- -> -SetHandle -( -std -: -: -move -( -aHandle -) -aOpenRights -) -| -| -! -shmem -- -> -Map -( -aSize -) -) -{ -return -false -; -} -shmem -- -> -CloseHandle -( -) -; -aShmem -= -shmem -. -forget -( -) -; -return -true -; -} mozilla : : @@ -549,19 +492,16 @@ const TextureType & aTextureType +ipc +: +: +SharedMemoryBasic +: +: Handle & & aReadHandle -nsTArray -< -Handle -> -& -& -aBufferHandles -uint64_t -aBufferSize CrossProcessSemaphoreHandle & & @@ -570,13 +510,15 @@ CrossProcessSemaphoreHandle & & aWriterSem +const bool +& aUseIPDLThread ) { if ( -mHeaderShmem +mStream ) { return @@ -596,14 +538,11 @@ mTextureType = aTextureType ; -mHeaderShmem +mStream = -MakeAndAddRef +MakeUnique < -ipc -: -: -SharedMemoryBasic +CanvasEventRingBuffer > ( ) @@ -611,9 +550,11 @@ SharedMemoryBasic if ( ! -CreateAndMapShmem +mStream +- +> +InitReader ( -mHeaderShmem std : : @@ -621,119 +562,70 @@ move ( aReadHandle ) -ipc +std : : -SharedMemory +move +( +aReaderSem +) +std : : -RightsReadWrite -sizeof +move +( +aWriterSem +) +MakeUnique +< +RingBufferReaderServices +> ( -Header +this ) ) ) { +mStream += +nullptr +; return IPC_FAIL ( this " Failed +to +initialize +ring +buffer +reader . " ) ; } -mHeader -= -static_cast -< -Header -* -> -( -mHeaderShmem -- -> -memory +# +if +defined ( +XP_WIN ) -) -; -mWriterSemaphore -. -reset -( -CrossProcessSemaphore -: -: -Create +if ( -std -: -: -move +! +CheckForFreshCanvasDevice ( -aWriterSem -) -) +__LINE__ ) -; -mWriterSemaphore -- -> -CloseHandle -( ) -; -mReaderSemaphore -. -reset -( -CrossProcessSemaphore -: -: -Create -( -std -: -: -move -( -aReaderSem -) -) -) -; -mReaderSemaphore -- -> -CloseHandle -( -) -; -# -if -defined -( -XP_WIN -) -if -( -! -CheckForFreshCanvasDevice -( -__LINE__ -) -) -{ -gfxCriticalNote -< -< -" -GFX +{ +gfxCriticalNote +< +< +" +GFX : CanvasTranslator failed @@ -742,6 +634,10 @@ get device " ; +mStream += +nullptr +; return IPC_OK ( @@ -769,44 +665,37 @@ CreateWorkerTaskQueue ) ; } -mDefaultBufferSize -= -aBufferSize -; -auto -handleIter -= -aBufferHandles -. -begin +return +RecvResumeTranslation ( ) ; -if -( -! -CreateAndMapShmem -( -mCurrentShmem -. -shmem -std +} +ipc : : -move +IPCResult +CanvasTranslator +: +: +RecvNewBuffer ( -* -handleIter -) ipc : : -SharedMemory +SharedMemoryBasic : : -RightsReadOnly -aBufferSize +Handle +& +& +aReadHandle ) +{ +if +( +! +mStream ) { return @@ -814,67 +703,85 @@ IPC_FAIL ( this " -Failed +RecvNewBuffer +before +RecvInitTranslator . " ) ; } -mCurrentMemReader +DispatchToTaskQueue +( +NS_NewRunnableFunction +( +" +CanvasTranslator +SetNewBuffer +" +[ +self = -mCurrentShmem -. -CreateMemReader +RefPtr ( +this ) -; -for -( -handleIter -+ -+ -; -handleIter -< -aBufferHandles -. -end +readHandle += +std +: +: +move ( +aReadHandle ) -; -handleIter -+ -+ +] +( ) +mutable { -CanvasShmem -newShmem -; -if -( -! -CreateAndMapShmem +self +- +> +mStream +- +> +SetNewBuffer ( -newShmem -. -shmem std : : move ( -* -handleIter +readHandle +) +) +; +} +) +) +; +return +RecvResumeTranslation +( ) +; +} ipc : : -SharedMemory +IPCResult +CanvasTranslator : : -RightsReadOnly -aBufferSize +RecvResumeTranslation +( ) +{ +if +( +! +mStream ) { return @@ -882,24 +789,25 @@ IPC_FAIL ( this " -Failed +RecvResumeTranslation +before +RecvInitTranslator . " ) ; } -mCanvasShmems -. -emplace +if ( -std -: -: -move +CheckDeactivated ( -newShmem ) ) +{ +return +IPC_OK +( +) ; } DispatchToTaskQueue @@ -910,14 +818,14 @@ NewRunnableMethod CanvasTranslator : : -TranslateRecording +StartTranslation " this & CanvasTranslator : : -TranslateRecording +StartTranslation ) ) ; @@ -927,28 +835,47 @@ IPC_OK ) ; } -ipc -: -: -IPCResult +void CanvasTranslator : : -RecvRestartTranslation +StartTranslation ( ) { +MOZ_RELEASE_ASSERT +( +mStream +- +> +IsValid +( +) +" +StartTranslation +called +before +buffer +has +been +set +. +" +) +; if ( -mDeactivated +! +TranslateRecording +( ) -{ -return -IPC_OK +& +& +CanSend ( ) -; -} +) +{ DispatchToTaskQueue ( NewRunnableMethod @@ -957,373 +884,141 @@ NewRunnableMethod CanvasTranslator : : -TranslateRecording +StartTranslation " this & CanvasTranslator : : -TranslateRecording +StartTranslation ) ) ; -return -IPC_OK -( -) -; } -ipc -: -: -IPCResult -CanvasTranslator -: -: -RecvAddBuffer -( -ipc -: -: -SharedMemoryBasic -: -: -Handle -& -& -aBufferHandle -uint64_t -aBufferSize -) -{ if ( -mDeactivated -) -{ -return -IPC_OK +! +mStream +- +> +good ( ) -; -} -DispatchToTaskQueue -( -NewRunnableMethod -< -ipc -: -: -SharedMemoryBasic -: -: -Handle & & -size_t +! +mStream +- > +WriterFailed ( -" -CanvasTranslator +) +) +{ +Telemetry : : -AddBuffer -" -this -& -CanvasTranslator +ScalarAdd +( +Telemetry : : -AddBuffer -std +ScalarID : : -move -( -aBufferHandle -) -aBufferSize -) +GFX_CANVAS_REMOTE_DEACTIVATED_BAD_STREAM +1 ) ; -return -IPC_OK +Deactivate ( ) ; } +} void CanvasTranslator : : -AddBuffer +ActorDestroy ( -ipc -: -: -SharedMemoryBasic -: -: -Handle -& -& -aBufferHandle -size_t -aBufferSize +ActorDestroyReason +why ) { MOZ_ASSERT ( -IsInTaskQueue -( -) -) -; -MOZ_RELEASE_ASSERT -( -mHeader -- -> -readerState -= -= -State +gfx : : -Paused -) -; -if -( -mCurrentShmem -. -Size -( -) -= -= -mDefaultBufferSize -) -{ -mCanvasShmems -. -emplace -( -std +CanvasRenderThread : : -move +IsInCanvasRenderThread ( -mCurrentShmem ) ) ; -} -CanvasShmem -newShmem -; if ( ! -CreateAndMapShmem -( -newShmem -. -shmem -std -: -: -move -( -aBufferHandle -) -ipc -: -: -SharedMemory -: -: -RightsReadOnly -aBufferSize -) +mTranslationTaskQueue ) { -return -; -} -mCurrentShmem -= -std -: -: -move -( -newShmem -) -; -mCurrentMemReader -= -mCurrentShmem -. -CreateMemReader -( -) -; -TranslateRecording -( -) -; -} -ipc -: -: -IPCResult -CanvasTranslator -: -: -RecvSetDataSurfaceBuffer -( -ipc +gfx : : -SharedMemoryBasic +CanvasRenderThread : : -Handle -& -& -aBufferHandle -uint64_t -aBufferSize -) -{ -if -( -mDeactivated -) -{ -return -IPC_OK -( -) -; -} -DispatchToTaskQueue +Dispatch ( NewRunnableMethod -< -ipc -: -: -SharedMemoryBasic -: -: -Handle -& -& -size_t -> ( " CanvasTranslator : : -SetDataSurfaceBuffer +FinishShutdown " this & CanvasTranslator : : -SetDataSurfaceBuffer -std -: -: -move -( -aBufferHandle -) -aBufferSize +FinishShutdown ) ) ; return -IPC_OK -( -) ; } -void -CanvasTranslator -: -: -SetDataSurfaceBuffer -( -ipc -: -: -SharedMemoryBasic -: -: -Handle -& -& -aBufferHandle -size_t -aBufferSize -) -{ -MOZ_ASSERT -( -IsInTaskQueue +mTranslationTaskQueue +- +> +BeginShutdown ( ) -) -; -MOZ_RELEASE_ASSERT -( -mHeader - > -readerState -= -= -State -: -: -Paused -) -; -if -( -! -CreateAndMapShmem +Then ( -mDataSurfaceShmem -std -: -: -move +GetCurrentSerialEventTarget ( -aBufferHandle ) -ipc +__func__ +this +& +CanvasTranslator : : -SharedMemory +FinishShutdown +& +CanvasTranslator : : -RightsReadWrite -aBufferSize -) -) -{ -return -; -} -TranslateRecording -( +FinishShutdown ) ; } @@ -1331,952 +1026,166 @@ void CanvasTranslator : : -GetDataSurface +FinishShutdown ( -uint64_t -aSurfaceRef ) { MOZ_ASSERT ( -IsInTaskQueue -( -) -) -; -ReferencePtr -surfaceRef -= -reinterpret_cast -< -void -* -> -( -aSurfaceRef -) -; gfx : : -SourceSurface -* -surface -= -LookupSourceSurface +CanvasRenderThread +: +: +IsInCanvasRenderThread ( -surfaceRef ) -; -if -( -! -surface ) -{ -return ; -} -UniquePtr -< +mStream += +nullptr +; gfx : : -DataSourceSurface +CanvasManagerParent : : -ScopedMap -> -map -= -GetPreparedMap -( -surfaceRef -) -; -if -( -! -map -) -{ -return -; -} -auto -dstSize -= -surface -- -> -GetSize -( -) -; -auto -srcSize -= -map -- -> -GetSurface -( -) -- -> -GetSize -( -) -; -int32_t -dataFormatWidth -= -dstSize -. -width -* -BytesPerPixel -( -surface -- -> -GetFormat -( -) -) -; -int32_t -srcStride -= -map -- -> -GetStride -( -) -; -if -( -dataFormatWidth -> -srcStride -| -| -srcSize -! -= -dstSize -) -{ -return -; -} -auto -requiredSize -= -dataFormatWidth -* -dstSize -. -height -; -if -( -requiredSize -< -= -0 -| -| -size_t -( -requiredSize -) -> -mDataSurfaceShmem -- -> -Size -( -) -) -{ -return -; -} -char -* -dst -= -static_cast -< -char -* -> -( -mDataSurfaceShmem -- -> -memory -( -) -) -; -const -char -* -src -= -reinterpret_cast -< -char -* -> -( -map -- -> -GetData -( -) -) -; -const -char -* -endSrc -= -src -+ -( -srcSize -. -height -* -srcStride -) -; -while -( -src -< -endSrc -) -{ -memcpy -( -dst -src -dataFormatWidth -) -; -src -+ -= -srcStride -; -dst -+ -= -dataFormatWidth -; -} -} -void -CanvasTranslator -: -: -RecycleBuffer -( -) -{ -mCanvasShmems -. -emplace -( -std -: -: -move -( -mCurrentShmem -) -) -; -NextBuffer -( -) -; -} -void -CanvasTranslator -: -: -NextBuffer -( -) -{ -mCurrentShmem -= -std -: -: -move -( -mCanvasShmems -. -front -( -) -) -; -mCanvasShmems -. -pop -( -) -; -mCurrentMemReader -= -mCurrentShmem -. -CreateMemReader -( -) -; -} -void -CanvasTranslator -: -: -ActorDestroy -( -ActorDestroyReason -why -) -{ -MOZ_ASSERT -( -gfx -: -: -CanvasRenderThread -: -: -IsInCanvasRenderThread -( -) -) -; -if -( -! -mTranslationTaskQueue -) -{ -gfx -: -: -CanvasRenderThread -: -: -Dispatch -( -NewRunnableMethod -( -" -CanvasTranslator -: -: -FinishShutdown -" -this -& -CanvasTranslator -: -: -FinishShutdown -) -) -; -return -; -} -mTranslationTaskQueue -- -> -BeginShutdown -( -) -- -> -Then -( -GetCurrentSerialEventTarget -( -) -__func__ -this -& -CanvasTranslator -: -: -FinishShutdown -& -CanvasTranslator -: -: -FinishShutdown -) -; -} -void -CanvasTranslator -: -: -FinishShutdown -( -) -{ -MOZ_ASSERT -( -gfx -: -: -CanvasRenderThread -: -: -IsInCanvasRenderThread -( -) -) -; -} -bool -CanvasTranslator -: -: -CheckDeactivated -( -) -{ -if -( -mDeactivated -) -{ -return -true -; -} -if -( -NS_WARN_IF -( -! -gfx -: -: -gfxVars -: -: -RemoteCanvasEnabled -( -) -) -) -{ -Deactivate -( -) -; -} -return -mDeactivated -; -} -void -CanvasTranslator -: -: -Deactivate -( -) -{ -if -( -mDeactivated -) -{ -return -; -} -mDeactivated -= -true -; -mHeader -- -> -readerState -= -State -: -: -Failed -; -gfx -: -: -CanvasRenderThread -: -: -Dispatch -( -NewRunnableMethod -( -" -CanvasTranslator -: -: -SendDeactivate -" -this -& -CanvasTranslator -: -: -SendDeactivate -) -) -; -for -( -auto -const -& -entry -: -mTextureDatas -) -{ -entry -. -second -- -> -Unlock -( -) -; -} -gfx -: -: -CanvasManagerParent -: -: -DisableRemoteCanvas -( -) -; -} -void -CanvasTranslator -: -: -CheckAndSignalWriter -( -) -{ -do -{ -switch -( -mHeader -- -> -writerState -) -{ -case -State -: -: -Processing -: -return -; -case -State -: -: -AboutToWait -: -if -( -! -CanSend -( -) -) -{ -return -; -} -continue -; -case -State -: -: -Waiting -: -if -( -mHeader -- -> -processedCount -> -= -mHeader -- -> -writerWaitCount -) -{ -mHeader -- -> -writerState -= -State -: -: -Processing -; -mWriterSemaphore -- -> -Signal -( -) -; -} -return -; -default -: -MOZ_ASSERT_UNREACHABLE -( -" -Invalid -waiting -state -. -" -) -; -return -; -} -} -while -( -true -) -; -} -bool -CanvasTranslator -: -: -HasPendingEvent -( -) -{ -return -mHeader -- -> -processedCount -< -mHeader -- -> -eventCount -; -} -bool -CanvasTranslator -: -: -ReadPendingEvent -( -EventType -& -aEventType -) -{ -ReadElementConstrained -( -mCurrentMemReader -aEventType -EventType -: -: -DRAWTARGETCREATION -LAST_CANVAS_EVENT_TYPE -) -; -return -mCurrentMemReader -. -good +RemoveReplayTextures ( +this ) ; } bool -CanvasTranslator -: -: -ReadNextEvent -( -EventType -& -aEventType -) -{ -if -( -mHeader -- -> -readerState -= -= -State -: -: -Paused -) -{ -Flush -( -) -; -return -false -; -} -uint32_t -spinCount -= -mMaxSpinCount -; -do -{ -if -( -HasPendingEvent -( -) -) -{ -return -ReadPendingEvent -( -aEventType -) -; -} -} -while -( -- -- -spinCount -! -= -0 -) -; -Flush -( -) -; -mHeader -- -> -readerState -= -State -: -: -AboutToWait -; -if -( -HasPendingEvent -( -) -) -{ -mHeader -- -> -readerState -= -State +CanvasTranslator : : -Processing -; -return -ReadPendingEvent +CheckDeactivated ( -aEventType ) -; -} +{ if ( -! -mIsInTransaction +mDeactivated ) { -mHeader -- -> -readerState -= -State -: -: -Stopped -; return -false +true ; } -mHeader -- -> -readerState -= -State -: -: -Waiting -; if ( -mReaderSemaphore -- -> -Wait +NS_WARN_IF ( -Some +! +gfx +: +: +gfxVars +: +: +RemoteCanvasEnabled ( -mNextEventTimeout ) ) ) { -MOZ_RELEASE_ASSERT -( -HasPendingEvent +Deactivate ( ) -) ; -MOZ_RELEASE_ASSERT -( -mHeader -- -> -readerState -= -= -State +} +return +mDeactivated +; +} +void +CanvasTranslator : : -Processing +Deactivate +( ) -; -return -ReadPendingEvent +{ +if ( -aEventType +mDeactivated ) +{ +return ; } -if -( -! -mHeader +mDeactivated += +true +; +mStream - > -readerState -. -compareExchange +SetIsBad ( -State +) +; +gfx : : -Waiting -State +CanvasRenderThread : : -Stopped -) -) -{ -MOZ_RELEASE_ASSERT +Dispatch ( -HasPendingEvent +NewRunnableMethod ( +" +CanvasTranslator +: +: +SendDeactivate +" +this +& +CanvasTranslator +: +: +SendDeactivate ) ) ; -MOZ_RELEASE_ASSERT +for ( -mHeader -- -> -readerState -= -= -State -: +auto +const +& +entry : -Processing +mTextureDatas ) -; -MOZ_ALWAYS_TRUE -( -mReaderSemaphore +{ +entry +. +second - > -Wait +Unlock ( ) -) ; -return -ReadPendingEvent +} +gfx +: +: +CanvasManagerParent +: +: +DisableRemoteCanvas ( -aEventType ) ; } -return -false -; -} -void +bool CanvasTranslator : : @@ -2291,25 +1200,40 @@ IsInTaskQueue ) ) ; -mHeader -- -> -readerState -= -State -: -: -Processing +if +( +! +mStream +) +{ +return +false ; -EventType +} +uint8_t eventType += +mStream +- +> +ReadNextEvent +( +) ; while ( -ReadNextEvent +mStream +- +> +good ( -eventType ) +& +& +eventType +! += +kDropBufferEventType ) { bool @@ -2318,9 +1242,10 @@ success RecordedEvent : : -DoWithEvent +DoWithEventFromStream ( -mCurrentMemReader +* +mStream static_cast < RecordedEvent @@ -2346,8 +1271,9 @@ bool if ( ! -mCurrentMemReader -. +mStream +- +> good ( ) @@ -2426,14 +1352,16 @@ this if ( ! -mCurrentMemReader -. +mStream +- +> good ( ) ) { return +true ; } if @@ -2492,15 +1420,83 @@ type eventType ; } +if +( +! +mStream +- +> +good +( +) +) +{ +return +true +; +} +} +if +( +! +mIsInTransaction +) +{ +return +mStream +- +> +StopIfEmpty +( +) +; +} +if +( +! +mStream +- +> +HasDataToRead +( +) +) +{ +Flush +( +) +; +if +( +! +mStream +- +> +WaitForDataToRead +( +kReadEventTimeout +0 +) +) +{ +return +true +; } -mHeader +} +eventType += +mStream - > -processedCount -+ -+ +ReadNextEvent +( +) ; } +return +true +; } # define @@ -2520,15 +1516,17 @@ e = _class ( -mCurrentMemReader +* +mStream ) ; \ if ( ! -mCurrentMemReader -. +mStream +- +> good ( ) @@ -3375,38 +2373,6 @@ aKey ) ; } -void -CanvasTranslator -: -: -CheckpointReached -( -) -{ -CheckAndSignalWriter -( -) -; -} -void -CanvasTranslator -: -: -PauseTranslation -( -) -{ -mHeader -- -> -readerState -= -State -: -: -Paused -; -} already_AddRefed < gfx diff --git a/gfx/layers/ipc/CanvasTranslator.h b/gfx/layers/ipc/CanvasTranslator.h index f170e946625c3..1036c05222972 100644 --- a/gfx/layers/ipc/CanvasTranslator.h +++ b/gfx/layers/ipc/CanvasTranslator.h @@ -30,24 +30,6 @@ include " mozilla / -gfx -/ -RecordedEvent -. -h -" -# -include -" -CanvasChild -. -h -" -# -include -" -mozilla -/ layers / CanvasDrawEventRecorder @@ -108,17 +90,6 @@ h namespace mozilla { -using -EventType -= -gfx -: -: -RecordedEvent -: -: -EventType -; class TaskQueue ; @@ -180,19 +151,16 @@ const TextureType & aTextureType +ipc +: +: +SharedMemoryBasic +: +: Handle & & aReadHandle -nsTArray -< -Handle -> -& -& -aBufferHandles -uint64_t -aBufferSize CrossProcessSemaphoreHandle & & @@ -201,7 +169,9 @@ CrossProcessSemaphoreHandle & & aWriterSem +const bool +& aUseIPDLThread ) ; @@ -209,36 +179,26 @@ ipc : : IPCResult -RecvRestartTranslation +RecvNewBuffer ( -) -; ipc : : -IPCResult -RecvAddBuffer -( +SharedMemoryBasic +: +: Handle & & -aBufferHandle -uint64_t -aBufferSize +aReadHandle ) ; ipc : : IPCResult -RecvSetDataSurfaceBuffer +RecvResumeTranslation ( -Handle -& -& -aBufferHandle -uint64_t -aBufferSize ) ; void @@ -249,12 +209,7 @@ why ) final ; -void -CheckAndSignalWriter -( -) -; -void +bool TranslateRecording ( ) @@ -280,6 +235,27 @@ DeviceChangeAcknowledged ) ; void +ReturnWrite +( +const +char +* +aData +size_t +aSize +) +{ +mStream +- +> +ReturnWrite +( +aData +aSize +) +; +} +void SetNextTextureId ( int64_t @@ -354,16 +330,6 @@ aTextureId ) ; void -CheckpointReached -( -) -; -void -PauseTranslation -( -) -; -void RemoveTexture ( int64_t @@ -559,23 +525,6 @@ ReferencePtr aSurface ) ; -void -RecycleBuffer -( -) -; -void -NextBuffer -( -) -; -void -GetDataSurface -( -uint64_t -aSurfaceRef -) -; private : ~ @@ -584,46 +533,20 @@ CanvasTranslator ) ; void -AddBuffer +Bind ( -Handle +Endpoint +< +PCanvasParent +> & & -aBufferHandle -size_t -aBufferSize +aEndpoint ) ; void -SetDataSurfaceBuffer -( -Handle -& -& -aBufferHandle -size_t -aBufferSize -) -; -bool -ReadNextEvent +StartTranslation ( -EventType -& -aEventType -) -; -bool -HasPendingEvent -( -) -; -bool -ReadPendingEvent -( -EventType -& -aEventType ) ; void @@ -715,139 +638,11 @@ mDevice ; # endif -size_t -mDefaultBufferSize -; -uint32_t -mMaxSpinCount -; -TimeDuration -mNextEventTimeout -; -using -State -= -CanvasDrawEventRecorder -: -: -State -; -using -Header -= -CanvasDrawEventRecorder -: -: -Header -; -RefPtr -< -ipc -: -: -SharedMemoryBasic -> -mHeaderShmem -; -Header -* -mHeader -= -nullptr -; -struct -CanvasShmem -{ -RefPtr -< -ipc -: -: -SharedMemoryBasic -> -shmem -; -auto -Size -( -) -{ -return -shmem -- -> -Size -( -) -; -} -MemReader -CreateMemReader -( -) -{ -return -{ -static_cast -< -char -* -> -( -shmem -- -> -memory -( -) -) -Size -( -) -} -; -} -} -; -std -: -: -queue -< -CanvasShmem -> -mCanvasShmems -; -CanvasShmem -mCurrentShmem -; -MemReader -mCurrentMemReader -{ -0 -0 -} -; -RefPtr -< -ipc -: -: -SharedMemoryBasic -> -mDataSurfaceShmem -; UniquePtr < -CrossProcessSemaphore -> -mWriterSemaphore -; -UniquePtr -< -CrossProcessSemaphore +CanvasEventRingBuffer > -mReaderSemaphore +mStream ; TextureType mTextureType diff --git a/gfx/layers/ipc/CompositorBridgeChild.cpp b/gfx/layers/ipc/CompositorBridgeChild.cpp index f26be460beb50..55fe2e07601f9 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -2665,32 +2665,14 @@ ClearCachedResources ( ) { -if -( -auto -* -cm -= -gfx -: -: -CanvasManagerChild +CanvasChild : : -Get -( -) -) -{ -cm -- -> ClearCachedResources ( ) ; } -} bool CompositorBridgeChild : diff --git a/gfx/layers/ipc/PCanvas.ipdl b/gfx/layers/ipc/PCanvas.ipdl index 1a4df93a51b2d..35512e33c41ad 100644 --- a/gfx/layers/ipc/PCanvas.ipdl +++ b/gfx/layers/ipc/PCanvas.ipdl @@ -115,13 +115,7 @@ InitTranslator TextureType aTextureType Handle -aHeaderHandle -Handle -[ -] -aBufferHandles -uint64_t -aBufferSize +aReadHandle CrossProcessSemaphoreHandle aReaderSem CrossProcessSemaphoreHandle @@ -131,26 +125,15 @@ aUseIPDLThread ) ; async -RestartTranslation -( -) -; -async -AddBuffer +NewBuffer ( Handle -aBufferHandle -uint64_t -aBufferSize +aReadHandle ) ; async -SetDataSurfaceBuffer +ResumeTranslation ( -Handle -aBufferHandle -uint64_t -aBufferSize ) ; async diff --git a/gfx/webrender_bindings/RenderD3D11TextureHost.cpp b/gfx/webrender_bindings/RenderD3D11TextureHost.cpp index 1f31adf777bd4..f11b67b9935b8 100644 --- a/gfx/webrender_bindings/RenderD3D11TextureHost.cpp +++ b/gfx/webrender_bindings/RenderD3D11TextureHost.cpp @@ -63,17 +63,6 @@ mozilla / gfx / -CanvasManagerParent -. -h -" -# -include -" -mozilla -/ -gfx -/ Logging . h diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 3558aab9bebc1..217284e07b07f 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -35905,188 +35905,6 @@ endif mirror : once -# -Default -size -of -the -shmem -buffers -used -for -recording -- -name -: -gfx -. -canvas -. -remote -. -default -- -buffer -- -size -type -: -RelaxedAtomicUint32 -value -: -32 -* -1024 -mirror -: -always -# -How -many -times -to -spin -before -waiting -in -remote -canvas -- -name -: -gfx -. -canvas -. -remote -. -max -- -spin -- -count -type -: -RelaxedAtomicUint32 -value -: -500 -mirror -: -always -# -How -long -to -wait -in -milliseconds -for -the -next -event -while -in -a -transaction -- -name -: -gfx -. -canvas -. -remote -. -event -- -timeout -- -ms -type -: -RelaxedAtomicUint32 -value -: -2 -mirror -: -always -# -How -many -times -we -have -a -spare -buffer -before -we -drop -one -- -name -: -gfx -. -canvas -. -remote -. -drop -- -buffer -- -limit -type -: -RelaxedAtomicUint32 -value -: -100 -mirror -: -always -# -Delay -in -milliseconds -to -drop -buffers -when -there -have -been -no -non -- -empty -transactions -- -name -: -gfx -. -canvas -. -remote -. -drop -- -buffer -- -milliseconds -type -: -RelaxedAtomicUint32 -value -: -10000 -mirror -: -always - name :