OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_GL_ASYNC_TASK_DELEGATE_STUB_H_ | 5 #ifndef UI_GL_ASYNC_TASK_DELEGATE_STUB_H_ |
6 #define UI_GL_ASYNC_TASK_DELEGATE_STUB_H_ | 6 #define UI_GL_ASYNC_TASK_DELEGATE_STUB_H_ |
7 | 7 |
| 8 #include <list> |
| 9 #include <queue> |
| 10 |
| 11 #include "base/callback.h" |
8 #include "ui/gl/async_pixel_transfer_delegate.h" | 12 #include "ui/gl/async_pixel_transfer_delegate.h" |
9 | 13 |
10 namespace gfx { | 14 namespace gfx { |
| 15 class GLSurface; |
| 16 class TransferStateInternalStub; |
| 17 class ScopedSafeSharedMemory; |
11 | 18 |
12 class AsyncTransferStateStub : public AsyncPixelTransferState { | 19 // Class which handles async pixel transfers in a platform |
13 public: | 20 // independent way. |
14 // implement AsyncPixelTransferState: | 21 class AsyncPixelTransferDelegateStub : public AsyncPixelTransferDelegate, |
15 virtual bool TransferIsInProgress() OVERRIDE; | 22 public base::SupportsWeakPtr<AsyncPixelTransferDelegateStub> { |
16 virtual void BindTransfer(AsyncTexImage2DParams* bound_params) OVERRIDE; | |
17 | |
18 private: | |
19 friend class AsyncPixelTransferDelegateStub; | |
20 bool needs_late_bind_; | |
21 AsyncTexImage2DParams late_bind_define_params_ ; | |
22 | |
23 explicit AsyncTransferStateStub(GLuint texture_id); | |
24 virtual ~AsyncTransferStateStub(); | |
25 DISALLOW_COPY_AND_ASSIGN(AsyncTransferStateStub); | |
26 }; | |
27 | |
28 // Class which handles async pixel transfers (as a fallback). | |
29 // This class just does the uploads synchronously. | |
30 class AsyncPixelTransferDelegateStub : public AsyncPixelTransferDelegate { | |
31 public: | 23 public: |
32 static scoped_ptr<AsyncPixelTransferDelegate> | 24 static scoped_ptr<AsyncPixelTransferDelegate> |
33 Create(gfx::GLContext* context); | 25 Create(gfx::GLContext* context); |
34 | 26 |
35 AsyncPixelTransferDelegateStub(); | 27 AsyncPixelTransferDelegateStub(); |
36 virtual ~AsyncPixelTransferDelegateStub(); | 28 virtual ~AsyncPixelTransferDelegateStub(); |
37 | 29 |
38 // implement AsyncPixelTransferDelegate: | 30 // implement AsyncPixelTransferDelegate: |
39 virtual void AsyncNotifyCompletion( | 31 virtual void AsyncNotifyCompletion( |
40 const AsyncMemoryParams& mem_params, | 32 const AsyncMemoryParams& mem_params, |
41 const CompletionCallback& callback) OVERRIDE; | 33 const CompletionCallback& callback) OVERRIDE; |
42 virtual void AsyncTexImage2D( | 34 virtual void AsyncTexImage2D( |
43 AsyncPixelTransferState* transfer_state, | 35 AsyncPixelTransferState* transfer_state, |
44 const AsyncTexImage2DParams& tex_params, | 36 const AsyncTexImage2DParams& tex_params, |
45 const AsyncMemoryParams& mem_params) OVERRIDE; | 37 const AsyncMemoryParams& mem_params) OVERRIDE; |
46 virtual void AsyncTexSubImage2D( | 38 virtual void AsyncTexSubImage2D( |
47 AsyncPixelTransferState* transfer_state, | 39 AsyncPixelTransferState* transfer_state, |
48 const AsyncTexSubImage2DParams& tex_params, | 40 const AsyncTexSubImage2DParams& tex_params, |
49 const AsyncMemoryParams& mem_params) OVERRIDE; | 41 const AsyncMemoryParams& mem_params) OVERRIDE; |
50 virtual void WaitForTransferCompletion( | 42 virtual void WaitForTransferCompletion( |
51 AsyncPixelTransferState* state) OVERRIDE; | 43 AsyncPixelTransferState* transfer_state) OVERRIDE; |
52 virtual uint32 GetTextureUploadCount() OVERRIDE; | 44 virtual uint32 GetTextureUploadCount() OVERRIDE; |
53 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE; | 45 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE; |
| 46 virtual void ProcessPendingTransfers() OVERRIDE; |
| 47 virtual bool CanProcessPendingTransfers() OVERRIDE; |
| 48 |
54 private: | 49 private: |
| 50 struct Transfer { |
| 51 Transfer(TransferStateInternalStub* state, const base::Closure& task); |
| 52 ~Transfer(); |
| 53 |
| 54 scoped_refptr<TransferStateInternalStub> state; |
| 55 base::Closure task; |
| 56 std::queue<base::Closure> notifications; |
| 57 }; |
| 58 |
| 59 void ProcessTransfer(Transfer& transfer); |
| 60 |
55 // implement AsyncPixelTransferDelegate: | 61 // implement AsyncPixelTransferDelegate: |
56 virtual AsyncPixelTransferState* | 62 virtual AsyncPixelTransferState* |
57 CreateRawPixelTransferState(GLuint texture_id) OVERRIDE; | 63 CreateRawPixelTransferState(GLuint texture_id) OVERRIDE; |
58 | 64 |
| 65 void PerformNotifyCompletion( |
| 66 AsyncMemoryParams mem_params, |
| 67 ScopedSafeSharedMemory* safe_shared_memory, |
| 68 const CompletionCallback& callback); |
| 69 void PerformAsyncTexImage2D( |
| 70 scoped_refptr<TransferStateInternalStub> state, |
| 71 AsyncTexImage2DParams tex_params, |
| 72 AsyncMemoryParams mem_params, |
| 73 ScopedSafeSharedMemory* safe_shared_memory); |
| 74 void PerformAsyncTexSubImage2D( |
| 75 scoped_refptr<TransferStateInternalStub> state, |
| 76 AsyncTexSubImage2DParams tex_params, |
| 77 AsyncMemoryParams mem_params, |
| 78 ScopedSafeSharedMemory* safe_shared_memory); |
| 79 |
59 int texture_upload_count_; | 80 int texture_upload_count_; |
60 base::TimeDelta total_texture_upload_time_; | 81 base::TimeDelta total_texture_upload_time_; |
61 | 82 |
| 83 std::list<Transfer> transfers_; |
| 84 |
62 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateStub); | 85 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateStub); |
63 }; | 86 }; |
64 | 87 |
65 } // namespace gfx | 88 } // namespace gfx |
66 | 89 |
67 #endif // UI_GL_ASYNC_TASK_DELEGATE_ANDROID_H_ | 90 #endif // UI_GL_ASYNC_TASK_DELEGATE_ANDROID_H_ |
68 | 91 |
OLD | NEW |