| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_FRAMEBUFFER_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "gpu/command_buffer/service/gl_utils.h" | 12 #include "gpu/command_buffer/service/gl_utils.h" |
| 13 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 13 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 14 #include "gpu/command_buffer/service/texture_manager.h" |
| 14 | 15 |
| 15 namespace gpu { | 16 namespace gpu { |
| 16 namespace gles2 { | 17 namespace gles2 { |
| 17 | 18 |
| 18 // This class keeps track of the frambebuffers and their attached renderbuffers | 19 // This class keeps track of the frambebuffers and their attached renderbuffers |
| 19 // so we can correctly clear them. | 20 // so we can correctly clear them. |
| 20 class FramebufferManager { | 21 class FramebufferManager { |
| 21 public: | 22 public: |
| 22 // Info about Framebuffers currently in the system. | 23 // Info about Framebuffers currently in the system. |
| 23 class FramebufferInfo : public base::RefCounted<FramebufferInfo> { | 24 class FramebufferInfo : public base::RefCounted<FramebufferInfo> { |
| 24 public: | 25 public: |
| 25 typedef scoped_refptr<FramebufferInfo> Ref; | 26 typedef scoped_refptr<FramebufferInfo> Ref; |
| 26 | 27 |
| 28 class Attachment : public base::RefCounted<Attachment> { |
| 29 public: |
| 30 typedef scoped_refptr<Attachment> Ref; |
| 31 |
| 32 virtual ~Attachment() { } |
| 33 virtual GLsizei width() const = 0; |
| 34 virtual GLsizei height() const = 0; |
| 35 virtual GLenum internal_format() const = 0; |
| 36 virtual GLsizei samples() const = 0; |
| 37 virtual bool cleared() const = 0; |
| 38 virtual void set_cleared() = 0; |
| 39 }; |
| 40 |
| 27 explicit FramebufferInfo(GLuint service_id); | 41 explicit FramebufferInfo(GLuint service_id); |
| 28 | 42 |
| 29 GLuint service_id() const { | 43 GLuint service_id() const { |
| 30 return service_id_; | 44 return service_id_; |
| 31 } | 45 } |
| 32 | 46 |
| 33 bool HasUnclearedAttachment(GLenum attachment) const; | 47 bool HasUnclearedAttachment(GLenum attachment) const; |
| 34 | 48 |
| 35 // Attaches a renderbuffer to a particlar attachment. | 49 // Attaches a renderbuffer to a particlar attachment. |
| 36 // Pass null to detach. | 50 // Pass null to detach. |
| 37 void AttachRenderbuffer( | 51 void AttachRenderbuffer( |
| 38 GLenum attachment, RenderbufferManager::RenderbufferInfo* renderbuffer); | 52 GLenum attachment, RenderbufferManager::RenderbufferInfo* renderbuffer); |
| 39 | 53 |
| 54 // Attaches a texture to a particlar attachment. Pass null to detach. |
| 55 void AttachTexture( |
| 56 GLenum attachment, TextureManager::TextureInfo* texture, GLenum target, |
| 57 GLint level); |
| 58 |
| 40 void MarkAttachedRenderbuffersAsCleared(); | 59 void MarkAttachedRenderbuffersAsCleared(); |
| 41 | 60 |
| 61 const Attachment* GetAttachment(GLenum attachment) const; |
| 62 |
| 42 bool IsDeleted() { | 63 bool IsDeleted() { |
| 43 return service_id_ == 0; | 64 return service_id_ == 0; |
| 44 } | 65 } |
| 45 | 66 |
| 46 private: | 67 private: |
| 47 friend class FramebufferManager; | 68 friend class FramebufferManager; |
| 48 friend class base::RefCounted<FramebufferInfo>; | 69 friend class base::RefCounted<FramebufferInfo>; |
| 49 | 70 |
| 50 ~FramebufferInfo(); | 71 ~FramebufferInfo(); |
| 51 | 72 |
| 52 void MarkAsDeleted() { | 73 void MarkAsDeleted() { |
| 53 service_id_ = 0; | 74 service_id_ = 0; |
| 54 renderbuffers_.clear(); | 75 attachments_.clear(); |
| 55 } | 76 } |
| 56 | 77 |
| 57 // Service side framebuffer id. | 78 // Service side framebuffer id. |
| 58 GLuint service_id_; | 79 GLuint service_id_; |
| 59 | 80 |
| 60 // A map of attachments to renderbuffers. | 81 // A map of attachments. |
| 61 typedef std::map<GLenum, RenderbufferManager::RenderbufferInfo::Ref> | 82 typedef std::map<GLenum, Attachment::Ref> AttachmentMap; |
| 62 AttachmentToRenderbufferMap; | 83 AttachmentMap attachments_; |
| 63 AttachmentToRenderbufferMap renderbuffers_; | 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(FramebufferInfo); |
| 64 }; | 86 }; |
| 65 | 87 |
| 66 FramebufferManager(); | 88 FramebufferManager(); |
| 67 ~FramebufferManager(); | 89 ~FramebufferManager(); |
| 68 | 90 |
| 69 // Must call before destruction. | 91 // Must call before destruction. |
| 70 void Destroy(bool have_context); | 92 void Destroy(bool have_context); |
| 71 | 93 |
| 72 // Creates a FramebufferInfo for the given framebuffer. | 94 // Creates a FramebufferInfo for the given framebuffer. |
| 73 void CreateFramebufferInfo(GLuint client_id, GLuint service_id); | 95 void CreateFramebufferInfo(GLuint client_id, GLuint service_id); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 87 typedef std::map<GLuint, FramebufferInfo::Ref> FramebufferInfoMap; | 109 typedef std::map<GLuint, FramebufferInfo::Ref> FramebufferInfoMap; |
| 88 FramebufferInfoMap framebuffer_infos_; | 110 FramebufferInfoMap framebuffer_infos_; |
| 89 | 111 |
| 90 DISALLOW_COPY_AND_ASSIGN(FramebufferManager); | 112 DISALLOW_COPY_AND_ASSIGN(FramebufferManager); |
| 91 }; | 113 }; |
| 92 | 114 |
| 93 } // namespace gles2 | 115 } // namespace gles2 |
| 94 } // namespace gpu | 116 } // namespace gpu |
| 95 | 117 |
| 96 #endif // GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ | 118 #endif // GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ |
| OLD | NEW |