#include "config.h"
#include "TextureMapperGL.h"
+#include "GLPlatformContext.h"
#include "GraphicsContext.h"
#include "Image.h"
#include "NotImplemented.h"
#define GL_BGRA 0x80E1
#endif
+#if !defined(GL_UNPACK_ROW_LENGTH)
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#endif
+
+#if !defined(GL_UNPACK_SKIP_PIXELS)
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#endif
+
+#if !defined(GL_UNPACK_SKIP_ROWS)
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#endif
+
namespace WebCore {
#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
static int gAngle = 0;
GL_CMD(glLineWidth(width));
#if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
- drawQuad(targetRect, modelViewMatrix, program.get(), GL_LINE_LOOP, color.hasAlpha(), true);
+ drawQuad(targetRect, modelViewMatrix, program.get(), GL_LINE_LOOP, color.hasAlpha(), true);
#else
drawQuad(targetRect, modelViewMatrix, program.get(), GL_LINE_LOOP, color.hasAlpha());
#endif
const BitmapTextureGL& textureGL = static_cast<const BitmapTextureGL&>(texture);
#if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
- drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : SupportsBlending, textureGL.size(), targetRect, matrix, opacity, textureGL.size(), true, exposedEdges);
+ drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : SupportsBlending, textureGL.size(), targetRect, matrix, opacity, textureGL.size(), true, exposedEdges);
#else
drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : SupportsBlending, textureGL.size(), targetRect, matrix, opacity, exposedEdges);
#endif
bool needsBlending = (flags & SupportsBlending) || opacity < 0.99 || maskTexture;
drawQuad(targetRect, modelViewMatrix, program.get(), GL_TRIANGLE_FAN, needsBlending);
}
-#endif // defined(GL_ARB_texture_rectangle)
+#endif // defined(GL_ARB_texture_rectangle)
#if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
void TextureMapperGL::drawTexture(uint32_t texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const IntSize& platformSurfaceSize, bool premultipliedAlpha, unsigned exposedEdges)
bool needsBlending = (flags & SupportsBlending) || opacity < 0.99;
#if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
- drawQuad(quadToDraw, modelViewMatrix, program, GL_TRIANGLE_FAN, needsBlending, premultipliedAlpha);
+ drawQuad(quadToDraw, modelViewMatrix, program, GL_TRIANGLE_FAN, needsBlending, premultipliedAlpha);
#else
drawQuad(quadToDraw, modelViewMatrix, program, GL_TRIANGLE_FAN, needsBlending);
#endif
}
}
+// If GL_EXT_texture_format_BGRA8888 is supported in the OpenGLES
+// internal and external formats need to be BGRA
static bool driverSupportsBGRASwizzling()
{
#if defined(TEXMAP_OPENGL_ES_2)
- // FIXME: Implement reliable detection. See also https://bugs.webkit.org/show_bug.cgi?id=81103.
- return false;
+ static bool supportsBGRASwizzling = GLPlatformContext::supportsGLExtension("GL_EXT_texture_format_BGRA8888");
+ return supportsBGRASwizzling;
#else
return true;
#endif
static bool driverSupportsSubImage()
{
#if defined(TEXMAP_OPENGL_ES_2)
- // FIXME: Implement reliable detection.
- return false;
+ static bool supportsSubImage = GLPlatformContext::supportsGLExtension("GL_EXT_unpack_subimage");
+ return supportsSubImage;
#else
return true;
#endif
GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
- GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_textureSize.width(), m_textureSize.height(), 0, format, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0));
+ GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, format, m_textureSize.width(), m_textureSize.height(), 0, format, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0));
#if !ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
// some graphics driver did not support odd texture size.
if (m_textureSize.width() % 2)
GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, temporaryData.data()));
#endif
return;
+ } else {
+ // Use the OpenGL sub-image extension, now that we know it's available.
+ GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel));
+ GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y()));
+ GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x()));
+ GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data));
+ GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
+ GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, 0));
+ GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0));
}
-
-#if !defined(TEXMAP_OPENGL_ES_2)
- // Use the OpenGL sub-image extension, now that we know it's available.
- GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel));
- GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y()));
- GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x()));
- GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data));
- GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
- GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, 0));
- GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0));
-#endif
}
void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset)