Bumping manifests a=b2g-bump
[gecko.git] / dom / canvas / WebGL2ContextFramebuffers.cpp
blob27cab63b46b10bf452b0efc3e71734ea971d63df
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "WebGL2Context.h"
7 #include "GLContext.h"
9 using namespace mozilla;
10 using namespace mozilla::dom;
12 // -------------------------------------------------------------------------
13 // Framebuffer objects
15 void
16 WebGL2Context::BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
17 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
18 GLbitfield mask, GLenum filter)
20 MOZ_CRASH("Not Implemented.");
23 void
24 WebGL2Context::FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
26 MOZ_CRASH("Not Implemented.");
29 void
30 WebGL2Context::GetInternalformatParameter(JSContext*, GLenum target, GLenum internalformat, GLenum pname, JS::MutableHandleValue retval)
32 MOZ_CRASH("Not Implemented.");
35 // Map attachments intended for the default buffer, to attachments for a non-
36 // default buffer.
37 static void
38 TranslateDefaultAttachments(const dom::Sequence<GLenum>& in, dom::Sequence<GLenum>* out)
40 for (size_t i = 0; i < in.Length(); i++) {
41 switch (in[i]) {
42 case LOCAL_GL_COLOR:
43 out->AppendElement(LOCAL_GL_COLOR_ATTACHMENT0);
44 break;
45 case LOCAL_GL_DEPTH:
46 out->AppendElement(LOCAL_GL_DEPTH_ATTACHMENT);
47 break;
48 case LOCAL_GL_STENCIL:
49 out->AppendElement(LOCAL_GL_STENCIL_ATTACHMENT);
50 break;
55 void
56 WebGL2Context::InvalidateFramebuffer(GLenum target, const dom::Sequence<GLenum>& attachments)
58 if (IsContextLost())
59 return;
60 MakeContextCurrent();
62 if (target != LOCAL_GL_FRAMEBUFFER)
63 return ErrorInvalidEnumInfo("invalidateFramebuffer: target", target);
64 for (size_t i = 0; i < attachments.Length(); i++) {
65 if (!ValidateFramebufferAttachment(attachments[i], "invalidateFramebuffer"))
66 return;
69 if (!mBoundFramebuffer && !gl->IsDrawingToDefaultFramebuffer()) {
70 dom::Sequence<GLenum> tmpAttachments;
71 TranslateDefaultAttachments(attachments, &tmpAttachments);
72 gl->fInvalidateFramebuffer(target, tmpAttachments.Length(), tmpAttachments.Elements());
73 } else {
74 gl->fInvalidateFramebuffer(target, attachments.Length(), attachments.Elements());
78 void
79 WebGL2Context::InvalidateSubFramebuffer(GLenum target, const dom::Sequence<GLenum>& attachments,
80 GLint x, GLint y, GLsizei width, GLsizei height)
82 if (IsContextLost())
83 return;
84 MakeContextCurrent();
86 if (target != LOCAL_GL_FRAMEBUFFER)
87 return ErrorInvalidEnumInfo("invalidateFramebuffer: target", target);
88 for (size_t i = 0; i < attachments.Length(); i++) {
89 if (!ValidateFramebufferAttachment(attachments[i], "invalidateSubFramebuffer"))
90 return;
93 if (!mBoundFramebuffer && !gl->IsDrawingToDefaultFramebuffer()) {
94 dom::Sequence<GLenum> tmpAttachments;
95 TranslateDefaultAttachments(attachments, &tmpAttachments);
96 gl->fInvalidateSubFramebuffer(target, tmpAttachments.Length(), tmpAttachments.Elements(),
97 x, y, width, height);
98 } else {
99 gl->fInvalidateSubFramebuffer(target, attachments.Length(), attachments.Elements(),
100 x, y, width, height);
104 void
105 WebGL2Context::ReadBuffer(GLenum mode)
107 MOZ_CRASH("Not Implemented.");
110 void
111 WebGL2Context::RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat,
112 GLsizei width, GLsizei height)
114 MOZ_CRASH("Not Implemented.");