| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/services/gles2/command_buffer_impl.h" | 5 #include "mojo/services/gles2/command_buffer_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 | 9 |
| 10 #include "gpu/command_buffer/common/constants.h" | 10 #include "gpu/command_buffer/common/constants.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 DISALLOW_COPY_AND_ASSIGN(MemoryTrackerStub); | 46 DISALLOW_COPY_AND_ASSIGN(MemoryTrackerStub); |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 } // anonymous namespace | 49 } // anonymous namespace |
| 50 | 50 |
| 51 CommandBufferImpl::CommandBufferImpl(gfx::AcceleratedWidget widget, | 51 CommandBufferImpl::CommandBufferImpl(gfx::AcceleratedWidget widget, |
| 52 const gfx::Size& size) | 52 const gfx::Size& size) |
| 53 : widget_(widget), size_(size) {} | 53 : widget_(widget), size_(size) {} |
| 54 | 54 |
| 55 CommandBufferImpl::~CommandBufferImpl() { | 55 CommandBufferImpl::~CommandBufferImpl() { |
| 56 client_->DidDestroy(); | 56 client()->DidDestroy(); |
| 57 if (decoder_.get()) { | 57 if (decoder_.get()) { |
| 58 bool have_context = decoder_->MakeCurrent(); | 58 bool have_context = decoder_->MakeCurrent(); |
| 59 decoder_->Destroy(have_context); | 59 decoder_->Destroy(have_context); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 void CommandBufferImpl::OnConnectionError() { | 63 void CommandBufferImpl::OnConnectionError() { |
| 64 // TODO(darin): How should we handle this error? | 64 // TODO(darin): How should we handle this error? |
| 65 } | 65 } |
| 66 | 66 |
| 67 void CommandBufferImpl::SetClient(CommandBufferClient* client) { | |
| 68 client_ = client; | |
| 69 } | |
| 70 | |
| 71 void CommandBufferImpl::Initialize( | 67 void CommandBufferImpl::Initialize( |
| 72 CommandBufferSyncClientPtr sync_client, | 68 CommandBufferSyncClientPtr sync_client, |
| 73 mojo::ScopedSharedBufferHandle shared_state) { | 69 mojo::ScopedSharedBufferHandle shared_state) { |
| 74 sync_client_ = sync_client.Pass(); | 70 sync_client_ = sync_client.Pass(); |
| 75 sync_client_->DidInitialize(DoInitialize(shared_state.Pass())); | 71 sync_client_->DidInitialize(DoInitialize(shared_state.Pass())); |
| 76 } | 72 } |
| 77 | 73 |
| 78 bool CommandBufferImpl::DoInitialize( | 74 bool CommandBufferImpl::DoInitialize( |
| 79 mojo::ScopedSharedBufferHandle shared_state) { | 75 mojo::ScopedSharedBufferHandle shared_state) { |
| 80 // TODO(piman): offscreen surface. | 76 // TODO(piman): offscreen surface. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 timer_.Start(FROM_HERE, | 183 timer_.Start(FROM_HERE, |
| 188 base::TimeDelta::FromMilliseconds(16), | 184 base::TimeDelta::FromMilliseconds(16), |
| 189 this, | 185 this, |
| 190 &CommandBufferImpl::DrawAnimationFrame); | 186 &CommandBufferImpl::DrawAnimationFrame); |
| 191 } | 187 } |
| 192 | 188 |
| 193 void CommandBufferImpl::CancelAnimationFrames() { timer_.Stop(); } | 189 void CommandBufferImpl::CancelAnimationFrames() { timer_.Stop(); } |
| 194 | 190 |
| 195 void CommandBufferImpl::OnParseError() { | 191 void CommandBufferImpl::OnParseError() { |
| 196 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 192 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
| 197 client_->LostContext(state.context_lost_reason); | 193 client()->LostContext(state.context_lost_reason); |
| 198 } | 194 } |
| 199 | 195 |
| 200 void CommandBufferImpl::DrawAnimationFrame() { client_->DrawAnimationFrame(); } | 196 void CommandBufferImpl::DrawAnimationFrame() { client()->DrawAnimationFrame(); } |
| 201 | 197 |
| 202 } // namespace services | 198 } // namespace services |
| 203 } // namespace mojo | 199 } // namespace mojo |
| OLD | NEW |