diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-13 16:23:34 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-14 10:37:21 +0000 |
commit | 38a9a29f4f9436cace7f0e7abf9c586057df8a4e (patch) | |
tree | c4e8c458dc595bc0ddb435708fa2229edfd00bd4 /chromium/components/viz/common | |
parent | e684a3455bcc29a6e3e66a004e352dea4e1141e7 (diff) | |
download | qtwebengine-chromium-38a9a29f4f9436cace7f0e7abf9c586057df8a4e.tar.gz |
BASELINE: Update Chromium to 73.0.3683.37
Change-Id: I08c9af2948b645f671e5d933aca1f7a90ea372f2
Reviewed-by: Michael Brüning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/components/viz/common')
34 files changed, 503 insertions, 321 deletions
diff --git a/chromium/components/viz/common/BUILD.gn b/chromium/components/viz/common/BUILD.gn index fd0ee4f98e1..7156c304153 100644 --- a/chromium/components/viz/common/BUILD.gn +++ b/chromium/components/viz/common/BUILD.gn @@ -3,8 +3,8 @@ # found in the LICENSE file. import("//components/viz/viz.gni") -import("//testing/test.gni") import("//gpu/vulkan/features.gni") +import("//testing/test.gni") source_set("resource_format") { sources = [ @@ -33,6 +33,7 @@ viz_component("resource_format_utils") { deps = [ "//base", "//cc/base:base", + "//gpu/vulkan:buildflags", "//skia", "//ui/gfx:buffer_types", "//ui/gfx/geometry:geometry", @@ -45,6 +46,13 @@ if (enable_vulkan) { defines = [ "VIZ_VULKAN_CONTEXT_PROVIDER_IMPLEMENTATION" ] + # TODO(cblume): http://crbug.com/911313 + # Abstract out the platform specific defines. Right now we need the android + # platform specific define here to be able to include android specific + # functions. + if (is_android) { + defines += [ "VK_USE_PLATFORM_ANDROID_KHR" ] + } sources = [ "gpu/vulkan_context_provider.h", "gpu/vulkan_in_process_context_provider.cc", @@ -106,9 +114,9 @@ viz_component("common") { "gpu/context_provider.h", "gpu/raster_context_provider.cc", "gpu/raster_context_provider.h", - "gpu/texture_allocation.cc", - "gpu/texture_allocation.h", "hit_test/aggregated_hit_test_region.h", + "hit_test/hit_test_data_builder.cc", + "hit_test/hit_test_data_builder.h", "hit_test/hit_test_region_list.cc", "hit_test/hit_test_region_list.h", "quads/compositor_frame.cc", @@ -221,6 +229,10 @@ viz_component("common") { deps += [ "//ui/base" ] } + if (is_chromecast) { + defines += [ "IS_CHROMECAST" ] + } + public_deps = [ ":resource_format_utils", "//gpu/command_buffer/client", diff --git a/chromium/components/viz/common/display/renderer_settings.h b/chromium/components/viz/common/display/renderer_settings.h index 9539d2b5ad1..2b8cd275a5e 100644 --- a/chromium/components/viz/common/display/renderer_settings.h +++ b/chromium/components/viz/common/display/renderer_settings.h @@ -9,6 +9,7 @@ #include "build/build_config.h" #include "components/viz/common/viz_common_export.h" +#include "ui/gfx/color_space.h" #include "ui/gfx/geometry/size.h" namespace viz { @@ -30,7 +31,6 @@ class VIZ_COMMON_EXPORT RendererSettings { bool show_overdraw_feedback = false; bool enable_draw_occlusion = false; bool use_skia_renderer = false; - bool use_skia_deferred_display_list = false; bool allow_overlays = true; bool dont_round_texture_sizes_for_pixel_tests = false; int highp_threshold_min = 0; @@ -46,6 +46,8 @@ class VIZ_COMMON_EXPORT RendererSettings { #if defined(OS_ANDROID) // The screen size at renderer creation time. gfx::Size initial_screen_size = gfx::Size(0, 0); + + gfx::ColorSpace color_space; #endif }; diff --git a/chromium/components/viz/common/features.cc b/chromium/components/viz/common/features.cc index 551fd5d84d8..f0c077da19a 100644 --- a/chromium/components/viz/common/features.cc +++ b/chromium/components/viz/common/features.cc @@ -26,8 +26,15 @@ const base::Feature kEnableSurfaceSynchronization{ // Enables running the display compositor as part of the viz service in the GPU // process. This is also referred to as out-of-process display compositor // (OOP-D). +// TODO(dnicoara): Look at enabling Chromecast support when ChromeOS support is +// ready. +#if defined(OS_CHROMEOS) || defined(IS_CHROMECAST) const base::Feature kVizDisplayCompositor{"VizDisplayCompositor", base::FEATURE_DISABLED_BY_DEFAULT}; +#else +const base::Feature kVizDisplayCompositor{"VizDisplayCompositor", + base::FEATURE_ENABLED_BY_DEFAULT}; +#endif // Enables running the Viz-assisted hit-test logic. const base::Feature kEnableVizHitTestDrawQuad{"VizHitTestDrawQuad", @@ -36,10 +43,6 @@ const base::Feature kEnableVizHitTestDrawQuad{"VizHitTestDrawQuad", const base::Feature kEnableVizHitTestSurfaceLayer{ "VizHitTestSurfaceLayer", base::FEATURE_DISABLED_BY_DEFAULT}; -// Use the Skia deferred display list. -const base::Feature kUseSkiaDeferredDisplayList{ - "UseSkiaDeferredDisplayList", base::FEATURE_DISABLED_BY_DEFAULT}; - // Use the SkiaRenderer. const base::Feature kUseSkiaRenderer{"UseSkiaRenderer", base::FEATURE_DISABLED_BY_DEFAULT}; @@ -62,6 +65,8 @@ bool IsVizHitTestingDebugEnabled() { } bool IsVizHitTestingDrawQuadEnabled() { + if (IsVizHitTestingSurfaceLayerEnabled()) + return false; return base::FeatureList::IsEnabled(kEnableVizHitTestDrawQuad) || base::FeatureList::IsEnabled(kVizDisplayCompositor); } @@ -72,12 +77,9 @@ bool IsVizHitTestingEnabled() { } bool IsVizHitTestingSurfaceLayerEnabled() { - // TODO(riajiang): Check kVizDisplayCompositor feature when it works with - // that config. - return (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseVizHitTestSurfaceLayer) || - base::FeatureList::IsEnabled(kEnableVizHitTestSurfaceLayer)) && - !IsVizHitTestingDrawQuadEnabled(); + return base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kUseVizHitTestSurfaceLayer) || + base::FeatureList::IsEnabled(kEnableVizHitTestSurfaceLayer); } bool IsDrawOcclusionEnabled() { @@ -93,10 +95,4 @@ bool IsRecordingSkPicture() { base::FeatureList::IsEnabled(kRecordSkPicture); } -bool IsUsingSkiaDeferredDisplayList() { - return IsUsingSkiaRenderer() && - base::FeatureList::IsEnabled(kUseSkiaDeferredDisplayList) && - base::FeatureList::IsEnabled(kVizDisplayCompositor); -} - } // namespace features diff --git a/chromium/components/viz/common/features.h b/chromium/components/viz/common/features.h index f7d5435a4da..2d76f380b3a 100644 --- a/chromium/components/viz/common/features.h +++ b/chromium/components/viz/common/features.h @@ -15,7 +15,6 @@ VIZ_COMMON_EXPORT extern const base::Feature kEnableDrawOcclusion; VIZ_COMMON_EXPORT extern const base::Feature kEnableSurfaceSynchronization; VIZ_COMMON_EXPORT extern const base::Feature kEnableVizHitTestDrawQuad; VIZ_COMMON_EXPORT extern const base::Feature kEnableVizHitTestSurfaceLayer; -VIZ_COMMON_EXPORT extern const base::Feature kUseSkiaDeferredDisplayList; VIZ_COMMON_EXPORT extern const base::Feature kUseSkiaRenderer; VIZ_COMMON_EXPORT extern const base::Feature kRecordSkPicture; VIZ_COMMON_EXPORT extern const base::Feature kVizDisplayCompositor; @@ -26,7 +25,6 @@ VIZ_COMMON_EXPORT bool IsVizHitTestingDebugEnabled(); VIZ_COMMON_EXPORT bool IsVizHitTestingDrawQuadEnabled(); VIZ_COMMON_EXPORT bool IsVizHitTestingEnabled(); VIZ_COMMON_EXPORT bool IsVizHitTestingSurfaceLayerEnabled(); -VIZ_COMMON_EXPORT bool IsUsingSkiaDeferredDisplayList(); VIZ_COMMON_EXPORT bool IsUsingSkiaRenderer(); VIZ_COMMON_EXPORT bool IsRecordingSkPicture(); diff --git a/chromium/components/viz/common/frame_sinks/begin_frame_args.cc b/chromium/components/viz/common/frame_sinks/begin_frame_args.cc index 29d1a3da940..336637875f5 100644 --- a/chromium/components/viz/common/frame_sinks/begin_frame_args.cc +++ b/chromium/components/viz/common/frame_sinks/begin_frame_args.cc @@ -4,6 +4,8 @@ #include "components/viz/common/frame_sinks/begin_frame_args.h" +#include <utility> + #include "base/trace_event/traced_value.h" namespace viz { @@ -16,8 +18,6 @@ const char* BeginFrameArgs::TypeToString(BeginFrameArgsType type) { return "NORMAL"; case BeginFrameArgs::MISSED: return "MISSED"; - case BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX: - return "BEGIN_FRAME_ARGS_TYPE_MAX"; } NOTREACHED(); return "???"; @@ -64,7 +64,6 @@ BeginFrameArgs BeginFrameArgs::Create(BeginFrameArgs::CreationLocation location, base::TimeDelta interval, BeginFrameArgs::BeginFrameArgsType type) { DCHECK_NE(type, BeginFrameArgs::INVALID); - DCHECK_NE(type, BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX); #ifdef NDEBUG return BeginFrameArgs(source_id, sequence_number, frame_time, deadline, interval, type); diff --git a/chromium/components/viz/common/frame_sinks/begin_frame_args.h b/chromium/components/viz/common/frame_sinks/begin_frame_args.h index ff33a47dd8f..63642475f67 100644 --- a/chromium/components/viz/common/frame_sinks/begin_frame_args.h +++ b/chromium/components/viz/common/frame_sinks/begin_frame_args.h @@ -44,9 +44,6 @@ struct VIZ_COMMON_EXPORT BeginFrameArgs { INVALID, NORMAL, MISSED, - // Not a real type, but used by the IPC system. Should always remain the - // *last* value in this enum. - BEGIN_FRAME_ARGS_TYPE_MAX, }; static const char* TypeToString(BeginFrameArgsType type); diff --git a/chromium/components/viz/common/frame_sinks/copy_output_result.cc b/chromium/components/viz/common/frame_sinks/copy_output_result.cc index 0354e37a22c..54fad114381 100644 --- a/chromium/components/viz/common/frame_sinks/copy_output_result.cc +++ b/chromium/components/viz/common/frame_sinks/copy_output_result.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "third_party/libyuv/include/libyuv.h" +#include "ui/gfx/color_space.h" namespace viz { @@ -35,6 +36,7 @@ bool CopyOutputResult::IsEmpty() const { } const SkBitmap& CopyOutputResult::AsSkBitmap() const { + DCHECK(!cached_bitmap_.readyToDraw() || cached_bitmap_.colorSpace()); return cached_bitmap_; } @@ -58,7 +60,11 @@ bool CopyOutputResult::ReadI420Planes(uint8_t* y_out, if (!bitmap.readyToDraw()) return false; const uint8_t* pixels = static_cast<uint8_t*>(bitmap.getPixels()); - // TODO(crbug/758057): The conversion below ignores color space completely. + // The conversion below ignores color space completely, and it's not even + // sRGB→Rec.709. Unfortunately, hand-optimized routines are not available, and + // a perfect conversion using gfx::ColorTransform would execute way too + // slowly. See SoftwareRenderer for related comments on its lack of color + // space management (due to performance concerns). if (bitmap.colorType() == kBGRA_8888_SkColorType) { return 0 == libyuv::ARGBToI420(pixels, bitmap.rowBytes(), y_out, y_out_stride, u_out, u_out_stride, v_out, @@ -81,12 +87,22 @@ bool CopyOutputResult::ReadRGBAPlane(uint8_t* dest, int stride) const { const SkBitmap& bitmap = AsSkBitmap(); if (!bitmap.readyToDraw()) return false; - SkImageInfo image_info = SkImageInfo::MakeN32(bitmap.width(), bitmap.height(), - kPremul_SkAlphaType); + DCHECK(bitmap.colorSpace()); + SkImageInfo image_info = + SkImageInfo::MakeN32(bitmap.width(), bitmap.height(), kPremul_SkAlphaType, + bitmap.refColorSpace()); bitmap.readPixels(image_info, dest, stride, 0, 0); return true; } +gfx::ColorSpace CopyOutputResult::GetRGBAColorSpace() const { + const SkBitmap& bitmap = AsSkBitmap(); + if (!bitmap.readyToDraw()) + return gfx::ColorSpace(); + DCHECK(bitmap.colorSpace()); + return gfx::ColorSpace(*(bitmap.colorSpace())); +} + CopyOutputSkBitmapResult::CopyOutputSkBitmapResult(const gfx::Rect& rect, const SkBitmap& bitmap) : CopyOutputSkBitmapResult(Format::RGBA_BITMAP, rect, bitmap) {} @@ -98,6 +114,7 @@ CopyOutputSkBitmapResult::CopyOutputSkBitmapResult( : CopyOutputResult(format, rect) { DCHECK(format == Format::RGBA_BITMAP || format == Format::I420_PLANES); if (!rect.IsEmpty()) { + DCHECK(!bitmap.readyToDraw() || bitmap.colorSpace()); // Hold a reference to the |bitmap|'s pixels, for AsSkBitmap(). *(cached_bitmap()) = bitmap; } @@ -143,6 +160,8 @@ CopyOutputTextureResult::CopyOutputTextureResult( release_callback_(std::move(release_callback)) { DCHECK_EQ(rect.IsEmpty(), mailbox.IsZero()); DCHECK_EQ(!release_callback_, mailbox.IsZero()); + DCHECK(texture_result_.mailbox.IsZero() || + texture_result_.color_space.IsValid()); } CopyOutputTextureResult::~CopyOutputTextureResult() { diff --git a/chromium/components/viz/common/frame_sinks/copy_output_result.h b/chromium/components/viz/common/frame_sinks/copy_output_result.h index 2ae0b84452e..9f9d951b8ab 100644 --- a/chromium/components/viz/common/frame_sinks/copy_output_result.h +++ b/chromium/components/viz/common/frame_sinks/copy_output_result.h @@ -60,7 +60,8 @@ class VIZ_COMMON_EXPORT CopyOutputResult { // Convenience to provide this result in SkBitmap form. Returns a // !readyToDraw() bitmap if this result is empty or if a conversion is not - // possible in the current implementation. + // possible in the current implementation. The returned SkBitmap also carries + // its color space information. virtual const SkBitmap& AsSkBitmap() const; // Returns a pointer with the gpu::Mailbox referencing a RGBA_TEXTURE result, @@ -94,9 +95,14 @@ class VIZ_COMMON_EXPORT CopyOutputResult { // |y_out|, |u_out| and |v_out| point to the start of the memory regions to // receive each plane. These memory regions must have the following sizes: // - // Y plane: y_out_stride * size().height() bytes - // U plane: u_out_stride * CEIL(size().height() / 2) bytes - // V plane: v_out_stride * CEIL(size().height() / 2) bytes + // Y plane: y_out_stride * size().height() bytes, with + // y_out_stride >= size().width() + // U plane: u_out_stride * CEIL(size().height() / 2) bytes, with + // u_out_stride >= CEIL(size().width() / 2) + // V plane: v_out_stride * CEIL(size().height() / 2) bytes, with + // v_out_stride >= CEIL(size().width() / 2) + // + // The color space is always Rec.709 (see gfx::ColorSpace::CreateREC709()). virtual bool ReadI420Planes(uint8_t* y_out, int y_out_stride, uint8_t* u_out, @@ -109,6 +115,9 @@ class VIZ_COMMON_EXPORT CopyOutputResult { // 2) the result format is not RGBA_BITMAP and conversion is not implemented. virtual bool ReadRGBAPlane(uint8_t* dest, int stride) const; + // Returns the color space of the image data returned by ReadRGBAPlane(). + virtual gfx::ColorSpace GetRGBAColorSpace() const; + protected: // Accessor for subclasses to initialize the cached SkBitmap. SkBitmap* cached_bitmap() const { return &cached_bitmap_; } diff --git a/chromium/components/viz/common/frame_sinks/delay_based_time_source.cc b/chromium/components/viz/common/frame_sinks/delay_based_time_source.cc index eb34c492eff..ddab391b159 100644 --- a/chromium/components/viz/common/frame_sinks/delay_based_time_source.cc +++ b/chromium/components/viz/common/frame_sinks/delay_based_time_source.cc @@ -155,8 +155,8 @@ void DelayBasedTimeSource::PostNextTickTask(base::TimeTicks now) { next_tick_time_ += interval_; DCHECK_GT(next_tick_time_, now); } - tick_closure_.Reset(base::Bind(&DelayBasedTimeSource::OnTimerTick, - weak_factory_.GetWeakPtr())); + tick_closure_.Reset(base::BindOnce(&DelayBasedTimeSource::OnTimerTick, + weak_factory_.GetWeakPtr())); task_runner_->PostDelayedTask(FROM_HERE, tick_closure_.callback(), next_tick_time_ - now); } diff --git a/chromium/components/viz/common/frame_sinks/delay_based_time_source.h b/chromium/components/viz/common/frame_sinks/delay_based_time_source.h index 7d58a2e2fc8..322ad3a063a 100644 --- a/chromium/components/viz/common/frame_sinks/delay_based_time_source.h +++ b/chromium/components/viz/common/frame_sinks/delay_based_time_source.h @@ -76,7 +76,7 @@ class VIZ_COMMON_EXPORT DelayBasedTimeSource { base::TimeTicks last_tick_time_; base::TimeTicks next_tick_time_; - base::CancelableClosure tick_closure_; + base::CancelableOnceClosure tick_closure_; base::SingleThreadTaskRunner* task_runner_; diff --git a/chromium/components/viz/common/gl_helper_benchmark.cc b/chromium/components/viz/common/gl_helper_benchmark.cc index af88ea01838..ded755d9905 100644 --- a/chromium/components/viz/common/gl_helper_benchmark.cc +++ b/chromium/components/viz/common/gl_helper_benchmark.cc @@ -21,8 +21,8 @@ #include "base/at_exit.h" #include "base/command_line.h" #include "base/files/file_util.h" -#include "base/macros.h" #include "base/run_loop.h" +#include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/test/scoped_task_environment.h" #include "base/threading/thread_task_runner_handle.h" @@ -131,9 +131,9 @@ TEST_F(GLHelperBenchmark, ScaleBenchmark) { int input_sizes[] = {3200, 2040, 2560, 1476, // Pixel tab size 1920, 1080, 1280, 720, 800, 480, 256, 144}; - for (size_t q = 0; q < arraysize(kQualities); q++) { - for (size_t outsize = 0; outsize < arraysize(output_sizes); outsize += 2) { - for (size_t insize = 0; insize < arraysize(input_sizes); insize += 2) { + for (size_t q = 0; q < base::size(kQualities); q++) { + for (size_t outsize = 0; outsize < base::size(output_sizes); outsize += 2) { + for (size_t insize = 0; insize < base::size(input_sizes); insize += 2) { uint32_t src_texture; gl_->GenTextures(1, &src_texture); uint32_t dst_texture; diff --git a/chromium/components/viz/common/gl_helper_unittest.cc b/chromium/components/viz/common/gl_helper_unittest.cc index 1b671de5f4e..ae1bf518938 100644 --- a/chromium/components/viz/common/gl_helper_unittest.cc +++ b/chromium/components/viz/common/gl_helper_unittest.cc @@ -19,9 +19,9 @@ #include <vector> #include "base/bind.h" -#include "base/macros.h" #include "base/memory/ref_counted_memory.h" #include "base/run_loop.h" +#include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread_task_runner_handle.h" @@ -1333,20 +1333,20 @@ INSTANTIATE_TEST_CASE_P( , GLHelperPixelReadbackTest, ::testing::Combine( - ::testing::Range<unsigned int>(0, arraysize(kQualities)), - ::testing::Range<unsigned int>(0, arraysize(kRGBReadBackSizes)), - ::testing::Range<unsigned int>(0, arraysize(kRGBReadBackSizes)), - ::testing::Range<unsigned int>(0, arraysize(kRGBReadBackSizes)), - ::testing::Range<unsigned int>(0, arraysize(kRGBReadBackSizes)))); + ::testing::Range<unsigned int>(0, base::size(kQualities)), + ::testing::Range<unsigned int>(0, base::size(kRGBReadBackSizes)), + ::testing::Range<unsigned int>(0, base::size(kRGBReadBackSizes)), + ::testing::Range<unsigned int>(0, base::size(kRGBReadBackSizes)), + ::testing::Range<unsigned int>(0, base::size(kRGBReadBackSizes)))); // Validate that all scaling generates valid pipelines. TEST_F(GLHelperTest, ValidateScalerPipelines) { int sizes[] = {7, 99, 128, 256, 512, 719, 720, 721, 1920, 2011, 3217, 4096}; - for (size_t q = 0; q < arraysize(kQualities); q++) { - for (size_t x = 0; x < arraysize(sizes); x++) { - for (size_t y = 0; y < arraysize(sizes); y++) { - for (size_t dst_x = 0; dst_x < arraysize(sizes); dst_x++) { - for (size_t dst_y = 0; dst_y < arraysize(sizes); dst_y++) { + for (size_t q = 0; q < base::size(kQualities); q++) { + for (size_t x = 0; x < base::size(sizes); x++) { + for (size_t y = 0; y < base::size(sizes); y++) { + for (size_t dst_x = 0; dst_x < base::size(sizes); dst_x++) { + for (size_t dst_y = 0; dst_y < base::size(sizes); dst_y++) { TestScalerPipeline(q, sizes[x], sizes[y], sizes[dst_x], sizes[dst_y]); if (HasFailure()) { diff --git a/chromium/components/viz/common/gl_scaler.cc b/chromium/components/viz/common/gl_scaler.cc index befcb2cd479..417b83d412b 100644 --- a/chromium/components/viz/common/gl_scaler.cc +++ b/chromium/components/viz/common/gl_scaler.cc @@ -192,7 +192,7 @@ bool GLScaler::Configure(const Parameters& new_params) { scaling_color_space_ = params_.source_color_space; } else { // Use the source color space, but with a linear transfer function. - SkMatrix44 to_XYZD50; + skcms_Matrix3x3 to_XYZD50; params_.source_color_space.GetPrimaryMatrix(&to_XYZD50); std::tie(fn.fA, fn.fB, fn.fC, fn.fD, fn.fE, fn.fF, fn.fG) = kLinearFunction; diff --git a/chromium/components/viz/common/gpu/context_cache_controller.cc b/chromium/components/viz/common/gpu/context_cache_controller.cc index 6b27d149e10..a5906970ace 100644 --- a/chromium/components/viz/common/gpu/context_cache_controller.cc +++ b/chromium/components/viz/common/gpu/context_cache_controller.cc @@ -44,7 +44,10 @@ ContextCacheController::ContextCacheController( weak_ptr_ = weak_factory_.GetWeakPtr(); } -ContextCacheController::~ContextCacheController() = default; +ContextCacheController::~ContextCacheController() { + if (held_visibility_) + ClientBecameNotVisible(std::move(held_visibility_)); +} void ContextCacheController::SetGrContext(GrContext* gr_context) { gr_context_ = gr_context; @@ -90,6 +93,16 @@ void ContextCacheController::ClientBecameNotVisible( } } +void ContextCacheController::ClientBecameNotVisibleDuringShutdown( + std::unique_ptr<ScopedVisibility> scoped_visibility) { + // We only need to hold on to one visibility token, so free any others that + // come in. + if (!held_visibility_) + held_visibility_ = std::move(scoped_visibility); + else + ClientBecameNotVisible(std::move(scoped_visibility)); +} + std::unique_ptr<ContextCacheController::ScopedBusy> ContextCacheController::ClientBecameBusy() { if (context_lock_) diff --git a/chromium/components/viz/common/gpu/context_cache_controller.h b/chromium/components/viz/common/gpu/context_cache_controller.h index feea7f33b3d..5596c7d53ca 100644 --- a/chromium/components/viz/common/gpu/context_cache_controller.h +++ b/chromium/components/viz/common/gpu/context_cache_controller.h @@ -67,6 +67,12 @@ class VIZ_COMMON_EXPORT ContextCacheController { virtual void ClientBecameNotVisible( std::unique_ptr<ScopedVisibility> scoped_visibility); + // When a client becomes not visible because it is being deleted, hold on to + // the visibility token so that we don't aggressively free resources that are + // still going to be used. Instead, release the token when this is deleted. + virtual void ClientBecameNotVisibleDuringShutdown( + std::unique_ptr<ScopedVisibility> scoped_visibility); + // Clients of the owning ContextProvider may call this function when they // become busy. The returned ScopedBusy pointer must be passed back // to ClientBecameNotBusy or it will DCHECK in its destructor. @@ -85,6 +91,8 @@ class VIZ_COMMON_EXPORT ContextCacheController { scoped_refptr<base::SingleThreadTaskRunner> task_runner_; GrContext* gr_context_ = nullptr; + std::unique_ptr<ScopedVisibility> held_visibility_; + // If set, |context_lock_| must be held before accessing any member within // the idle callback. Exceptions to this are |current_idle_generation_|, // which has its own lock, and weak_ptr_ and task_runner_, which may be diff --git a/chromium/components/viz/common/gpu/context_cache_controller_unittest.cc b/chromium/components/viz/common/gpu/context_cache_controller_unittest.cc index 44a04c02c53..a2bd148e75d 100644 --- a/chromium/components/viz/common/gpu/context_cache_controller_unittest.cc +++ b/chromium/components/viz/common/gpu/context_cache_controller_unittest.cc @@ -55,6 +55,46 @@ TEST(ContextCacheControllerTest, ScopedVisibilityMulti) { cache_controller.ClientBecameNotVisible(std::move(visibility_2)); } +// Check that resources aren't freed during shutdown until the +// ContextCacheController is also deleted. +TEST(ContextCacheControllerTest, ScopedVisibilityDuringShutdown) { + StrictMock<MockContextSupport> context_support; + auto task_runner = base::MakeRefCounted<base::TestMockTimeTaskRunner>(); + std::unique_ptr<ContextCacheController> cache_controller = + std::make_unique<ContextCacheController>(&context_support, task_runner); + + EXPECT_CALL(context_support, SetAggressivelyFreeResources(false)); + std::unique_ptr<ContextCacheController::ScopedVisibility> visibility = + cache_controller->ClientBecameVisible(); + Mock::VerifyAndClearExpectations(&context_support); + + cache_controller->ClientBecameNotVisibleDuringShutdown(std::move(visibility)); + + EXPECT_CALL(context_support, SetAggressivelyFreeResources(true)); + cache_controller.reset(); +} + +// Check that multiple clients can shutdown successfully. +TEST(ContextCacheControllerTest, ScopedVisibilityDuringShutdownMulti) { + StrictMock<MockContextSupport> context_support; + auto task_runner = base::MakeRefCounted<base::TestMockTimeTaskRunner>(); + std::unique_ptr<ContextCacheController> cache_controller = + std::make_unique<ContextCacheController>(&context_support, task_runner); + + EXPECT_CALL(context_support, SetAggressivelyFreeResources(false)); + auto visibility_1 = cache_controller->ClientBecameVisible(); + Mock::VerifyAndClearExpectations(&context_support); + auto visibility_2 = cache_controller->ClientBecameVisible(); + + cache_controller->ClientBecameNotVisibleDuringShutdown( + std::move(visibility_1)); + cache_controller->ClientBecameNotVisibleDuringShutdown( + std::move(visibility_2)); + + EXPECT_CALL(context_support, SetAggressivelyFreeResources(true)); + cache_controller.reset(); +} + TEST(ContextCacheControllerTest, ScopedBusyWhileVisible) { StrictMock<MockContextSupport> context_support; auto task_runner = base::MakeRefCounted<base::TestMockTimeTaskRunner>(); diff --git a/chromium/components/viz/common/gpu/texture_allocation.cc b/chromium/components/viz/common/gpu/texture_allocation.cc deleted file mode 100644 index 646f0fa558c..00000000000 --- a/chromium/components/viz/common/gpu/texture_allocation.cc +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/viz/common/gpu/texture_allocation.h" - -#include "components/viz/common/resources/resource_format_utils.h" -#include "components/viz/common/resources/resource_sizes.h" -#include "gpu/GLES2/gl2extchromium.h" -#include "gpu/command_buffer/client/gles2_interface.h" -#include "gpu/command_buffer/client/raster_interface.h" -#include "gpu/command_buffer/common/capabilities.h" -#include "gpu/command_buffer/common/gpu_memory_buffer_support.h" -#include "ui/gfx/color_space.h" -#include "ui/gfx/geometry/size.h" - -namespace viz { - -// static -TextureAllocation TextureAllocation::MakeTextureId( - gpu::gles2::GLES2Interface* gl, - const gpu::Capabilities& caps, - ResourceFormat format, - bool use_gpu_memory_buffer_resources, - bool for_framebuffer_attachment) { - uint32_t texture_target = GL_TEXTURE_2D; - - bool overlay_candidate = use_gpu_memory_buffer_resources && - caps.texture_storage_image && - IsGpuMemoryBufferFormatSupported(format); - if (overlay_candidate) { - texture_target = gpu::GetBufferTextureTarget(gfx::BufferUsage::SCANOUT, - BufferFormat(format), caps); - } - - uint32_t texture_id; - gl->GenTextures(1, &texture_id); - gl->BindTexture(texture_target, texture_id); - gl->TexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - gl->TexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - gl->TexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - gl->TexParameteri(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - if (for_framebuffer_attachment && caps.texture_usage) { - // Set GL_FRAMEBUFFER_ATTACHMENT_ANGLE since we'll be binding these - // textures as a framebuffer for drawing directly to them on the gpu. - gl->TexParameteri(texture_target, GL_TEXTURE_USAGE_ANGLE, - GL_FRAMEBUFFER_ATTACHMENT_ANGLE); - } - gl->BindTexture(texture_target, 0); - return {texture_id, texture_target, overlay_candidate}; -} - -// static -void TextureAllocation::AllocateStorage(gpu::gles2::GLES2Interface* gl, - const gpu::Capabilities& caps, - ResourceFormat format, - const gfx::Size& size, - const TextureAllocation& alloc, - const gfx::ColorSpace& color_space) { - gl->BindTexture(alloc.texture_target, alloc.texture_id); - // Allocate backing storage for the texture. The best choice is to use - // GpuMemoryBuffers if we can use the texture as an overlay and its asked - // for by the caller. Else we try to make the texture have immutable - // storage, and finally fall back to standard storage if we must. - if (alloc.overlay_candidate) { - // |overlay_candidate| was only set when these were true, and - // |use_gpu_memory_buffer_resources| was specified by the caller. - DCHECK(caps.texture_storage_image); - DCHECK(IsGpuMemoryBufferFormatSupported(format)); - - gl->TexStorage2DImageCHROMIUM( - alloc.texture_target, TextureStorageFormat(format), GL_SCANOUT_CHROMIUM, - size.width(), size.height()); - if (color_space.IsValid()) { - gl->SetColorSpaceMetadataCHROMIUM( - alloc.texture_id, reinterpret_cast<GLColorSpace>( - const_cast<gfx::ColorSpace*>(&color_space))); - } - } else if (caps.texture_storage) { - gl->TexStorage2DEXT(alloc.texture_target, 1, TextureStorageFormat(format), - size.width(), size.height()); - } else { - gl->TexImage2D(alloc.texture_target, 0, GLInternalFormat(format), - size.width(), size.height(), 0, GLDataFormat(format), - GLDataType(format), nullptr); - } -} - -void TextureAllocation::UploadStorage(gpu::gles2::GLES2Interface* gl, - const gpu::Capabilities& caps, - ResourceFormat format, - const gfx::Size& size, - const TextureAllocation& alloc, - const gfx::ColorSpace& color_space, - const void* pixels) { - if (format == ETC1) { - DCHECK_EQ(alloc.texture_target, static_cast<GLenum>(GL_TEXTURE_2D)); - int num_bytes = ResourceSizes::CheckedSizeInBytes<int>(size, ETC1); - - gl->BindTexture(alloc.texture_target, alloc.texture_id); - gl->CompressedTexImage2D(alloc.texture_target, 0, GLInternalFormat(ETC1), - size.width(), size.height(), 0, num_bytes, - const_cast<void*>(pixels)); - } else { - AllocateStorage(gl, caps, format, size, alloc, color_space); - gl->TexSubImage2D(alloc.texture_target, 0, 0, 0, size.width(), - size.height(), GLDataFormat(format), GLDataType(format), - const_cast<void*>(pixels)); - } -} - -} // namespace viz diff --git a/chromium/components/viz/common/gpu/texture_allocation.h b/chromium/components/viz/common/gpu/texture_allocation.h deleted file mode 100644 index 9a4ac7e6615..00000000000 --- a/chromium/components/viz/common/gpu/texture_allocation.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_VIZ_COMMON_GPU_TEXTURE_ALLOCATION_H_ -#define COMPONENTS_VIZ_COMMON_GPU_TEXTURE_ALLOCATION_H_ - -#include "components/viz/common/resources/resource_format.h" -#include "components/viz/common/viz_common_export.h" -#include "third_party/khronos/GLES2/gl2.h" - -#include <stdint.h> - -namespace gfx { -class ColorSpace; -class Size; -} // namespace gfx - -namespace gpu { -struct Capabilities; -namespace gles2 { -class GLES2Interface; -} -} // namespace gpu - -namespace viz { - -class VIZ_COMMON_EXPORT TextureAllocation { - public: - GLuint texture_id = 0; - GLenum texture_target = 0; - bool overlay_candidate = false; - - // Generates a texture id and sets it up for use, but without any storage - // allocated pixels. - static TextureAllocation MakeTextureId(gpu::gles2::GLES2Interface* gl, - const gpu::Capabilities& caps, - ResourceFormat format, - bool use_gpu_memory_buffer_resources, - bool for_framebuffer_attachment); - - // Allocates the storage for a texture id previously from MakeTextureId(). - // Can be called on a different context, if the texture id is mapped to - // another context with a mailbox. The |format| should match the one given to - // MakeTextureId(). - static void AllocateStorage(gpu::gles2::GLES2Interface* gl, - const gpu::Capabilities& caps, - ResourceFormat format, - const gfx::Size& size, - const TextureAllocation& alloc, - const gfx::ColorSpace& color_space); - - // Allocates storage for a texture id previously generated by MakeTextureId(), - // and uploads the contents of |pixels| to it. |pixels| should point to a - // bitmap with a width and height of |size|, and no additional row stride - // padding. - static void UploadStorage(gpu::gles2::GLES2Interface* gl, - const gpu::Capabilities& caps, - ResourceFormat format, - const gfx::Size& size, - const TextureAllocation& alloc, - const gfx::ColorSpace& color_space, - const void* pixels); -}; - -} // namespace viz - -#endif // COMPONENTS_VIZ_COMMON_GPU_TEXTURE_ALLOCATION_H_ diff --git a/chromium/components/viz/common/gpu/vulkan_in_process_context_provider.cc b/chromium/components/viz/common/gpu/vulkan_in_process_context_provider.cc index 7dee33e3d68..74d4461fc77 100644 --- a/chromium/components/viz/common/gpu/vulkan_in_process_context_provider.cc +++ b/chromium/components/viz/common/gpu/vulkan_in_process_context_provider.cc @@ -44,21 +44,23 @@ bool VulkanInProcessContextProvider::Initialize() { } device_queue_ = std::move(device_queue); - const uint32_t feature_flags = kGeometryShader_GrVkFeatureFlag | - kDualSrcBlend_GrVkFeatureFlag | - kSampleRateShading_GrVkFeatureFlag; - const uint32_t extension_flags = - kEXT_debug_report_GrVkExtensionFlag | kKHR_surface_GrVkExtensionFlag | - kKHR_swapchain_GrVkExtensionFlag | kKHR_xcb_surface_GrVkExtensionFlag; GrVkBackendContext backend_context; backend_context.fInstance = device_queue_->GetVulkanInstance(); backend_context.fPhysicalDevice = device_queue_->GetVulkanPhysicalDevice(); backend_context.fDevice = device_queue_->GetVulkanDevice(); backend_context.fQueue = device_queue_->GetVulkanQueue(); backend_context.fGraphicsQueueIndex = device_queue_->GetVulkanQueueIndex(); - backend_context.fMinAPIVersion = VK_MAKE_VERSION(1, 0, 8); - backend_context.fExtensions = extension_flags; - backend_context.fFeatures = feature_flags; + + // gpu::VulkanInstance always initializes apiVersion=1.1. + // TODO(sergeyu): Extend VulkanImplementation interface to provide apiVersion + // and list of enabled extensions instead of hardcoding them here. + backend_context.fInstanceVersion = VK_MAKE_VERSION(1, 1, 0); + backend_context.fExtensions = + kEXT_debug_report_GrVkExtensionFlag | kKHR_surface_GrVkExtensionFlag | + kKHR_swapchain_GrVkExtensionFlag | kKHR_xcb_surface_GrVkExtensionFlag; + backend_context.fFeatures = kGeometryShader_GrVkFeatureFlag | + kDualSrcBlend_GrVkFeatureFlag | + kSampleRateShading_GrVkFeatureFlag; gpu::VulkanFunctionPointers* vulkan_function_pointers = gpu::GetVulkanFunctionPointers(); @@ -67,7 +69,8 @@ bool VulkanInProcessContextProvider::Initialize() { vulkan_function_pointers->vkGetDeviceProcAddrFn); backend_context.fOwnsInstanceAndDevice = false; gr_context_ = GrContext::MakeVulkan(backend_context); - return true; + + return gr_context_ != nullptr; } void VulkanInProcessContextProvider::Destroy() { diff --git a/chromium/components/viz/common/hit_test/hit_test_data_builder.cc b/chromium/components/viz/common/hit_test/hit_test_data_builder.cc new file mode 100644 index 00000000000..4751d12efc5 --- /dev/null +++ b/chromium/components/viz/common/hit_test/hit_test_data_builder.cc @@ -0,0 +1,114 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/viz/common/hit_test/hit_test_data_builder.h" + +#include "components/viz/common/quads/surface_draw_quad.h" + +namespace viz { + +// static +base::Optional<HitTestRegionList> HitTestDataBuilder::CreateHitTestData( + const CompositorFrame& compositor_frame, + bool root_accepts_events, + bool should_ask_for_child_region) { + base::Optional<HitTestRegionList> hit_test_region_list(base::in_place); + hit_test_region_list->flags = + (root_accepts_events ? HitTestRegionFlags::kHitTestMine + : HitTestRegionFlags::kHitTestIgnore) | + HitTestRegionFlags::kHitTestMouse | HitTestRegionFlags::kHitTestTouch; + hit_test_region_list->bounds.set_size(compositor_frame.size_in_pixels()); + AddHitTestDataFromRenderPass( + compositor_frame, compositor_frame.render_pass_list.back()->id, + &hit_test_region_list->regions, should_ask_for_child_region); + return hit_test_region_list; +} + +// static +const RenderPass* HitTestDataBuilder::GetRenderPassInFrame( + const CompositorFrame& frame, + RenderPassId render_pass_id) { + if (!render_pass_id) + return frame.render_pass_list.back().get(); + + for (const auto& render_pass : frame.render_pass_list) { + if (render_pass->id == render_pass_id) + return render_pass.get(); + } + + return nullptr; +} + +// static +void HitTestDataBuilder::AddHitTestDataFromRenderPass( + const CompositorFrame& frame, + RenderPassId render_pass_id, + std::vector<HitTestRegion>* regions, + bool should_ask_for_child_region) { + const RenderPass* render_pass = GetRenderPassInFrame(frame, render_pass_id); + if (!render_pass) + return; + + // Skip the render_pass if the transform is not invertible (i.e. it will not + // be able to receive events). + gfx::Transform transform_to_root_target = + render_pass->transform_to_root_target; + transform_to_root_target.FlattenTo2d(); + gfx::Transform transform_from_root_target; + if (!transform_to_root_target.GetInverse(&transform_from_root_target)) { + return; + } + + for (const DrawQuad* quad : render_pass->quad_list) { + if (quad->material == DrawQuad::SURFACE_CONTENT) { + const SurfaceDrawQuad* surface_quad = SurfaceDrawQuad::MaterialCast(quad); + + // Skip the quad if it has pointer-events:none set. + if (surface_quad->ignores_input_event) + continue; + + // Skip the quad if the FrameSinkId between fallback and primary is not + // the same, because we don't know which FrameSinkId would be used to + // draw this quad. + if (surface_quad->surface_range.start() && + surface_quad->surface_range.start()->frame_sink_id() != + surface_quad->surface_range.end().frame_sink_id()) { + continue; + } + + // Skip the quad if the transform is not invertible (i.e. it will not + // be able to receive events). + gfx::Transform quad_to_target_transform = + quad->shared_quad_state->quad_to_target_transform; + quad_to_target_transform.FlattenTo2d(); + gfx::Transform target_to_quad_transform; + if (!quad_to_target_transform.GetInverse(&target_to_quad_transform)) { + continue; + } + + regions->emplace_back(); + HitTestRegion* hit_test_region = ®ions->back(); + hit_test_region->frame_sink_id = + surface_quad->surface_range.end().frame_sink_id(); + hit_test_region->flags = HitTestRegionFlags::kHitTestMouse | + HitTestRegionFlags::kHitTestTouch | + HitTestRegionFlags::kHitTestChildSurface; + if (should_ask_for_child_region) { + hit_test_region->flags |= HitTestRegionFlags::kHitTestAsk; + hit_test_region->async_hit_test_reasons = + AsyncHitTestReasons::kUseDrawQuadData; + } + hit_test_region->rect = surface_quad->rect; + hit_test_region->transform = + target_to_quad_transform * transform_from_root_target; + } else if (quad->material == DrawQuad::RENDER_PASS) { + const RenderPassDrawQuad* render_quad = + RenderPassDrawQuad::MaterialCast(quad); + AddHitTestDataFromRenderPass(frame, render_quad->render_pass_id, regions, + should_ask_for_child_region); + } + } +} + +} // namespace viz diff --git a/chromium/components/viz/common/hit_test/hit_test_data_builder.h b/chromium/components/viz/common/hit_test/hit_test_data_builder.h new file mode 100644 index 00000000000..526101ed5ad --- /dev/null +++ b/chromium/components/viz/common/hit_test/hit_test_data_builder.h @@ -0,0 +1,39 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_VIZ_COMMON_HIT_TEST_HIT_TEST_DATA_BUILDER_H_ +#define COMPONENTS_VIZ_COMMON_HIT_TEST_HIT_TEST_DATA_BUILDER_H_ + +#include "base/macros.h" +#include "components/viz/common/hit_test/hit_test_region_list.h" +#include "components/viz/common/quads/compositor_frame.h" +#include "components/viz/common/quads/render_pass_draw_quad.h" +#include "components/viz/common/viz_common_export.h" + +namespace viz { + +// TODO(riajiang): Move this back to viz/client once DirectLayerTreeFrameSink +// no longer needs this. +class VIZ_COMMON_EXPORT HitTestDataBuilder { + public: + static base::Optional<HitTestRegionList> CreateHitTestData( + const CompositorFrame& frame, + bool root_accepts_events, + bool should_ask_for_child_region); + + private: + static const RenderPass* GetRenderPassInFrame(const CompositorFrame& frame, + RenderPassId render_pass_id); + + static void AddHitTestDataFromRenderPass(const CompositorFrame& frame, + RenderPassId render_pass_id, + std::vector<HitTestRegion>* regions, + bool should_ask_for_child_region); + + DISALLOW_COPY_AND_ASSIGN(HitTestDataBuilder); +}; + +} // namespace viz + +#endif // COMPONENTS_VIZ_COMMON_HIT_TEST_HIT_TEST_DATA_BUILDER_H_ diff --git a/chromium/components/viz/common/hit_test/hit_test_region_list.cc b/chromium/components/viz/common/hit_test/hit_test_region_list.cc index 62887c1b925..04fd6d9084b 100644 --- a/chromium/components/viz/common/hit_test/hit_test_region_list.cc +++ b/chromium/components/viz/common/hit_test/hit_test_region_list.cc @@ -9,7 +9,28 @@ namespace viz { HitTestRegionList::HitTestRegionList() = default; HitTestRegionList::~HitTestRegionList() = default; +HitTestRegionList::HitTestRegionList(const HitTestRegionList&) = default; +HitTestRegionList& HitTestRegionList::operator=(const HitTestRegionList&) = + default; + HitTestRegionList::HitTestRegionList(HitTestRegionList&&) = default; HitTestRegionList& HitTestRegionList::operator=(HitTestRegionList&&) = default; +bool HitTestRegionList::IsEqual(const HitTestRegionList& u, + const HitTestRegionList& v) { + // Simple checks first. + bool ret = u.flags == v.flags && u.bounds == v.bounds && + u.transform == v.transform && u.regions.size() == v.regions.size(); + if (!ret) + return false; + for (size_t i = u.regions.size(); i > 0 && ret; --i) + ret &= HitTestRegion::IsEqual(u.regions[i - 1], v.regions[i - 1]); + return ret; +} + +bool HitTestRegion::IsEqual(const HitTestRegion& u, const HitTestRegion& v) { + return u.flags == v.flags && u.frame_sink_id == v.frame_sink_id && + u.rect == v.rect && u.transform == v.transform; +} + } // namespace viz diff --git a/chromium/components/viz/common/hit_test/hit_test_region_list.h b/chromium/components/viz/common/hit_test/hit_test_region_list.h index 8011c16ce60..2a834a083bb 100644 --- a/chromium/components/viz/common/hit_test/hit_test_region_list.h +++ b/chromium/components/viz/common/hit_test/hit_test_region_list.h @@ -81,12 +81,17 @@ struct HitTestRegion { // defines the space occupied by this region in the coordinate space of // the embedder. gfx::Transform transform; + + static bool IsEqual(const HitTestRegion&, const HitTestRegion&); }; struct VIZ_COMMON_EXPORT HitTestRegionList { HitTestRegionList(); ~HitTestRegionList(); + HitTestRegionList(const HitTestRegionList&); + HitTestRegionList& operator=(const HitTestRegionList&); + HitTestRegionList(HitTestRegionList&&); HitTestRegionList& operator=(HitTestRegionList&&); @@ -105,6 +110,8 @@ struct VIZ_COMMON_EXPORT HitTestRegionList { // The list of sub-regions in front to back order. std::vector<HitTestRegion> regions; + + static bool IsEqual(const HitTestRegionList&, const HitTestRegionList&); }; } // namespace viz diff --git a/chromium/components/viz/common/quads/compositor_frame_metadata.h b/chromium/components/viz/common/quads/compositor_frame_metadata.h index d717b7a38cd..e2f3fbca24f 100644 --- a/chromium/components/viz/common/quads/compositor_frame_metadata.h +++ b/chromium/components/viz/common/quads/compositor_frame_metadata.h @@ -36,6 +36,20 @@ inline bool FrameTokenGT(uint32_t token1, uint32_t token2) { return (token2 - token1) > 0x80000000u; } +class VIZ_COMMON_EXPORT FrameTokenGenerator { + public: + inline uint32_t operator++() { + if (++frame_token_ == 0) + ++frame_token_; + return frame_token_; + } + + inline uint32_t operator*() const { return frame_token_; } + + private: + uint32_t frame_token_ = 0; +}; + class VIZ_COMMON_EXPORT CompositorFrameMetadata { public: CompositorFrameMetadata(); @@ -123,11 +137,6 @@ class VIZ_COMMON_EXPORT CompositorFrameMetadata { // wants to do something after a particular frame is processed. bool send_frame_token_to_embedder = false; - // Once the display compositor presents a frame with - // |request_presentation_feedback| flag turned on, a presentation feedback - // will be provided to CompositorFrameSinkClient. - bool request_presentation_feedback = false; - // These limits can be used together with the scroll/scale fields above to // determine if scrolling/scaling in a particular direction is possible. float min_page_scale_factor = 0.f; diff --git a/chromium/components/viz/common/quads/render_pass.cc b/chromium/components/viz/common/quads/render_pass.cc index 1720831d1b2..b432ad9e94a 100644 --- a/chromium/components/viz/common/quads/render_pass.cc +++ b/chromium/components/viz/common/quads/render_pass.cc @@ -110,8 +110,8 @@ std::unique_ptr<RenderPass> RenderPass::Copy(int new_id) const { std::unique_ptr<RenderPass> copy_pass( Create(shared_quad_state_list.size(), quad_list.size())); copy_pass->SetAll(new_id, output_rect, damage_rect, transform_to_root_target, - filters, backdrop_filters, color_space, - has_transparent_background, cache_render_pass, + filters, backdrop_filters, backdrop_filter_bounds, + color_space, has_transparent_background, cache_render_pass, has_damage_from_contributing_content, generate_mipmap); return copy_pass; } @@ -124,8 +124,8 @@ std::unique_ptr<RenderPass> RenderPass::DeepCopy() const { std::unique_ptr<RenderPass> copy_pass( Create(shared_quad_state_list.size(), quad_list.size())); copy_pass->SetAll(id, output_rect, damage_rect, transform_to_root_target, - filters, backdrop_filters, color_space, - has_transparent_background, cache_render_pass, + filters, backdrop_filters, backdrop_filter_bounds, + color_space, has_transparent_background, cache_render_pass, has_damage_from_contributing_content, generate_mipmap); if (shared_quad_state_list.empty()) { @@ -189,6 +189,7 @@ void RenderPass::SetAll(uint64_t id, const gfx::Transform& transform_to_root_target, const cc::FilterOperations& filters, const cc::FilterOperations& backdrop_filters, + const gfx::RectF& backdrop_filter_bounds, const gfx::ColorSpace& color_space, bool has_transparent_background, bool cache_render_pass, @@ -202,6 +203,7 @@ void RenderPass::SetAll(uint64_t id, this->transform_to_root_target = transform_to_root_target; this->filters = filters; this->backdrop_filters = backdrop_filters; + this->backdrop_filter_bounds = backdrop_filter_bounds; this->color_space = color_space; this->has_transparent_background = has_transparent_background; this->cache_render_pass = cache_render_pass; @@ -234,6 +236,9 @@ void RenderPass::AsValueInto(base::trace_event::TracedValue* value) const { backdrop_filters.AsValueInto(value); value->EndArray(); + cc::MathUtil::AddToTracedValue("backdrop_filter_bounds", + backdrop_filter_bounds, value); + value->BeginArray("shared_quad_state_list"); for (auto* shared_quad_state : shared_quad_state_list) { value->BeginDictionary(); diff --git a/chromium/components/viz/common/quads/render_pass.h b/chromium/components/viz/common/quads/render_pass.h index 904b0cfd116..b4f422630b6 100644 --- a/chromium/components/viz/common/quads/render_pass.h +++ b/chromium/components/viz/common/quads/render_pass.h @@ -91,6 +91,7 @@ class VIZ_COMMON_EXPORT RenderPass { const gfx::Transform& transform_to_root_target, const cc::FilterOperations& filters, const cc::FilterOperations& backdrop_filters, + const gfx::RectF& backdrop_filter_bounds, const gfx::ColorSpace& color_space, bool has_transparent_background, bool cache_render_pass, @@ -129,6 +130,9 @@ class VIZ_COMMON_EXPORT RenderPass { // backdrop of the render pass, from behind it. cc::FilterOperations backdrop_filters; + // Clipping bounds for backdrop filter. + gfx::RectF backdrop_filter_bounds; + // The color space into which content will be rendered for this render pass. gfx::ColorSpace color_space = gfx::ColorSpace::CreateSRGB(); diff --git a/chromium/components/viz/common/quads/render_pass_unittest.cc b/chromium/components/viz/common/quads/render_pass_unittest.cc index 34c754684b3..57e756f5c82 100644 --- a/chromium/components/viz/common/quads/render_pass_unittest.cc +++ b/chromium/components/viz/common/quads/render_pass_unittest.cc @@ -14,6 +14,7 @@ #include "components/viz/common/quads/solid_color_draw_quad.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/effects/SkBlurImageFilter.h" +#include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/transform.h" namespace viz { @@ -28,6 +29,7 @@ struct RenderPassSize { gfx::Transform transform_to_root_target; cc::FilterOperations filters; cc::FilterOperations backdrop_filters; + gfx::RectF backdrop_filter_bounds; gfx::ColorSpace color_space; bool has_transparent_background; bool generate_mipmap; @@ -50,6 +52,8 @@ static void CompareRenderPassLists(const RenderPassList& expected_list, EXPECT_EQ(expected->damage_rect, actual->damage_rect); EXPECT_EQ(expected->filters, actual->filters); EXPECT_EQ(expected->backdrop_filters, expected->backdrop_filters); + EXPECT_EQ(expected->backdrop_filter_bounds, + expected->backdrop_filter_bounds); EXPECT_EQ(expected->has_transparent_background, actual->has_transparent_background); EXPECT_EQ(expected->generate_mipmap, actual->generate_mipmap); @@ -78,6 +82,7 @@ TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { filters.Append(cc::FilterOperation::CreateOpacityFilter(0.5)); cc::FilterOperations backdrop_filters; backdrop_filters.Append(cc::FilterOperation::CreateInvertFilter(1.0)); + gfx::RectF backdrop_filter_bounds = gfx::RectF(10, 20, 130, 140); gfx::ColorSpace color_space = gfx::ColorSpace::CreateSRGB(); bool has_transparent_background = true; bool cache_render_pass = false; @@ -86,7 +91,7 @@ TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { std::unique_ptr<RenderPass> pass = RenderPass::Create(); pass->SetAll(render_pass_id, output_rect, damage_rect, transform_to_root, - filters, backdrop_filters, color_space, + filters, backdrop_filters, backdrop_filter_bounds, color_space, has_transparent_background, cache_render_pass, has_damage_from_contributing_content, generate_mipmap); pass->copy_requests.push_back(CopyOutputRequest::CreateStubForTesting()); @@ -109,6 +114,8 @@ TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { EXPECT_EQ(pass->damage_rect, copy->damage_rect); EXPECT_EQ(pass->filters, copy->filters); EXPECT_EQ(pass->backdrop_filters, copy->backdrop_filters); + EXPECT_EQ(gfx::ToNearestRect(pass->backdrop_filter_bounds), + gfx::ToNearestRect(copy->backdrop_filter_bounds)); EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); EXPECT_EQ(pass->generate_mipmap, copy->generate_mipmap); EXPECT_EQ(0u, copy->quad_list.size()); @@ -132,6 +139,7 @@ TEST(RenderPassTest, CopyAllShouldBeIdentical) { filters.Append(cc::FilterOperation::CreateOpacityFilter(0.5)); cc::FilterOperations backdrop_filters; backdrop_filters.Append(cc::FilterOperation::CreateInvertFilter(1.0)); + gfx::RectF backdrop_filter_bounds = gfx::RectF(10, 20, 130, 140); gfx::ColorSpace color_space = gfx::ColorSpace::CreateXYZD50(); bool has_transparent_background = true; bool cache_render_pass = false; @@ -140,9 +148,9 @@ TEST(RenderPassTest, CopyAllShouldBeIdentical) { std::unique_ptr<RenderPass> pass = RenderPass::Create(); pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, - backdrop_filters, color_space, has_transparent_background, - cache_render_pass, has_damage_from_contributing_content, - generate_mipmap); + backdrop_filters, backdrop_filter_bounds, color_space, + has_transparent_background, cache_render_pass, + has_damage_from_contributing_content, generate_mipmap); // Two quads using one shared state. SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); @@ -184,6 +192,7 @@ TEST(RenderPassTest, CopyAllShouldBeIdentical) { contrib_filters.Append(cc::FilterOperation::CreateSepiaFilter(0.5)); cc::FilterOperations contrib_backdrop_filters; contrib_backdrop_filters.Append(cc::FilterOperation::CreateSaturateFilter(1)); + gfx::RectF contrib_backdrop_filter_bounds = gfx::RectF(20, 30, 140, 150); gfx::ColorSpace contrib_color_space = gfx::ColorSpace::CreateSCRGBLinear(); bool contrib_has_transparent_background = true; bool contrib_cache_render_pass = false; @@ -191,12 +200,12 @@ TEST(RenderPassTest, CopyAllShouldBeIdentical) { bool contrib_generate_mipmap = false; std::unique_ptr<RenderPass> contrib = RenderPass::Create(); - contrib->SetAll(contrib_id, contrib_output_rect, contrib_damage_rect, - contrib_transform_to_root, contrib_filters, - contrib_backdrop_filters, contrib_color_space, - contrib_has_transparent_background, contrib_cache_render_pass, - contrib_has_damage_from_contributing_content, - contrib_generate_mipmap); + contrib->SetAll( + contrib_id, contrib_output_rect, contrib_damage_rect, + contrib_transform_to_root, contrib_filters, contrib_backdrop_filters, + contrib_backdrop_filter_bounds, contrib_color_space, + contrib_has_transparent_background, contrib_cache_render_pass, + contrib_has_damage_from_contributing_content, contrib_generate_mipmap); SharedQuadState* contrib_shared_state = contrib->CreateAndAppendSharedQuadState(); @@ -238,6 +247,7 @@ TEST(RenderPassTest, CopyAllWithCulledQuads) { filters.Append(cc::FilterOperation::CreateOpacityFilter(0.5)); cc::FilterOperations backdrop_filters; backdrop_filters.Append(cc::FilterOperation::CreateInvertFilter(1.0)); + gfx::RectF backdrop_filter_bounds = gfx::RectF(10, 20, 130, 140); gfx::ColorSpace color_space = gfx::ColorSpace::CreateSCRGBLinear(); bool has_transparent_background = true; bool cache_render_pass = false; @@ -246,9 +256,9 @@ TEST(RenderPassTest, CopyAllWithCulledQuads) { std::unique_ptr<RenderPass> pass = RenderPass::Create(); pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, - backdrop_filters, color_space, has_transparent_background, - cache_render_pass, has_damage_from_contributing_content, - generate_mipmap); + backdrop_filters, backdrop_filter_bounds, color_space, + has_transparent_background, cache_render_pass, + has_damage_from_contributing_content, generate_mipmap); // A shared state with a quad. SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); diff --git a/chromium/components/viz/common/resources/DEPS b/chromium/components/viz/common/resources/DEPS index 899f6b5280a..d6e39ea70d7 100644 --- a/chromium/components/viz/common/resources/DEPS +++ b/chromium/components/viz/common/resources/DEPS @@ -5,9 +5,11 @@ include_rules = [ # cc::MathUtil. Remove it once cc/base/math_util* are moved to viz. "+cc/base", "+gpu/command_buffer/common", + "+gpu/vulkan/buildflags.h", "+gpu/GLES2", "+mojo/public/cpp/system/buffer.h", "+mojo/public/cpp/system/platform_handle.h", "+third_party/khronos/GLES2", "+third_party/skia", + "+third_party/vulkan", ] diff --git a/chromium/components/viz/common/resources/resource_format_utils.cc b/chromium/components/viz/common/resources/resource_format_utils.cc index b0dd346129f..012c6171076 100644 --- a/chromium/components/viz/common/resources/resource_format_utils.cc +++ b/chromium/components/viz/common/resources/resource_format_utils.cc @@ -5,7 +5,7 @@ #include "components/viz/common/resources/resource_format_utils.h" #include "base/logging.h" -#include "base/macros.h" +#include "base/stl_util.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2ext.h" #include "ui/gfx/buffer_types.h" @@ -114,7 +114,7 @@ unsigned int GLDataType(ResourceFormat format) { GL_ZERO, // YUV_420_BIPLANAR GL_ZERO, // UYVY_422 }; - static_assert(arraysize(format_gl_data_type) == (RESOURCE_FORMAT_MAX + 1), + static_assert(base::size(format_gl_data_type) == (RESOURCE_FORMAT_MAX + 1), "format_gl_data_type does not handle all cases."); return format_gl_data_type[format]; @@ -123,28 +123,28 @@ unsigned int GLDataType(ResourceFormat format) { unsigned int GLDataFormat(ResourceFormat format) { DCHECK_LE(format, RESOURCE_FORMAT_MAX); static const GLenum format_gl_data_format[] = { - GL_RGBA, // RGBA_8888 - GL_RGBA, // RGBA_4444 - GL_BGRA_EXT, // BGRA_8888 - GL_ALPHA, // ALPHA_8 - GL_LUMINANCE, // LUMINANCE_8 - GL_RGB, // RGB_565 - GL_ZERO, // BGR_565 - GL_ETC1_RGB8_OES, // ETC1 - GL_RED_EXT, // RED_8 - GL_RG_EXT, // RG_88 - GL_LUMINANCE, // LUMINANCE_F16 - GL_RGBA, // RGBA_F16 - GL_RED_EXT, // R16_EXT - GL_RGB, // RGBX_8888 - GL_ZERO, // BGRX_8888 - GL_RGBA, // RGBX_1010102 - GL_ZERO, // BGRX_1010102 - GL_ZERO, // YVU_420 - GL_ZERO, // YUV_420_BIPLANAR - GL_ZERO, // UYVY_422 + GL_RGBA, // RGBA_8888 + GL_RGBA, // RGBA_4444 + GL_BGRA_EXT, // BGRA_8888 + GL_ALPHA, // ALPHA_8 + GL_LUMINANCE, // LUMINANCE_8 + GL_RGB, // RGB_565 + GL_ZERO, // BGR_565 + GL_RGB, // ETC1 + GL_RED_EXT, // RED_8 + GL_RG_EXT, // RG_88 + GL_LUMINANCE, // LUMINANCE_F16 + GL_RGBA, // RGBA_F16 + GL_RED_EXT, // R16_EXT + GL_RGB, // RGBX_8888 + GL_ZERO, // BGRX_8888 + GL_RGBA, // RGBX_1010102 + GL_ZERO, // BGRX_1010102 + GL_ZERO, // YVU_420 + GL_ZERO, // YUV_420_BIPLANAR + GL_ZERO, // UYVY_422 }; - static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1), + static_assert(base::size(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1), "format_gl_data_format does not handle all cases."); return format_gl_data_format[format]; @@ -159,6 +159,8 @@ unsigned int GLInternalFormat(ResourceFormat format) { return GL_R16_EXT; else if (format == RG_88) return GL_RG8_EXT; + else if (format == ETC1) + return GL_ETC1_RGB8_OES; return GLDataFormat(format); } @@ -194,7 +196,7 @@ unsigned int GLCopyTextureInternalFormat(ResourceFormat format) { GL_ZERO, // UYVY_422 }; - static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1), + static_assert(base::size(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1), "format_gl_data_format does not handle all cases."); return format_gl_data_format[format]; @@ -401,4 +403,47 @@ bool GLSupportsFormat(ResourceFormat format) { } } +#if BUILDFLAG(ENABLE_VULKAN) +VkFormat ToVkFormat(ResourceFormat format) { + switch (format) { + case RGBA_8888: + return VK_FORMAT_R8G8B8A8_UNORM; // or VK_FORMAT_R8G8B8A8_SRGB + case RGBA_4444: + return VK_FORMAT_R4G4B4A4_UNORM_PACK16; + case BGRA_8888: + return VK_FORMAT_B8G8R8A8_UNORM; + case RED_8: + return VK_FORMAT_R8_UNORM; + case RGB_565: + return VK_FORMAT_R5G6B5_UNORM_PACK16; + case BGR_565: + return VK_FORMAT_B5G6R5_UNORM_PACK16; + case RG_88: + return VK_FORMAT_R8G8_UNORM; + case RGBA_F16: + return VK_FORMAT_R16_SFLOAT; + case R16_EXT: + return VK_FORMAT_R16_UNORM; + case RGBX_8888: + return VK_FORMAT_R8G8B8_UNORM; + case BGRX_8888: + return VK_FORMAT_B8G8R8_UNORM; + case RGBX_1010102: + return VK_FORMAT_A2R10G10B10_UNORM_PACK32; + case BGRX_1010102: + return VK_FORMAT_A2B10G10R10_UNORM_PACK32; + case ALPHA_8: + case LUMINANCE_8: + case LUMINANCE_F16: + case YVU_420: + case YUV_420_BIPLANAR: + case UYVY_422: + case ETC1: + break; + } + NOTREACHED(); + return VK_FORMAT_UNDEFINED; +} +#endif + } // namespace viz diff --git a/chromium/components/viz/common/resources/resource_format_utils.h b/chromium/components/viz/common/resources/resource_format_utils.h index 1b7cf812d59..a4e354b3198 100644 --- a/chromium/components/viz/common/resources/resource_format_utils.h +++ b/chromium/components/viz/common/resources/resource_format_utils.h @@ -7,10 +7,15 @@ #include "components/viz/common/resources/resource_format.h" #include "components/viz/common/viz_resource_format_export.h" +#include "gpu/vulkan/buildflags.h" #include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/gpu/GrTypes.h" #include "ui/gfx/buffer_types.h" +#if BUILDFLAG(ENABLE_VULKAN) +#include "third_party/vulkan/include/vulkan/vulkan.h" +#endif + namespace viz { VIZ_RESOURCE_FORMAT_EXPORT SkColorType @@ -52,6 +57,10 @@ GetResourceFormat(gfx::BufferFormat format); VIZ_RESOURCE_FORMAT_EXPORT bool GLSupportsFormat(ResourceFormat format); +#if BUILDFLAG(ENABLE_VULKAN) +VIZ_RESOURCE_FORMAT_EXPORT VkFormat ToVkFormat(ResourceFormat format); +#endif + } // namespace viz #endif // COMPONENTS_VIZ_COMMON_RESOURCES_RESOURCE_FORMAT_UTILS_H_ diff --git a/chromium/components/viz/common/skia_helper.cc b/chromium/components/viz/common/skia_helper.cc index eef02030fe2..2228ca37349 100644 --- a/chromium/components/viz/common/skia_helper.cc +++ b/chromium/components/viz/common/skia_helper.cc @@ -9,7 +9,8 @@ #include "ui/gfx/skia_util.h" namespace viz { -sk_sp<SkImage> SkiaHelper::ApplyImageFilter(sk_sp<SkImage> src_image, +sk_sp<SkImage> SkiaHelper::ApplyImageFilter(GrContext* context, + sk_sp<SkImage> src_image, const gfx::RectF& src_rect, const gfx::RectF& dst_rect, const gfx::Vector2dF& scale, @@ -42,8 +43,8 @@ sk_sp<SkImage> SkiaHelper::ApplyImageFilter(sk_sp<SkImage> src_image, filter = filter->makeWithLocalMatrix(local_matrix); SkIRect in_subset = SkIRect::MakeWH(src_rect.width(), src_rect.height()); - sk_sp<SkImage> image = src_image->makeWithFilter(filter.get(), in_subset, - clip_bounds, subset, offset); + sk_sp<SkImage> image = src_image->makeWithFilter( + context, filter.get(), in_subset, clip_bounds, subset, offset); if (!image || !image->isTextureBacked()) { return nullptr; } diff --git a/chromium/components/viz/common/skia_helper.h b/chromium/components/viz/common/skia_helper.h index d4bab0ac620..8aefe8fcff9 100644 --- a/chromium/components/viz/common/skia_helper.h +++ b/chromium/components/viz/common/skia_helper.h @@ -17,7 +17,8 @@ namespace viz { class VIZ_COMMON_EXPORT SkiaHelper { public: // |flush| is necessary for GLRenderer but not SkiaRenderer. - static sk_sp<SkImage> ApplyImageFilter(sk_sp<SkImage> src_image, + static sk_sp<SkImage> ApplyImageFilter(GrContext* context, + sk_sp<SkImage> src_image, const gfx::RectF& src_rect, const gfx::RectF& dst_rect, const gfx::Vector2dF& scale, diff --git a/chromium/components/viz/common/surfaces/parent_local_surface_id_allocator.cc b/chromium/components/viz/common/surfaces/parent_local_surface_id_allocator.cc index 21c75555d8e..abe57aa4658 100644 --- a/chromium/components/viz/common/surfaces/parent_local_surface_id_allocator.cc +++ b/chromium/components/viz/common/surfaces/parent_local_surface_id_allocator.cc @@ -81,9 +81,9 @@ void ParentLocalSurfaceIdAllocator::Invalidate() { } void ParentLocalSurfaceIdAllocator::GenerateId() { - is_invalid_ = false; if (is_allocation_suppressed_) return; + is_invalid_ = false; ++current_local_surface_id_allocation_.local_surface_id_ .parent_sequence_number_; diff --git a/chromium/components/viz/common/yuv_readback_unittest.cc b/chromium/components/viz/common/yuv_readback_unittest.cc index 45b1adfa547..fa3ae47daaf 100644 --- a/chromium/components/viz/common/yuv_readback_unittest.cc +++ b/chromium/components/viz/common/yuv_readback_unittest.cc @@ -7,6 +7,7 @@ #include "base/json/json_reader.h" #include "base/memory/ref_counted_memory.h" #include "base/run_loop.h" +#include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" @@ -73,7 +74,7 @@ class YUVReadbackTest : public testing::Test { } static void TraceDataCB( - const base::Callback<void()>& callback, + base::OnceClosure quit_closure, std::string* output, const scoped_refptr<base::RefCountedString>& json_events_str, bool has_more_events) { @@ -82,7 +83,7 @@ class YUVReadbackTest : public testing::Test { } output->append(json_events_str->data()); if (!has_more_events) { - callback.Run(); + std::move(quit_closure).Run(); } } @@ -92,9 +93,9 @@ class YUVReadbackTest : public testing::Test { std::string json_data = "["; base::trace_event::TraceLog::GetInstance()->SetDisabled(); base::RunLoop run_loop; - base::trace_event::TraceLog::GetInstance()->Flush( - base::Bind(&YUVReadbackTest::TraceDataCB, run_loop.QuitClosure(), - base::Unretained(&json_data))); + base::trace_event::TraceLog::GetInstance()->Flush(base::BindRepeating( + &YUVReadbackTest::TraceDataCB, run_loop.QuitClosure(), + base::Unretained(&json_data))); run_loop.Run(); json_data.append("]"); @@ -256,11 +257,6 @@ class YUVReadbackTest : public testing::Test { return ret; } - static void callcallback(const base::Callback<void()>& callback, - bool result) { - callback.Run(); - } - void PrintPlane(unsigned char* plane, int xsize, int stride, int ysize) { for (int y = 0; y < std::min(24, ysize); y++) { std::string formatted; @@ -390,16 +386,20 @@ class YUVReadbackTest : public testing::Test { base::TimeDelta::FromSeconds(0)); base::RunLoop run_loop; - yuv_reader->ReadbackYUV(mailbox, sync_token, gfx::Size(xsize, ysize), - gfx::Rect(0, 0, xsize, ysize), - output_frame->stride(media::VideoFrame::kYPlane), - output_frame->data(media::VideoFrame::kYPlane), - output_frame->stride(media::VideoFrame::kUPlane), - output_frame->data(media::VideoFrame::kUPlane), - output_frame->stride(media::VideoFrame::kVPlane), - output_frame->data(media::VideoFrame::kVPlane), - gfx::Point(xmargin, ymargin), - base::Bind(&callcallback, run_loop.QuitClosure())); + auto run_quit_closure = [](base::OnceClosure quit_closure, bool result) { + std::move(quit_closure).Run(); + }; + yuv_reader->ReadbackYUV( + mailbox, sync_token, gfx::Size(xsize, ysize), + gfx::Rect(0, 0, xsize, ysize), + output_frame->stride(media::VideoFrame::kYPlane), + output_frame->data(media::VideoFrame::kYPlane), + output_frame->stride(media::VideoFrame::kUPlane), + output_frame->data(media::VideoFrame::kUPlane), + output_frame->stride(media::VideoFrame::kVPlane), + output_frame->data(media::VideoFrame::kVPlane), + gfx::Point(xmargin, ymargin), + base::BindOnce(run_quit_closure, run_loop.QuitClosure())); const gfx::Rect paste_rect(gfx::Point(xmargin, ymargin), gfx::Size(xsize, ysize)); @@ -523,8 +523,8 @@ TEST_P(YUVReadbackPixelTest, Test) { unsigned int x = std::get<2>(GetParam()); unsigned int y = std::get<3>(GetParam()); - for (unsigned int ox = x; ox < arraysize(kYUVReadbackSizes); ox++) { - for (unsigned int oy = y; oy < arraysize(kYUVReadbackSizes); oy++) { + for (unsigned int ox = x; ox < base::size(kYUVReadbackSizes); ox++) { + for (unsigned int oy = y; oy < base::size(kYUVReadbackSizes); oy++) { // If output is a subsection of the destination frame, (letterbox) // then try different variations of where the subsection goes. for (Margin xm = x < ox ? MarginLeft : MarginRight; xm <= MarginRight; @@ -555,8 +555,8 @@ INSTANTIATE_TEST_CASE_P( ::testing::Combine( ::testing::Bool(), ::testing::Bool(), - ::testing::Range<unsigned int>(0, arraysize(kYUVReadbackSizes)), - ::testing::Range<unsigned int>(0, arraysize(kYUVReadbackSizes)))); + ::testing::Range<unsigned int>(0, base::size(kYUVReadbackSizes)), + ::testing::Range<unsigned int>(0, base::size(kYUVReadbackSizes)))); } // namespace viz |