| 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_egl.h" | 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 | 87 |
| 88 class TransferThread : public base::Thread { | 88 class TransferThread : public base::Thread { |
| 89 public: | 89 public: |
| 90 TransferThread() : base::Thread(kAsyncTransferThreadName) { | 90 TransferThread() : base::Thread(kAsyncTransferThreadName) { |
| 91 Start(); | 91 Start(); |
| 92 #if defined(OS_ANDROID) || defined(OS_LINUX) | 92 #if defined(OS_ANDROID) || defined(OS_LINUX) |
| 93 SetPriority(base::kThreadPriority_Background); | 93 SetPriority(base::kThreadPriority_Background); |
| 94 #endif | 94 #endif |
| 95 } | 95 } |
| 96 virtual ~TransferThread() { | 96 ~TransferThread() override { Stop(); } |
| 97 Stop(); | |
| 98 } | |
| 99 | 97 |
| 100 virtual void Init() override { | 98 void Init() override { |
| 101 gfx::GLShareGroup* share_group = NULL; | 99 gfx::GLShareGroup* share_group = NULL; |
| 102 surface_ = new gfx::PbufferGLSurfaceEGL(gfx::Size(1, 1)); | 100 surface_ = new gfx::PbufferGLSurfaceEGL(gfx::Size(1, 1)); |
| 103 surface_->Initialize(); | 101 surface_->Initialize(); |
| 104 context_ = gfx::GLContext::CreateGLContext( | 102 context_ = gfx::GLContext::CreateGLContext( |
| 105 share_group, surface_.get(), gfx::PreferDiscreteGpu); | 103 share_group, surface_.get(), gfx::PreferDiscreteGpu); |
| 106 bool is_current = context_->MakeCurrent(surface_.get()); | 104 bool is_current = context_->MakeCurrent(surface_.get()); |
| 107 DCHECK(is_current); | 105 DCHECK(is_current); |
| 108 } | 106 } |
| 109 | 107 |
| 110 virtual void CleanUp() override { | 108 void CleanUp() override { |
| 111 surface_ = NULL; | 109 surface_ = NULL; |
| 112 context_->ReleaseCurrent(surface_.get()); | 110 context_->ReleaseCurrent(surface_.get()); |
| 113 context_ = NULL; | 111 context_ = NULL; |
| 114 } | 112 } |
| 115 | 113 |
| 116 private: | 114 private: |
| 117 scoped_refptr<gfx::GLContext> context_; | 115 scoped_refptr<gfx::GLContext> context_; |
| 118 scoped_refptr<gfx::GLSurface> surface_; | 116 scoped_refptr<gfx::GLSurface> surface_; |
| 119 | 117 |
| 120 DISALLOW_COPY_AND_ASSIGN(TransferThread); | 118 DISALLOW_COPY_AND_ASSIGN(TransferThread); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 // Class which handles async pixel transfers using EGLImageKHR and another | 392 // Class which handles async pixel transfers using EGLImageKHR and another |
| 395 // upload thread | 393 // upload thread |
| 396 class AsyncPixelTransferDelegateEGL | 394 class AsyncPixelTransferDelegateEGL |
| 397 : public AsyncPixelTransferDelegate, | 395 : public AsyncPixelTransferDelegate, |
| 398 public base::SupportsWeakPtr<AsyncPixelTransferDelegateEGL> { | 396 public base::SupportsWeakPtr<AsyncPixelTransferDelegateEGL> { |
| 399 public: | 397 public: |
| 400 AsyncPixelTransferDelegateEGL( | 398 AsyncPixelTransferDelegateEGL( |
| 401 AsyncPixelTransferManagerEGL::SharedState* shared_state, | 399 AsyncPixelTransferManagerEGL::SharedState* shared_state, |
| 402 GLuint texture_id, | 400 GLuint texture_id, |
| 403 const AsyncTexImage2DParams& define_params); | 401 const AsyncTexImage2DParams& define_params); |
| 404 virtual ~AsyncPixelTransferDelegateEGL(); | 402 ~AsyncPixelTransferDelegateEGL() override; |
| 405 | 403 |
| 406 void BindTransfer() { state_->BindTransfer(); } | 404 void BindTransfer() { state_->BindTransfer(); } |
| 407 | 405 |
| 408 // Implement AsyncPixelTransferDelegate: | 406 // Implement AsyncPixelTransferDelegate: |
| 409 virtual void AsyncTexImage2D( | 407 void AsyncTexImage2D(const AsyncTexImage2DParams& tex_params, |
| 410 const AsyncTexImage2DParams& tex_params, | 408 const AsyncMemoryParams& mem_params, |
| 411 const AsyncMemoryParams& mem_params, | 409 const base::Closure& bind_callback) override; |
| 412 const base::Closure& bind_callback) override; | 410 void AsyncTexSubImage2D(const AsyncTexSubImage2DParams& tex_params, |
| 413 virtual void AsyncTexSubImage2D( | 411 const AsyncMemoryParams& mem_params) override; |
| 414 const AsyncTexSubImage2DParams& tex_params, | 412 bool TransferIsInProgress() override; |
| 415 const AsyncMemoryParams& mem_params) override; | 413 void WaitForTransferCompletion() override; |
| 416 virtual bool TransferIsInProgress() override; | |
| 417 virtual void WaitForTransferCompletion() override; | |
| 418 | 414 |
| 419 private: | 415 private: |
| 420 // Returns true if a work-around was used. | 416 // Returns true if a work-around was used. |
| 421 bool WorkAroundAsyncTexImage2D( | 417 bool WorkAroundAsyncTexImage2D( |
| 422 const AsyncTexImage2DParams& tex_params, | 418 const AsyncTexImage2DParams& tex_params, |
| 423 const AsyncMemoryParams& mem_params, | 419 const AsyncMemoryParams& mem_params, |
| 424 const base::Closure& bind_callback); | 420 const base::Closure& bind_callback); |
| 425 bool WorkAroundAsyncTexSubImage2D( | 421 bool WorkAroundAsyncTexSubImage2D( |
| 426 const AsyncTexSubImage2DParams& tex_params, | 422 const AsyncTexSubImage2DParams& tex_params, |
| 427 const AsyncMemoryParams& mem_params); | 423 const AsyncMemoryParams& mem_params); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 | 739 |
| 744 AsyncPixelTransferDelegate* | 740 AsyncPixelTransferDelegate* |
| 745 AsyncPixelTransferManagerEGL::CreatePixelTransferDelegateImpl( | 741 AsyncPixelTransferManagerEGL::CreatePixelTransferDelegateImpl( |
| 746 gles2::TextureRef* ref, | 742 gles2::TextureRef* ref, |
| 747 const AsyncTexImage2DParams& define_params) { | 743 const AsyncTexImage2DParams& define_params) { |
| 748 return new AsyncPixelTransferDelegateEGL( | 744 return new AsyncPixelTransferDelegateEGL( |
| 749 &shared_state_, ref->service_id(), define_params); | 745 &shared_state_, ref->service_id(), define_params); |
| 750 } | 746 } |
| 751 | 747 |
| 752 } // namespace gpu | 748 } // namespace gpu |
| OLD | NEW |