| Index: gpu/command_buffer/service/framebuffer_manager.h
|
| diff --git a/gpu/command_buffer/service/framebuffer_manager.h b/gpu/command_buffer/service/framebuffer_manager.h
|
| index ccc24b19e307ef1fea2d9f07be475ff000c634c2..b285cc72ee6ed28d92db99b5d11c43a29cc4ed5d 100644
|
| --- a/gpu/command_buffer/service/framebuffer_manager.h
|
| +++ b/gpu/command_buffer/service/framebuffer_manager.h
|
| @@ -17,182 +17,180 @@
|
| namespace gpu {
|
| namespace gles2 {
|
|
|
| -// This class keeps track of the frambebuffers and their attached renderbuffers
|
| -// so we can correctly clear them.
|
| -class GPU_EXPORT FramebufferManager {
|
| +class FramebufferManager;
|
| +
|
| +// Info about a particular Framebuffer.
|
| +class GPU_EXPORT Framebuffer : public base::RefCounted<Framebuffer> {
|
| public:
|
| - // Info about Framebuffers currently in the system.
|
| - class GPU_EXPORT FramebufferInfo : public base::RefCounted<FramebufferInfo> {
|
| + class Attachment : public base::RefCounted<Attachment> {
|
| public:
|
| - typedef scoped_refptr<FramebufferInfo> Ref;
|
| -
|
| - class Attachment : public base::RefCounted<Attachment> {
|
| - public:
|
| - typedef scoped_refptr<Attachment> Ref;
|
| -
|
| - virtual GLsizei width() const = 0;
|
| - virtual GLsizei height() const = 0;
|
| - virtual GLenum internal_format() const = 0;
|
| - virtual GLsizei samples() const = 0;
|
| - virtual bool cleared() const = 0;
|
| - virtual void SetCleared(
|
| - RenderbufferManager* renderbuffer_manager,
|
| - TextureManager* texture_manager,
|
| - bool cleared) = 0;
|
| - virtual bool IsTexture(TextureManager::TextureInfo* texture) const = 0;
|
| - virtual bool IsRenderbuffer(
|
| - RenderbufferManager::RenderbufferInfo* renderbuffer) const = 0;
|
| - virtual bool CanRenderTo() const = 0;
|
| - virtual void DetachFromFramebuffer() const = 0;
|
| - virtual bool ValidForAttachmentType(GLenum attachment_type) = 0;
|
| - virtual void AddToSignature(
|
| - TextureManager* texture_manager, std::string* signature) const = 0;
|
| -
|
| - protected:
|
| - friend class base::RefCounted<Attachment>;
|
| - virtual ~Attachment() {}
|
| - };
|
| -
|
| - FramebufferInfo(FramebufferManager* manager, GLuint service_id);
|
| + virtual GLsizei width() const = 0;
|
| + virtual GLsizei height() const = 0;
|
| + virtual GLenum internal_format() const = 0;
|
| + virtual GLsizei samples() const = 0;
|
| + virtual bool cleared() const = 0;
|
| + virtual void SetCleared(
|
| + RenderbufferManager* renderbuffer_manager,
|
| + TextureManager* texture_manager,
|
| + bool cleared) = 0;
|
| + virtual bool IsTexture(Texture* texture) const = 0;
|
| + virtual bool IsRenderbuffer(
|
| + Renderbuffer* renderbuffer) const = 0;
|
| + virtual bool CanRenderTo() const = 0;
|
| + virtual void DetachFromFramebuffer() const = 0;
|
| + virtual bool ValidForAttachmentType(GLenum attachment_type) = 0;
|
| + virtual void AddToSignature(
|
| + TextureManager* texture_manager, std::string* signature) const = 0;
|
| +
|
| + protected:
|
| + friend class base::RefCounted<Attachment>;
|
| + virtual ~Attachment() {}
|
| + };
|
|
|
| - GLuint service_id() const {
|
| - return service_id_;
|
| - }
|
| + Framebuffer(FramebufferManager* manager, GLuint service_id);
|
|
|
| - bool HasUnclearedAttachment(GLenum attachment) const;
|
| -
|
| - void MarkAttachmentAsCleared(
|
| - RenderbufferManager* renderbuffer_manager,
|
| - TextureManager* texture_manager,
|
| - GLenum attachment,
|
| - bool cleared);
|
| -
|
| - // Attaches a renderbuffer to a particlar attachment.
|
| - // Pass null to detach.
|
| - void AttachRenderbuffer(
|
| - GLenum attachment, RenderbufferManager::RenderbufferInfo* renderbuffer);
|
| -
|
| - // Attaches a texture to a particlar attachment. Pass null to detach.
|
| - void AttachTexture(
|
| - GLenum attachment, TextureManager::TextureInfo* texture, GLenum target,
|
| - GLint level);
|
| -
|
| - // Unbinds the given renderbuffer if it is bound.
|
| - void UnbindRenderbuffer(
|
| - GLenum target, RenderbufferManager::RenderbufferInfo* renderbuffer);
|
| -
|
| - // Unbinds the given texture if it is bound.
|
| - void UnbindTexture(
|
| - GLenum target, TextureManager::TextureInfo* texture);
|
| -
|
| - const Attachment* GetAttachment(GLenum attachment) const;
|
| -
|
| - bool IsDeleted() const {
|
| - return deleted_;
|
| - }
|
| -
|
| - void MarkAsValid() {
|
| - has_been_bound_ = true;
|
| - }
|
| -
|
| - bool IsValid() const {
|
| - return has_been_bound_ && !IsDeleted();
|
| - }
|
| -
|
| - bool HasDepthAttachment() const;
|
| - bool HasStencilAttachment() const;
|
| - GLenum GetColorAttachmentFormat() const;
|
| -
|
| - // Verify all the rules in OpenGL ES 2.0.25 4.4.5 are followed.
|
| - // Returns GL_FRAMEBUFFER_COMPLETE if there are no reasons we know we can't
|
| - // use this combination of attachments. Otherwise returns the value
|
| - // that glCheckFramebufferStatus should return for this set of attachments.
|
| - // Note that receiving GL_FRAMEBUFFER_COMPLETE from this function does
|
| - // not mean the real OpenGL will consider it framebuffer complete. It just
|
| - // means it passed our tests.
|
| - GLenum IsPossiblyComplete() const;
|
| -
|
| - // Implements optimized glGetFramebufferStatus.
|
| - GLenum GetStatus(TextureManager* texture_manager, GLenum target) const;
|
| -
|
| - // Check all attachments are cleared
|
| - bool IsCleared() const;
|
| -
|
| - static void ClearFramebufferCompleteComboMap();
|
| -
|
| - private:
|
| - friend class FramebufferManager;
|
| - friend class base::RefCounted<FramebufferInfo>;
|
| -
|
| - ~FramebufferInfo();
|
| -
|
| - void MarkAsDeleted();
|
| -
|
| - void MarkAttachmentsAsCleared(
|
| - RenderbufferManager* renderbuffer_manager,
|
| - TextureManager* texture_manager,
|
| - bool cleared);
|
| -
|
| - void MarkAsComplete(unsigned state_id) {
|
| - framebuffer_complete_state_count_id_ = state_id;
|
| - }
|
| + GLuint service_id() const {
|
| + return service_id_;
|
| + }
|
|
|
| - unsigned framebuffer_complete_state_count_id() const {
|
| - return framebuffer_complete_state_count_id_;
|
| - }
|
| + bool HasUnclearedAttachment(GLenum attachment) const;
|
|
|
| - // The managers that owns this.
|
| - FramebufferManager* manager_;
|
| + void MarkAttachmentAsCleared(
|
| + RenderbufferManager* renderbuffer_manager,
|
| + TextureManager* texture_manager,
|
| + GLenum attachment,
|
| + bool cleared);
|
|
|
| - bool deleted_;
|
| + // Attaches a renderbuffer to a particlar attachment.
|
| + // Pass null to detach.
|
| + void AttachRenderbuffer(
|
| + GLenum attachment, Renderbuffer* renderbuffer);
|
|
|
| - // Service side framebuffer id.
|
| - GLuint service_id_;
|
| + // Attaches a texture to a particlar attachment. Pass null to detach.
|
| + void AttachTexture(
|
| + GLenum attachment, Texture* texture, GLenum target,
|
| + GLint level);
|
|
|
| - // Whether this framebuffer has ever been bound.
|
| - bool has_been_bound_;
|
| + // Unbinds the given renderbuffer if it is bound.
|
| + void UnbindRenderbuffer(
|
| + GLenum target, Renderbuffer* renderbuffer);
|
|
|
| - // state count when this framebuffer was last checked for completeness.
|
| - unsigned framebuffer_complete_state_count_id_;
|
| + // Unbinds the given texture if it is bound.
|
| + void UnbindTexture(
|
| + GLenum target, Texture* texture);
|
|
|
| - // A map of attachments.
|
| - typedef base::hash_map<GLenum, Attachment::Ref> AttachmentMap;
|
| - AttachmentMap attachments_;
|
| + const Attachment* GetAttachment(GLenum attachment) const;
|
|
|
| - // A map of successful frame buffer combos. If it's in the map
|
| - // it should be FRAMEBUFFER_COMPLETE.
|
| - typedef base::hash_map<std::string, bool> FramebufferComboCompleteMap;
|
| - static FramebufferComboCompleteMap* framebuffer_combo_complete_map_;
|
| + bool IsDeleted() const {
|
| + return deleted_;
|
| + }
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(FramebufferInfo);
|
| - };
|
| + void MarkAsValid() {
|
| + has_been_bound_ = true;
|
| + }
|
| +
|
| + bool IsValid() const {
|
| + return has_been_bound_ && !IsDeleted();
|
| + }
|
| +
|
| + bool HasDepthAttachment() const;
|
| + bool HasStencilAttachment() const;
|
| + GLenum GetColorAttachmentFormat() const;
|
| +
|
| + // Verify all the rules in OpenGL ES 2.0.25 4.4.5 are followed.
|
| + // Returns GL_FRAMEBUFFER_COMPLETE if there are no reasons we know we can't
|
| + // use this combination of attachments. Otherwise returns the value
|
| + // that glCheckFramebufferStatus should return for this set of attachments.
|
| + // Note that receiving GL_FRAMEBUFFER_COMPLETE from this function does
|
| + // not mean the real OpenGL will consider it framebuffer complete. It just
|
| + // means it passed our tests.
|
| + GLenum IsPossiblyComplete() const;
|
| +
|
| + // Implements optimized glGetFramebufferStatus.
|
| + GLenum GetStatus(TextureManager* texture_manager, GLenum target) const;
|
| +
|
| + // Check all attachments are cleared
|
| + bool IsCleared() const;
|
| +
|
| + static void ClearFramebufferCompleteComboMap();
|
| +
|
| + private:
|
| + friend class FramebufferManager;
|
| + friend class base::RefCounted<Framebuffer>;
|
| +
|
| + ~Framebuffer();
|
| +
|
| + void MarkAsDeleted();
|
|
|
| + void MarkAttachmentsAsCleared(
|
| + RenderbufferManager* renderbuffer_manager,
|
| + TextureManager* texture_manager,
|
| + bool cleared);
|
| +
|
| + void MarkAsComplete(unsigned state_id) {
|
| + framebuffer_complete_state_count_id_ = state_id;
|
| + }
|
| +
|
| + unsigned framebuffer_complete_state_count_id() const {
|
| + return framebuffer_complete_state_count_id_;
|
| + }
|
| +
|
| + // The managers that owns this.
|
| + FramebufferManager* manager_;
|
| +
|
| + bool deleted_;
|
| +
|
| + // Service side framebuffer id.
|
| + GLuint service_id_;
|
| +
|
| + // Whether this framebuffer has ever been bound.
|
| + bool has_been_bound_;
|
| +
|
| + // state count when this framebuffer was last checked for completeness.
|
| + unsigned framebuffer_complete_state_count_id_;
|
| +
|
| + // A map of attachments.
|
| + typedef base::hash_map<GLenum, scoped_refptr<Attachment> > AttachmentMap;
|
| + AttachmentMap attachments_;
|
| +
|
| + // A map of successful frame buffer combos. If it's in the map
|
| + // it should be FRAMEBUFFER_COMPLETE.
|
| + typedef base::hash_map<std::string, bool> FramebufferComboCompleteMap;
|
| + static FramebufferComboCompleteMap* framebuffer_combo_complete_map_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(Framebuffer);
|
| +};
|
| +
|
| +// This class keeps track of the frambebuffers and their attached renderbuffers
|
| +// so we can correctly clear them.
|
| +class GPU_EXPORT FramebufferManager {
|
| + public:
|
| FramebufferManager();
|
| ~FramebufferManager();
|
|
|
| // Must call before destruction.
|
| void Destroy(bool have_context);
|
|
|
| - // Creates a FramebufferInfo for the given framebuffer.
|
| - void CreateFramebufferInfo(GLuint client_id, GLuint service_id);
|
| + // Creates a Framebuffer for the given framebuffer.
|
| + void CreateFramebuffer(GLuint client_id, GLuint service_id);
|
|
|
| // Gets the framebuffer info for the given framebuffer.
|
| - FramebufferInfo* GetFramebufferInfo(GLuint client_id);
|
| + Framebuffer* GetFramebuffer(GLuint client_id);
|
|
|
| // Removes a framebuffer info for the given framebuffer.
|
| - void RemoveFramebufferInfo(GLuint client_id);
|
| + void RemoveFramebuffer(GLuint client_id);
|
|
|
| // Gets a client id for a given service id.
|
| bool GetClientId(GLuint service_id, GLuint* client_id) const;
|
|
|
| void MarkAttachmentsAsCleared(
|
| - FramebufferInfo* framebuffer,
|
| + Framebuffer* framebuffer,
|
| RenderbufferManager* renderbuffer_manager,
|
| TextureManager* texture_manager);
|
|
|
| - void MarkAsComplete(FramebufferInfo* framebuffer);
|
| + void MarkAsComplete(Framebuffer* framebuffer);
|
|
|
| - bool IsComplete(FramebufferInfo* framebuffer);
|
| + bool IsComplete(Framebuffer* framebuffer);
|
|
|
| void IncFramebufferStateChangeCount() {
|
| // make sure this is never 0.
|
| @@ -201,19 +199,22 @@ class GPU_EXPORT FramebufferManager {
|
| }
|
|
|
| private:
|
| - void StartTracking(FramebufferInfo* info);
|
| - void StopTracking(FramebufferInfo* info);
|
| + friend class Framebuffer;
|
| +
|
| + void StartTracking(Framebuffer* info);
|
| + void StopTracking(Framebuffer* info);
|
|
|
| // Info for each framebuffer in the system.
|
| - typedef base::hash_map<GLuint, FramebufferInfo::Ref> FramebufferInfoMap;
|
| + typedef base::hash_map<GLuint, scoped_refptr<Framebuffer> >
|
| + FramebufferInfoMap;
|
| FramebufferInfoMap framebuffer_infos_;
|
|
|
| // Incremented anytime anything changes that might effect framebuffer
|
| // state.
|
| unsigned framebuffer_state_change_count_;
|
|
|
| - // Counts the number of FramebufferInfo allocated with 'this' as its manager.
|
| - // Allows to check no FramebufferInfo will outlive this.
|
| + // Counts the number of Framebuffer allocated with 'this' as its manager.
|
| + // Allows to check no Framebuffer will outlive this.
|
| unsigned int framebuffer_info_count_;
|
|
|
| bool have_context_;
|
|
|