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 30 matching lines...) Expand all Loading... |
41 }; | 41 }; |
42 | 42 |
43 private: | 43 private: |
44 virtual ~MemoryTrackerStub() {} | 44 virtual ~MemoryTrackerStub() {} |
45 | 45 |
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(ScopedCommandBufferClientHandle client, | 51 CommandBufferImpl::CommandBufferImpl(gfx::AcceleratedWidget widget, |
52 gfx::AcceleratedWidget widget, | |
53 const gfx::Size& size) | 52 const gfx::Size& size) |
54 : client_(client.Pass(), this), widget_(widget), size_(size) {} | 53 : widget_(widget), size_(size) {} |
55 | 54 |
56 CommandBufferImpl::~CommandBufferImpl() { | 55 CommandBufferImpl::~CommandBufferImpl() { |
57 client_->DidDestroy(); | 56 client_->DidDestroy(); |
58 if (decoder_.get()) { | 57 if (decoder_.get()) { |
59 bool have_context = decoder_->MakeCurrent(); | 58 bool have_context = decoder_->MakeCurrent(); |
60 decoder_->Destroy(have_context); | 59 decoder_->Destroy(have_context); |
61 } | 60 } |
62 } | 61 } |
63 | 62 |
| 63 void CommandBufferImpl::OnConnectionError() { |
| 64 // TODO(darin): How should we handle this error? |
| 65 } |
| 66 |
| 67 void CommandBufferImpl::SetClient(CommandBufferClient* client) { |
| 68 client_ = client; |
| 69 } |
| 70 |
64 void CommandBufferImpl::Initialize( | 71 void CommandBufferImpl::Initialize( |
65 ScopedCommandBufferSyncClientHandle sync_client, | 72 CommandBufferSyncClientPtr sync_client, |
66 mojo::ScopedSharedBufferHandle shared_state) { | 73 mojo::ScopedSharedBufferHandle shared_state) { |
67 sync_client_.reset(sync_client.Pass(), NULL); | 74 sync_client_ = sync_client.Pass(); |
68 sync_client_->DidInitialize(DoInitialize(shared_state.Pass())); | 75 sync_client_->DidInitialize(DoInitialize(shared_state.Pass())); |
69 } | 76 } |
70 | 77 |
71 bool CommandBufferImpl::DoInitialize( | 78 bool CommandBufferImpl::DoInitialize( |
72 mojo::ScopedSharedBufferHandle shared_state) { | 79 mojo::ScopedSharedBufferHandle shared_state) { |
73 // TODO(piman): offscreen surface. | 80 // TODO(piman): offscreen surface. |
74 scoped_refptr<gfx::GLSurface> surface = | 81 scoped_refptr<gfx::GLSurface> surface = |
75 gfx::GLSurface::CreateViewGLSurface(widget_); | 82 gfx::GLSurface::CreateViewGLSurface(widget_); |
76 if (!surface.get()) | 83 if (!surface.get()) |
77 return false; | 84 return false; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 194 |
188 void CommandBufferImpl::OnParseError() { | 195 void CommandBufferImpl::OnParseError() { |
189 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 196 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
190 client_->LostContext(state.context_lost_reason); | 197 client_->LostContext(state.context_lost_reason); |
191 } | 198 } |
192 | 199 |
193 void CommandBufferImpl::DrawAnimationFrame() { client_->DrawAnimationFrame(); } | 200 void CommandBufferImpl::DrawAnimationFrame() { client_->DrawAnimationFrame(); } |
194 | 201 |
195 } // namespace services | 202 } // namespace services |
196 } // namespace mojo | 203 } // namespace mojo |
OLD | NEW |