summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Antoine LaFayette <plafayet@codeaurora.org>2012-06-06 18:29:21 (GMT)
committerLinux Build Service Account <lnxbuild@localhost>2012-06-22 16:17:32 (GMT)
commit22e98195ac73e7e12a59d5b9a42dfc4e2252b475 (patch)
tree8e9ef1bade6cfdf362300ebdd259219a3fa16752
parent08297fd613f510346ee61b1f6abee06db7e205e4 (diff)
Fix for context-attributes-alpha-depth-stencil-antialias
Support for alpha, depth and stencil to fix WebGL Khronos 1.0.1 conformance test. Report back that antialiasing is not supported on our platform. CRs-fixed: 340907 Change-Id: Ie32d4b1384b07332ee39ff5e55ea874c73edc033
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.cpp67
1 files changed, 44 insertions, 23 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.cpp b/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.cpp
index c6b7c62..90f2987 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.cpp
@@ -57,7 +57,7 @@ namespace WebCore {
#define OLD_GRAPHICBUFFER_ALLOC
class FBO {
public:
- static FBO* createFBO(EGLDisplay dpy, int width, int height);
+ static FBO* createFBO(EGLDisplay dpy, int width, int height, GraphicsContext3D::Attributes attrs);
~FBO();
EGLSyncKHR sync() { return m_sync; }
@@ -82,13 +82,15 @@ public:
private:
FBO(EGLDisplay dpy);
- bool init(int width, int height);
+ bool init(int width, int height, GraphicsContext3D::Attributes attrs);
+
GLuint createTexture(EGLImageKHR image, int width, int height);
EGLDisplay m_dpy;
GLuint m_texture;
GLuint m_fbo;
GLuint m_depthBuffer;
+ GLuint m_stencilBuffer;
EGLImageKHR m_image;
EGLSyncKHR m_sync;
sp<IGraphicBufferAlloc> m_graphicBufferAlloc;
@@ -292,12 +294,8 @@ bool GraphicsContext3DInternal::initEGL()
config_attribs[p++] = EGL_STENCIL_SIZE;
config_attribs[p++] = 8;
}
- if (m_attrs.antialias) {
- config_attribs[p++] = EGL_SAMPLE_BUFFERS;
- config_attribs[p++] = 1;
- config_attribs[p++] = EGL_SAMPLES;
- config_attribs[p++] = 4;
- }
+ // Antialiasing currently is not supported.
+ m_attrs.antialias = false;
config_attribs[p] = EGL_NONE;
EGLint num_configs = 0;
@@ -327,7 +325,7 @@ bool GraphicsContext3DInternal::createContext(bool createEGLContext)
makeContextCurrent();
for (int i = 0; i < NUM_BUFFERS; i++) {
- FBO* tmp = FBO::createFBO(m_dpy, m_width > 0 ? m_width : 1, m_height > 0 ? m_height : 1);
+ FBO* tmp = FBO::createFBO(m_dpy, m_width > 0 ? m_width : 1, m_height > 0 ? m_height : 1, m_attrs);
if (tmp == 0) {
LOGWEBGL("Failed to create FBO");
deleteContext(createEGLContext);
@@ -407,12 +405,12 @@ void GraphicsContext3DInternal::synthesizeGLError(unsigned long error)
m_syntheticErrors.add(error);
}
-FBO* FBO::createFBO(EGLDisplay dpy, int width, int height)
+FBO* FBO::createFBO(EGLDisplay dpy, int width, int height, GraphicsContext3D::Attributes attributes)
{
LOGWEBGL("createFBO()");
FBO* fbo = new FBO(dpy);
- if (!fbo->init(width, height)) {
+ if (!fbo->init(width, height, attributes)) {
delete fbo;
return 0;
}
@@ -431,15 +429,17 @@ FBO::FBO(EGLDisplay dpy)
{
}
-bool FBO::init(int width, int height)
+bool FBO::init(int width, int height, GraphicsContext3D::Attributes attributes)
{
// 1. Allocate a graphic buffer
sp<ISurfaceComposer> composer(ComposerService::getComposerService());
m_graphicBufferAlloc = composer->createGraphicBufferAlloc();
status_t error;
- m_grBuffer = m_graphicBufferAlloc->createGraphicBuffer(width, height,
- HAL_PIXEL_FORMAT_RGBA_8888,
+
+ PixelFormat format = attributes.alpha ? HAL_PIXEL_FORMAT_RGBA_8888 : HAL_PIXEL_FORMAT_RGBX_8888;
+
+ m_grBuffer = m_graphicBufferAlloc->createGraphicBuffer(width, height, format,
GRALLOC_USAGE_HW_TEXTURE, &error);
if (error != NO_ERROR) {
LOGWEBGL(" failed to allocate GraphicBuffer, error = %d", error);
@@ -470,6 +470,7 @@ bool FBO::init(int width, int height)
EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
EGL_NONE, EGL_NONE
};
+
m_image = eglCreateImageKHR(m_dpy,
EGL_NO_CONTEXT,
EGL_NATIVE_BUFFER_ANDROID,
@@ -489,23 +490,40 @@ bool FBO::init(int width, int height)
// 4. Create the Framebuffer Object from the texture
glGenFramebuffers(1, &m_fbo);
- glGenRenderbuffers(1, &m_depthBuffer);
- glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);
- glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
- if (GraphicsContext3DInternal::checkGLError("glRenderbufferStorage") != GL_NO_ERROR) {
- return false;
+ if (attributes.depth) {
+ glGenRenderbuffers(1, &m_depthBuffer);
+ glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
+ if (GraphicsContext3DInternal::checkGLError("glRenderbufferStorage") != GL_NO_ERROR)
+ return false;
}
+
+ if (attributes.stencil) {
+ glGenRenderbuffers(1, &m_stencilBuffer);
+ glBindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height);
+ if (GraphicsContext3DInternal::checkGLError("glRenderbufferStorage") != GL_NO_ERROR)
+ return false;
+ }
+
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0);
- if (GraphicsContext3DInternal::checkGLError("glFramebufferTexture2D") != GL_NO_ERROR) {
+ if (GraphicsContext3DInternal::checkGLError("glFramebufferTexture2D") != GL_NO_ERROR)
return false;
+
+ if (attributes.depth) {
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer);
+ if (GraphicsContext3DInternal::checkGLError("glFramebufferRenderbuffer") != GL_NO_ERROR)
+ return false;
}
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer);
- if (GraphicsContext3DInternal::checkGLError("glFramebufferRenderbuffer") != GL_NO_ERROR) {
- return false;
+
+ if (attributes.stencil) {
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_stencilBuffer);
+ if (GraphicsContext3DInternal::checkGLError("glFramebufferRenderbuffer") != GL_NO_ERROR)
+ return false;
}
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
@@ -513,6 +531,7 @@ bool FBO::init(int width, int height)
LOGWEBGL("Framebuffer incomplete: %d", status);
return false;
}
+
glBindFramebuffer(GL_FRAMEBUFFER, 0);
return true;
@@ -533,6 +552,8 @@ FBO::~FBO()
glDeleteTextures(1, &m_texture);
if (m_depthBuffer)
glDeleteRenderbuffers(1, &m_depthBuffer);
+ if (m_stencilBuffer)
+ glDeleteRenderbuffers(1, &m_stencilBuffer);
if (m_fbo)
glDeleteFramebuffers(1, &m_fbo);
}