| 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 11 matching lines...) Expand all Loading... |
| 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 "bindings/core/v8/ScriptWrappable.h" | 29 #include "bindings/core/v8/ScriptWrappable.h" |
| 30 #include "core/html/canvas/WebGLContextObject.h" | 30 #include "core/html/canvas/WebGLContextObject.h" |
| 31 #include "core/html/canvas/WebGLSharedObject.h" | 31 #include "core/html/canvas/WebGLSharedObject.h" |
| 32 #include "wtf/HashMap.h" |
| 32 #include "wtf/PassRefPtr.h" | 33 #include "wtf/PassRefPtr.h" |
| 33 #include "wtf/RefCounted.h" | 34 #include "wtf/RefCounted.h" |
| 35 #include "wtf/Vector.h" |
| 34 | 36 |
| 35 namespace blink { | 37 namespace blink { |
| 36 | 38 |
| 37 class WebGLRenderbuffer; | 39 class WebGLRenderbuffer; |
| 38 class WebGLTexture; | 40 class WebGLTexture; |
| 39 | 41 |
| 40 class WebGLFramebuffer final : public WebGLContextObject, public ScriptWrappable
{ | 42 class WebGLFramebuffer final : public WebGLContextObject, public ScriptWrappable
{ |
| 41 DEFINE_WRAPPERTYPEINFO(); | 43 DEFINE_WRAPPERTYPEINFO(); |
| 42 public: | 44 public: |
| 43 class WebGLAttachment : public RefCounted<WebGLAttachment> { | 45 class WebGLAttachment : public RefCounted<WebGLAttachment> { |
| 44 public: | 46 public: |
| 45 virtual ~WebGLAttachment(); | 47 virtual ~WebGLAttachment(); |
| 46 | 48 |
| 47 virtual GLsizei width() const = 0; | 49 virtual GLsizei width() const = 0; |
| 48 virtual GLsizei height() const = 0; | 50 virtual GLsizei height() const = 0; |
| 49 virtual GLenum format() const = 0; | 51 virtual GLenum format() const = 0; |
| 50 // For texture attachment, type() returns the type of the attached textu
re. | 52 // For texture attachment, type() returns the type of the attached textu
re. |
| 51 // For renderbuffer attachment, the type of the renderbuffer may vary wi
th GL implementation. | 53 // For renderbuffer attachment, the type of the renderbuffer may vary wi
th GL implementation. |
| 52 // To avoid confusion, it would be better to not implement type() for re
nderbuffer attachment and | 54 // To avoid confusion, it would be better to not implement type() for re
nderbuffer attachment and |
| 53 // we should always use the internalformat of the renderbuffer and avoid
using type() API. | 55 // we should always use the internalformat of the renderbuffer and avoid
using type() API. |
| 54 virtual GLenum type() const = 0; | 56 virtual GLenum type() const = 0; |
| 55 virtual WebGLSharedObject* object() const = 0; | 57 virtual WebGLSharedObject* object() const = 0; |
| 56 virtual bool isSharedObject(WebGLSharedObject*) const = 0; | 58 virtual bool isSharedObject(WebGLSharedObject*) const = 0; |
| 57 virtual bool valid() const = 0; | 59 virtual bool valid() const = 0; |
| 58 virtual void onDetached(blink::WebGraphicsContext3D*) = 0; | 60 virtual void onDetached(blink::WebGraphicsContext3D*) = 0; |
| 59 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) = 0
; | 61 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) = 0
; |
| 60 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) =
0; | 62 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) =
0; |
| 61 | 63 |
| 62 virtual void trace(Visitor*) { } | |
| 63 | |
| 64 protected: | 64 protected: |
| 65 WebGLAttachment(); | 65 WebGLAttachment(); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 virtual ~WebGLFramebuffer(); | 68 virtual ~WebGLFramebuffer(); |
| 69 | 69 |
| 70 static PassRefPtr<WebGLFramebuffer> create(WebGLRenderingContextBase*); | 70 static PassRefPtr<WebGLFramebuffer> create(WebGLRenderingContextBase*); |
| 71 | 71 |
| 72 void setAttachmentForBoundFramebuffer(GLenum attachment, GLenum texTarget, W
ebGLTexture*, GLint level); | 72 void setAttachmentForBoundFramebuffer(GLenum attachment, GLenum texTarget, W
ebGLTexture*, GLint level); |
| 73 void setAttachmentForBoundFramebuffer(GLenum attachment, WebGLRenderbuffer*)
; | 73 void setAttachmentForBoundFramebuffer(GLenum attachment, WebGLRenderbuffer*)
; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 95 | 95 |
| 96 void setHasEverBeenBound() { m_hasEverBeenBound = true; } | 96 void setHasEverBeenBound() { m_hasEverBeenBound = true; } |
| 97 | 97 |
| 98 bool hasStencilBuffer() const; | 98 bool hasStencilBuffer() const; |
| 99 | 99 |
| 100 // Wrapper for drawBuffersEXT/drawBuffersARB to work around a driver bug. | 100 // Wrapper for drawBuffersEXT/drawBuffersARB to work around a driver bug. |
| 101 void drawBuffers(const Vector<GLenum>& bufs); | 101 void drawBuffers(const Vector<GLenum>& bufs); |
| 102 | 102 |
| 103 GLenum getDrawBuffer(GLenum); | 103 GLenum getDrawBuffer(GLenum); |
| 104 | 104 |
| 105 virtual void trace(Visitor*) override; | |
| 106 | |
| 107 protected: | 105 protected: |
| 108 explicit WebGLFramebuffer(WebGLRenderingContextBase*); | 106 explicit WebGLFramebuffer(WebGLRenderingContextBase*); |
| 109 | 107 |
| 110 virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, Platform3DObject
) override; | 108 virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, Platform3DObject
) override; |
| 111 | 109 |
| 112 private: | 110 private: |
| 113 WebGLAttachment* getAttachment(GLenum) const; | 111 WebGLAttachment* getAttachment(GLenum) const; |
| 114 bool isAttachmentComplete(WebGLAttachment* attachedObject, GLenum attachment
, const char** reason) const; | 112 bool isAttachmentComplete(WebGLAttachment* attachedObject, GLenum attachment
, const char** reason) const; |
| 115 | 113 |
| 116 // Check if the framebuffer is currently bound. | 114 // Check if the framebuffer is currently bound. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 128 | 126 |
| 129 bool m_hasEverBeenBound; | 127 bool m_hasEverBeenBound; |
| 130 | 128 |
| 131 Vector<GLenum> m_drawBuffers; | 129 Vector<GLenum> m_drawBuffers; |
| 132 Vector<GLenum> m_filteredDrawBuffers; | 130 Vector<GLenum> m_filteredDrawBuffers; |
| 133 }; | 131 }; |
| 134 | 132 |
| 135 } // namespace blink | 133 } // namespace blink |
| 136 | 134 |
| 137 #endif // WebGLFramebuffer_h | 135 #endif // WebGLFramebuffer_h |
| OLD | NEW |