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 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 class Attachment : public base::RefCounted<Attachment> { | 28 class Attachment : public base::RefCounted<Attachment> { |
29 public: | 29 public: |
30 typedef scoped_refptr<Attachment> Ref; | 30 typedef scoped_refptr<Attachment> Ref; |
31 | 31 |
32 virtual ~Attachment() { } | 32 virtual ~Attachment() { } |
33 virtual GLsizei width() const = 0; | 33 virtual GLsizei width() const = 0; |
34 virtual GLsizei height() const = 0; | 34 virtual GLsizei height() const = 0; |
35 virtual GLenum internal_format() const = 0; | 35 virtual GLenum internal_format() const = 0; |
36 virtual GLsizei samples() const = 0; | 36 virtual GLsizei samples() const = 0; |
37 virtual bool cleared() const = 0; | 37 virtual bool cleared() const = 0; |
38 virtual void set_cleared() = 0; | 38 virtual void SetCleared( |
| 39 RenderbufferManager* renderbuffer_manager, |
| 40 TextureManager* texture_manager) = 0; |
39 virtual bool IsTexture(TextureManager::TextureInfo* texture) const = 0; | 41 virtual bool IsTexture(TextureManager::TextureInfo* texture) const = 0; |
40 virtual bool CanRenderTo() const = 0; | 42 virtual bool CanRenderTo() const = 0; |
| 43 virtual void DetachFromFramebuffer() = 0; |
| 44 virtual bool ValidForAttachmentType(GLenum attachment_type) = 0; |
41 }; | 45 }; |
42 | 46 |
43 explicit FramebufferInfo(GLuint service_id); | 47 explicit FramebufferInfo(GLuint service_id); |
44 | 48 |
45 GLuint service_id() const { | 49 GLuint service_id() const { |
46 return service_id_; | 50 return service_id_; |
47 } | 51 } |
48 | 52 |
49 bool HasUnclearedAttachment(GLenum attachment) const; | 53 bool HasUnclearedAttachment(GLenum attachment) const; |
50 | 54 |
51 // Attaches a renderbuffer to a particlar attachment. | 55 // Attaches a renderbuffer to a particlar attachment. |
52 // Pass null to detach. | 56 // Pass null to detach. |
53 void AttachRenderbuffer( | 57 void AttachRenderbuffer( |
54 GLenum attachment, RenderbufferManager::RenderbufferInfo* renderbuffer); | 58 GLenum attachment, RenderbufferManager::RenderbufferInfo* renderbuffer); |
55 | 59 |
56 // Attaches a texture to a particlar attachment. Pass null to detach. | 60 // Attaches a texture to a particlar attachment. Pass null to detach. |
57 void AttachTexture( | 61 void AttachTexture( |
58 GLenum attachment, TextureManager::TextureInfo* texture, GLenum target, | 62 GLenum attachment, TextureManager::TextureInfo* texture, GLenum target, |
59 GLint level); | 63 GLint level); |
60 | 64 |
61 void MarkAttachedRenderbuffersAsCleared(); | 65 void MarkAttachmentsAsCleared( |
| 66 RenderbufferManager* renderbuffer_manager, |
| 67 TextureManager* texture_manager); |
62 | 68 |
63 const Attachment* GetAttachment(GLenum attachment) const; | 69 const Attachment* GetAttachment(GLenum attachment) const; |
64 | 70 |
65 bool IsDeleted() const { | 71 bool IsDeleted() const { |
66 return service_id_ == 0; | 72 return service_id_ == 0; |
67 } | 73 } |
68 | 74 |
69 void MarkAsValid() { | 75 void MarkAsValid() { |
70 has_been_bound_ = true; | 76 has_been_bound_ = true; |
71 } | 77 } |
72 | 78 |
73 bool IsValid() const { | 79 bool IsValid() const { |
74 return has_been_bound_ && !IsDeleted(); | 80 return has_been_bound_ && !IsDeleted(); |
75 } | 81 } |
76 | 82 |
77 bool HasDepthAttachment() const; | 83 bool HasDepthAttachment() const; |
78 bool HasStencilAttachment() const; | 84 bool HasStencilAttachment() const; |
79 GLenum GetColorAttachmentFormat() const; | 85 GLenum GetColorAttachmentFormat() const; |
80 | 86 |
81 // We can't know if the frame buffer is complete since that is | 87 // Verify all the rules in OpenGL ES 2.0.25 4.4.5 are followed. |
82 // implementation dependent and we'd have to check after every glTexImage | 88 // Returns GL_FRAMEBUFFER_COMPLETE if there are no reasons we know we can't |
83 // call but we can know in certain cases that it's NOT complete which we | 89 // use this combination of attachments. Otherwise returns the value |
84 // need to enforce the OpenGL ES 2.0 spec on top of DesktopGL. | 90 // that glCheckFramebufferStatus should return for this set of attachments. |
85 bool IsNotComplete() const; | 91 // Note that receiving GL_FRAMEBUFFER_COMPLETE from this function does |
| 92 // not mean the real OpenGL will consider it framebuffer complete. It just |
| 93 // means it passed our tests. |
| 94 GLenum IsPossiblyComplete() const; |
| 95 |
| 96 // Check all attachments are cleared |
| 97 bool IsCleared() const; |
86 | 98 |
87 private: | 99 private: |
88 friend class FramebufferManager; | 100 friend class FramebufferManager; |
89 friend class base::RefCounted<FramebufferInfo>; | 101 friend class base::RefCounted<FramebufferInfo>; |
90 | 102 |
91 ~FramebufferInfo(); | 103 ~FramebufferInfo(); |
92 | 104 |
93 void MarkAsDeleted() { | 105 void MarkAsDeleted(); |
94 service_id_ = 0; | |
95 attachments_.clear(); | |
96 } | |
97 | 106 |
98 // Service side framebuffer id. | 107 // Service side framebuffer id. |
99 GLuint service_id_; | 108 GLuint service_id_; |
100 | 109 |
101 // Whether this framebuffer has ever been bound. | 110 // Whether this framebuffer has ever been bound. |
102 bool has_been_bound_; | 111 bool has_been_bound_; |
103 | 112 |
104 // A map of attachments. | 113 // A map of attachments. |
105 typedef base::hash_map<GLenum, Attachment::Ref> AttachmentMap; | 114 typedef base::hash_map<GLenum, Attachment::Ref> AttachmentMap; |
106 AttachmentMap attachments_; | 115 AttachmentMap attachments_; |
(...skipping 24 matching lines...) Expand all Loading... |
131 typedef base::hash_map<GLuint, FramebufferInfo::Ref> FramebufferInfoMap; | 140 typedef base::hash_map<GLuint, FramebufferInfo::Ref> FramebufferInfoMap; |
132 FramebufferInfoMap framebuffer_infos_; | 141 FramebufferInfoMap framebuffer_infos_; |
133 | 142 |
134 DISALLOW_COPY_AND_ASSIGN(FramebufferManager); | 143 DISALLOW_COPY_AND_ASSIGN(FramebufferManager); |
135 }; | 144 }; |
136 | 145 |
137 } // namespace gles2 | 146 } // namespace gles2 |
138 } // namespace gpu | 147 } // namespace gpu |
139 | 148 |
140 #endif // GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ | 149 #endif // GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ |
OLD | NEW |