WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-129626-20150925153422.patch (text/plain), 28.64 KB, created by
Jer Noble
on 2015-09-25 15:34:42 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Jer Noble
Created:
2015-09-25 15:34:42 PDT
Size:
28.64 KB
patch
obsolete
>Subversion Revision: 190250 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index efeb5955700a966199d887600d6484e3f6ae0385..3c4d1d315fc23295bd530a546d1d3a4e6add0899 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,38 @@ >+2015-05-11 Jer Noble <jer.noble@apple.com> >+ >+ WebGL slow video to texture >+ https://bugs.webkit.org/show_bug.cgi?id=129626 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Support a direct GPU-to-GPU copy of video textures. Add a new AVPlayerItemVideoOutput which, >+ when lazily-created, will emit CVPixelBuffers which are guaranteed to be compatable with >+ OpenGL framebuffers. Then, use a CVOpenGLTextureCache object to convert those CVPixelBuffers >+ to OpenGL textures. Once the video frame is in an OpenGL texture, use an OpenGL framebuffer >+ to copy the underlying video texture memory to the destination texture. >+ >+ The copy step uses glTexImage2D, which requires format and type parameters, so change the >+ signature of copyVideoTextureToPlatformTexture() to pass those parameters in. >+ >+ * html/HTMLVideoElement.cpp: >+ (WebCore::HTMLVideoElement::copyVideoTextureToPlatformTexture): Changed signature. >+ * html/HTMLVideoElement.h: >+ * html/canvas/WebGLRenderingContextBase.cpp: >+ (WebCore::WebGLRenderingContextBase::texImage2D): Changed signature. >+ * platform/graphics/MediaPlayer.cpp: >+ (WebCore::MediaPlayer::copyVideoTextureToPlatformTexture): Changed signature. >+ * platform/graphics/MediaPlayer.h: >+ * platform/graphics/MediaPlayerPrivate.h: >+ (WebCore::MediaPlayerPrivateInterface::copyVideoTextureToPlatformTexture): Changed signature. >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createOpenGLVideoOutput): Create an OpenGL-compatible >+ AVPlayerItemVideoOutput. >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::destroyOpenGLVideoOutput): Destroy same. >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastOpenGLImage): Cache the current frame, if available. >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::copyVideoTextureToPlatformTexture): Convert the >+ current frame to a texture, and use that texture to render into the destination texture. >+ > 2015-09-25 Brady Eidson <beidson@apple.com> > > PassRefPtr<> to RefPtr<> conversion in legacy IndexedDB code. >diff --git a/Source/WebCore/html/HTMLVideoElement.cpp b/Source/WebCore/html/HTMLVideoElement.cpp >index bd30675cb1acea8a15e779d763bbdea669793af4..b636b8d0b5a89769a70e6897f8cec6dedd63dad0 100644 >--- a/Source/WebCore/html/HTMLVideoElement.cpp >+++ b/Source/WebCore/html/HTMLVideoElement.cpp >@@ -244,11 +244,11 @@ void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext& context, cons > player->paintCurrentFrameInContext(context, destRect); > } > >-bool HTMLVideoElement::copyVideoTextureToPlatformTexture(GraphicsContext3D* context, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY) >+bool HTMLVideoElement::copyVideoTextureToPlatformTexture(GraphicsContext3D* context, Platform3DObject texture, GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Denum format, GC3Denum type, bool premultiplyAlpha, bool flipY) > { > if (!player()) > return false; >- return player()->copyVideoTextureToPlatformTexture(context, texture, level, type, internalFormat, premultiplyAlpha, flipY); >+ return player()->copyVideoTextureToPlatformTexture(context, texture, target, level, internalFormat, format, type, premultiplyAlpha, flipY); > } > > bool HTMLVideoElement::hasAvailableVideoFrame() const >diff --git a/Source/WebCore/html/HTMLVideoElement.h b/Source/WebCore/html/HTMLVideoElement.h >index 334a6a0f6447217b542126857aa48faab76b6ede..b240ffd2a6561d48d4fa5363f6ec56fecfdebea6 100644 >--- a/Source/WebCore/html/HTMLVideoElement.h >+++ b/Source/WebCore/html/HTMLVideoElement.h >@@ -71,7 +71,7 @@ public: > > // Used by WebGL to do GPU-GPU textures copy if possible. > // See more details at MediaPlayer::copyVideoTextureToPlatformTexture() defined in Source/WebCore/platform/graphics/MediaPlayer.h. >- bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY); >+ bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject texture, GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Denum format, GC3Denum type, bool premultiplyAlpha, bool flipY); > > bool shouldDisplayPosterImage() const { return displayMode() == Poster || displayMode() == PosterWaitingForVideo; } > >diff --git a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >index 614da433078da9b16575be1b27ac2f71a72a58ef..458af9c00c91584a7d473d45db0e7e49c872a10e 100644 >--- a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >+++ b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >@@ -3268,7 +3268,7 @@ void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3De > && type == GraphicsContext3D::UNSIGNED_BYTE > && (texture->getType(target, level) == GraphicsContext3D::UNSIGNED_BYTE || !texture->isValid(target, level)) > && !level) { >- if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->object(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) { >+ if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->object(), target, level, internalformat, format, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { > texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), type); > return; > } >diff --git a/Source/WebCore/page/ChromeClient.h b/Source/WebCore/page/ChromeClient.h >index 137c1862bec941c4fabb5216bc04db92b36a555d..13197c7a390c68b2dae32b1a9d62b04cd4832e24 100644 >--- a/Source/WebCore/page/ChromeClient.h >+++ b/Source/WebCore/page/ChromeClient.h >@@ -80,6 +80,7 @@ class GraphicsContext3D; > class GraphicsLayer; > class GraphicsLayerFactory; > class HTMLInputElement; >+class HTMLMediaElement; > class HTMLVideoElement; > class HitTestResult; > class IntRect; >diff --git a/Source/WebCore/platform/graphics/MediaPlayer.cpp b/Source/WebCore/platform/graphics/MediaPlayer.cpp >index 93957d3bbc0c3962376c548fc5d53c556488a002..8ab8b9639e1235cff53a0849716ec6f3e247fc67 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayer.cpp >+++ b/Source/WebCore/platform/graphics/MediaPlayer.cpp >@@ -814,9 +814,9 @@ void MediaPlayer::paintCurrentFrameInContext(GraphicsContext& p, const FloatRect > m_private->paintCurrentFrameInContext(p, r); > } > >-bool MediaPlayer::copyVideoTextureToPlatformTexture(GraphicsContext3D* context, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY) >+bool MediaPlayer::copyVideoTextureToPlatformTexture(GraphicsContext3D* context, Platform3DObject texture, GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Denum format, GC3Denum type, bool premultiplyAlpha, bool flipY) > { >- return m_private->copyVideoTextureToPlatformTexture(context, texture, level, type, internalFormat, premultiplyAlpha, flipY); >+ return m_private->copyVideoTextureToPlatformTexture(context, texture, target, level, internalFormat, format, type, premultiplyAlpha, flipY); > } > > PassNativeImagePtr MediaPlayer::nativeImageForCurrentTime() >diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h >index ea0d7248a12bf55206a95a6b069386a1b29b6aa2..ff53e421380ed01a2fc851a9aa39f600039b4b52 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayer.h >+++ b/Source/WebCore/platform/graphics/MediaPlayer.h >@@ -421,7 +421,7 @@ public: > // In chromium, the implementation is based on GL_CHROMIUM_copy_texture extension which is documented at > // http://src.chromium.org/viewvc/chrome/trunk/src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_copy_texture.txt and implemented at > // http://src.chromium.org/viewvc/chrome/trunk/src/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc via shaders. >- bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY); >+ bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject texture, GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Denum format, GC3Denum type, bool premultiplyAlpha, bool flipY); > > PassNativeImagePtr nativeImageForCurrentTime(); > >diff --git a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h >index 960a2c3cedaad04c3305244017882ba88b4b240e..52c60025886f26fc8d95b46b3f709b1bde01606b 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h >+++ b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h >@@ -147,7 +147,7 @@ public: > virtual void paint(GraphicsContext&, const FloatRect&) = 0; > > virtual void paintCurrentFrameInContext(GraphicsContext& c, const FloatRect& r) { paint(c, r); } >- virtual bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject, GC3Dint, GC3Denum, GC3Denum, bool, bool) { return false; } >+ virtual bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject, GC3Denum, GC3Dint, GC3Denum, GC3Denum, GC3Denum, bool, bool) { return false; } > virtual PassNativeImagePtr nativeImageForCurrentTime() { return nullptr; } > > virtual void setPreload(MediaPlayer::Preload) { } >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >index f8badddf428c8c640a584967743edb3dd3d85d33..978fe5a2b7280da984e4829c1d4879cdc21b771d 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >@@ -57,6 +57,11 @@ OBJC_CLASS AVAssetResourceLoadingRequest; > typedef struct CGImage *CGImageRef; > typedef struct __CVBuffer *CVPixelBufferRef; > typedef struct OpaqueVTPixelTransferSession* VTPixelTransferSessionRef; >+#if PLATFORM(IOS) >+typedef struct __CVOpenGLESTextureCache *CVOpenGLESTextureCacheRef; >+#else >+typedef struct __CVOpenGLTextureCache* CVOpenGLTextureCacheRef; >+#endif > > namespace WebCore { > >@@ -235,6 +240,12 @@ private: > void paintWithVideoOutput(GraphicsContext&, const FloatRect&); > virtual PassNativeImagePtr nativeImageForCurrentTime() override; > void waitForVideoOutputMediaDataWillChange(); >+ >+ void createOpenGLVideoOutput(); >+ void destroyOpenGLVideoOutput(); >+ void updateLastOpenGLImage(); >+ >+ bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject, GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Denum format, GC3Denum type, bool premultiplyAlpha, bool flipY) override; > #endif > > #if ENABLE(ENCRYPTED_MEDIA) >@@ -327,6 +338,14 @@ private: > RetainPtr<WebCoreAVFPullDelegate> m_videoOutputDelegate; > RetainPtr<CGImageRef> m_lastImage; > dispatch_semaphore_t m_videoOutputSemaphore; >+ >+ RetainPtr<AVPlayerItemVideoOutput> m_openGLVideoOutput; >+#if PLATFORM(IOS) >+ RetainPtr<CVOpenGLESTextureCacheRef> m_openGLTextureCache; >+#else >+ RetainPtr<CVOpenGLTextureCacheRef> m_openGLTextureCache; >+#endif >+ RetainPtr<CVPixelBufferRef> m_lastOpenGLImage; > #endif > > #if USE(VIDEOTOOLBOX) >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >index 503c4fb02b9c4eadc00f3754f535043fe469e7fa..68d5af7608ef4a3b0a47b2ff94b7aa860550d769 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >@@ -37,9 +37,11 @@ > #import "CDMSessionAVFoundationObjC.h" > #import "Cookie.h" > #import "ExceptionCodePlaceholder.h" >+#import "Extensions3D.h" > #import "FloatConversion.h" > #import "FloatConversion.h" > #import "GraphicsContext.h" >+#import "GraphicsContext3D.h" > #import "GraphicsContextCG.h" > #import "InbandMetadataTextTrackPrivateAVF.h" > #import "InbandTextTrackPrivateAVFObjC.h" >@@ -62,6 +64,7 @@ > #import "WebCoreCALayerExtras.h" > #import "WebCoreSystemInterface.h" > #import <functional> >+#import <map> > #import <objc/runtime.h> > #import <runtime/DataView.h> > #import <runtime/JSCInlines.h> >@@ -99,6 +102,10 @@ > #include "CFNSURLConnectionSPI.h" > #endif > >+#if PLATFORM(IOS) >+#include <OpenGLES/ES3/glext.h> >+#endif >+ > namespace std { > template <> struct iterator_traits<HashSet<RefPtr<WebCore::MediaSelectionOptionAVFObjC>>::iterator> { > typedef RefPtr<WebCore::MediaSelectionOptionAVFObjC> value_type; >@@ -295,6 +302,24 @@ SOFT_LINK_POINTER(AVFoundation, AVURLAssetBoundNetworkInterfaceName, NSString *) > #define AVURLAssetBoundNetworkInterfaceName getAVURLAssetBoundNetworkInterfaceName() > #endif > >+#if PLATFORM(IOS) >+SOFT_LINK(CoreVideo, CVOpenGLESTextureCacheCreate, CVReturn, (CFAllocatorRef allocator, CFDictionaryRef cacheAttributes, CVEAGLContext eaglContext, CFDictionaryRef textureAttributes, CVOpenGLESTextureCacheRef* cacheOut), (allocator, cacheAttributes, eaglContext, textureAttributes, cacheOut)) >+SOFT_LINK(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(CoreVideo, CVOpenGLESTextureCacheFlush, void, (CVOpenGLESTextureCacheRef textureCache, CVOptionFlags options), (textureCache, options)) >+SOFT_LINK(CoreVideo, CVOpenGLESTextureGetTarget, GLenum, (CVOpenGLESTextureRef image), (image)) >+SOFT_LINK(CoreVideo, CVOpenGLESTextureGetName, GLuint, (CVOpenGLESTextureRef image), (image)) >+SOFT_LINK_POINTER(CoreVideo, kCVPixelBufferIOSurfaceOpenGLESFBOCompatibilityKey, NSString *) >+#define kCVPixelBufferIOSurfaceOpenGLESFBOCompatibilityKey getkCVPixelBufferIOSurfaceOpenGLESFBOCompatibilityKey() >+#else >+SOFT_LINK(CoreVideo, CVOpenGLTextureCacheCreate, CVReturn, (CFAllocatorRef allocator, CFDictionaryRef cacheAttributes, CGLContextObj cglContext, CGLPixelFormatObj cglPixelFormat, CFDictionaryRef textureAttributes, CVOpenGLTextureCacheRef* cacheOut), (allocator, cacheAttributes, cglContext, cglPixelFormat, textureAttributes, cacheOut)) >+SOFT_LINK(CoreVideo, CVOpenGLTextureCacheCreateTextureFromImage, CVReturn, (CFAllocatorRef allocator, CVOpenGLTextureCacheRef textureCache, CVImageBufferRef sourceImage, CFDictionaryRef attributes, CVOpenGLTextureRef* textureOut), (allocator, textureCache, sourceImage, attributes, textureOut)) >+SOFT_LINK(CoreVideo, CVOpenGLTextureCacheFlush, void, (CVOpenGLTextureCacheRef textureCache, CVOptionFlags options), (textureCache, options)) >+SOFT_LINK(CoreVideo, CVOpenGLTextureGetTarget, GLenum, (CVOpenGLTextureRef image), (image)) >+SOFT_LINK(CoreVideo, CVOpenGLTextureGetName, GLuint, (CVOpenGLTextureRef image), (image)) >+SOFT_LINK_POINTER(CoreVideo, kCVPixelBufferIOSurfaceOpenGLFBOCompatibilityKey, NSString *) >+#define kCVPixelBufferIOSurfaceOpenGLFBOCompatibilityKey getkCVPixelBufferIOSurfaceOpenGLFBOCompatibilityKey() >+#endif >+ > using namespace WebCore; > > enum MediaPlayerAVFoundationObservationContext { >@@ -623,6 +648,7 @@ void MediaPlayerPrivateAVFoundationObjC::destroyContextVideoRenderer() > { > #if HAVE(AVFOUNDATION_VIDEO_OUTPUT) > destroyVideoOutput(); >+ destroyOpenGLVideoOutput(); > #endif > destroyImageGenerator(); > } >@@ -2356,6 +2382,265 @@ void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext& c > > } > >+void MediaPlayerPrivateAVFoundationObjC::createOpenGLVideoOutput() >+{ >+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createOpenGLVideoOutput(%p)", this); >+ >+ if (!m_avPlayerItem || m_openGLVideoOutput) >+ return; >+ >+#if PLATFORM(IOS) >+ NSDictionary* attributes = @{(NSString *)kCVPixelBufferIOSurfaceOpenGLESFBOCompatibilityKey: @YES}; >+#else >+ NSDictionary* attributes = @{(NSString *)kCVPixelBufferIOSurfaceOpenGLFBOCompatibilityKey: @YES}; >+#endif >+ m_openGLVideoOutput = adoptNS([allocAVPlayerItemVideoOutputInstance() initWithPixelBufferAttributes:attributes]); >+ ASSERT(m_openGLVideoOutput); >+ >+ [m_avPlayerItem.get() addOutput:m_openGLVideoOutput.get()]; >+ >+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createOpenGLVideoOutput(%p) - returning %p", this, m_openGLVideoOutput.get()); >+} >+ >+void MediaPlayerPrivateAVFoundationObjC::destroyOpenGLVideoOutput() >+{ >+ if (!m_openGLVideoOutput) >+ return; >+ >+ if (m_avPlayerItem) >+ [m_avPlayerItem.get() removeOutput:m_openGLVideoOutput.get()]; >+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::destroyOpenGLVideoOutput(%p) - destroying %p", this, m_videoOutput.get()); >+ >+ m_openGLVideoOutput = 0; >+} >+ >+void MediaPlayerPrivateAVFoundationObjC::updateLastOpenGLImage() >+{ >+ if (!m_openGLVideoOutput) >+ return; >+ >+ CMTime currentTime = [m_openGLVideoOutput itemTimeForHostTime:CACurrentMediaTime()]; >+ if (![m_openGLVideoOutput hasNewPixelBufferForItemTime:currentTime]) >+ return; >+ >+ m_lastOpenGLImage = adoptCF([m_openGLVideoOutput copyPixelBufferForItemTime:currentTime itemTimeForDisplay:nil]); >+} >+ >+ >+#if !LOG_DISABLED >+ >+#define STRINGIFY_PAIR(e) e, #e >+static std::map<uint32_t, const char*>& enumToStringMap() >+{ >+ static NeverDestroyed<std::map<uint32_t, const char*>> map; >+ if (map.get().empty()) { >+ std::map<uint32_t, const char*> stringMap; >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA)); >+ map.get().emplace(STRINGIFY_PAIR(GL_LUMINANCE_ALPHA)); >+ map.get().emplace(STRINGIFY_PAIR(GL_LUMINANCE)); >+ map.get().emplace(STRINGIFY_PAIR(GL_ALPHA)); >+ map.get().emplace(STRINGIFY_PAIR(GL_R8)); >+ map.get().emplace(STRINGIFY_PAIR(GL_R16F)); >+ map.get().emplace(STRINGIFY_PAIR(GL_R32F)); >+ map.get().emplace(STRINGIFY_PAIR(GL_R8UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_R8I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_R16UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_R16I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_R32UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_R32I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG8)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG16F)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG32F)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG8UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG8I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG16UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG16I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG32UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG32I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB8)); >+ map.get().emplace(STRINGIFY_PAIR(GL_SRGB8)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA8)); >+ map.get().emplace(STRINGIFY_PAIR(GL_SRGB8_ALPHA8)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA4)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB10_A2)); >+ map.get().emplace(STRINGIFY_PAIR(GL_DEPTH_COMPONENT16)); >+ map.get().emplace(STRINGIFY_PAIR(GL_DEPTH_COMPONENT24)); >+ map.get().emplace(STRINGIFY_PAIR(GL_DEPTH_COMPONENT32F)); >+ map.get().emplace(STRINGIFY_PAIR(GL_DEPTH24_STENCIL8)); >+ map.get().emplace(STRINGIFY_PAIR(GL_DEPTH32F_STENCIL8)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA)); >+ map.get().emplace(STRINGIFY_PAIR(GL_LUMINANCE_ALPHA)); >+ map.get().emplace(STRINGIFY_PAIR(GL_LUMINANCE)); >+ map.get().emplace(STRINGIFY_PAIR(GL_ALPHA)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RED)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG_INTEGER)); >+ map.get().emplace(STRINGIFY_PAIR(GL_DEPTH_STENCIL)); >+ map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_BYTE)); >+ map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_SHORT_5_6_5)); >+ map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_SHORT_4_4_4_4)); >+ map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_SHORT_5_5_5_1)); >+ map.get().emplace(STRINGIFY_PAIR(GL_BYTE)); >+ map.get().emplace(STRINGIFY_PAIR(GL_HALF_FLOAT)); >+ map.get().emplace(STRINGIFY_PAIR(GL_FLOAT)); >+ map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_SHORT)); >+ map.get().emplace(STRINGIFY_PAIR(GL_SHORT)); >+ map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_INT)); >+ map.get().emplace(STRINGIFY_PAIR(GL_INT)); >+ map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_INT_2_10_10_10_REV)); >+ 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) >+ map.get().emplace(STRINGIFY_PAIR(GL_RED_INTEGER)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB_INTEGER)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG8_SNORM)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB565)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB8_SNORM)); >+ map.get().emplace(STRINGIFY_PAIR(GL_R11F_G11F_B10F)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB9_E5)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB16F)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB32F)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB8UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB8I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB16UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB16I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB32UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB32I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA8_SNORM)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA16F)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA32F)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA8UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA8I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB10_A2UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA16UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA16I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA32I)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA32UI)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGB5_A1)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RG)); >+ map.get().emplace(STRINGIFY_PAIR(GL_RGBA_INTEGER)); >+ map.get().emplace(STRINGIFY_PAIR(GL_DEPTH_COMPONENT)); >+ map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_INT_10F_11F_11F_REV)); >+ map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_INT_5_9_9_9_REV)); >+#endif >+ } >+ return map.get(); >+} >+ >+#endif // !LOG_DISABLED >+ >+bool MediaPlayerPrivateAVFoundationObjC::copyVideoTextureToPlatformTexture(GraphicsContext3D* context, Platform3DObject outputTexture, GC3Denum outputTarget, GC3Dint level, GC3Denum internalFormat, GC3Denum format, GC3Denum type, bool premultiplyAlpha, bool flipY) >+{ >+ ASSERT(context); >+ UNUSED_PARAM(premultiplyAlpha); >+ UNUSED_PARAM(flipY); >+ >+ if (!m_openGLVideoOutput) >+ createOpenGLVideoOutput(); >+ >+ updateLastOpenGLImage(); >+ >+ if (!m_lastOpenGLImage) >+ return false; >+ >+ if (!m_openGLTextureCache) { >+#if PLATFORM(IOS) >+ CVOpenGLESTextureCacheRef cache = nullptr; >+ CVReturn error = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, nullptr, context->platformGraphicsContext3D(), nullptr, &cache); >+#else >+ CVOpenGLTextureCacheRef cache = nullptr; >+ CVReturn error = CVOpenGLTextureCacheCreate(kCFAllocatorDefault, nullptr, context->platformGraphicsContext3D(), CGLGetPixelFormat(context->platformGraphicsContext3D()), nullptr, &cache); >+#endif >+ if (error != kCVReturnSuccess) >+ return false; >+ m_openGLTextureCache = adoptCF(cache); >+ } >+ >+ size_t width = CVPixelBufferGetWidth(m_lastOpenGLImage.get()); >+ size_t height = CVPixelBufferGetHeight(m_lastOpenGLImage.get()); >+ >+ >+#if PLATFORM(IOS) >+ CVOpenGLESTextureRef bareVideoTexture = nullptr; >+ if (kCVReturnSuccess != CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_openGLTextureCache.get(), m_lastOpenGLImage.get(), nullptr, outputTarget, internalFormat, width, height, format, type, level, &bareVideoTexture)) >+ return false; >+ RetainPtr<CVOpenGLESTextureRef> videoTexture = adoptCF(bareVideoTexture); >+ Platform3DObject videoTextureName = CVOpenGLESTextureGetName(videoTexture.get()); >+ GC3Denum videoTextureTarget = CVOpenGLESTextureGetTarget(videoTexture.get()); >+#else >+ CVOpenGLTextureRef bareVideoTexture = nullptr; >+ if (kCVReturnSuccess != CVOpenGLTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_openGLTextureCache.get(), m_lastOpenGLImage.get(), nullptr, &bareVideoTexture)) >+ return false; >+ RetainPtr<CVOpenGLTextureRef> videoTexture = adoptCF(bareVideoTexture); >+ Platform3DObject videoTextureName = CVOpenGLTextureGetName(videoTexture.get()); >+ GC3Denum videoTextureTarget = CVOpenGLTextureGetTarget(videoTexture.get()); >+#endif >+ >+ auto weakThis = createWeakPtr(); >+ dispatch_async(dispatch_get_main_queue(), [weakThis] { >+ if (!weakThis) >+ return; >+ >+ if (auto cache = weakThis->m_openGLTextureCache.get()) >+#if PLATFORM(IOS) >+ CVOpenGLESTextureCacheFlush(cache, 0); >+#else >+ CVOpenGLTextureCacheFlush(cache, 0); >+#endif >+ }); >+ >+ >+ GC3Denum readFramebufferTarget = GraphicsContext3D::READ_FRAMEBUFFER; >+ GC3Denum readFramebufferBinding = GraphicsContext3D::READ_FRAMEBUFFER_BINDING; >+ >+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::copyVideoTextureToPlatformTexture(%p) - internalFormat: %s, format: %s, type: %s", this, enumToStringMap()[internalFormat], enumToStringMap()[format], enumToStringMap()[type]); >+ >+ // Save the origial bound texture & framebuffer names so we can re-bind them after copying the video texture. >+ GC3Dint boundTexture = 0; >+ GC3Dint boundReadFramebuffer = 0; >+ context->getIntegerv(GraphicsContext3D::TEXTURE_BINDING_2D, &boundTexture); >+ context->getIntegerv(readFramebufferBinding, &boundReadFramebuffer); >+ >+ context->bindTexture(videoTextureTarget, videoTextureName); >+ context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); >+ context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); >+ context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); >+ >+ // Create a framebuffer object to represent the video texture's memory. >+ Platform3DObject readFramebuffer = context->createFramebuffer(); >+ >+ // Make that framebuffer the read source from which drawing commands will read voxels. >+ context->bindFramebuffer(readFramebufferTarget, readFramebuffer); >+ >+ // Allocate uninitialized memory for the output texture. >+ context->bindTexture(outputTarget, outputTexture); >+ context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); >+ context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); >+ context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); >+ context->texImage2DDirect(outputTarget, level, internalFormat, width, height, 0, format, type, nullptr); >+ >+ // Attach the video texture to the framebuffer. >+ context->framebufferTexture2D(readFramebufferTarget, GraphicsContext3D::COLOR_ATTACHMENT0, videoTextureTarget, videoTextureName, level); >+ >+ GC3Denum status = context->checkFramebufferStatus(readFramebufferTarget); >+ if (status != GraphicsContext3D::FRAMEBUFFER_COMPLETE) >+ return false; >+ >+ // Copy texture from the read framebuffer (and thus the video texture) to the output texture. >+ context->copyTexImage2D(outputTarget, level, internalFormat, 0, 0, width, height, 0); >+ >+ // Restore the previous texture and framebuffer bindings. >+ context->bindTexture(outputTarget, boundTexture); >+ context->bindFramebuffer(readFramebufferTarget, boundReadFramebuffer); >+ >+ // Clean up after ourselves. >+ context->deleteFramebuffer(readFramebuffer); >+ >+ return !context->getError(); >+} >+ > PassNativeImagePtr MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime() > { > updateLastImage();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 129626
:
252863
|
252865
|
252875
|
252877
|
252886
|
252891
|
252892
|
252893
|
252898
|
252900
|
259527
|
259622
|
259627
|
259629
|
261948
|
261950
|
261952
|
261963
|
262015
|
265807