| 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 <list> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "gpu/command_buffer/service/feature_info.h" | 15 #include "gpu/command_buffer/service/feature_info.h" |
| 15 #include "gpu/command_buffer/service/gl_utils.h" | 16 #include "gpu/command_buffer/service/gl_utils.h" |
| 16 #include "gpu/command_buffer/service/memory_tracking.h" | 17 #include "gpu/command_buffer/service/memory_tracking.h" |
| 17 #include "gpu/gpu_export.h" | 18 #include "gpu/gpu_export.h" |
| 19 #include "ui/gl/async_pixel_transfer_delegate.h" |
| 18 #include "ui/gl/gl_image.h" | 20 #include "ui/gl/gl_image.h" |
| 19 | 21 |
| 20 namespace gpu { | 22 namespace gpu { |
| 21 namespace gles2 { | 23 namespace gles2 { |
| 22 | 24 |
| 23 class GLES2Decoder; | 25 class GLES2Decoder; |
| 24 class Display; | 26 class Display; |
| 25 class TextureDefinition; | 27 class TextureDefinition; |
| 26 | 28 |
| 27 // This class keeps track of the textures and their sizes so we can do NPOT and | 29 // 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 } | 169 } |
| 168 | 170 |
| 169 void SetStreamTexture(bool stream_texture) { | 171 void SetStreamTexture(bool stream_texture) { |
| 170 stream_texture_ = stream_texture; | 172 stream_texture_ = stream_texture; |
| 171 } | 173 } |
| 172 | 174 |
| 173 int IsStreamTexture() { | 175 int IsStreamTexture() { |
| 174 return stream_texture_; | 176 return stream_texture_; |
| 175 } | 177 } |
| 176 | 178 |
| 179 gfx::AsyncPixelTransferState* GetAsyncTransferState() const { |
| 180 return async_transfer_state_.get(); |
| 181 } |
| 182 void SetAsyncTransferState(scoped_ptr<gfx::AsyncPixelTransferState> state) { |
| 183 async_transfer_state_ = state.Pass(); |
| 184 } |
| 185 bool AsyncTransferIsInProgress() { |
| 186 return async_transfer_state_ && |
| 187 async_transfer_state_->TransferIsInProgress(); |
| 188 } |
| 189 |
| 177 void SetImmutable(bool immutable) { | 190 void SetImmutable(bool immutable) { |
| 178 immutable_ = immutable; | 191 immutable_ = immutable; |
| 179 } | 192 } |
| 180 | 193 |
| 181 bool IsImmutable() { | 194 bool IsImmutable() { |
| 182 return immutable_; | 195 return immutable_; |
| 183 } | 196 } |
| 184 | 197 |
| 185 // Whether a particular level/face is cleared. | 198 // Whether a particular level/face is cleared. |
| 186 bool IsLevelCleared(GLenum target, GLint level); | 199 bool IsLevelCleared(GLenum target, GLint level); |
| 187 | 200 |
| 201 // Whether the texture has been defined |
| 202 bool IsDefined() { |
| 203 return estimated_size() > 0; |
| 204 } |
| 205 |
| 188 private: | 206 private: |
| 189 friend class TextureManager; | 207 friend class TextureManager; |
| 190 friend class base::RefCounted<TextureInfo>; | 208 friend class base::RefCounted<TextureInfo>; |
| 191 | 209 |
| 192 ~TextureInfo(); | 210 ~TextureInfo(); |
| 193 | 211 |
| 194 struct LevelInfo { | 212 struct LevelInfo { |
| 195 LevelInfo(); | 213 LevelInfo(); |
| 196 LevelInfo(const LevelInfo& rhs); | 214 LevelInfo(const LevelInfo& rhs); |
| 197 ~LevelInfo(); | 215 ~LevelInfo(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 // The number of framebuffers this texture is attached to. | 352 // The number of framebuffers this texture is attached to. |
| 335 int framebuffer_attachment_count_; | 353 int framebuffer_attachment_count_; |
| 336 | 354 |
| 337 // Whether the associated context group owns this texture and should delete | 355 // Whether the associated context group owns this texture and should delete |
| 338 // it. | 356 // it. |
| 339 bool owned_; | 357 bool owned_; |
| 340 | 358 |
| 341 // Whether this is a special streaming texture. | 359 // Whether this is a special streaming texture. |
| 342 bool stream_texture_; | 360 bool stream_texture_; |
| 343 | 361 |
| 362 // State to facilitate async transfers on this texture. |
| 363 scoped_ptr<gfx::AsyncPixelTransferState> async_transfer_state_; |
| 364 |
| 344 // Whether the texture is immutable and no further changes to the format | 365 // Whether the texture is immutable and no further changes to the format |
| 345 // or dimensions of the texture object can be made. | 366 // or dimensions of the texture object can be made. |
| 346 bool immutable_; | 367 bool immutable_; |
| 347 | 368 |
| 348 // Size in bytes this texture is assumed to take in memory. | 369 // Size in bytes this texture is assumed to take in memory. |
| 349 uint32 estimated_size_; | 370 uint32 estimated_size_; |
| 350 | 371 |
| 351 DISALLOW_COPY_AND_ASSIGN(TextureInfo); | 372 DISALLOW_COPY_AND_ASSIGN(TextureInfo); |
| 352 }; | 373 }; |
| 353 | 374 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 GLenum target, | 544 GLenum target, |
| 524 GLint level, | 545 GLint level, |
| 525 gfx::GLImage* image); | 546 gfx::GLImage* image); |
| 526 | 547 |
| 527 void AddToSignature( | 548 void AddToSignature( |
| 528 TextureInfo* info, | 549 TextureInfo* info, |
| 529 GLenum target, | 550 GLenum target, |
| 530 GLint level, | 551 GLint level, |
| 531 std::string* signature) const; | 552 std::string* signature) const; |
| 532 | 553 |
| 554 // Transfers added will get their TextureInfo updated at the same time |
| 555 // the async transfer is bound to the real texture. |
| 556 void AddPendingAsyncPixelTransfer( |
| 557 base::WeakPtr<gfx::AsyncPixelTransferState> state, TextureInfo* info); |
| 558 // Returns true if any textures are attached to the frame-buffer. |
| 559 void BindFinishedAsyncPixelTransfers(bool* texture_dirty, |
| 560 bool* framebuffer_dirty); |
| 561 |
| 533 private: | 562 private: |
| 534 // Helper for Initialize(). | 563 // Helper for Initialize(). |
| 535 TextureInfo::Ref CreateDefaultAndBlackTextures( | 564 TextureInfo::Ref CreateDefaultAndBlackTextures( |
| 536 GLenum target, | 565 GLenum target, |
| 537 GLuint* black_texture); | 566 GLuint* black_texture); |
| 538 | 567 |
| 539 void StartTracking(TextureInfo* info); | 568 void StartTracking(TextureInfo* info); |
| 540 void StopTracking(TextureInfo* info); | 569 void StopTracking(TextureInfo* info); |
| 541 | 570 |
| 542 MemoryTypeTracker* GetMemTracker(MemoryTracker::Pool tracking_pool); | 571 MemoryTypeTracker* GetMemTracker(MemoryTracker::Pool tracking_pool); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 565 bool have_context_; | 594 bool have_context_; |
| 566 | 595 |
| 567 // Black (0,0,0,1) textures for when non-renderable textures are used. | 596 // Black (0,0,0,1) textures for when non-renderable textures are used. |
| 568 // NOTE: There is no corresponding TextureInfo for these textures. | 597 // NOTE: There is no corresponding TextureInfo for these textures. |
| 569 // TextureInfos are only for textures the client side can access. | 598 // TextureInfos are only for textures the client side can access. |
| 570 GLuint black_texture_ids_[kNumDefaultTextures]; | 599 GLuint black_texture_ids_[kNumDefaultTextures]; |
| 571 | 600 |
| 572 // The default textures for each target (texture name = 0) | 601 // The default textures for each target (texture name = 0) |
| 573 TextureInfo::Ref default_textures_[kNumDefaultTextures]; | 602 TextureInfo::Ref default_textures_[kNumDefaultTextures]; |
| 574 | 603 |
| 604 // Async texture allocations which haven't been bound to their textures |
| 605 // yet. This facilitates updating the TextureInfo at the same time the |
| 606 // real texture data is bound. |
| 607 typedef std::pair<base::WeakPtr<gfx::AsyncPixelTransferState>, |
| 608 TextureInfo*> PendingAsyncTransfer; |
| 609 typedef std::list<PendingAsyncTransfer> PendingAsyncTransferList; |
| 610 PendingAsyncTransferList pending_async_transfers_; |
| 611 |
| 575 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 612 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
| 576 }; | 613 }; |
| 577 | 614 |
| 578 } // namespace gles2 | 615 } // namespace gles2 |
| 579 } // namespace gpu | 616 } // namespace gpu |
| 580 | 617 |
| 581 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 618 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| OLD | NEW |