Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: gpu/command_buffer/service/async_pixel_transfer_manager_share_group.cc

Issue 16325018: GPU: Factory produces APTManagers instead of APTDelegates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_delegate_share_group.h " 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager_share_group.h"
6
7 #include <list>
6 8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
9 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
11 #include "base/synchronization/cancellation_flag.h" 15 #include "base/synchronization/cancellation_flag.h"
12 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
13 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
14 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
15 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h" 19 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h"
16 #include "gpu/command_buffer/service/safe_shared_memory_pool.h" 20 #include "gpu/command_buffer/service/safe_shared_memory_pool.h"
17 #include "ui/gl/gl_bindings.h" 21 #include "ui/gl/gl_bindings.h"
18 #include "ui/gl/gl_context.h" 22 #include "ui/gl/gl_context.h"
19 #include "ui/gl/gl_surface.h" 23 #include "ui/gl/gl_surface.h"
20 #include "ui/gl/gpu_preference.h" 24 #include "ui/gl/gpu_preference.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 private: 318 private:
315 virtual ~AsyncTransferStateImpl() { 319 virtual ~AsyncTransferStateImpl() {
316 TRACE_EVENT0("gpu", " ~AsyncTransferStateImpl"); 320 TRACE_EVENT0("gpu", " ~AsyncTransferStateImpl");
317 base::AutoLock locked(*internal_->upload_lock()); 321 base::AutoLock locked(*internal_->upload_lock());
318 internal_->cancel_upload_flag()->Set(); 322 internal_->cancel_upload_flag()->Set();
319 } 323 }
320 324
321 scoped_refptr<TransferStateInternal> internal_; 325 scoped_refptr<TransferStateInternal> internal_;
322 }; 326 };
323 327
328 class AsyncPixelTransferDelegateShareGroup : public AsyncPixelTransferDelegate {
329 public:
330 explicit AsyncPixelTransferDelegateShareGroup(gfx::GLContext* context);
331 virtual ~AsyncPixelTransferDelegateShareGroup();
332
333 // Implement AsyncPixelTransferDelegate:
334 virtual AsyncPixelTransferState* CreatePixelTransferState(
335 GLuint texture_id,
336 const AsyncTexImage2DParams& define_params) OVERRIDE;
337 virtual void BindCompletedAsyncTransfers() OVERRIDE;
338 virtual void AsyncNotifyCompletion(
339 const AsyncMemoryParams& mem_params,
340 const CompletionCallback& callback) OVERRIDE;
341 virtual void AsyncTexImage2D(
342 AsyncPixelTransferState* state,
343 const AsyncTexImage2DParams& tex_params,
344 const AsyncMemoryParams& mem_params,
345 const base::Closure& bind_callback) OVERRIDE;
346 virtual void AsyncTexSubImage2D(
347 AsyncPixelTransferState* state,
348 const AsyncTexSubImage2DParams& tex_params,
349 const AsyncMemoryParams& mem_params) OVERRIDE;
350 virtual void WaitForTransferCompletion(
351 AsyncPixelTransferState* state) OVERRIDE;
352 virtual uint32 GetTextureUploadCount() OVERRIDE;
353 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
354 virtual void ProcessMorePendingTransfers() OVERRIDE;
355 virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
356
357 private:
358 typedef std::list<base::WeakPtr<AsyncPixelTransferState> > TransferQueue;
359 TransferQueue pending_allocations_;
360
361 scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats_;
362
363 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateShareGroup);
364 };
365
324 AsyncPixelTransferDelegateShareGroup::AsyncPixelTransferDelegateShareGroup( 366 AsyncPixelTransferDelegateShareGroup::AsyncPixelTransferDelegateShareGroup(
325 gfx::GLContext* context) { 367 gfx::GLContext* context) {
326 g_transfer_thread.Pointer()->InitializeOnMainThread(context); 368 g_transfer_thread.Pointer()->InitializeOnMainThread(context);
327 369
328 // TODO(reveman): Skip this if --enable-gpu-benchmarking is not present. 370 // TODO(reveman): Skip this if --enable-gpu-benchmarking is not present.
329 texture_upload_stats_ = make_scoped_refptr(new AsyncPixelTransferUploadStats); 371 texture_upload_stats_ = make_scoped_refptr(new AsyncPixelTransferUploadStats);
330 } 372 }
331 373
332 AsyncPixelTransferDelegateShareGroup::~AsyncPixelTransferDelegateShareGroup() { 374 AsyncPixelTransferDelegateShareGroup::~AsyncPixelTransferDelegateShareGroup() {
333 } 375 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 return total_texture_upload_time; 536 return total_texture_upload_time;
495 } 537 }
496 538
497 void AsyncPixelTransferDelegateShareGroup::ProcessMorePendingTransfers() { 539 void AsyncPixelTransferDelegateShareGroup::ProcessMorePendingTransfers() {
498 } 540 }
499 541
500 bool AsyncPixelTransferDelegateShareGroup::NeedsProcessMorePendingTransfers() { 542 bool AsyncPixelTransferDelegateShareGroup::NeedsProcessMorePendingTransfers() {
501 return false; 543 return false;
502 } 544 }
503 545
546 AsyncPixelTransferManagerShareGroup::AsyncPixelTransferManagerShareGroup(
547 gfx::GLContext* context)
548 : delegate_(new AsyncPixelTransferDelegateShareGroup(context)) {}
549
550 AsyncPixelTransferManagerShareGroup::~AsyncPixelTransferManagerShareGroup() {}
551
552 AsyncPixelTransferDelegate*
553 AsyncPixelTransferManagerShareGroup::GetAsyncPixelTransferDelegate() {
554 return delegate_.get();
555 }
556
504 } // namespace gpu 557 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698