Commit 1ef0d20c authored by jchen10's avatar jchen10 Committed by Chromium LUCI CQ

WEBGL_webcodecs_video_frame: Support software video frame

This uses GpuMemoryBufferVideoFramePool to import software video
frames.

Bug: 1142754
Change-Id: Ic1a7849ca7a833ecf255892ba962ce2207b57546
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2603036Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Cr-Commit-Position: refs/heads/master@{#841423}
parent 2149a931
...@@ -963,11 +963,18 @@ RendererBlinkPlatformImpl::GetGpuFactories() { ...@@ -963,11 +963,18 @@ RendererBlinkPlatformImpl::GetGpuFactories() {
return render_thread->GetGpuFactories(); return render_thread->GetGpuFactories();
} }
media::DecoderFactory* RendererBlinkPlatformImpl::GetMediaDecoderFactory() { scoped_refptr<base::SingleThreadTaskRunner>
RendererBlinkPlatformImpl::MediaThreadTaskRunner() {
auto* render_thread = RenderThreadImpl::current(); auto* render_thread = RenderThreadImpl::current();
if (!render_thread) if (!render_thread)
return nullptr; return nullptr;
return render_thread->GetMediaThreadTaskRunner();
}
media::DecoderFactory* RendererBlinkPlatformImpl::GetMediaDecoderFactory() {
auto* render_thread = RenderThreadImpl::current();
DCHECK(!!render_thread);
return render_thread->GetMediaDecoderFactory(); return render_thread->GetMediaDecoderFactory();
} }
......
...@@ -210,6 +210,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { ...@@ -210,6 +210,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
blink::MediaInspectorContext* inspector_context, blink::MediaInspectorContext* inspector_context,
scoped_refptr<base::SingleThreadTaskRunner> owner_task_runner) override; scoped_refptr<base::SingleThreadTaskRunner> owner_task_runner) override;
media::GpuVideoAcceleratorFactories* GetGpuFactories() override; media::GpuVideoAcceleratorFactories* GetGpuFactories() override;
scoped_refptr<base::SingleThreadTaskRunner> MediaThreadTaskRunner() override;
media::DecoderFactory* GetMediaDecoderFactory() override; media::DecoderFactory* GetMediaDecoderFactory() override;
void SetRenderingColorSpace(const gfx::ColorSpace& color_space) override; void SetRenderingColorSpace(const gfx::ColorSpace& color_space) override;
void SetActiveURL(const blink::WebURL& url, void SetActiveURL(const blink::WebURL& url,
......
...@@ -387,6 +387,12 @@ class BLINK_PLATFORM_EXPORT Platform { ...@@ -387,6 +387,12 @@ class BLINK_PLATFORM_EXPORT Platform {
// once CreateAndSetCompositorThread() is called. // once CreateAndSetCompositorThread() is called.
scoped_refptr<base::SingleThreadTaskRunner> CompositorThreadTaskRunner(); scoped_refptr<base::SingleThreadTaskRunner> CompositorThreadTaskRunner();
// Returns the task runner of the media thread.
// This method should only be called on the main thread, or it crashes.
virtual scoped_refptr<base::SingleThreadTaskRunner> MediaThreadTaskRunner() {
return nullptr;
}
// This is called after the compositor thread is created, so the embedder // This is called after the compositor thread is created, so the embedder
// can initiate an IPC to change its thread priority (on Linux we can't // can initiate an IPC to change its thread priority (on Linux we can't
// increase the nice value, so we need to ask the browser process). This // increase the nice value, so we need to ask the browser process). This
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
enum ColorSpacePrimaryID { enum ColorSpacePrimaryID {
"BT709", "BT709",
"BT407M", "BT470M",
"BT470BG", "BT470BG",
"SMPTE170M", "SMPTE170M",
"SMPTE240M", "SMPTE240M",
......
...@@ -8,6 +8,7 @@ include_rules = [ ...@@ -8,6 +8,7 @@ include_rules = [
"+gpu/config/gpu_feature_info.h", "+gpu/config/gpu_feature_info.h",
"+media/base/video_frame.h", "+media/base/video_frame.h",
"+media/base/wait_and_replace_sync_token_client.h", "+media/base/wait_and_replace_sync_token_client.h",
"+media/video/gpu_memory_buffer_video_frame_pool.h",
"+skia/ext", "+skia/ext",
"+third_party/blink/renderer/modules/webcodecs", "+third_party/blink/renderer/modules/webcodecs",
"+ui/gl/gpu_preference.h", "+ui/gl/gpu_preference.h",
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
#include "third_party/blink/renderer/modules/webcodecs/video_frame.h" #include "third_party/blink/renderer/modules/webcodecs/video_frame.h"
#include "third_party/blink/renderer/modules/webgl/webgl_extension.h" #include "third_party/blink/renderer/modules/webgl/webgl_extension.h"
namespace media {
class GpuMemoryBufferVideoFramePool;
} // namespace media
namespace blink { namespace blink {
class WebGLWebCodecsVideoFrameHandle; class WebGLWebCodecsVideoFrameHandle;
...@@ -18,6 +22,8 @@ class WebGLWebCodecsVideoFrame final : public WebGLExtension { ...@@ -18,6 +22,8 @@ class WebGLWebCodecsVideoFrame final : public WebGLExtension {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
~WebGLWebCodecsVideoFrame() override;
static bool Supported(WebGLRenderingContextBase*); static bool Supported(WebGLRenderingContextBase*);
static const char* ExtensionName(); static const char* ExtensionName();
...@@ -36,9 +42,13 @@ class WebGLWebCodecsVideoFrame final : public WebGLExtension { ...@@ -36,9 +42,13 @@ class WebGLWebCodecsVideoFrame final : public WebGLExtension {
ExceptionState&); ExceptionState&);
private: private:
void OnHardwareVideoFrameCreated(
base::WaitableEvent* waitable_event,
scoped_refptr<media::VideoFrame> video_frame);
void InitializeGpuMemoryBufferPool();
std::bitset<media::PIXEL_FORMAT_MAX + 1> formats_supported; std::bitset<media::PIXEL_FORMAT_MAX + 1> formats_supported;
std::string sampler_type_;
std::string sampler_func_;
std::array<std::array<std::string, media::VideoFrame::kMaxPlanes>, std::array<std::array<std::string, media::VideoFrame::kMaxPlanes>,
media::PIXEL_FORMAT_MAX + 1> media::PIXEL_FORMAT_MAX + 1>
format_to_components_map_; format_to_components_map_;
...@@ -47,6 +57,11 @@ class WebGLWebCodecsVideoFrame final : public WebGLExtension { ...@@ -47,6 +57,11 @@ class WebGLWebCodecsVideoFrame final : public WebGLExtension {
// This holds the reference for all video frames being imported, but not // This holds the reference for all video frames being imported, but not
// yet released. // yet released.
VideoFrameHandleMap tex0_to_video_frame_map_; VideoFrameHandleMap tex0_to_video_frame_map_;
std::unique_ptr<media::GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_;
scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
scoped_refptr<media::VideoFrame> hardware_video_frame_;
}; };
} // namespace blink } // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment