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 { |
11 | 15 class GLSurface; |
12 class AsyncTransferStateStub : public AsyncPixelTransferState { | 16 class TransferStateInternalStub; |
13 public: | 17 class ScopedSafeSharedMemory; |
14 // implement AsyncPixelTransferState: | |
15 virtual bool TransferIsInProgress() OVERRIDE; | |
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 | 18 |
28 // Class which handles async pixel transfers (as a fallback). | 19 // Class which handles async pixel transfers (as a fallback). |
29 // This class just does the uploads synchronously. | 20 // This class just does the uploads synchronously. |
Sami
2013/03/07 16:57:19
Please update this comment. Maybe the class could
reveman
2013/03/07 20:21:04
Updated the comment.
I think there's some cleanup
| |
30 class AsyncPixelTransferDelegateStub : public AsyncPixelTransferDelegate { | 21 class AsyncPixelTransferDelegateStub : public AsyncPixelTransferDelegate, |
22 public base::SupportsWeakPtr<AsyncPixelTransferDelegateStub> { | |
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 HasPendingTransfers() 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 | |
55 // implement AsyncPixelTransferDelegate: | 59 // implement AsyncPixelTransferDelegate: |
56 virtual AsyncPixelTransferState* | 60 virtual AsyncPixelTransferState* |
57 CreateRawPixelTransferState(GLuint texture_id) OVERRIDE; | 61 CreateRawPixelTransferState(GLuint texture_id) OVERRIDE; |
58 | 62 |
63 void PerformNotifyCompletion( | |
64 AsyncMemoryParams mem_params, | |
65 ScopedSafeSharedMemory* safe_shared_memory, | |
66 const CompletionCallback& callback); | |
67 void PerformAsyncTexImage2D( | |
68 scoped_refptr<TransferStateInternalStub> state, | |
69 AsyncTexImage2DParams tex_params, | |
70 AsyncMemoryParams mem_params, | |
71 ScopedSafeSharedMemory* safe_shared_memory); | |
72 void PerformAsyncTexSubImage2D( | |
73 scoped_refptr<TransferStateInternalStub> state, | |
74 AsyncTexSubImage2DParams tex_params, | |
75 AsyncMemoryParams mem_params, | |
76 ScopedSafeSharedMemory* safe_shared_memory); | |
77 | |
59 int texture_upload_count_; | 78 int texture_upload_count_; |
60 base::TimeDelta total_texture_upload_time_; | 79 base::TimeDelta total_texture_upload_time_; |
61 | 80 |
81 std::list<Transfer> transfers_; | |
82 | |
62 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateStub); | 83 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateStub); |
63 }; | 84 }; |
64 | 85 |
65 } // namespace gfx | 86 } // namespace gfx |
66 | 87 |
67 #endif // UI_GL_ASYNC_TASK_DELEGATE_ANDROID_H_ | 88 #endif // UI_GL_ASYNC_TASK_DELEGATE_ANDROID_H_ |
68 | 89 |
OLD | NEW |