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

Side by Side Diff: gpu/command_buffer/service/async_pixel_transfer_manager_egl.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_egl.h" 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h"
6 6
7 #include <list>
7 #include <string> 8 #include <string>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
11 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
15 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h"
16 #include "gpu/command_buffer/service/safe_shared_memory_pool.h" 18 #include "gpu/command_buffer/service/safe_shared_memory_pool.h"
17 #include "ui/gl/gl_context.h" 19 #include "ui/gl/gl_context.h"
18 #include "ui/gl/gl_surface_egl.h" 20 #include "ui/gl/gl_surface_egl.h"
19 #include "ui/gl/scoped_binders.h" 21 #include "ui/gl/scoped_binders.h"
20 22
21 namespace gpu { 23 namespace gpu {
22 24
23 namespace { 25 namespace {
24 26
25 bool CheckErrors(const char* file, int line) { 27 bool CheckErrors(const char* file, int line) {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 405 }
404 406
405 scoped_refptr<TransferStateInternal> internal_; 407 scoped_refptr<TransferStateInternal> internal_;
406 408
407 private: 409 private:
408 virtual ~AsyncTransferStateImpl() {} 410 virtual ~AsyncTransferStateImpl() {}
409 }; 411 };
410 412
411 } // namespace 413 } // namespace
412 414
415 // Class which handles async pixel transfers using EGLImageKHR and another
416 // upload thread
417 class AsyncPixelTransferDelegateEGL
418 : public AsyncPixelTransferDelegate,
419 public base::SupportsWeakPtr<AsyncPixelTransferDelegateEGL> {
420 public:
421 AsyncPixelTransferDelegateEGL();
422 virtual ~AsyncPixelTransferDelegateEGL();
423
424 // Implement AsyncPixelTransferDelegate:
425 virtual AsyncPixelTransferState* CreatePixelTransferState(
426 GLuint texture_id,
427 const AsyncTexImage2DParams& define_params) OVERRIDE;
428 virtual void BindCompletedAsyncTransfers() OVERRIDE;
429 virtual void AsyncNotifyCompletion(
430 const AsyncMemoryParams& mem_params,
431 const CompletionCallback& callback) OVERRIDE;
432 virtual void AsyncTexImage2D(
433 AsyncPixelTransferState* state,
434 const AsyncTexImage2DParams& tex_params,
435 const AsyncMemoryParams& mem_params,
436 const base::Closure& bind_callback) OVERRIDE;
437 virtual void AsyncTexSubImage2D(
438 AsyncPixelTransferState* state,
439 const AsyncTexSubImage2DParams& tex_params,
440 const AsyncMemoryParams& mem_params) OVERRIDE;
441 virtual void WaitForTransferCompletion(
442 AsyncPixelTransferState* state) OVERRIDE;
443 virtual uint32 GetTextureUploadCount() OVERRIDE;
444 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
445 virtual void ProcessMorePendingTransfers() OVERRIDE;
446 virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
447
448 private:
449 static void PerformNotifyCompletion(
450 AsyncMemoryParams mem_params,
451 ScopedSafeSharedMemory* safe_shared_memory,
452 const CompletionCallback& callback);
453
454 // Returns true if a work-around was used.
455 bool WorkAroundAsyncTexImage2D(
456 AsyncPixelTransferState* state,
457 const AsyncTexImage2DParams& tex_params,
458 const AsyncMemoryParams& mem_params,
459 const base::Closure& bind_callback);
460 bool WorkAroundAsyncTexSubImage2D(
461 AsyncPixelTransferState* state,
462 const AsyncTexSubImage2DParams& tex_params,
463 const AsyncMemoryParams& mem_params);
464
465 typedef std::list<base::WeakPtr<AsyncPixelTransferState> > TransferQueue;
466 TransferQueue pending_allocations_;
467
468 scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats_;
469 bool is_imagination_;
470 bool is_qualcomm_;
471
472 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateEGL);
473 };
474
413 AsyncPixelTransferDelegateEGL::AsyncPixelTransferDelegateEGL() { 475 AsyncPixelTransferDelegateEGL::AsyncPixelTransferDelegateEGL() {
414 std::string vendor; 476 std::string vendor;
415 vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR)); 477 vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
416 is_imagination_ = vendor.find("Imagination") != std::string::npos; 478 is_imagination_ = vendor.find("Imagination") != std::string::npos;
417 is_qualcomm_ = vendor.find("Qualcomm") != std::string::npos; 479 is_qualcomm_ = vendor.find("Qualcomm") != std::string::npos;
418 // TODO(reveman): Skip this if --enable-gpu-benchmarking is not present. 480 // TODO(reveman): Skip this if --enable-gpu-benchmarking is not present.
419 texture_upload_stats_ = make_scoped_refptr(new AsyncPixelTransferUploadStats); 481 texture_upload_stats_ = make_scoped_refptr(new AsyncPixelTransferUploadStats);
420 } 482 }
421 483
422 AsyncPixelTransferDelegateEGL::~AsyncPixelTransferDelegateEGL() {} 484 AsyncPixelTransferDelegateEGL::~AsyncPixelTransferDelegateEGL() {}
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 } 803 }
742 if (texture_upload_stats_) { 804 if (texture_upload_stats_) {
743 texture_upload_stats_->AddUpload( 805 texture_upload_stats_->AddUpload(
744 base::TimeTicks::HighResNow() - begin_time); 806 base::TimeTicks::HighResNow() - begin_time);
745 } 807 }
746 808
747 DCHECK(CHECK_GL()); 809 DCHECK(CHECK_GL());
748 return true; 810 return true;
749 } 811 }
750 812
813 AsyncPixelTransferManagerEGL::AsyncPixelTransferManagerEGL()
814 : delegate_(new AsyncPixelTransferDelegateEGL()) {}
815
816 AsyncPixelTransferManagerEGL::~AsyncPixelTransferManagerEGL() {}
817
818 AsyncPixelTransferDelegate*
819 AsyncPixelTransferManagerEGL::GetAsyncPixelTransferDelegate() {
820 return delegate_.get();
821 }
822
751 } // namespace gpu 823 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698