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 GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "gpu/command_buffer/service/feature_info.h" | 14 #include "gpu/command_buffer/service/feature_info.h" |
15 #include "gpu/command_buffer/service/gl_utils.h" | 15 #include "gpu/command_buffer/service/gl_utils.h" |
16 #include "gpu/command_buffer/service/memory_tracking.h" | 16 #include "gpu/command_buffer/service/memory_tracking.h" |
17 #include "gpu/gpu_export.h" | 17 #include "gpu/gpu_export.h" |
| 18 #include "ui/gl/async_pixel_transfer_delegate.h" |
18 #include "ui/gl/gl_image.h" | 19 #include "ui/gl/gl_image.h" |
19 | 20 |
20 namespace gpu { | 21 namespace gpu { |
21 namespace gles2 { | 22 namespace gles2 { |
22 | 23 |
23 class GLES2Decoder; | 24 class GLES2Decoder; |
24 class Display; | 25 class Display; |
25 class TextureDefinition; | 26 class TextureDefinition; |
26 | 27 |
27 // This class keeps track of the textures and their sizes so we can do NPOT and | 28 // This class keeps track of the textures and their sizes so we can do NPOT and |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 168 } |
168 | 169 |
169 void SetStreamTexture(bool stream_texture) { | 170 void SetStreamTexture(bool stream_texture) { |
170 stream_texture_ = stream_texture; | 171 stream_texture_ = stream_texture; |
171 } | 172 } |
172 | 173 |
173 int IsStreamTexture() { | 174 int IsStreamTexture() { |
174 return stream_texture_; | 175 return stream_texture_; |
175 } | 176 } |
176 | 177 |
| 178 gfx::AsyncPixelTransferState* GetAsyncTransferState() const { |
| 179 return async_transfer_state_.get(); |
| 180 } |
| 181 void SetAsyncTransferState(gfx::AsyncPixelTransferState* state) { |
| 182 async_transfer_state_ = state; |
| 183 } |
| 184 bool AsyncTransferIsInProgress() { |
| 185 return async_transfer_state_ && |
| 186 async_transfer_state_->TransferIsInProgress(); |
| 187 } |
| 188 |
177 void SetImmutable(bool immutable) { | 189 void SetImmutable(bool immutable) { |
178 immutable_ = immutable; | 190 immutable_ = immutable; |
179 } | 191 } |
180 | 192 |
181 bool IsImmutable() { | 193 bool IsImmutable() { |
182 return immutable_; | 194 return immutable_; |
183 } | 195 } |
184 | 196 |
185 // Whether a particular level/face is cleared. | 197 // Whether a particular level/face is cleared. |
186 bool IsLevelCleared(GLenum target, GLint level); | 198 bool IsLevelCleared(GLenum target, GLint level); |
187 | 199 |
| 200 // Whether the texture has been defined |
| 201 bool IsDefined() { |
| 202 return estimated_size() > 0; |
| 203 } |
| 204 |
188 private: | 205 private: |
189 friend class TextureManager; | 206 friend class TextureManager; |
190 friend class base::RefCounted<TextureInfo>; | 207 friend class base::RefCounted<TextureInfo>; |
191 | 208 |
192 ~TextureInfo(); | 209 ~TextureInfo(); |
193 | 210 |
194 struct LevelInfo { | 211 struct LevelInfo { |
195 LevelInfo(); | 212 LevelInfo(); |
196 LevelInfo(const LevelInfo& rhs); | 213 LevelInfo(const LevelInfo& rhs); |
197 ~LevelInfo(); | 214 ~LevelInfo(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // The number of framebuffers this texture is attached to. | 351 // The number of framebuffers this texture is attached to. |
335 int framebuffer_attachment_count_; | 352 int framebuffer_attachment_count_; |
336 | 353 |
337 // Whether the associated context group owns this texture and should delete | 354 // Whether the associated context group owns this texture and should delete |
338 // it. | 355 // it. |
339 bool owned_; | 356 bool owned_; |
340 | 357 |
341 // Whether this is a special streaming texture. | 358 // Whether this is a special streaming texture. |
342 bool stream_texture_; | 359 bool stream_texture_; |
343 | 360 |
| 361 // State to facilitate async transfers on this texture. |
| 362 scoped_refptr<gfx::AsyncPixelTransferState> async_transfer_state_; |
| 363 |
344 // Whether the texture is immutable and no further changes to the format | 364 // Whether the texture is immutable and no further changes to the format |
345 // or dimensions of the texture object can be made. | 365 // or dimensions of the texture object can be made. |
346 bool immutable_; | 366 bool immutable_; |
347 | 367 |
348 // Size in bytes this texture is assumed to take in memory. | 368 // Size in bytes this texture is assumed to take in memory. |
349 uint32 estimated_size_; | 369 uint32 estimated_size_; |
350 | 370 |
351 DISALLOW_COPY_AND_ASSIGN(TextureInfo); | 371 DISALLOW_COPY_AND_ASSIGN(TextureInfo); |
352 }; | 372 }; |
353 | 373 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 // The default textures for each target (texture name = 0) | 592 // The default textures for each target (texture name = 0) |
573 TextureInfo::Ref default_textures_[kNumDefaultTextures]; | 593 TextureInfo::Ref default_textures_[kNumDefaultTextures]; |
574 | 594 |
575 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 595 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
576 }; | 596 }; |
577 | 597 |
578 } // namespace gles2 | 598 } // namespace gles2 |
579 } // namespace gpu | 599 } // namespace gpu |
580 | 600 |
581 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 601 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |