Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp (191578 => 191579)
--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp 2015-10-26 09:26:41 UTC (rev 191578)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp 2015-10-26 09:30:10 UTC (rev 191579)
@@ -69,19 +69,23 @@
, m_depthBufferObject(0)
, m_shouldClear(true)
, m_context3D(context3D)
-{
-}
-
-bool BitmapTextureGL::canReuseWith(const IntSize& contentsSize, Flags)
-{
- return contentsSize == m_textureSize;
-}
-
#if OS(DARWIN)
-#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+ , m_type(GL_UNSIGNED_INT_8_8_8_8_REV)
#else
-#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GraphicsContext3D::UNSIGNED_BYTE
+ , m_type(GraphicsContext3D::UNSIGNED_BYTE)
#endif
+{
+ // If GL_EXT_texture_format_BGRA8888 is supported in the OpenGLES
+ // internal and external formats need to be BGRA
+ m_internalFormat = GraphicsContext3D::RGBA;
+ m_format = GraphicsContext3D::BGRA;
+ if (m_context3D->isGLES2Compliant()) {
+ if (m_context3D->getExtensions()->supports("GL_EXT_texture_format_BGRA8888"))
+ m_internalFormat = GraphicsContext3D::BGRA;
+ else
+ m_format = GraphicsContext3D::RGBA;
+ }
+}
static void swizzleBGRAToRGBA(uint32_t* data, const IntRect& rect, int stride = 0)
{
@@ -93,18 +97,6 @@
}
}
-// If GL_EXT_texture_format_BGRA8888 is supported in the OpenGLES
-// internal and external formats need to be BGRA
-static bool driverSupportsExternalTextureBGRA(GraphicsContext3D* context)
-{
- if (context->isGLES2Compliant()) {
- static bool supportsExternalTextureBGRA = context->getExtensions()->supports("GL_EXT_texture_format_BGRA8888");
- return supportsExternalTextureBGRA;
- }
-
- return true;
-}
-
static bool driverSupportsSubImage(GraphicsContext3D* context)
{
if (context->isGLES2Compliant()) {
@@ -124,7 +116,6 @@
if (m_textureSize == contentSize())
return;
-
m_textureSize = contentSize();
m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
@@ -132,16 +123,7 @@
m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
- Platform3DObject internalFormat = GraphicsContext3D::RGBA;
- Platform3DObject externalFormat = GraphicsContext3D::BGRA;
- if (m_context3D->isGLES2Compliant()) {
- if (driverSupportsExternalTextureBGRA(m_context3D.get()))
- internalFormat = GraphicsContext3D::BGRA;
- else
- externalFormat = GraphicsContext3D::RGBA;
- }
-
- m_context3D->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, internalFormat, m_textureSize.width(), m_textureSize.height(), 0, externalFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0);
+ m_context3D->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, m_internalFormat, m_textureSize.width(), m_textureSize.height(), 0, m_format, m_type, 0);
}
void BitmapTextureGL::updateContentsNoSwizzle(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, unsigned bytesPerPixel, Platform3DObject glFormat)
@@ -155,7 +137,7 @@
m_context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x());
}
- m_context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, srcData);
+ m_context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, m_type, srcData);
// For ES drivers that don't support sub-images.
if (driverSupportsSubImage(m_context3D.get())) {
@@ -167,7 +149,6 @@
void BitmapTextureGL::updateContents(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag updateContentsFlag)
{
- Platform3DObject glFormat = GraphicsContext3D::RGBA;
m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
const unsigned bytesPerPixel = 4;
@@ -180,7 +161,7 @@
&& !(bytesPerLine == static_cast<int>(targetRect.width() * bytesPerPixel) && adjustedSourceOffset == IntPoint::zero());
// prepare temporaryData if necessary
- if ((!driverSupportsExternalTextureBGRA(m_context3D.get()) && updateContentsFlag == UpdateCannotModifyOriginalImageData) || requireSubImageBuffer) {
+ if ((m_format == GraphicsContext3D::RGBA && updateContentsFlag == UpdateCannotModifyOriginalImageData) || requireSubImageBuffer) {
temporaryData.resize(targetRect.width() * targetRect.height() * bytesPerPixel);
data = ""
const char* bits = static_cast<const char*>(srcData);
@@ -197,12 +178,10 @@
adjustedSourceOffset = IntPoint(0, 0);
}
- if (driverSupportsExternalTextureBGRA(m_context3D.get()))
- glFormat = GraphicsContext3D::BGRA;
- else
+ if (m_format == GraphicsContext3D::RGBA)
swizzleBGRAToRGBA(reinterpret_cast_ptr<uint32_t*>(data), IntRect(adjustedSourceOffset, targetRect.size()), bytesPerLine / bytesPerPixel);
- updateContentsNoSwizzle(data, targetRect, adjustedSourceOffset, bytesPerLine, bytesPerPixel, glFormat);
+ updateContentsNoSwizzle(data, targetRect, adjustedSourceOffset, bytesPerLine, bytesPerPixel, m_format);
}
void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag)