| 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 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef WebGLFramebuffer_h | 26 #ifndef WebGLFramebuffer_h |
| 27 #define WebGLFramebuffer_h | 27 #define WebGLFramebuffer_h |
| 28 | 28 |
| 29 #include "modules/webgl/WebGLContextObject.h" | 29 #include "modules/webgl/WebGLContextObject.h" |
| 30 #include "modules/webgl/WebGLSharedObject.h" | 30 #include "modules/webgl/WebGLSharedObject.h" |
| 31 #include "wtf/PassRefPtr.h" |
| 32 #include "wtf/RefCounted.h" |
| 31 | 33 |
| 32 namespace blink { | 34 namespace blink { |
| 33 | 35 |
| 34 class WebGLRenderbuffer; | 36 class WebGLRenderbuffer; |
| 35 class WebGLTexture; | 37 class WebGLTexture; |
| 36 | 38 |
| 37 class WebGLFramebuffer final : public WebGLContextObject { | 39 class WebGLFramebuffer final : public WebGLContextObject { |
| 38 DEFINE_WRAPPERTYPEINFO(); | 40 DEFINE_WRAPPERTYPEINFO(); |
| 39 public: | 41 public: |
| 40 class WebGLAttachment : public GarbageCollectedFinalized<WebGLAttachment> { | 42 class WebGLAttachment : public RefCountedWillBeGarbageCollectedFinalized<Web
GLAttachment> { |
| 41 public: | 43 public: |
| 42 virtual ~WebGLAttachment(); | 44 virtual ~WebGLAttachment(); |
| 43 | 45 |
| 44 virtual GLsizei width() const = 0; | 46 virtual GLsizei width() const = 0; |
| 45 virtual GLsizei height() const = 0; | 47 virtual GLsizei height() const = 0; |
| 46 virtual GLenum format() const = 0; | 48 virtual GLenum format() const = 0; |
| 47 // 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. |
| 48 // 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. |
| 49 // 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 |
| 50 // 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. |
| 51 virtual GLenum type() const = 0; | 53 virtual GLenum type() const = 0; |
| 52 virtual WebGLSharedObject* object() const = 0; | 54 virtual WebGLSharedObject* object() const = 0; |
| 53 virtual bool isSharedObject(WebGLSharedObject*) const = 0; | 55 virtual bool isSharedObject(WebGLSharedObject*) const = 0; |
| 54 virtual bool valid() const = 0; | 56 virtual bool valid() const = 0; |
| 55 virtual void onDetached(WebGraphicsContext3D*) = 0; | 57 virtual void onDetached(WebGraphicsContext3D*) = 0; |
| 56 virtual void attach(WebGraphicsContext3D*, GLenum target, GLenum attachm
ent) = 0; | 58 virtual void attach(WebGraphicsContext3D*, GLenum target, GLenum attachm
ent) = 0; |
| 57 virtual void unattach(WebGraphicsContext3D*, GLenum target, GLenum attac
hment) = 0; | 59 virtual void unattach(WebGraphicsContext3D*, GLenum target, GLenum attac
hment) = 0; |
| 58 | 60 |
| 59 DEFINE_INLINE_VIRTUAL_TRACE() { } | 61 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 60 | 62 |
| 61 protected: | 63 protected: |
| 62 WebGLAttachment(); | 64 WebGLAttachment(); |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 ~WebGLFramebuffer() override; | 67 ~WebGLFramebuffer() override; |
| 66 | 68 |
| 67 static WebGLFramebuffer* create(WebGLRenderingContextBase*); | 69 static PassRefPtrWillBeRawPtr<WebGLFramebuffer> create(WebGLRenderingContext
Base*); |
| 68 | 70 |
| 69 Platform3DObject object() const { return m_object; } | 71 Platform3DObject object() const { return m_object; } |
| 70 | 72 |
| 71 void setAttachmentForBoundFramebuffer(GLenum target, GLenum attachment, GLen
um texTarget, WebGLTexture*, GLint level); | 73 void setAttachmentForBoundFramebuffer(GLenum target, GLenum attachment, GLen
um texTarget, WebGLTexture*, GLint level); |
| 72 void setAttachmentForBoundFramebuffer(GLenum target, GLenum attachment, WebG
LRenderbuffer*); | 74 void setAttachmentForBoundFramebuffer(GLenum target, GLenum attachment, WebG
LRenderbuffer*); |
| 73 // 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. |
| 74 void removeAttachmentFromBoundFramebuffer(GLenum target, WebGLSharedObject*)
; | 76 void removeAttachmentFromBoundFramebuffer(GLenum target, WebGLSharedObject*)
; |
| 75 // 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. |
| 76 void removeAttachmentFromBoundFramebuffer(GLenum target, GLenum attachment); | 78 void removeAttachmentFromBoundFramebuffer(GLenum target, GLenum attachment); |
| 77 WebGLSharedObject* getAttachmentObject(GLenum) const; | 79 WebGLSharedObject* getAttachmentObject(GLenum) const; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 bool isBound(GLenum target) const; | 127 bool isBound(GLenum target) const; |
| 126 | 128 |
| 127 // attach 'attachment' at 'attachmentPoint'. | 129 // attach 'attachment' at 'attachmentPoint'. |
| 128 void attach(GLenum target, GLenum attachment, GLenum attachmentPoint); | 130 void attach(GLenum target, GLenum attachment, GLenum attachmentPoint); |
| 129 | 131 |
| 130 // Check if a new drawBuffers call should be issued. This is called when we
add or remove an attachment. | 132 // Check if a new drawBuffers call should be issued. This is called when we
add or remove an attachment. |
| 131 void drawBuffersIfNecessary(bool force); | 133 void drawBuffersIfNecessary(bool force); |
| 132 | 134 |
| 133 Platform3DObject m_object; | 135 Platform3DObject m_object; |
| 134 | 136 |
| 135 typedef HeapHashMap<GLenum, Member<WebGLAttachment>> AttachmentMap; | 137 typedef WillBeHeapHashMap<GLenum, RefPtrWillBeMember<WebGLAttachment>> Attac
hmentMap; |
| 136 | 138 |
| 137 AttachmentMap m_attachments; | 139 AttachmentMap m_attachments; |
| 138 | 140 |
| 139 bool m_hasEverBeenBound; | 141 bool m_hasEverBeenBound; |
| 140 | 142 |
| 141 Vector<GLenum> m_drawBuffers; | 143 Vector<GLenum> m_drawBuffers; |
| 142 Vector<GLenum> m_filteredDrawBuffers; | 144 Vector<GLenum> m_filteredDrawBuffers; |
| 143 | 145 |
| 144 GLenum m_readBuffer; | 146 GLenum m_readBuffer; |
| 145 }; | 147 }; |
| 146 | 148 |
| 147 } // namespace blink | 149 } // namespace blink |
| 148 | 150 |
| 149 #endif // WebGLFramebuffer_h | 151 #endif // WebGLFramebuffer_h |
| OLD | NEW |