Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1178)

Side by Side Diff: sky/engine/core/html/canvas/WebGLFramebuffer.h

Issue 1001913003: Remove <canvas> (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
24 */
25
26 #ifndef SKY_ENGINE_CORE_HTML_CANVAS_WEBGLFRAMEBUFFER_H_
27 #define SKY_ENGINE_CORE_HTML_CANVAS_WEBGLFRAMEBUFFER_H_
28
29 #include "sky/engine/tonic/dart_wrappable.h"
30 #include "sky/engine/core/html/canvas/WebGLContextObject.h"
31 #include "sky/engine/core/html/canvas/WebGLSharedObject.h"
32 #include "sky/engine/wtf/HashMap.h"
33 #include "sky/engine/wtf/PassRefPtr.h"
34 #include "sky/engine/wtf/RefCounted.h"
35 #include "sky/engine/wtf/Vector.h"
36
37 namespace blink {
38
39 class WebGLRenderbuffer;
40 class WebGLTexture;
41
42 class WebGLFramebuffer final : public WebGLContextObject, public DartWrappable {
43 DEFINE_WRAPPERTYPEINFO();
44 public:
45 class WebGLAttachment : public RefCounted<WebGLAttachment> {
46 public:
47 virtual ~WebGLAttachment();
48
49 virtual GLsizei width() const = 0;
50 virtual GLsizei height() const = 0;
51 virtual GLenum format() const = 0;
52 // For texture attachment, type() returns the type of the attached textu re.
53 // For renderbuffer attachment, the type of the renderbuffer may vary wi th GL implementation.
54 // To avoid confusion, it would be better to not implement type() for re nderbuffer attachment and
55 // we should always use the internalformat of the renderbuffer and avoid using type() API.
56 virtual GLenum type() const = 0;
57 virtual WebGLSharedObject* object() const = 0;
58 virtual bool isSharedObject(WebGLSharedObject*) const = 0;
59 virtual bool valid() const = 0;
60 virtual void onDetached(blink::WebGraphicsContext3D*) = 0;
61 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) = 0 ;
62 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) = 0;
63
64 protected:
65 WebGLAttachment();
66 };
67
68 virtual ~WebGLFramebuffer();
69
70 static PassRefPtr<WebGLFramebuffer> create(WebGLRenderingContextBase*);
71
72 void setAttachmentForBoundFramebuffer(GLenum attachment, GLenum texTarget, W ebGLTexture*, GLint level);
73 void setAttachmentForBoundFramebuffer(GLenum attachment, WebGLRenderbuffer*) ;
74 // If an object is attached to the currently bound framebuffer, remove it.
75 void removeAttachmentFromBoundFramebuffer(WebGLSharedObject*);
76 // If a given attachment point for the currently bound framebuffer is not nu ll, remove the attached object.
77 void removeAttachmentFromBoundFramebuffer(GLenum);
78 WebGLSharedObject* getAttachmentObject(GLenum) const;
79
80 GLenum colorBufferFormat() const;
81
82 // This should always be called before drawArray, drawElements, clear,
83 // readPixels, copyTexImage2D, copyTexSubImage2D if this framebuffer is
84 // currently bound.
85 // Return false if the framebuffer is incomplete.
86 bool onAccess(blink::WebGraphicsContext3D*, const char** reason);
87
88 // Software version of glCheckFramebufferStatus(), except that when
89 // FRAMEBUFFER_COMPLETE is returned, it is still possible for
90 // glCheckFramebufferStatus() to return FRAMEBUFFER_UNSUPPORTED,
91 // depending on hardware implementation.
92 GLenum checkStatus(const char** reason) const;
93
94 bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; }
95
96 void setHasEverBeenBound() { m_hasEverBeenBound = true; }
97
98 bool hasStencilBuffer() const;
99
100 // Wrapper for drawBuffersEXT/drawBuffersARB to work around a driver bug.
101 void drawBuffers(const Vector<GLenum>& bufs);
102
103 GLenum getDrawBuffer(GLenum);
104
105 protected:
106 explicit WebGLFramebuffer(WebGLRenderingContextBase*);
107
108 virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, Platform3DObject ) override;
109
110 private:
111 WebGLAttachment* getAttachment(GLenum) const;
112 bool isAttachmentComplete(WebGLAttachment* attachedObject, GLenum attachment , const char** reason) const;
113
114 // Check if the framebuffer is currently bound.
115 bool isBound() const;
116
117 // attach 'attachment' at 'attachmentPoint'.
118 void attach(GLenum attachment, GLenum attachmentPoint);
119
120 // Check if a new drawBuffers call should be issued. This is called when we add or remove an attachment.
121 void drawBuffersIfNecessary(bool force);
122
123 typedef HashMap<GLenum, RefPtr<WebGLAttachment> > AttachmentMap;
124
125 AttachmentMap m_attachments;
126
127 bool m_hasEverBeenBound;
128
129 Vector<GLenum> m_drawBuffers;
130 Vector<GLenum> m_filteredDrawBuffers;
131 };
132
133 } // namespace blink
134
135 #endif // SKY_ENGINE_CORE_HTML_CANVAS_WEBGLFRAMEBUFFER_H_
OLDNEW
« no previous file with comments | « sky/engine/core/html/canvas/WebGLExtensionName.h ('k') | sky/engine/core/html/canvas/WebGLFramebuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698