| 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_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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 virtual bool Is3D() const = 0; | 56 virtual bool Is3D() const = 0; |
| 57 | 57 |
| 58 // If it's a 3D texture attachment, return true if | 58 // If it's a 3D texture attachment, return true if |
| 59 // FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER is smaller than the number of | 59 // FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER is smaller than the number of |
| 60 // layers in the texture. | 60 // layers in the texture. |
| 61 virtual bool IsLayerValid() const = 0; | 61 virtual bool IsLayerValid() const = 0; |
| 62 | 62 |
| 63 virtual bool CanRenderTo(const FeatureInfo* feature_info) const = 0; | 63 virtual bool CanRenderTo(const FeatureInfo* feature_info) const = 0; |
| 64 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) const = 0; | 64 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) const = 0; |
| 65 virtual bool ValidForAttachmentType(GLenum attachment_type, | 65 virtual bool ValidForAttachmentType(GLenum attachment_type, |
| 66 ContextType context_type, | |
| 67 uint32_t max_color_attachments) = 0; | 66 uint32_t max_color_attachments) = 0; |
| 68 virtual size_t GetSignatureSize(TextureManager* texture_manager) const = 0; | 67 virtual size_t GetSignatureSize(TextureManager* texture_manager) const = 0; |
| 69 virtual void AddToSignature( | 68 virtual void AddToSignature( |
| 70 TextureManager* texture_manager, std::string* signature) const = 0; | 69 TextureManager* texture_manager, std::string* signature) const = 0; |
| 71 virtual bool FormsFeedbackLoop( | 70 virtual bool FormsFeedbackLoop( |
| 72 TextureRef* texture, GLint level, GLint layer) const = 0; | 71 TextureRef* texture, GLint level, GLint layer) const = 0; |
| 73 virtual bool EmulatingRGB() const = 0; | 72 virtual bool EmulatingRGB() const = 0; |
| 74 | 73 |
| 75 protected: | 74 protected: |
| 76 friend class base::RefCounted<Attachment>; | 75 friend class base::RefCounted<Attachment>; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 has_been_bound_ = true; | 143 has_been_bound_ = true; |
| 145 } | 144 } |
| 146 | 145 |
| 147 bool IsValid() const { | 146 bool IsValid() const { |
| 148 return has_been_bound_ && !IsDeleted(); | 147 return has_been_bound_ && !IsDeleted(); |
| 149 } | 148 } |
| 150 | 149 |
| 151 bool HasColorAttachment(int index) const; | 150 bool HasColorAttachment(int index) const; |
| 152 bool HasDepthAttachment() const; | 151 bool HasDepthAttachment() const; |
| 153 bool HasStencilAttachment() const; | 152 bool HasStencilAttachment() const; |
| 154 // The following look at DEPTH_STENCIL_ATTACHMENT or | |
| 155 // DEPTH_ATTACHMENT/STENCIL_ATTACHMENT. | |
| 156 // TODO(piman): DEPTH_STENCIL_ATTACHMENT is not a real attachment point, | |
| 157 // except for WebGL1. Fix this. http://crbug.com/630568 | |
| 158 const Attachment* GetDepthAttachment() const; | |
| 159 const Attachment* GetStencilAttachment() const; | |
| 160 GLenum GetDepthFormat() const; | 153 GLenum GetDepthFormat() const; |
| 161 GLenum GetStencilFormat() const; | 154 GLenum GetStencilFormat() const; |
| 162 GLenum GetDrawBufferInternalFormat() const; | 155 GLenum GetDrawBufferInternalFormat() const; |
| 163 GLenum GetReadBufferInternalFormat() const; | 156 GLenum GetReadBufferInternalFormat() const; |
| 164 // If the color attachment is a texture, returns its type; otherwise, | 157 // If the color attachment is a texture, returns its type; otherwise, |
| 165 // returns 0. | 158 // returns 0. |
| 166 GLenum GetReadBufferTextureType() const; | 159 GLenum GetReadBufferTextureType() const; |
| 167 | 160 |
| 168 // Verify all the rules in OpenGL ES 2.0.25 4.4.5 are followed. | 161 // Verify all the rules in OpenGL ES 2.0.25 4.4.5 are followed. |
| 169 // Returns GL_FRAMEBUFFER_COMPLETE if there are no reasons we know we can't | 162 // Returns GL_FRAMEBUFFER_COMPLETE if there are no reasons we know we can't |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 scoped_refptr<Framebuffer> bound_read_framebuffer; | 302 scoped_refptr<Framebuffer> bound_read_framebuffer; |
| 310 scoped_refptr<Framebuffer> bound_draw_framebuffer; | 303 scoped_refptr<Framebuffer> bound_draw_framebuffer; |
| 311 }; | 304 }; |
| 312 | 305 |
| 313 // This class keeps track of the frambebuffers and their attached renderbuffers | 306 // This class keeps track of the frambebuffers and their attached renderbuffers |
| 314 // so we can correctly clear them. | 307 // so we can correctly clear them. |
| 315 class GPU_EXPORT FramebufferManager { | 308 class GPU_EXPORT FramebufferManager { |
| 316 public: | 309 public: |
| 317 FramebufferManager(uint32_t max_draw_buffers, | 310 FramebufferManager(uint32_t max_draw_buffers, |
| 318 uint32_t max_color_attachments, | 311 uint32_t max_color_attachments, |
| 319 ContextType context_type, | |
| 320 const scoped_refptr<FramebufferCompletenessCache>& | 312 const scoped_refptr<FramebufferCompletenessCache>& |
| 321 framebuffer_combo_complete_cache); | 313 framebuffer_combo_complete_cache); |
| 322 ~FramebufferManager(); | 314 ~FramebufferManager(); |
| 323 | 315 |
| 324 // Must call before destruction. | 316 // Must call before destruction. |
| 325 void Destroy(bool have_context); | 317 void Destroy(bool have_context); |
| 326 | 318 |
| 327 // Creates a Framebuffer for the given framebuffer. | 319 // Creates a Framebuffer for the given framebuffer. |
| 328 void CreateFramebuffer(GLuint client_id, GLuint service_id); | 320 void CreateFramebuffer(GLuint client_id, GLuint service_id); |
| 329 | 321 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 344 void MarkAsComplete(Framebuffer* framebuffer); | 336 void MarkAsComplete(Framebuffer* framebuffer); |
| 345 | 337 |
| 346 bool IsComplete(Framebuffer* framebuffer); | 338 bool IsComplete(Framebuffer* framebuffer); |
| 347 | 339 |
| 348 void IncFramebufferStateChangeCount() { | 340 void IncFramebufferStateChangeCount() { |
| 349 // make sure this is never 0. | 341 // make sure this is never 0. |
| 350 framebuffer_state_change_count_ = | 342 framebuffer_state_change_count_ = |
| 351 (framebuffer_state_change_count_ + 1) | 0x80000000U; | 343 (framebuffer_state_change_count_ + 1) | 0x80000000U; |
| 352 } | 344 } |
| 353 | 345 |
| 354 ContextType context_type() const { return context_type_; } | |
| 355 | |
| 356 private: | 346 private: |
| 357 friend class Framebuffer; | 347 friend class Framebuffer; |
| 358 | 348 |
| 359 void StartTracking(Framebuffer* framebuffer); | 349 void StartTracking(Framebuffer* framebuffer); |
| 360 void StopTracking(Framebuffer* framebuffer); | 350 void StopTracking(Framebuffer* framebuffer); |
| 361 | 351 |
| 362 FramebufferCompletenessCache* GetFramebufferComboCompleteCache() { | 352 FramebufferCompletenessCache* GetFramebufferComboCompleteCache() { |
| 363 return framebuffer_combo_complete_cache_.get(); | 353 return framebuffer_combo_complete_cache_.get(); |
| 364 } | 354 } |
| 365 | 355 |
| 366 // Info for each framebuffer in the system. | 356 // Info for each framebuffer in the system. |
| 367 typedef base::hash_map<GLuint, scoped_refptr<Framebuffer> > | 357 typedef base::hash_map<GLuint, scoped_refptr<Framebuffer> > |
| 368 FramebufferMap; | 358 FramebufferMap; |
| 369 FramebufferMap framebuffers_; | 359 FramebufferMap framebuffers_; |
| 370 | 360 |
| 371 // Incremented anytime anything changes that might effect framebuffer | 361 // Incremented anytime anything changes that might effect framebuffer |
| 372 // state. | 362 // state. |
| 373 unsigned framebuffer_state_change_count_; | 363 unsigned framebuffer_state_change_count_; |
| 374 | 364 |
| 375 // Counts the number of Framebuffer allocated with 'this' as its manager. | 365 // Counts the number of Framebuffer allocated with 'this' as its manager. |
| 376 // Allows to check no Framebuffer will outlive this. | 366 // Allows to check no Framebuffer will outlive this. |
| 377 unsigned int framebuffer_count_; | 367 unsigned int framebuffer_count_; |
| 378 | 368 |
| 379 bool have_context_; | 369 bool have_context_; |
| 380 | 370 |
| 381 uint32_t max_draw_buffers_; | 371 uint32_t max_draw_buffers_; |
| 382 uint32_t max_color_attachments_; | 372 uint32_t max_color_attachments_; |
| 383 | 373 |
| 384 ContextType context_type_; | |
| 385 | |
| 386 scoped_refptr<FramebufferCompletenessCache> framebuffer_combo_complete_cache_; | 374 scoped_refptr<FramebufferCompletenessCache> framebuffer_combo_complete_cache_; |
| 387 | 375 |
| 388 DISALLOW_COPY_AND_ASSIGN(FramebufferManager); | 376 DISALLOW_COPY_AND_ASSIGN(FramebufferManager); |
| 389 }; | 377 }; |
| 390 | 378 |
| 391 } // namespace gles2 | 379 } // namespace gles2 |
| 392 } // namespace gpu | 380 } // namespace gpu |
| 393 | 381 |
| 394 #endif // GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ | 382 #endif // GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ |
| OLD | NEW |