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 "gpu/command_buffer/service/async_pixel_transfer_manager_share_group.h" | 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager_share_group.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // The texture_id is accessed by either thread, but everything | 209 // The texture_id is accessed by either thread, but everything |
210 // else accessed only on the main thread. | 210 // else accessed only on the main thread. |
211 class TransferStateInternal | 211 class TransferStateInternal |
212 : public base::RefCountedThreadSafe<TransferStateInternal> { | 212 : public base::RefCountedThreadSafe<TransferStateInternal> { |
213 public: | 213 public: |
214 TransferStateInternal(GLuint texture_id, | 214 TransferStateInternal(GLuint texture_id, |
215 const AsyncTexImage2DParams& define_params) | 215 const AsyncTexImage2DParams& define_params) |
216 : texture_id_(texture_id), define_params_(define_params) {} | 216 : texture_id_(texture_id), define_params_(define_params) {} |
217 | 217 |
218 bool TransferIsInProgress() { | 218 bool TransferIsInProgress() { |
219 return pending_upload_task_ && pending_upload_task_->TaskIsInProgress(); | 219 return pending_upload_task_.get() && |
| 220 pending_upload_task_->TaskIsInProgress(); |
220 } | 221 } |
221 | 222 |
222 void BindTransfer() { | 223 void BindTransfer() { |
223 TRACE_EVENT2("gpu", "BindAsyncTransfer", | 224 TRACE_EVENT2("gpu", "BindAsyncTransfer", |
224 "width", define_params_.width, | 225 "width", define_params_.width, |
225 "height", define_params_.height); | 226 "height", define_params_.height); |
226 DCHECK(texture_id_); | 227 DCHECK(texture_id_); |
227 | 228 |
228 glBindTexture(GL_TEXTURE_2D, texture_id_); | 229 glBindTexture(GL_TEXTURE_2D, texture_id_); |
229 bind_callback_.Run(); | 230 bind_callback_.Run(); |
230 } | 231 } |
231 | 232 |
232 void WaitForTransferCompletion() { | 233 void WaitForTransferCompletion() { |
233 TRACE_EVENT0("gpu", "WaitForTransferCompletion"); | 234 TRACE_EVENT0("gpu", "WaitForTransferCompletion"); |
234 DCHECK(pending_upload_task_); | 235 DCHECK(pending_upload_task_.get()); |
235 if (!pending_upload_task_->TryRun()) { | 236 if (!pending_upload_task_->TryRun()) { |
236 pending_upload_task_->WaitForTask(); | 237 pending_upload_task_->WaitForTask(); |
237 } | 238 } |
238 pending_upload_task_ = NULL; | 239 pending_upload_task_ = NULL; |
239 } | 240 } |
240 | 241 |
241 void CancelUpload() { | 242 void CancelUpload() { |
242 TRACE_EVENT0("gpu", "CancelUpload"); | 243 TRACE_EVENT0("gpu", "CancelUpload"); |
243 if (pending_upload_task_) | 244 if (pending_upload_task_.get()) |
244 pending_upload_task_->Cancel(); | 245 pending_upload_task_->Cancel(); |
245 pending_upload_task_ = NULL; | 246 pending_upload_task_ = NULL; |
246 } | 247 } |
247 | 248 |
248 void ScheduleAsyncTexImage2D( | 249 void ScheduleAsyncTexImage2D( |
249 const AsyncTexImage2DParams tex_params, | 250 const AsyncTexImage2DParams tex_params, |
250 const AsyncMemoryParams mem_params, | 251 const AsyncMemoryParams mem_params, |
251 scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats, | 252 scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats, |
252 const base::Closure& bind_callback) { | 253 const base::Closure& bind_callback) { |
253 pending_upload_task_ = new PendingTask(base::Bind( | 254 pending_upload_task_ = new PendingTask(base::Bind( |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 | 570 |
570 AsyncPixelTransferDelegate* | 571 AsyncPixelTransferDelegate* |
571 AsyncPixelTransferManagerShareGroup::CreatePixelTransferDelegateImpl( | 572 AsyncPixelTransferManagerShareGroup::CreatePixelTransferDelegateImpl( |
572 gles2::TextureRef* ref, | 573 gles2::TextureRef* ref, |
573 const AsyncTexImage2DParams& define_params) { | 574 const AsyncTexImage2DParams& define_params) { |
574 return new AsyncPixelTransferDelegateShareGroup( | 575 return new AsyncPixelTransferDelegateShareGroup( |
575 &shared_state_, ref->service_id(), define_params); | 576 &shared_state_, ref->service_id(), define_params); |
576 } | 577 } |
577 | 578 |
578 } // namespace gpu | 579 } // namespace gpu |
OLD | NEW |