| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 virtual GLsizei height() const = 0; | 47 virtual GLsizei height() const = 0; |
| 48 virtual GLenum format() const = 0; | 48 virtual GLenum format() const = 0; |
| 49 // For texture attachment, type() returns the type of the attached textu
re. | 49 // For texture attachment, type() returns the type of the attached textu
re. |
| 50 // For renderbuffer attachment, the type of the renderbuffer may vary wi
th GL implementation. | 50 // For renderbuffer attachment, the type of the renderbuffer may vary wi
th GL implementation. |
| 51 // To avoid confusion, it would be better to not implement type() for re
nderbuffer attachment and | 51 // To avoid confusion, it would be better to not implement type() for re
nderbuffer attachment and |
| 52 // we should always use the internalformat of the renderbuffer and avoid
using type() API. | 52 // we should always use the internalformat of the renderbuffer and avoid
using type() API. |
| 53 virtual GLenum type() const = 0; | 53 virtual GLenum type() const = 0; |
| 54 virtual WebGLSharedObject* object() const = 0; | 54 virtual WebGLSharedObject* object() const = 0; |
| 55 virtual bool isSharedObject(WebGLSharedObject*) const = 0; | 55 virtual bool isSharedObject(WebGLSharedObject*) const = 0; |
| 56 virtual bool valid() const = 0; | 56 virtual bool valid() const = 0; |
| 57 virtual void onDetached(blink::WebGraphicsContext3D*) = 0; | 57 virtual void onDetached(WebGraphicsContext3D*) = 0; |
| 58 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) = 0
; | 58 virtual void attach(WebGraphicsContext3D*, GLenum attachment) = 0; |
| 59 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) =
0; | 59 virtual void unattach(WebGraphicsContext3D*, GLenum attachment) = 0; |
| 60 | 60 |
| 61 DEFINE_INLINE_VIRTUAL_TRACE() { } | 61 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 62 | 62 |
| 63 protected: | 63 protected: |
| 64 WebGLAttachment(); | 64 WebGLAttachment(); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 ~WebGLFramebuffer() override; | 67 ~WebGLFramebuffer() override; |
| 68 | 68 |
| 69 static PassRefPtrWillBeRawPtr<WebGLFramebuffer> create(WebGLRenderingContext
Base*); | 69 static PassRefPtrWillBeRawPtr<WebGLFramebuffer> create(WebGLRenderingContext
Base*); |
| 70 | 70 |
| 71 Platform3DObject object() const { return m_object; } | 71 Platform3DObject object() const { return m_object; } |
| 72 | 72 |
| 73 void setAttachmentForBoundFramebuffer(GLenum attachment, GLenum texTarget, W
ebGLTexture*, GLint level); | 73 void setAttachmentForBoundFramebuffer(GLenum attachment, GLenum texTarget, W
ebGLTexture*, GLint level); |
| 74 void setAttachmentForBoundFramebuffer(GLenum attachment, WebGLRenderbuffer*)
; | 74 void setAttachmentForBoundFramebuffer(GLenum attachment, WebGLRenderbuffer*)
; |
| 75 // If an object is attached to the currently bound framebuffer, remove it. | 75 // If an object is attached to the currently bound framebuffer, remove it. |
| 76 void removeAttachmentFromBoundFramebuffer(WebGLSharedObject*); | 76 void removeAttachmentFromBoundFramebuffer(WebGLSharedObject*); |
| 77 // If a given attachment point for the currently bound framebuffer is not nu
ll, remove the attached object. | 77 // If a given attachment point for the currently bound framebuffer is not nu
ll, remove the attached object. |
| 78 void removeAttachmentFromBoundFramebuffer(GLenum); | 78 void removeAttachmentFromBoundFramebuffer(GLenum); |
| 79 WebGLSharedObject* getAttachmentObject(GLenum) const; | 79 WebGLSharedObject* getAttachmentObject(GLenum) const; |
| 80 | 80 |
| 81 GLenum colorBufferFormat() const; | 81 GLenum colorBufferFormat() const; |
| 82 | 82 |
| 83 // This should always be called before drawArray, drawElements, clear, | 83 // This should always be called before drawArray, drawElements, clear, |
| 84 // readPixels, copyTexImage2D, copyTexSubImage2D if this framebuffer is | 84 // readPixels, copyTexImage2D, copyTexSubImage2D if this framebuffer is |
| 85 // currently bound. | 85 // currently bound. |
| 86 // Return false if the framebuffer is incomplete. | 86 // Return false if the framebuffer is incomplete. |
| 87 bool onAccess(blink::WebGraphicsContext3D*, const char** reason); | 87 bool onAccess(WebGraphicsContext3D*, const char** reason); |
| 88 | 88 |
| 89 // Software version of glCheckFramebufferStatus(), except that when | 89 // Software version of glCheckFramebufferStatus(), except that when |
| 90 // FRAMEBUFFER_COMPLETE is returned, it is still possible for | 90 // FRAMEBUFFER_COMPLETE is returned, it is still possible for |
| 91 // glCheckFramebufferStatus() to return FRAMEBUFFER_UNSUPPORTED, | 91 // glCheckFramebufferStatus() to return FRAMEBUFFER_UNSUPPORTED, |
| 92 // depending on hardware implementation. | 92 // depending on hardware implementation. |
| 93 GLenum checkStatus(const char** reason) const; | 93 GLenum checkStatus(const char** reason) const; |
| 94 | 94 |
| 95 bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; } | 95 bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; } |
| 96 | 96 |
| 97 void setHasEverBeenBound() { m_hasEverBeenBound = true; } | 97 void setHasEverBeenBound() { m_hasEverBeenBound = true; } |
| 98 | 98 |
| 99 bool hasStencilBuffer() const; | 99 bool hasStencilBuffer() const; |
| 100 | 100 |
| 101 // Wrapper for drawBuffersEXT/drawBuffersARB to work around a driver bug. | 101 // Wrapper for drawBuffersEXT/drawBuffersARB to work around a driver bug. |
| 102 void drawBuffers(const Vector<GLenum>& bufs); | 102 void drawBuffers(const Vector<GLenum>& bufs); |
| 103 | 103 |
| 104 GLenum getDrawBuffer(GLenum); | 104 GLenum getDrawBuffer(GLenum); |
| 105 | 105 |
| 106 DECLARE_VIRTUAL_TRACE(); | 106 DECLARE_VIRTUAL_TRACE(); |
| 107 | 107 |
| 108 protected: | 108 protected: |
| 109 explicit WebGLFramebuffer(WebGLRenderingContextBase*); | 109 explicit WebGLFramebuffer(WebGLRenderingContextBase*); |
| 110 | 110 |
| 111 bool hasObject() const override { return m_object != 0; } | 111 bool hasObject() const override { return m_object != 0; } |
| 112 void deleteObjectImpl(blink::WebGraphicsContext3D*) override; | 112 void deleteObjectImpl(WebGraphicsContext3D*) override; |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 WebGLAttachment* getAttachment(GLenum) const; | 115 WebGLAttachment* getAttachment(GLenum) const; |
| 116 bool isAttachmentComplete(WebGLAttachment* attachedObject, GLenum attachment
, const char** reason) const; | 116 bool isAttachmentComplete(WebGLAttachment* attachedObject, GLenum attachment
, const char** reason) const; |
| 117 | 117 |
| 118 // Check if the framebuffer is currently bound. | 118 // Check if the framebuffer is currently bound. |
| 119 bool isBound() const; | 119 bool isBound() const; |
| 120 | 120 |
| 121 // attach 'attachment' at 'attachmentPoint'. | 121 // attach 'attachment' at 'attachmentPoint'. |
| 122 void attach(GLenum attachment, GLenum attachmentPoint); | 122 void attach(GLenum attachment, GLenum attachmentPoint); |
| 123 | 123 |
| 124 // Check if a new drawBuffers call should be issued. This is called when we
add or remove an attachment. | 124 // Check if a new drawBuffers call should be issued. This is called when we
add or remove an attachment. |
| 125 void drawBuffersIfNecessary(bool force); | 125 void drawBuffersIfNecessary(bool force); |
| 126 | 126 |
| 127 Platform3DObject m_object; | 127 Platform3DObject m_object; |
| 128 | 128 |
| 129 typedef WillBeHeapHashMap<GLenum, RefPtrWillBeMember<WebGLAttachment>> Attac
hmentMap; | 129 typedef WillBeHeapHashMap<GLenum, RefPtrWillBeMember<WebGLAttachment>> Attac
hmentMap; |
| 130 | 130 |
| 131 AttachmentMap m_attachments; | 131 AttachmentMap m_attachments; |
| 132 | 132 |
| 133 bool m_hasEverBeenBound; | 133 bool m_hasEverBeenBound; |
| 134 | 134 |
| 135 Vector<GLenum> m_drawBuffers; | 135 Vector<GLenum> m_drawBuffers; |
| 136 Vector<GLenum> m_filteredDrawBuffers; | 136 Vector<GLenum> m_filteredDrawBuffers; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 } // namespace blink | 139 } // namespace blink |
| 140 | 140 |
| 141 #endif // WebGLFramebuffer_h | 141 #endif // WebGLFramebuffer_h |
| OLD | NEW |