Diff
Modified: trunk/Source/WebCore/ChangeLog (228848 => 228849)
--- trunk/Source/WebCore/ChangeLog 2018-02-20 23:31:25 UTC (rev 228848)
+++ trunk/Source/WebCore/ChangeLog 2018-02-20 23:34:00 UTC (rev 228849)
@@ -1,3 +1,29 @@
+2018-02-20 Tim Horton <[email protected]>
+
+ Make more use of USE(OPENGL_ES) where it makes sense
+ https://bugs.webkit.org/show_bug.cgi?id=182957
+ <rdar://problem/37699443>
+
+ Reviewed by Dan Bernstein.
+
+ No new tests, no behavior change.
+
+ Make use of USE(OPENGL_ES) for CoreVideo functions that differ based
+ on GL availability. Also adjust GraphicsContext3D in the same way.
+
+ * platform/cocoa/CoreVideoSoftLink.cpp:
+ * platform/cocoa/CoreVideoSoftLink.h:
+ * platform/graphics/GraphicsContext3D.h:
+ * platform/graphics/cv/TextureCacheCV.mm:
+ (WebCore::TextureCacheCV::create):
+ (WebCore::TextureCacheCV::textureFromImage):
+ * platform/graphics/cv/VideoTextureCopierCV.cpp:
+ (WebCore::enumToStringMap):
+ (WebCore::VideoTextureCopierCV::initializeContextObjects):
+ (WebCore::VideoTextureCopierCV::initializeUVContextObjects):
+ (WebCore::VideoTextureCopierCV::copyImageToPlatformTexture):
+ (WebCore::VideoTextureCopierCV::copyVideoTextureToPlatformTexture):
+
2018-02-20 Nan Wang <[email protected]>
AX: AOM: Dispatch accessibleclick event
Modified: trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp (228848 => 228849)
--- trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp 2018-02-20 23:31:25 UTC (rev 228848)
+++ trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp 2018-02-20 23:34:00 UTC (rev 228849)
@@ -64,7 +64,7 @@
SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferYCbCrMatrix_P3_D65, CFStringRef)
SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferYCbCrMatrix_ITU_R_2020, CFStringRef)
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLESTextureCacheCreate, CVReturn, (CFAllocatorRef allocator, CFDictionaryRef cacheAttributes, CVEAGLContext eaglContext, CFDictionaryRef textureAttributes, CVOpenGLESTextureCacheRef* cacheOut), (allocator, cacheAttributes, eaglContext, textureAttributes, cacheOut))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLESTextureCacheCreateTextureFromImage, CVReturn, (CFAllocatorRef allocator, CVOpenGLESTextureCacheRef textureCache, CVImageBufferRef sourceImage, CFDictionaryRef textureAttributes, GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, size_t planeIndex, CVOpenGLESTextureRef* textureOut), (allocator, textureCache, sourceImage, textureAttributes, target, internalFormat, width, height, format, type, planeIndex, textureOut))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLESTextureCacheFlush, void, (CVOpenGLESTextureCacheRef textureCache, CVOptionFlags options), (textureCache, options))
Modified: trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h (228848 => 228849)
--- trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h 2018-02-20 23:31:25 UTC (rev 228848)
+++ trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h 2018-02-20 23:34:00 UTC (rev 228849)
@@ -91,7 +91,7 @@
SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(WebCore, CoreVideo, kCVImageBufferYCbCrMatrix_ITU_R_2020, CFStringRef)
#define kCVImageBufferYCbCrMatrix_ITU_R_2020 get_CoreVideo_kCVImageBufferYCbCrMatrix_ITU_R_2020()
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVOpenGLESTextureCacheCreate, CVReturn, (CFAllocatorRef allocator, CFDictionaryRef cacheAttributes, CVEAGLContext eaglContext, CFDictionaryRef textureAttributes, CVOpenGLESTextureCacheRef* cacheOut), (allocator, cacheAttributes, eaglContext, textureAttributes, cacheOut))
#define CVOpenGLESTextureCacheCreate softLink_CoreVideo_CVOpenGLESTextureCacheCreate
SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVOpenGLESTextureCacheCreateTextureFromImage, CVReturn, (CFAllocatorRef allocator, CVOpenGLESTextureCacheRef textureCache, CVImageBufferRef sourceImage, CFDictionaryRef textureAttributes, GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, size_t planeIndex, CVOpenGLESTextureRef* textureOut), (allocator, textureCache, sourceImage, textureAttributes, target, internalFormat, width, height, format, type, planeIndex, textureOut))
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (228848 => 228849)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2018-02-20 23:31:25 UTC (rev 228848)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2018-02-20 23:34:00 UTC (rev 228849)
@@ -36,6 +36,7 @@
#include <wtf/HashMap.h>
#include <wtf/ListHashSet.h>
#include <wtf/RefCounted.h>
+#include <wtf/RetainPtr.h>
#include <wtf/text/WTFString.h>
#if USE(CA)
@@ -51,34 +52,32 @@
#endif
#if PLATFORM(COCOA)
-#if PLATFORM(IOS)
+
+#if USE(OPENGL_ES)
#include <OpenGLES/ES2/gl.h>
#ifdef __OBJC__
#import <OpenGLES/EAGL.h>
-#endif // __OBJC__
-#endif // PLATFORM(IOS)
-#include <wtf/RetainPtr.h>
-OBJC_CLASS CALayer;
-OBJC_CLASS WebGLLayer;
-typedef struct __IOSurface* IOSurfaceRef;
-#else
-typedef unsigned int GLuint;
-#endif
-
-#if PLATFORM(IOS)
-#ifdef __OBJC__
typedef EAGLContext* PlatformGraphicsContext3D;
#else
typedef void* PlatformGraphicsContext3D;
#endif // __OBJC__
-#elif PLATFORM(MAC)
+#endif // USE(OPENGL_ES)
+
+#if !USE(OPENGL_ES)
typedef struct _CGLContextObject *CGLContextObj;
+typedef CGLContextObj PlatformGraphicsContext3D;
+#endif
-typedef CGLContextObj PlatformGraphicsContext3D;
-#else
+OBJC_CLASS CALayer;
+OBJC_CLASS WebGLLayer;
+typedef struct __IOSurface* IOSurfaceRef;
+#endif // PLATFORM(COCOA)
+
+#if !PLATFORM(COCOA)
+typedef unsigned GLuint;
typedef void* PlatformGraphicsContext3D;
typedef void* PlatformGraphicsSurface3D;
-#endif
+#endif // !PLATFORM(COCOA)
// These are currently the same among all implementations.
const PlatformGraphicsContext3D NullPlatformGraphicsContext3D = 0;
Modified: trunk/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm (228848 => 228849)
--- trunk/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm 2018-02-20 23:31:25 UTC (rev 228848)
+++ trunk/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm 2018-02-20 23:34:00 UTC (rev 228849)
@@ -35,7 +35,7 @@
std::unique_ptr<TextureCacheCV> TextureCacheCV::create(GraphicsContext3D& context)
{
TextureCacheType cache = nullptr;
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
CVReturn error = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, nullptr, context.platformGraphicsContext3D(), nullptr, &cache);
#else
CVReturn error = CVOpenGLTextureCacheCreate(kCFAllocatorDefault, nullptr, context.platformGraphicsContext3D(), CGLGetPixelFormat(context.platformGraphicsContext3D()), nullptr, &cache);
@@ -56,7 +56,7 @@
RetainPtr<TextureCacheCV::TextureType> TextureCacheCV::textureFromImage(CVPixelBufferRef image, GC3Denum outputTarget, GC3Dint level, GC3Denum internalFormat, GC3Denum format, GC3Denum type)
{
TextureType bareVideoTexture = nullptr;
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
size_t width = CVPixelBufferGetWidth(image);
size_t height = CVPixelBufferGetHeight(image);
if (kCVReturnSuccess != CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_cache.get(), image, nullptr, outputTarget, internalFormat, width, height, format, type, level, &bareVideoTexture))
@@ -78,7 +78,7 @@
return;
if (auto cache = weakThis->m_cache.get())
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
CVOpenGLESTextureCacheFlush(cache, 0);
#else
CVOpenGLTextureCacheFlush(cache, 0);
Modified: trunk/Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp (228848 => 228849)
--- trunk/Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp 2018-02-20 23:31:25 UTC (rev 228848)
+++ trunk/Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp 2018-02-20 23:34:00 UTC (rev 228849)
@@ -33,7 +33,7 @@
#include <wtf/NeverDestroyed.h>
#include <wtf/text/StringBuilder.h>
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
#include <OpenGLES/ES3/glext.h>
#endif
@@ -455,7 +455,7 @@
map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_INT_24_8));
map.get().emplace(STRINGIFY_PAIR(GL_FLOAT_32_UNSIGNED_INT_24_8_REV));
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
map.get().emplace(STRINGIFY_PAIR(GL_RED_INTEGER));
map.get().emplace(STRINGIFY_PAIR(GL_RGB_INTEGER));
map.get().emplace(STRINGIFY_PAIR(GL_RG8_SNORM));
@@ -522,7 +522,7 @@
StringBuilder fragmentShaderSource;
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
fragmentShaderSource.appendLiteral("precision mediump float;\n");
fragmentShaderSource.appendLiteral("uniform sampler2D u_texture;\n");
#else
@@ -534,7 +534,7 @@
fragmentShaderSource.appendLiteral("uniform int u_swapColorChannels;\n");
fragmentShaderSource.appendLiteral("void main() {\n");
fragmentShaderSource.appendLiteral(" vec2 texPos = vec2(v_texturePosition.x * u_textureDimensions.x, v_texturePosition.y * u_textureDimensions.y);\n");
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
fragmentShaderSource.appendLiteral(" vec4 color = texture2D(u_texture, texPos);\n");
#else
fragmentShaderSource.appendLiteral(" vec4 color = texture2DRect(u_texture, texPos);\n");
@@ -615,7 +615,7 @@
" if (u_flipY == 1) {\n"
" normalizedPosition.y = 1.0 - normalizedPosition.y;\n"
" }\n"
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
" v_yTextureCoordinate = normalizedPosition;\n"
" v_uvTextureCoordinate = normalizedPosition;\n"
#else
@@ -638,7 +638,7 @@
}
String fragmentShaderSource = ASCIILiteral(
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
"precision mediump float;\n"
"#define SAMPLERTYPE sampler2D\n"
"#define TEXTUREFUNC texture2D\n"
@@ -721,7 +721,7 @@
if (auto texture = m_textureCache->textureFromImage(image, outputTarget, level, internalFormat, format, type)) {
bool swapColorChannels = false;
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
// FIXME: Remove this workaround once rdar://problem/35834388 is fixed.
swapColorChannels = CVPixelBufferGetPixelFormatType(image) == kCVPixelFormatType_32BGRA;
#endif
@@ -783,7 +783,7 @@
auto uvPlaneWidth = IOSurfaceGetWidthOfPlane(surface, 1);
auto uvPlaneHeight = IOSurfaceGetHeightOfPlane(surface, 1);
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
GC3Denum videoTextureTarget = GraphicsContext3D::TEXTURE_2D;
#else
GC3Denum videoTextureTarget = GL_TEXTURE_RECTANGLE_ARB;
@@ -828,7 +828,7 @@
// Do the actual drawing.
m_context->drawArrays(GraphicsContext3D::TRIANGLES, 0, 6);
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
// flush() must be called here in order to re-synchronize the output texture's contents across the
// two EAGL contexts.
m_context->flush();
@@ -858,7 +858,7 @@
GLfloat lowerRight[2] = { 0, 0 };
GLfloat upperRight[2] = { 0, 0 };
GLfloat upperLeft[2] = { 0, 0 };
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
Platform3DObject videoTextureName = CVOpenGLESTextureGetName(inputVideoTexture);
GC3Denum videoTextureTarget = CVOpenGLESTextureGetTarget(inputVideoTexture);
CVOpenGLESTextureGetCleanTexCoords(inputVideoTexture, lowerLeft, lowerRight, upperRight, upperLeft);
@@ -915,7 +915,7 @@
// Configure the drawing parameters.
m_context->uniform1i(m_textureUniformLocation, 0);
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
m_context->uniform2f(m_textureDimensionsUniformLocation, 1, 1);
#else
m_context->uniform2f(m_textureDimensionsUniformLocation, width, height);
@@ -931,7 +931,7 @@
m_context->vertexAttribPointer(m_positionAttributeLocation, 2, GraphicsContext3D::FLOAT, false, 0, 0);
m_context->drawArrays(GraphicsContext3D::TRIANGLES, 0, 6);
-#if PLATFORM(IOS)
+#if USE(OPENGL_ES)
// flush() must be called here in order to re-synchronize the output texture's contents across the
// two EAGL contexts.
m_context->flush();