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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 }; | 45 }; |
46 | 46 |
47 } // anonymous namespace | 47 } // anonymous namespace |
48 | 48 |
49 CommandBufferImpl::CommandBufferImpl(gfx::AcceleratedWidget widget, | 49 CommandBufferImpl::CommandBufferImpl(gfx::AcceleratedWidget widget, |
50 const gfx::Size& size) | 50 const gfx::Size& size) |
51 : widget_(widget), size_(size) {} | 51 : widget_(widget), size_(size) {} |
52 | 52 |
53 CommandBufferImpl::~CommandBufferImpl() { | 53 CommandBufferImpl::~CommandBufferImpl() { |
54 client()->DidDestroy(); | 54 client()->DidDestroy(); |
55 if (decoder_.get()) { | 55 if (decoder_) { |
56 bool have_context = decoder_->MakeCurrent(); | 56 bool have_context = decoder_->MakeCurrent(); |
57 decoder_->Destroy(have_context); | 57 decoder_->Destroy(have_context); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 void CommandBufferImpl::OnConnectionError() { | 61 void CommandBufferImpl::OnConnectionError() { |
62 // TODO(darin): How should we handle this error? | 62 // TODO(darin): How should we handle this error? |
63 } | 63 } |
64 | 64 |
65 void CommandBufferImpl::Initialize( | 65 void CommandBufferImpl::Initialize( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 command_buffer_->SetGetBufferChangeCallback(base::Bind( | 123 command_buffer_->SetGetBufferChangeCallback(base::Bind( |
124 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); | 124 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); |
125 command_buffer_->SetParseErrorCallback( | 125 command_buffer_->SetParseErrorCallback( |
126 base::Bind(&CommandBufferImpl::OnParseError, base::Unretained(this))); | 126 base::Bind(&CommandBufferImpl::OnParseError, base::Unretained(this))); |
127 | 127 |
128 // TODO(piman): other callbacks | 128 // TODO(piman): other callbacks |
129 | 129 |
130 const size_t kSize = sizeof(gpu::CommandBufferSharedState); | 130 const size_t kSize = sizeof(gpu::CommandBufferSharedState); |
131 scoped_ptr<gpu::BufferBacking> backing( | 131 scoped_ptr<gpu::BufferBacking> backing( |
132 gles2::MojoBufferBacking::Create(shared_state.Pass(), kSize)); | 132 gles2::MojoBufferBacking::Create(shared_state.Pass(), kSize)); |
133 if (!backing.get()) | 133 if (!backing) |
134 return false; | 134 return false; |
135 | 135 |
136 command_buffer_->SetSharedStateBuffer(backing.Pass()); | 136 command_buffer_->SetSharedStateBuffer(backing.Pass()); |
137 return true; | 137 return true; |
138 } | 138 } |
139 | 139 |
140 void CommandBufferImpl::SetGetBuffer(int32_t buffer) { | 140 void CommandBufferImpl::SetGetBuffer(int32_t buffer) { |
141 command_buffer_->SetGetBuffer(buffer); | 141 command_buffer_->SetGetBuffer(buffer); |
142 } | 142 } |
143 | 143 |
144 void CommandBufferImpl::Flush(int32_t put_offset) { | 144 void CommandBufferImpl::Flush(int32_t put_offset) { |
145 command_buffer_->Flush(put_offset); | 145 command_buffer_->Flush(put_offset); |
146 } | 146 } |
147 | 147 |
148 void CommandBufferImpl::MakeProgress(int32_t last_get_offset) { | 148 void CommandBufferImpl::MakeProgress(int32_t last_get_offset) { |
149 // TODO(piman): handle out-of-order. | 149 // TODO(piman): handle out-of-order. |
150 sync_client_->DidMakeProgress( | 150 sync_client_->DidMakeProgress( |
151 CommandBufferState::From(command_buffer_->GetLastState())); | 151 CommandBufferState::From(command_buffer_->GetLastState())); |
152 } | 152 } |
153 | 153 |
154 void CommandBufferImpl::RegisterTransferBuffer( | 154 void CommandBufferImpl::RegisterTransferBuffer( |
155 int32_t id, | 155 int32_t id, |
156 mojo::ScopedSharedBufferHandle transfer_buffer, | 156 mojo::ScopedSharedBufferHandle transfer_buffer, |
157 uint32_t size) { | 157 uint32_t size) { |
158 // Take ownership of the memory and map it into this process. | 158 // Take ownership of the memory and map it into this process. |
159 // This validates the size. | 159 // This validates the size. |
160 scoped_ptr<gpu::BufferBacking> backing( | 160 scoped_ptr<gpu::BufferBacking> backing( |
161 gles2::MojoBufferBacking::Create(transfer_buffer.Pass(), size)); | 161 gles2::MojoBufferBacking::Create(transfer_buffer.Pass(), size)); |
162 if (!backing.get()) { | 162 if (!backing) { |
163 DVLOG(0) << "Failed to map shared memory."; | 163 DVLOG(0) << "Failed to map shared memory."; |
164 return; | 164 return; |
165 } | 165 } |
166 command_buffer_->RegisterTransferBuffer(id, backing.Pass()); | 166 command_buffer_->RegisterTransferBuffer(id, backing.Pass()); |
167 } | 167 } |
168 | 168 |
169 void CommandBufferImpl::DestroyTransferBuffer(int32_t id) { | 169 void CommandBufferImpl::DestroyTransferBuffer(int32_t id) { |
170 command_buffer_->DestroyTransferBuffer(id); | 170 command_buffer_->DestroyTransferBuffer(id); |
171 } | 171 } |
172 | 172 |
(...skipping 16 matching lines...) Expand all Loading... |
189 } | 189 } |
190 | 190 |
191 void CommandBufferImpl::DrawAnimationFrame() { client()->DrawAnimationFrame(); } | 191 void CommandBufferImpl::DrawAnimationFrame() { client()->DrawAnimationFrame(); } |
192 | 192 |
193 void CommandBufferImpl::OnResize(gfx::Size size, float scale_factor) { | 193 void CommandBufferImpl::OnResize(gfx::Size size, float scale_factor) { |
194 surface_->Resize(size); | 194 surface_->Resize(size); |
195 } | 195 } |
196 | 196 |
197 } // namespace services | 197 } // namespace services |
198 } // namespace mojo | 198 } // namespace mojo |
OLD | NEW |