| Index: third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp b/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp
|
| index 984731ad183bfb040af56267ed74a04d6043a560..14c3b6e8d3c64432ed85febc2144f7d0fc949672 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp
|
| @@ -27,12 +27,6 @@
|
|
|
| namespace blink {
|
|
|
| -// This constant specifies the maximum number of pixel buffer that are allowed
|
| -// to co-exist at a given time. The minimum number is 2 (double buffered).
|
| -// larger numbers can help maintain a steadier frame rates, but they increase
|
| -// latency.
|
| -const int kMaximumOffscreenCanvasBufferCount = 3;
|
| -
|
| OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl(
|
| OffscreenCanvasFrameDispatcherClient* client,
|
| uint32_t clientId,
|
| @@ -45,6 +39,7 @@ OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl(
|
| m_width(width),
|
| m_height(height),
|
| m_changeSizeForNextCommit(false),
|
| + m_needsBeginFrame(false),
|
| m_nextResourceId(1u),
|
| m_binding(this),
|
| m_placeholderCanvasId(canvasId) {
|
| @@ -59,7 +54,6 @@ OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl(
|
| }
|
|
|
| OffscreenCanvasFrameDispatcherImpl::~OffscreenCanvasFrameDispatcherImpl() {
|
| - m_syntheticBeginFrameTask.cancel();
|
| }
|
|
|
| void OffscreenCanvasFrameDispatcherImpl::setTransferableResourceToSharedBitmap(
|
| @@ -371,44 +365,26 @@ void OffscreenCanvasFrameDispatcherImpl::dispatchFrame(
|
| m_currentLocalFrameId = m_surfaceIdAllocator.GenerateId();
|
| m_changeSizeForNextCommit = false;
|
| }
|
| - m_sink->SubmitCompositorFrame(m_currentLocalFrameId, std::move(frame));
|
| -
|
| - // TODO(crbug.com/674744): Get BeginFrame to fire on its own.
|
| - scheduleSyntheticBeginFrame();
|
| -}
|
|
|
| -void OffscreenCanvasFrameDispatcherImpl::scheduleSyntheticBeginFrame() {
|
| - m_syntheticBeginFrameTask =
|
| - Platform::current()
|
| - ->currentThread()
|
| - ->getWebTaskRunner()
|
| - ->postDelayedCancellableTask(
|
| - BLINK_FROM_HERE,
|
| - WTF::bind(&OffscreenCanvasFrameDispatcherImpl::OnBeginFrame,
|
| - WTF::unretained(this), cc::BeginFrameArgs()),
|
| - 16);
|
| + m_sink->SubmitCompositorFrame(m_currentLocalFrameId, std::move(frame));
|
| }
|
|
|
| void OffscreenCanvasFrameDispatcherImpl::DidReceiveCompositorFrameAck() {
|
| // TODO(fsamuel): Implement this.
|
| }
|
|
|
| +void OffscreenCanvasFrameDispatcherImpl::setNeedsBeginFrame(
|
| + bool needsBeginFrame) {
|
| + if (needsBeginFrame != m_needsBeginFrame) {
|
| + m_needsBeginFrame = needsBeginFrame;
|
| + m_sink->SetNeedsBeginFrame(needsBeginFrame);
|
| + }
|
| +}
|
| +
|
| void OffscreenCanvasFrameDispatcherImpl::OnBeginFrame(
|
| const cc::BeginFrameArgs& beginFrameArgs) {
|
| - if (!client())
|
| - return;
|
| - unsigned framesInFlight = m_cachedImages.size() + m_sharedBitmaps.size() +
|
| - m_cachedTextureIds.size();
|
| -
|
| - // Limit the rate of compositor commits.
|
| - if (framesInFlight < kMaximumOffscreenCanvasBufferCount) {
|
| - client()->beginFrame();
|
| - } else {
|
| - // TODO(crbug.com/674744): Get BeginFrame to fire on its own.
|
| - // The following call is to reschedule the frame in cases where we encounter
|
| - // a backlog.
|
| - scheduleSyntheticBeginFrame();
|
| - }
|
| + DCHECK(client());
|
| + client()->beginFrame();
|
| }
|
|
|
| void OffscreenCanvasFrameDispatcherImpl::ReclaimResources(
|
|
|