Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1093967 - Implement BlitFramebuffer. r=kamidphish
Browse files Browse the repository at this point in the history
  • Loading branch information
kdashg committed Jan 10, 2015
1 parent 92edf2b commit c9000b7
Show file tree
Hide file tree
Showing 12 changed files with 651 additions and 119 deletions.
373 changes: 364 additions & 9 deletions dom/canvas/WebGL2ContextFramebuffers.cpp

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions dom/canvas/WebGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ WebGLContext::DestroyResourcesAndContext()
mBoundUniformBuffer = nullptr;
mCurrentProgram = nullptr;
mActiveProgramLinkInfo = nullptr;
mBoundFramebuffer = nullptr;
mBoundDrawFramebuffer = nullptr;
mBoundReadFramebuffer = nullptr;
mActiveOcclusionQuery = nullptr;
mBoundRenderbuffer = nullptr;
mBoundVertexArray = nullptr;
Expand Down Expand Up @@ -1887,7 +1888,8 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WebGLContext,
mBoundTransformFeedbackBuffer,
mBoundUniformBuffer,
mCurrentProgram,
mBoundFramebuffer,
mBoundDrawFramebuffer,
mBoundReadFramebuffer,
mBoundRenderbuffer,
mBoundVertexArray,
mDefaultVertexArray,
Expand Down
11 changes: 8 additions & 3 deletions dom/canvas/WebGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ class WebGLContext
uint32_t Generation() { return mGeneration.value(); }

// Returns null if the current bound FB is not likely complete.
const WebGLRectangleObject* CurValidFBRectObject() const;
const WebGLRectangleObject* CurValidDrawFBRectObject() const;
const WebGLRectangleObject* CurValidReadFBRectObject() const;

static const size_t kMaxColorAttachments = 16;

Expand Down Expand Up @@ -422,7 +423,8 @@ class WebGLContext
GLint level);

// Framebuffer validation
bool ValidateFramebufferAttachment(GLenum attachment, const char* funcName);
bool ValidateFramebufferAttachment(const WebGLFramebuffer* fb,
GLenum attachment, const char* funcName);

void FrontFace(GLenum mode);
void GenerateMipmap(GLenum target);
Expand Down Expand Up @@ -1419,7 +1421,10 @@ class WebGLContext

uint32_t mMaxFramebufferColorAttachments;

WebGLRefPtr<WebGLFramebuffer> mBoundFramebuffer;
bool ValidateFramebufferTarget(GLenum target, const char* const info);

WebGLRefPtr<WebGLFramebuffer> mBoundDrawFramebuffer;
WebGLRefPtr<WebGLFramebuffer> mBoundReadFramebuffer;
WebGLRefPtr<WebGLRenderbuffer> mBoundRenderbuffer;
WebGLRefPtr<WebGLTransformFeedback> mBoundTransformFeedback;
WebGLRefPtr<WebGLVertexArray> mBoundVertexArray;
Expand Down
12 changes: 6 additions & 6 deletions dom/canvas/WebGLContextDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ bool WebGLContext::DrawArrays_check(GLint first, GLsizei count, GLsizei primcoun

MakeContextCurrent();

if (mBoundFramebuffer) {
if (!mBoundFramebuffer->CheckAndInitializeAttachments()) {
if (mBoundDrawFramebuffer) {
if (!mBoundDrawFramebuffer->CheckAndInitializeAttachments()) {
ErrorInvalidFramebufferOperation("%s: incomplete framebuffer", info);
return false;
}
Expand Down Expand Up @@ -279,8 +279,8 @@ WebGLContext::DrawElements_check(GLsizei count, GLenum type,

MakeContextCurrent();

if (mBoundFramebuffer) {
if (!mBoundFramebuffer->CheckAndInitializeAttachments()) {
if (mBoundDrawFramebuffer) {
if (!mBoundDrawFramebuffer->CheckAndInitializeAttachments()) {
ErrorInvalidFramebufferOperation("%s: incomplete framebuffer", info);
return false;
}
Expand Down Expand Up @@ -369,7 +369,7 @@ void WebGLContext::Draw_cleanup()
UndoFakeVertexAttrib0();
UnbindFakeBlackTextures();

if (!mBoundFramebuffer) {
if (!mBoundDrawFramebuffer) {
Invalidate();
mShouldPresent = true;
MOZ_ASSERT(!mBackbufferNeedsClear);
Expand All @@ -387,7 +387,7 @@ void WebGLContext::Draw_cleanup()
}

// Let's check the viewport
const WebGLRectangleObject* rect = CurValidFBRectObject();
const WebGLRectangleObject* rect = CurValidDrawFBRectObject();
if (rect) {
if (mViewportWidth > rect->Width() ||
mViewportHeight > rect->Height())
Expand Down
9 changes: 4 additions & 5 deletions dom/canvas/WebGLContextFramebufferOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ WebGLContext::Clear(GLbitfield mask)
GenerateWarning("Calling gl.clear() with RASTERIZER_DISCARD enabled has no effects.");
}

if (mBoundFramebuffer) {
if (!mBoundFramebuffer->CheckAndInitializeAttachments())
if (mBoundDrawFramebuffer) {
if (!mBoundDrawFramebuffer->CheckAndInitializeAttachments())
return ErrorInvalidFramebufferOperation("clear: incomplete framebuffer");

gl->fClear(mask);
Expand Down Expand Up @@ -131,12 +131,11 @@ WebGLContext::DrawBuffers(const dom::Sequence<GLenum>& buffers)

const size_t buffersLength = buffers.Length();

if (buffersLength == 0) {
if (!buffersLength) {
return ErrorInvalidValue("drawBuffers: invalid <buffers> (buffers must not be empty)");
}

if (mBoundFramebuffer == 0)
{
if (!mBoundDrawFramebuffer) {
// OK: we are rendering in the default framebuffer

/* EXT_draw_buffers :
Expand Down
Loading

0 comments on commit c9000b7

Please sign in to comment.