OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef UI_GL_ASYNC_TASK_DELEGATE_H_ |
6 #define UI_GL_ASYNC_TASK_DELEGATE_H_ | 6 #define UI_GL_ASYNC_TASK_DELEGATE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 friend class base::RefCounted<AsyncPixelTransferState>; | 71 friend class base::RefCounted<AsyncPixelTransferState>; |
72 AsyncPixelTransferState() {} | 72 AsyncPixelTransferState() {} |
73 | 73 |
74 | 74 |
75 private: | 75 private: |
76 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferState); | 76 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferState); |
77 }; | 77 }; |
78 | 78 |
79 class GL_EXPORT AsyncPixelTransferDelegate { | 79 class GL_EXPORT AsyncPixelTransferDelegate { |
80 public: | 80 public: |
| 81 typedef base::Callback<void(const AsyncMemoryParams&)> CompletionCallback; |
| 82 |
81 static scoped_ptr<AsyncPixelTransferDelegate> | 83 static scoped_ptr<AsyncPixelTransferDelegate> |
82 Create(gfx::GLContext* context); | 84 Create(gfx::GLContext* context); |
83 virtual ~AsyncPixelTransferDelegate() {} | 85 virtual ~AsyncPixelTransferDelegate() {} |
84 | 86 |
85 // This wouldn't work with MOCK_METHOD, so it routes through | 87 // This wouldn't work with MOCK_METHOD, so it routes through |
86 // a virtual protected version which returns a raw pointer. | 88 // a virtual protected version which returns a raw pointer. |
87 scoped_ptr<AsyncPixelTransferState> | 89 scoped_ptr<AsyncPixelTransferState> |
88 CreatePixelTransferState(GLuint texture_id) { | 90 CreatePixelTransferState(GLuint texture_id) { |
89 return make_scoped_ptr(CreateRawPixelTransferState(texture_id)); | 91 return make_scoped_ptr(CreateRawPixelTransferState(texture_id)); |
90 } | 92 } |
91 | 93 |
| 94 // There's no guarantee that callback will run on the caller thread. |
92 virtual void AsyncNotifyCompletion( | 95 virtual void AsyncNotifyCompletion( |
93 const base::Closure& notify_task) = 0; | 96 const AsyncMemoryParams& mem_params, |
| 97 const CompletionCallback& callback) = 0; |
94 | 98 |
95 virtual void AsyncTexImage2D( | 99 virtual void AsyncTexImage2D( |
96 AsyncPixelTransferState* state, | 100 AsyncPixelTransferState* state, |
97 const AsyncTexImage2DParams& tex_params, | 101 const AsyncTexImage2DParams& tex_params, |
98 const AsyncMemoryParams& mem_params) = 0; | 102 const AsyncMemoryParams& mem_params) = 0; |
99 | 103 |
100 virtual void AsyncTexSubImage2D( | 104 virtual void AsyncTexSubImage2D( |
101 AsyncPixelTransferState* state, | 105 AsyncPixelTransferState* state, |
102 const AsyncTexSubImage2DParams& tex_params, | 106 const AsyncTexSubImage2DParams& tex_params, |
103 const AsyncMemoryParams& mem_params) = 0; | 107 const AsyncMemoryParams& mem_params) = 0; |
104 | 108 |
105 virtual uint32 GetTextureUploadCount() = 0; | 109 virtual uint32 GetTextureUploadCount() = 0; |
106 virtual base::TimeDelta GetTotalTextureUploadTime() = 0; | 110 virtual base::TimeDelta GetTotalTextureUploadTime() = 0; |
107 | 111 |
108 protected: | 112 protected: |
109 AsyncPixelTransferDelegate() {} | 113 AsyncPixelTransferDelegate() {} |
110 // For testing, as returning scoped_ptr wouldn't work with MOCK_METHOD. | 114 // For testing, as returning scoped_ptr wouldn't work with MOCK_METHOD. |
111 virtual AsyncPixelTransferState* | 115 virtual AsyncPixelTransferState* |
112 CreateRawPixelTransferState(GLuint texture_id) = 0; | 116 CreateRawPixelTransferState(GLuint texture_id) = 0; |
113 | 117 |
114 private: | 118 private: |
115 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegate); | 119 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegate); |
116 }; | 120 }; |
117 | 121 |
118 } // namespace gfx | 122 } // namespace gfx |
119 | 123 |
120 #endif // UI_GL_ASYNC_TASK_DELEGATE_H_ | 124 #endif // UI_GL_ASYNC_TASK_DELEGATE_H_ |
121 | 125 |
OLD | NEW |