Commit 4e22dbd6 authored by Yan, Shaobo's avatar Yan, Shaobo Committed by Commit Bot

Reland "Support imageBitmap generated from video by GPU resource"

This is a reland of 46c9a968. Original
is in patch set 1. Disable gpu backing in D3D9 to handle the failure case.

Original change's description:
> Support imageBitmap generated from video by GPU resource
>
> This patch replaces the backed resource of imageBimap generated from
> video element to GPU resource.
>
> The old path has been used as fallback path.
>
> BUG=1098445

Bug: 1105923, 1098445
Change-Id: I08606e3a9c91b5ecc5e91359689680a0c3981f57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2304209Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Cr-Commit-Position: refs/heads/master@{#790244}
parent 920fe2a5
...@@ -3427,6 +3427,15 @@ ...@@ -3427,6 +3427,15 @@
"features": [ "features": [
"unbind_attachments_on_bound_render_fbo_delete" "unbind_attachments_on_bound_render_fbo_delete"
] ]
},
{
"id": 343,
"description": "Disable using GPU backed resource for imageBitmap from video on d3d9",
"cr_bugs": [1098445, 1105923],
"gl_renderer": ".*Direct3D9.*",
"features": [
"disable_imagebitmap_from_video_using_gpu"
]
} }
] ]
} }
...@@ -33,6 +33,7 @@ disable_es3_gl_context_for_testing ...@@ -33,6 +33,7 @@ disable_es3_gl_context_for_testing
disable_ext_draw_buffers disable_ext_draw_buffers
disable_gl_rgb_format disable_gl_rgb_format
disable_half_float_for_gmb disable_half_float_for_gmb
disable_imagebitmap_from_video_using_gpu
disable_larger_than_screen_overlays disable_larger_than_screen_overlays
disable_mediafoundation_async_h264_encoding disable_mediafoundation_async_h264_encoding
disable_multisampling_color_mask_usage disable_multisampling_color_mask_usage
......
...@@ -6,12 +6,13 @@ ...@@ -6,12 +6,13 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/numerics/checked_math.h" #include "base/numerics/checked_math.h"
#include "base/numerics/clamped_math.h" #include "base/numerics/clamped_math.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "gpu/command_buffer/client/shared_image_interface.h" #include "gpu/command_buffer/client/shared_image_interface.h"
#include "gpu/config/gpu_feature_info.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h" #include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
#include "third_party/blink/renderer/core/html/canvas/image_data.h" #include "third_party/blink/renderer/core/html/canvas/image_data.h"
...@@ -20,6 +21,7 @@ ...@@ -20,6 +21,7 @@
#include "third_party/blink/renderer/platform/graphics/accelerated_static_bitmap_image.h" #include "third_party/blink/renderer/platform/graphics/accelerated_static_bitmap_image.h"
#include "third_party/blink/renderer/platform/graphics/canvas_color_params.h" #include "third_party/blink/renderer/platform/graphics/canvas_color_params.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource_provider.h" #include "third_party/blink/renderer/platform/graphics/canvas_resource_provider.h"
#include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h"
#include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h" #include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
#include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h" #include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
...@@ -247,6 +249,35 @@ std::unique_ptr<CanvasResourceProvider> CreateProvider( ...@@ -247,6 +249,35 @@ std::unique_ptr<CanvasResourceProvider> CreateProvider(
size, kLow_SkFilterQuality, color_params); size, kLow_SkFilterQuality, color_params);
} }
std::unique_ptr<CanvasResourceProvider> CreateProviderForVideoElement(
HTMLVideoElement* video,
const ImageBitmapOptions* options) {
// TODO(crbug.com/1098445): ImageBitmap resize test case failed when
// quality equals to "low" and "medium". Need further investigate to
// enable gpu backed imageBitmap with resize options.
if (!SharedGpuContext::ContextProviderWrapper() ||
SharedGpuContext::ContextProviderWrapper()
->ContextProvider()
->GetGpuFeatureInfo()
.IsWorkaroundEnabled(DISABLE_IMAGEBITMAP_FROM_VIDEO_USING_GPU) ||
options->hasResizeWidth() || options->hasResizeHeight()) {
return CanvasResourceProvider::CreateBitmapProvider(
IntSize(video->videoWidth(), video->videoHeight()),
kLow_SkFilterQuality, CanvasColorParams());
}
uint32_t shared_image_usage_flags = gpu::SHARED_IMAGE_USAGE_DISPLAY;
return CanvasResourceProvider::CreateSharedImageProvider(
IntSize(video->videoWidth(), video->videoHeight()),
SharedGpuContext::ContextProviderWrapper(), kLow_SkFilterQuality,
CanvasColorParams(CanvasColorSpace::kSRGB,
CanvasColorParams::GetNativeCanvasPixelFormat(),
kNonOpaque), // Default canvas settings
false, // Origin of GL texture is bottom left on screen
RasterMode::kGPU, shared_image_usage_flags);
}
scoped_refptr<StaticBitmapImage> FlipImageVertically( scoped_refptr<StaticBitmapImage> FlipImageVertically(
scoped_refptr<StaticBitmapImage> input, scoped_refptr<StaticBitmapImage> input,
const ImageBitmap::ParsedOptions& parsed_options) { const ImageBitmap::ParsedOptions& parsed_options) {
...@@ -645,12 +676,8 @@ ImageBitmap::ImageBitmap(HTMLVideoElement* video, ...@@ -645,12 +676,8 @@ ImageBitmap::ImageBitmap(HTMLVideoElement* video,
if (DstBufferSizeHasOverflow(parsed_options)) if (DstBufferSizeHasOverflow(parsed_options))
return; return;
// TODO(fserb): this shouldn't be software?
std::unique_ptr<CanvasResourceProvider> resource_provider = std::unique_ptr<CanvasResourceProvider> resource_provider =
CanvasResourceProvider::CreateBitmapProvider( CreateProviderForVideoElement(video, options);
IntSize(video->videoWidth(), video->videoHeight()),
kLow_SkFilterQuality,
CanvasColorParams()); // TODO: set color space here to avoid clamping
if (!resource_provider) if (!resource_provider)
return; return;
......
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