+2012-04-16 ChangSeok Oh <shivamidow@gmail.com>
+
+ Update GraphicsContext3DOpenGLES.cpp and fix some issues to build with GLES.
+ https://bugs.webkit.org/show_bug.cgi?id=83982
+
+ Reviewed by Martin Robinson.
+
+ GL_BGRA is not defined in GLESv2, so it causes build-break at readRenderingResults.
+ To resolve this, a helper function readPixelsAndConvertToBGRAIfNecessary is added
+ in GC3DOpenGL.cpp & GC3DOpenGLES.cpp and it's used in GC3DOpenGLCommon.cpp.
+ And some other issues to build with GLES are gone with this patch.
+
+ No new tests, since no new feature.
+
+ * platform/graphics/GraphicsContext3D.h:
+ * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
+ (WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary):
+ (WebCore):
+ * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+ (WebCore::GraphicsContext3D::readRenderingResults):
+ * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
+ (WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary):
+ (WebCore):
+ (WebCore::GraphicsContext3D::reshapeFBOs):
+ (WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary):
+
2012-04-16 Xiaomei Ji <xji@chromium.org>
[chromium] wrong justification for arabic/persian page in cr-win.
void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSize)
{
- int totalBytes = m_currentWidth * m_currentHeight * 4;
- if (pixelsSize < totalBytes)
+ if (pixelsSize < m_currentWidth * m_currentHeight * 4)
return;
makeContextCurrent();
mustRestorePackAlignment = true;
}
- ::glReadPixels(0, 0, m_currentWidth, m_currentHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
- if (isGLES2Compliant()) {
- for (int i = 0; i < totalBytes; i += 4)
- std::swap(pixels[i], pixels[i + 2]); // Convert to BGRA.
- }
+ readPixelsAndConvertToBGRAIfNecessary(0, 0, m_currentWidth, m_currentHeight, pixels);
if (mustRestorePackAlignment)
::glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);
#include "GraphicsContext3D.h"
+#include "Extensions3DOpenGL.h"
#include "IntRect.h"
#include "IntSize.h"
#include "NotImplemented.h"
namespace WebCore {
+void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels)
+{
+ const int totalBytes = m_currentWidth * m_currentHeight * 4;
+ ::glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+ for (int i = 0; i < totalBytes; i += 4)
+ std::swap(pixels[i], pixels[i + 2]); // Convert to BGRA.
+}
+
bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
{
const int width = size.width();
if (m_attrs.stencil || m_attrs.depth) {
// Use a 24 bit depth buffer where we know we have it.
if (supportPackedDepthStencilBuffer) {
- ::glBindTexture(GL_TEXTURE_2D, m_depthStencilBuffr);
+ ::glBindTexture(GL_TEXTURE_2D, m_depthStencilBuffer);
::glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, width, height, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, 0);
if (m_attrs.stencil)
::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0);
::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0);
::glBindTexture(GL_TEXTURE_2D, 0);
} else {
- if (m_attributes.stencil) {
+ if (m_attrs.stencil) {
::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_stencilBuffer);
::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX8, width, height);
::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_stencilBuffer);
}
- if (m_attributes.depth) {
+ if (m_attrs.depth) {
::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthBuffer);
::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, width, height);
::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBuffer);
return mustRestoreFBO;
}
-void GraphicsContext3D::resolveMultisamplingIfNecessary(IntRect& rect)
+void GraphicsContext3D::resolveMultisamplingIfNecessary(const IntRect& rect)
{
// FIXME: We don't support antialiasing yet.
notImplemented();
return true;
}
+} // namespace WebCore
+
#endif // ENABLE(WEBGL)