#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;
}
}
-static bool driverSupportsBGRASwizzling()
+static HashSet<String> parseExtensions(const String& extensionsString)
{
-#if defined(TEXMAP_OPENGL_ES_2)
- // FIXME: Implement reliable detection. See also https://bugs.webkit.org/show_bug.cgi?id=81103.
- return false;
-#else
+ Vector<String> extNames;
+ extensionsString.split(" ", extNames);
+ HashSet<String> splitExtNames;
+ unsigned size = extNames.size();
+ for (unsigned i = 0; i < size; ++i)
+ splitExtNames.add(extNames[i]);
+ extNames.clear();
+
+ return splitExtNames;
+}
+
+static bool supportsGLExtension(const String& name)
+{
+ static HashSet<String> supportedExtensions;
+
+ if (!supportedExtensions.size()) {
+ String rawExtensions = reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS));
+ supportedExtensions = parseExtensions(rawExtensions);
+ }
+
+ if (supportedExtensions.contains(name))
return true;
-#endif
+
+ return false;
+}
+
+// If GL_EXT_texture_format_BGRA8888 is supported in the OpenGLES
+// internal and external formats need to be BGRA
+static bool driverSupportsBGRASwizzling()
+{
+ static bool supportsBGRASwizzling = supportsGLExtension("GL_EXT_texture_format_BGRA8888");
+ return supportsBGRASwizzling;
}
static bool driverSupportsSubImage()
{
-#if defined(TEXMAP_OPENGL_ES_2)
- // FIXME: Implement reliable detection.
- return false;
-#else
- return true;
-#endif
+ static bool supportsSubImage = supportsGLExtension("GL_EXT_unpack_subimage");
+ return supportsSubImage;
}
void BitmapTextureGL::didReset()
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)