Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| index 6934e8bc58baacbe074b94a54cc01b6e8f939737..d5734d0f174a5a9015159ce6d2748e83faded3cf 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| @@ -926,6 +926,7 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient { |
| const volatile GLint* rects); |
| // Callback for async SwapBuffers. |
| + void RegisterTraceAndFinishSwapBuffers(gfx::SwapResult result); |
|
reveman
2017/03/24 06:35:09
how about FinishAsyncSwapBuffers?
Daniele Castagna
2017/03/24 06:51:24
Done.
|
| void FinishSwapBuffers(gfx::SwapResult result); |
| void DoCommitOverlayPlanes(); |
| @@ -2371,6 +2372,8 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient { |
| bool supports_swap_buffers_with_bounds_; |
| bool supports_commit_overlay_planes_; |
| bool supports_async_swap_; |
| + uint32_t async_swap_id_ = 0; |
|
reveman
2017/03/24 06:35:09
nit: next_async_swap_id_ = 1
Daniele Castagna
2017/03/24 06:51:24
Not sure why you prefer to start from 1, but done.
|
| + std::queue<uint32_t> pending_swaps_; |
| bool supports_dc_layers_ = false; |
| // These flags are used to override the state of the shared feature_info_ |
| @@ -11884,10 +11887,13 @@ error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
| ClearScheduleDCLayerState(); |
| if (supports_async_swap_) { |
| - TRACE_EVENT_ASYNC_BEGIN0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); |
| + CHECK_LT(pending_swaps_.size(), 2); |
|
reveman
2017/03/24 06:35:09
nit: s/CHECK_LT/DCHECK_LT/
Daniele Castagna
2017/03/24 06:51:24
Done.
|
| + ++async_swap_id_; |
|
reveman
2017/03/24 06:35:09
nit: uint32_t async_swap_id = next_async_swap_id_+
Daniele Castagna
2017/03/24 06:51:24
Done.
|
| + pending_swaps_.push(async_swap_id_); |
| + TRACE_EVENT_ASYNC_BEGIN0("gpu", "AsyncSwapBuffers", async_swap_id_); |
| surface_->PostSubBufferAsync( |
| c.x, c.y, c.width, c.height, |
| - base::Bind(&GLES2DecoderImpl::FinishSwapBuffers, |
| + base::Bind(&GLES2DecoderImpl::RegisterTraceAndFinishSwapBuffers, |
| base::AsWeakPtr(this))); |
| } else { |
| FinishSwapBuffers(surface_->PostSubBuffer(c.x, c.y, c.width, c.height)); |
| @@ -15505,9 +15511,14 @@ void GLES2DecoderImpl::DoSwapBuffers() { |
| glFlush(); |
| } |
| } else if (supports_async_swap_) { |
| - TRACE_EVENT_ASYNC_BEGIN0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); |
| - surface_->SwapBuffersAsync(base::Bind(&GLES2DecoderImpl::FinishSwapBuffers, |
| - base::AsWeakPtr(this))); |
| + CHECK_LT(pending_swaps_.size(), 2); |
|
reveman
2017/03/24 06:35:09
nit: s/CHECK_LT/DCHECK_LT/
Daniele Castagna
2017/03/24 06:51:24
Done.
|
| + ++async_swap_id_; |
|
reveman
2017/03/24 06:35:09
nit: uint32_t async_swap_id = next_async_swap_id_+
Daniele Castagna
2017/03/24 06:51:24
Done.
|
| + pending_swaps_.push(async_swap_id_); |
| + TRACE_EVENT_ASYNC_BEGIN0("gpu", "AsyncSwapBuffers", async_swap_id_); |
| + |
| + surface_->SwapBuffersAsync( |
| + base::Bind(&GLES2DecoderImpl::RegisterTraceAndFinishSwapBuffers, |
| + base::AsWeakPtr(this))); |
| } else { |
| FinishSwapBuffers(surface_->SwapBuffers()); |
| } |
| @@ -15517,6 +15528,16 @@ void GLES2DecoderImpl::DoSwapBuffers() { |
| ExitCommandProcessingEarly(); |
| } |
| +void GLES2DecoderImpl::RegisterTraceAndFinishSwapBuffers( |
| + gfx::SwapResult result) { |
| + DCHECK(!pending_swaps_.empty()); |
| + uint32_t oldest_swap_id = pending_swaps_.front(); |
|
reveman
2017/03/24 06:35:10
nit: s/oldest_swap_id/async_swap_id/
Daniele Castagna
2017/03/24 06:51:24
Done.
|
| + pending_swaps_.pop(); |
| + TRACE_EVENT_ASYNC_END0("gpu", "AsyncSwapBuffers", oldest_swap_id); |
| + |
| + FinishSwapBuffers(result); |
| +} |
| + |
| void GLES2DecoderImpl::FinishSwapBuffers(gfx::SwapResult result) { |
| if (result == gfx::SwapResult::SWAP_FAILED) { |
| LOG(ERROR) << "Context lost because SwapBuffers failed."; |
| @@ -15531,10 +15552,6 @@ void GLES2DecoderImpl::FinishSwapBuffers(gfx::SwapResult result) { |
| // known values. |
| backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT; |
| } |
| - |
| - if (supports_async_swap_) { |
| - TRACE_EVENT_ASYNC_END0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); |
| - } |
| } |
| void GLES2DecoderImpl::DoCommitOverlayPlanes() { |