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

Unified Diff: Source/core/html/canvas/WebGLFramebuffer.cpp

Issue 106503003: Changed GL enums from GraphicsContext3D to standard versions (Take 2) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/canvas/WebGLDrawBuffers.cpp ('k') | Source/core/html/canvas/WebGLObject.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/canvas/WebGLFramebuffer.cpp
diff --git a/Source/core/html/canvas/WebGLFramebuffer.cpp b/Source/core/html/canvas/WebGLFramebuffer.cpp
index 73614b5e8cd4665b695e61604a8f8eda29f7227e..7ab97df91d1f01015d77cdeaa3f65dfb2dbdf1dd 100644
--- a/Source/core/html/canvas/WebGLFramebuffer.cpp
+++ b/Source/core/html/canvas/WebGLFramebuffer.cpp
@@ -87,9 +87,9 @@ namespace {
GC3Denum WebGLRenderbufferAttachment::format() const
{
GC3Denum format = m_renderbuffer->internalFormat();
- if (format == GraphicsContext3D::DEPTH_STENCIL
+ if (format == GL_DEPTH_STENCIL_OES
&& m_renderbuffer->emulatedStencilBuffer()
- && m_renderbuffer->emulatedStencilBuffer()->internalFormat() != GraphicsContext3D::STENCIL_INDEX8) {
+ && m_renderbuffer->emulatedStencilBuffer()->internalFormat() != GL_STENCIL_INDEX8) {
return 0;
}
return format;
@@ -129,21 +129,22 @@ namespace {
void WebGLRenderbufferAttachment::attach(GraphicsContext3D* context, GC3Denum attachment)
{
Platform3DObject object = objectOrZero(m_renderbuffer.get());
- if (attachment == GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT && m_renderbuffer->emulatedStencilBuffer()) {
- context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, object);
- context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, objectOrZero(m_renderbuffer->emulatedStencilBuffer()));
+ if (attachment == GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL && m_renderbuffer->emulatedStencilBuffer()) {
+ context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, object);
+ context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, objectOrZero(m_renderbuffer->emulatedStencilBuffer()));
} else {
- context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, attachment, GraphicsContext3D::RENDERBUFFER, object);
+ context->framebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, object);
}
}
void WebGLRenderbufferAttachment::unattach(GraphicsContext3D* context, GC3Denum attachment)
{
- if (attachment == GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT) {
- context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, 0);
- context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, 0);
- } else
- context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, attachment, GraphicsContext3D::RENDERBUFFER, 0);
+ if (attachment == GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL) {
+ context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
+ context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
+ } else {
+ context->framebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, 0);
+ }
}
GC3Denum WebGLRenderbufferAttachment::type() const
@@ -239,16 +240,17 @@ namespace {
void WebGLTextureAttachment::attach(GraphicsContext3D* context, GC3Denum attachment)
{
Platform3DObject object = objectOrZero(m_texture.get());
- context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, attachment, m_target, object, m_level);
+ context->framebufferTexture2D(GL_FRAMEBUFFER, attachment, m_target, object, m_level);
}
void WebGLTextureAttachment::unattach(GraphicsContext3D* context, GC3Denum attachment)
{
- if (attachment == GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT) {
- context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, m_target, 0, m_level);
- context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, m_target, 0, m_level);
- } else
- context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, attachment, m_target, 0, m_level);
+ if (attachment == GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL) {
+ context->framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_target, 0, m_level);
+ context->framebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, m_target, 0, m_level);
+ } else {
+ context->framebufferTexture2D(GL_FRAMEBUFFER, attachment, m_target, 0, m_level);
+ }
}
GC3Denum WebGLTextureAttachment::type() const
@@ -259,9 +261,9 @@ namespace {
bool isColorRenderable(GC3Denum internalformat)
{
switch (internalformat) {
- case GraphicsContext3D::RGBA4:
- case GraphicsContext3D::RGB5_A1:
- case GraphicsContext3D::RGB565:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGB565:
return true;
default:
return false;
@@ -347,46 +349,46 @@ bool WebGLFramebuffer::isAttachmentComplete(WebGLAttachment* attachedObject, GC3
WebGLSharedObject* object = attachedObject->object();
ASSERT(object && (object->isTexture() || object->isRenderbuffer()));
- if (attachment == GraphicsContext3D::DEPTH_ATTACHMENT) {
+ if (attachment == GL_DEPTH_ATTACHMENT) {
if (object->isRenderbuffer()) {
- if (internalformat != GraphicsContext3D::DEPTH_COMPONENT16) {
+ if (internalformat != GL_DEPTH_COMPONENT16) {
*reason = "the internalformat of the attached renderbuffer is not DEPTH_COMPONENT16";
return false;
}
} else if (object->isTexture()) {
GC3Denum type = attachedObject->type();
- if (!(context()->m_webglDepthTexture && internalformat == GraphicsContext3D::DEPTH_COMPONENT
- && (type == GraphicsContext3D::UNSIGNED_SHORT || type == GraphicsContext3D::UNSIGNED_INT))) {
+ if (!(context()->m_webglDepthTexture && internalformat == GL_DEPTH_COMPONENT
+ && (type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_INT))) {
*reason = "the attached texture is not a depth texture";
return false;
}
}
- } else if (attachment == GraphicsContext3D::STENCIL_ATTACHMENT) {
+ } else if (attachment == GL_STENCIL_ATTACHMENT) {
// Depend on the underlying GL drivers to check stencil textures
// and check renderbuffer type here only.
if (object->isRenderbuffer()) {
- if (internalformat != GraphicsContext3D::STENCIL_INDEX8) {
+ if (internalformat != GL_STENCIL_INDEX8) {
*reason = "the internalformat of the attached renderbuffer is not STENCIL_INDEX8";
return false;
}
}
- } else if (attachment == GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT) {
+ } else if (attachment == GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL) {
if (object->isRenderbuffer()) {
- if (internalformat != GraphicsContext3D::DEPTH_STENCIL) {
+ if (internalformat != GL_DEPTH_STENCIL_OES) {
*reason = "the internalformat of the attached renderbuffer is not DEPTH_STENCIL";
return false;
}
} else if (object->isTexture()) {
GC3Denum type = attachedObject->type();
- if (!(context()->m_webglDepthTexture && internalformat == GraphicsContext3D::DEPTH_STENCIL
- && type == GraphicsContext3D::UNSIGNED_INT_24_8)) {
+ if (!(context()->m_webglDepthTexture && internalformat == GL_DEPTH_STENCIL_OES
+ && type == GL_UNSIGNED_INT_24_8_OES)) {
*reason = "the attached texture is not a DEPTH_STENCIL texture";
return false;
}
}
- } else if (attachment == GraphicsContext3D::COLOR_ATTACHMENT0
- || (context()->m_webglDrawBuffers && attachment > GraphicsContext3D::COLOR_ATTACHMENT0
- && attachment < static_cast<GC3Denum>(GraphicsContext3D::COLOR_ATTACHMENT0 + context()->maxColorAttachments()))) {
+ } else if (attachment == GL_COLOR_ATTACHMENT0
+ || (context()->m_webglDrawBuffers && attachment > GL_COLOR_ATTACHMENT0
+ && attachment < static_cast<GC3Denum>(GL_COLOR_ATTACHMENT0 + context()->maxColorAttachments()))) {
if (object->isRenderbuffer()) {
if (!isColorRenderable(internalformat)) {
*reason = "the internalformat of the attached renderbuffer is not color-renderable";
@@ -394,7 +396,7 @@ bool WebGLFramebuffer::isAttachmentComplete(WebGLAttachment* attachedObject, GC3
}
} else if (object->isTexture()) {
GC3Denum type = attachedObject->type();
- if (internalformat != GraphicsContext3D::RGBA && internalformat != GraphicsContext3D::RGB) {
+ if (internalformat != GL_RGBA && internalformat != GL_RGB) {
*reason = "the internalformat of the attached texture is not color-renderable";
return false;
}
@@ -402,12 +404,12 @@ bool WebGLFramebuffer::isAttachmentComplete(WebGLAttachment* attachedObject, GC3
// WebGL yet. It would be better to depend on the underlying GL drivers to check on rendering to floating point textures
// and add the check back to WebGL when above two extensions are implemented.
// Assume UNSIGNED_BYTE is renderable here without the need to explicitly check if GL_OES_rgb8_rgba8 extension is supported.
- if (type != GraphicsContext3D::UNSIGNED_BYTE
- && type != GraphicsContext3D::UNSIGNED_SHORT_5_6_5
- && type != GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4
- && type != GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1
- && !(type == GraphicsContext3D::FLOAT && context()->m_oesTextureFloat)
- && !(type == GraphicsContext3D::HALF_FLOAT_OES && context()->m_oesTextureHalfFloat)) {
+ if (type != GL_UNSIGNED_BYTE
+ && type != GL_UNSIGNED_SHORT_5_6_5
+ && type != GL_UNSIGNED_SHORT_4_4_4_4
+ && type != GL_UNSIGNED_SHORT_5_5_5_1
+ && !(type == GL_FLOAT && context()->m_oesTextureFloat)
+ && !(type == GL_HALF_FLOAT_OES && context()->m_oesTextureHalfFloat)) {
*reason = "unsupported type: The attached texture is not supported to be rendered to";
return false;
}
@@ -442,15 +444,15 @@ void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GC3Denum attachment)
m_attachments.remove(attachment);
drawBuffersIfNecessary(false);
switch (attachment) {
- case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
- attach(GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::DEPTH_ATTACHMENT);
- attach(GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::STENCIL_ATTACHMENT);
+ case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL:
+ attach(GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT);
+ attach(GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT);
break;
- case GraphicsContext3D::DEPTH_ATTACHMENT:
- attach(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT, GraphicsContext3D::DEPTH_ATTACHMENT);
+ case GL_DEPTH_ATTACHMENT:
+ attach(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_DEPTH_ATTACHMENT);
break;
- case GraphicsContext3D::STENCIL_ATTACHMENT:
- attach(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT, GraphicsContext3D::STENCIL_ATTACHMENT);
+ case GL_STENCIL_ATTACHMENT:
+ attach(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_STENCIL_ATTACHMENT);
break;
}
}
@@ -484,7 +486,7 @@ GC3Dsizei WebGLFramebuffer::colorBufferWidth() const
{
if (!object())
return 0;
- WebGLAttachment* attachment = getAttachment(GraphicsContext3D::COLOR_ATTACHMENT0);
+ WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0);
if (!attachment)
return 0;
@@ -495,7 +497,7 @@ GC3Dsizei WebGLFramebuffer::colorBufferHeight() const
{
if (!object())
return 0;
- WebGLAttachment* attachment = getAttachment(GraphicsContext3D::COLOR_ATTACHMENT0);
+ WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0);
if (!attachment)
return 0;
@@ -506,7 +508,7 @@ GC3Denum WebGLFramebuffer::colorBufferFormat() const
{
if (!object())
return 0;
- WebGLAttachment* attachment = getAttachment(GraphicsContext3D::COLOR_ATTACHMENT0);
+ WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0);
if (!attachment)
return 0;
return attachment->format();
@@ -522,23 +524,23 @@ GC3Denum WebGLFramebuffer::checkStatus(const char** reason) const
for (AttachmentMap::const_iterator it = m_attachments.begin(); it != m_attachments.end(); ++it) {
WebGLAttachment* attachment = it->value.get();
if (!isAttachmentComplete(attachment, it->key, reason))
- return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
if (!attachment->valid()) {
*reason = "attachment is not valid";
- return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED;
+ return GL_FRAMEBUFFER_UNSUPPORTED;
}
if (!attachment->format()) {
*reason = "attachment is an unsupported format";
- return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
switch (it->key) {
- case GraphicsContext3D::DEPTH_ATTACHMENT:
+ case GL_DEPTH_ATTACHMENT:
haveDepth = true;
break;
- case GraphicsContext3D::STENCIL_ATTACHMENT:
+ case GL_STENCIL_ATTACHMENT:
haveStencil = true;
break;
- case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
+ case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL:
haveDepthStencil = true;
break;
}
@@ -548,39 +550,39 @@ GC3Denum WebGLFramebuffer::checkStatus(const char** reason) const
} else {
if (width != attachment->width() || height != attachment->height()) {
*reason = "attachments do not have the same dimensions";
- return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
+ return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
}
}
++count;
}
if (!count) {
*reason = "no attachments";
- return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
}
if (!width || !height) {
*reason = "framebuffer has a 0 dimension";
- return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
// WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments.
if ((haveDepthStencil && (haveDepth || haveStencil)) || (haveDepth && haveStencil)) {
*reason = "conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments";
- return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED;
+ return GL_FRAMEBUFFER_UNSUPPORTED;
}
- return GraphicsContext3D::FRAMEBUFFER_COMPLETE;
+ return GL_FRAMEBUFFER_COMPLETE;
}
bool WebGLFramebuffer::onAccess(GraphicsContext3D* context3d, const char** reason)
{
- if (checkStatus(reason) != GraphicsContext3D::FRAMEBUFFER_COMPLETE)
+ if (checkStatus(reason) != GL_FRAMEBUFFER_COMPLETE)
return false;
return true;
}
bool WebGLFramebuffer::hasStencilBuffer() const
{
- WebGLAttachment* attachment = getAttachment(GraphicsContext3D::STENCIL_ATTACHMENT);
+ WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT);
if (!attachment)
- attachment = getAttachment(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT);
+ attachment = getAttachment(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL);
return attachment && attachment->valid();
}
@@ -602,7 +604,7 @@ void WebGLFramebuffer::drawBuffers(const Vector<GC3Denum>& bufs)
m_drawBuffers = bufs;
m_filteredDrawBuffers.resize(m_drawBuffers.size());
for (size_t i = 0; i < m_filteredDrawBuffers.size(); ++i)
- m_filteredDrawBuffers[i] = GraphicsContext3D::NONE;
+ m_filteredDrawBuffers[i] = GL_NONE;
drawBuffersIfNecessary(true);
}
@@ -613,14 +615,14 @@ void WebGLFramebuffer::drawBuffersIfNecessary(bool force)
bool reset = force;
// This filtering works around graphics driver bugs on Mac OS X.
for (size_t i = 0; i < m_drawBuffers.size(); ++i) {
- if (m_drawBuffers[i] != GraphicsContext3D::NONE && getAttachment(m_drawBuffers[i])) {
+ if (m_drawBuffers[i] != GL_NONE && getAttachment(m_drawBuffers[i])) {
if (m_filteredDrawBuffers[i] != m_drawBuffers[i]) {
m_filteredDrawBuffers[i] = m_drawBuffers[i];
reset = true;
}
} else {
- if (m_filteredDrawBuffers[i] != GraphicsContext3D::NONE) {
- m_filteredDrawBuffers[i] = GraphicsContext3D::NONE;
+ if (m_filteredDrawBuffers[i] != GL_NONE) {
+ m_filteredDrawBuffers[i] = GL_NONE;
reset = true;
}
}
@@ -638,8 +640,8 @@ GC3Denum WebGLFramebuffer::getDrawBuffer(GC3Denum drawBuffer)
if (index < static_cast<int>(m_drawBuffers.size()))
return m_drawBuffers[index];
if (drawBuffer == Extensions3D::DRAW_BUFFER0_EXT)
- return GraphicsContext3D::COLOR_ATTACHMENT0;
- return GraphicsContext3D::NONE;
+ return GL_COLOR_ATTACHMENT0;
+ return GL_NONE;
}
}
« no previous file with comments | « Source/core/html/canvas/WebGLDrawBuffers.cpp ('k') | Source/core/html/canvas/WebGLObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698