| 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 21 matching lines...) Expand all Loading... |
| 32 #include "wtf/PassRefPtr.h" | 32 #include "wtf/PassRefPtr.h" |
| 33 #include "wtf/RefCounted.h" | 33 #include "wtf/RefCounted.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 class WebGLRenderbuffer; | 37 class WebGLRenderbuffer; |
| 38 class WebGLTexture; | 38 class WebGLTexture; |
| 39 | 39 |
| 40 class WebGLFramebuffer FINAL : public WebGLContextObject, public ScriptWrappable
{ | 40 class WebGLFramebuffer FINAL : public WebGLContextObject, public ScriptWrappable
{ |
| 41 public: | 41 public: |
| 42 class WebGLAttachment : public RefCounted<WebGLAttachment> { | 42 class WebGLAttachment : public RefCountedWillBeGarbageCollectedFinalized<Web
GLAttachment> { |
| 43 public: | 43 public: |
| 44 virtual ~WebGLAttachment(); | 44 virtual ~WebGLAttachment(); |
| 45 | 45 |
| 46 virtual GLsizei width() const = 0; | 46 virtual GLsizei width() const = 0; |
| 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(blink::WebGraphicsContext3D*) = 0; |
| 58 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) = 0
; | 58 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) = 0
; |
| 59 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) =
0; | 59 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) =
0; |
| 60 | 60 |
| 61 virtual void trace(Visitor*) { } |
| 62 |
| 61 protected: | 63 protected: |
| 62 WebGLAttachment(); | 64 WebGLAttachment(); |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 virtual ~WebGLFramebuffer(); | 67 virtual ~WebGLFramebuffer(); |
| 66 | 68 |
| 67 static PassRefPtr<WebGLFramebuffer> create(WebGLRenderingContextBase*); | 69 static PassRefPtrWillBeRawPtr<WebGLFramebuffer> create(WebGLRenderingContext
Base*); |
| 68 | 70 |
| 69 void setAttachmentForBoundFramebuffer(GLenum attachment, GLenum texTarget, W
ebGLTexture*, GLint level); | 71 void setAttachmentForBoundFramebuffer(GLenum attachment, GLenum texTarget, W
ebGLTexture*, GLint level); |
| 70 void setAttachmentForBoundFramebuffer(GLenum attachment, WebGLRenderbuffer*)
; | 72 void setAttachmentForBoundFramebuffer(GLenum attachment, WebGLRenderbuffer*)
; |
| 71 // If an object is attached to the currently bound framebuffer, remove it. | 73 // If an object is attached to the currently bound framebuffer, remove it. |
| 72 void removeAttachmentFromBoundFramebuffer(WebGLSharedObject*); | 74 void removeAttachmentFromBoundFramebuffer(WebGLSharedObject*); |
| 73 // If a given attachment point for the currently bound framebuffer is not nu
ll, remove the attached object. | 75 // If a given attachment point for the currently bound framebuffer is not nu
ll, remove the attached object. |
| 74 void removeAttachmentFromBoundFramebuffer(GLenum); | 76 void removeAttachmentFromBoundFramebuffer(GLenum); |
| 75 WebGLSharedObject* getAttachmentObject(GLenum) const; | 77 WebGLSharedObject* getAttachmentObject(GLenum) const; |
| 76 | 78 |
| 77 GLenum colorBufferFormat() const; | 79 GLenum colorBufferFormat() const; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 92 | 94 |
| 93 void setHasEverBeenBound() { m_hasEverBeenBound = true; } | 95 void setHasEverBeenBound() { m_hasEverBeenBound = true; } |
| 94 | 96 |
| 95 bool hasStencilBuffer() const; | 97 bool hasStencilBuffer() const; |
| 96 | 98 |
| 97 // Wrapper for drawBuffersEXT/drawBuffersARB to work around a driver bug. | 99 // Wrapper for drawBuffersEXT/drawBuffersARB to work around a driver bug. |
| 98 void drawBuffers(const Vector<GLenum>& bufs); | 100 void drawBuffers(const Vector<GLenum>& bufs); |
| 99 | 101 |
| 100 GLenum getDrawBuffer(GLenum); | 102 GLenum getDrawBuffer(GLenum); |
| 101 | 103 |
| 104 virtual void trace(Visitor*) OVERRIDE; |
| 105 |
| 102 protected: | 106 protected: |
| 103 WebGLFramebuffer(WebGLRenderingContextBase*); | 107 explicit WebGLFramebuffer(WebGLRenderingContextBase*); |
| 104 | 108 |
| 105 virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, Platform3DObject
) OVERRIDE; | 109 virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, Platform3DObject
) OVERRIDE; |
| 106 | 110 |
| 107 private: | 111 private: |
| 108 WebGLAttachment* getAttachment(GLenum) const; | 112 WebGLAttachment* getAttachment(GLenum) const; |
| 109 bool isAttachmentComplete(WebGLAttachment* attachedObject, GLenum attachment
, const char** reason) const; | 113 bool isAttachmentComplete(WebGLAttachment* attachedObject, GLenum attachment
, const char** reason) const; |
| 110 | 114 |
| 111 // Check if the framebuffer is currently bound. | 115 // Check if the framebuffer is currently bound. |
| 112 bool isBound() const; | 116 bool isBound() const; |
| 113 | 117 |
| 114 // attach 'attachment' at 'attachmentPoint'. | 118 // attach 'attachment' at 'attachmentPoint'. |
| 115 void attach(GLenum attachment, GLenum attachmentPoint); | 119 void attach(GLenum attachment, GLenum attachmentPoint); |
| 116 | 120 |
| 117 // Check if a new drawBuffers call should be issued. This is called when we
add or remove an attachment. | 121 // Check if a new drawBuffers call should be issued. This is called when we
add or remove an attachment. |
| 118 void drawBuffersIfNecessary(bool force); | 122 void drawBuffersIfNecessary(bool force); |
| 119 | 123 |
| 120 typedef WTF::HashMap<GLenum, RefPtr<WebGLAttachment> > AttachmentMap; | 124 typedef WillBeHeapHashMap<GLenum, RefPtrWillBeMember<WebGLAttachment> > Atta
chmentMap; |
| 121 | 125 |
| 122 AttachmentMap m_attachments; | 126 AttachmentMap m_attachments; |
| 123 | 127 |
| 124 bool m_hasEverBeenBound; | 128 bool m_hasEverBeenBound; |
| 125 | 129 |
| 126 Vector<GLenum> m_drawBuffers; | 130 Vector<GLenum> m_drawBuffers; |
| 127 Vector<GLenum> m_filteredDrawBuffers; | 131 Vector<GLenum> m_filteredDrawBuffers; |
| 128 }; | 132 }; |
| 129 | 133 |
| 130 } // namespace blink | 134 } // namespace blink |
| 131 | 135 |
| 132 #endif // WebGLFramebuffer_h | 136 #endif // WebGLFramebuffer_h |
| OLD | NEW |