Chromium Code Reviews| 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..3305cadd14dffd73dc904d8f8b87e580da9defed 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 doesNeedBeginFrame) { |
|
Justin Novosad
2017/01/19 18:06:49
This name doesNeedBeginFrame is a bit awkward. Jus
xlai (Olivia)
2017/01/19 19:14:34
Done.
|
| + if (doesNeedBeginFrame != m_needsBeginFrame) { |
| + m_needsBeginFrame = doesNeedBeginFrame; |
| + m_sink->SetNeedsBeginFrame(doesNeedBeginFrame); |
| + } |
| +} |
| + |
| 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) { |
| + if (client()) |
| 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(); |
| - } |
| } |
| void OffscreenCanvasFrameDispatcherImpl::ReclaimResources( |