diff options
Diffstat (limited to 'chromium/services/viz')
24 files changed, 415 insertions, 61 deletions
diff --git a/chromium/services/viz/privileged/mojom/compositing/frame_sink_manager.mojom b/chromium/services/viz/privileged/mojom/compositing/frame_sink_manager.mojom index 6f0ab01e9dc..c7a8c1e6f02 100644 --- a/chromium/services/viz/privileged/mojom/compositing/frame_sink_manager.mojom +++ b/chromium/services/viz/privileged/mojom/compositing/frame_sink_manager.mojom @@ -41,7 +41,8 @@ struct RootCompositorFrameSinkParams { pending_associated_receiver<DisplayPrivate> display_private; pending_remote<DisplayClient> display_client; - associated ExternalBeginFrameController&? external_begin_frame_controller; + pending_associated_receiver<ExternalBeginFrameController>? + external_begin_frame_controller; }; // The FrameSinkManager interface is a privileged interface that allows the diff --git a/chromium/services/viz/privileged/mojom/gl/BUILD.gn b/chromium/services/viz/privileged/mojom/gl/BUILD.gn index da48d0ac4db..bfa92f2b682 100644 --- a/chromium/services/viz/privileged/mojom/gl/BUILD.gn +++ b/chromium/services/viz/privileged/mojom/gl/BUILD.gn @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import("//build/config/profiling/profiling.gni") +import("//build/config/sanitizers/sanitizers.gni") import("//mojo/public/tools/bindings/mojom.gni") mojom("gl") { @@ -36,8 +36,8 @@ mojom("gl") { enabled_features += [ "is_not_android" ] } - if (use_clang_profiling) { - enabled_features += [ "use_clang_profiling" ] + if (use_clang_profiling_inside_sandbox) { + enabled_features += [ "use_clang_profiling_inside_sandbox" ] } cpp_typemaps = [ diff --git a/chromium/services/viz/privileged/mojom/gl/gpu_host.mojom b/chromium/services/viz/privileged/mojom/gl/gpu_host.mojom index efb330eb26a..9d40a960ab3 100644 --- a/chromium/services/viz/privileged/mojom/gl/gpu_host.mojom +++ b/chromium/services/viz/privileged/mojom/gl/gpu_host.mojom @@ -41,6 +41,11 @@ interface GpuHost { [EnableIf=is_win] DidUpdateOverlayInfo(gpu.mojom.OverlayInfo overlay_info); + // Tells the GPU host that the HDR status has been updated in the GPU + // process. + [EnableIf=is_win] + DidUpdateHDRStatus(bool hdr_enabled); + // GPU process has decided to disable GPU compositing. Host process keeps // track of this decision in case the GPU process crashes. DisableGpuCompositing(); diff --git a/chromium/services/viz/privileged/mojom/gl/gpu_service.mojom b/chromium/services/viz/privileged/mojom/gl/gpu_service.mojom index 0d1cc4af4a1..5d6701aaca3 100644 --- a/chromium/services/viz/privileged/mojom/gl/gpu_service.mojom +++ b/chromium/services/viz/privileged/mojom/gl/gpu_service.mojom @@ -153,7 +153,7 @@ interface GpuService { // Write out the accumulated code profiling profile to the configured file. // The callback is invoked once the profile has been flushed to disk. - [EnableIf=use_clang_profiling] + [EnableIf=use_clang_profiling_inside_sandbox] WriteClangProfilingProfile() => (); Crash(); diff --git a/chromium/services/viz/privileged/mojom/gl/info_collection_gpu_service.mojom b/chromium/services/viz/privileged/mojom/gl/info_collection_gpu_service.mojom index 4757b5ccbf7..c58d6f4a56b 100644 --- a/chromium/services/viz/privileged/mojom/gl/info_collection_gpu_service.mojom +++ b/chromium/services/viz/privileged/mojom/gl/info_collection_gpu_service.mojom @@ -14,15 +14,19 @@ interface InfoCollectionGpuService { [EnableIf=is_win] RequestDxDiagNodeInfo() => (gpu.mojom.DxDiagNode dx_diagnostics); - // Requests Vulkan and DX12 supports and device performance info on Windows. - // Returning whether Vulkan and DX12 are supported, and if yes, the - // supported version/feature level, together with a few metrics related - // to the device's performance for about:gpu and histogram recording - // purpose. + // Requests DX12 version and device performance info on Windows. + // Returning whether DX12 are supported, and if yes, the supported feature + // level, together with a few metrics related to the device's performance for + // about:gpu and histogram recording purpose. // TODO(crbug.com/1028263): histograms need to be recorded at browser process // for now. [EnableIf=is_win] - GetGpuSupportedRuntimeVersionAndDevicePerfInfo() - => (gpu.mojom.Dx12VulkanVersionInfo dx12_vulkan_version_info, + GetGpuSupportedDx12VersionAndDevicePerfInfo() + => (uint32 d3d12_feature_level, gpu.mojom.DevicePerfInfo device_perf_info); + + // Requests Vulkan version + [EnableIf=is_win] + GetGpuSupportedVulkanVersionInfo() + => (uint32 vulkan_version); }; diff --git a/chromium/services/viz/public/cpp/BUILD.gn b/chromium/services/viz/public/cpp/BUILD.gn new file mode 100644 index 00000000000..f58553703c2 --- /dev/null +++ b/chromium/services/viz/public/cpp/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2020 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. + +source_set("crash_keys") { + sources = [ + "crash_keys.cc", + "crash_keys.h", + ] + + deps = [ + "//base", + "//components/crash/core//common:crash_key", + ] +} diff --git a/chromium/services/viz/public/cpp/DEPS b/chromium/services/viz/public/cpp/DEPS new file mode 100644 index 00000000000..90e574cf755 --- /dev/null +++ b/chromium/services/viz/public/cpp/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+components/crash/core/common/crash_key.h", +] diff --git a/chromium/services/viz/public/cpp/compositing/begin_frame_args_mojom_traits.cc b/chromium/services/viz/public/cpp/compositing/begin_frame_args_mojom_traits.cc index 84a31fba2b8..b36230af3f6 100644 --- a/chromium/services/viz/public/cpp/compositing/begin_frame_args_mojom_traits.cc +++ b/chromium/services/viz/public/cpp/compositing/begin_frame_args_mojom_traits.cc @@ -5,6 +5,7 @@ #include "services/viz/public/cpp/compositing/begin_frame_args_mojom_traits.h" #include "mojo/public/cpp/base/time_mojom_traits.h" +#include "services/viz/public/cpp/crash_keys.h" namespace mojo { @@ -64,8 +65,11 @@ bool StructTraits<viz::mojom::BeginFrameArgsDataView, viz::BeginFrameArgs>:: bool StructTraits<viz::mojom::BeginFrameAckDataView, viz::BeginFrameAck>::Read( viz::mojom::BeginFrameAckDataView data, viz::BeginFrameAck* out) { - if (data.sequence_number() < viz::BeginFrameArgs::kStartingFrameNumber) + if (data.sequence_number() < viz::BeginFrameArgs::kStartingFrameNumber) { + viz::SetDeserializationCrashKeyString( + "Invalid begin frame ack sequence number"); return false; + } out->frame_id.source_id = data.source_id(); out->frame_id.sequence_number = data.sequence_number(); out->trace_id = data.trace_id(); diff --git a/chromium/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.cc b/chromium/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.cc index 51a7f00f143..cb57ef4394f 100644 --- a/chromium/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.cc +++ b/chromium/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.cc @@ -8,6 +8,7 @@ #include "services/viz/public/cpp/compositing/begin_frame_args_mojom_traits.h" #include "services/viz/public/cpp/compositing/selection_mojom_traits.h" #include "services/viz/public/cpp/compositing/surface_id_mojom_traits.h" +#include "services/viz/public/cpp/crash_keys.h" #include "ui/gfx/mojom/display_color_spaces_mojom_traits.h" #include "ui/gfx/mojom/selection_bound_mojom_traits.h" #include "ui/latency/mojom/latency_info_mojom_traits.h" @@ -19,11 +20,14 @@ bool StructTraits<viz::mojom::CompositorFrameMetadataDataView, viz::CompositorFrameMetadata>:: Read(viz::mojom::CompositorFrameMetadataDataView data, viz::CompositorFrameMetadata* out) { - if (data.device_scale_factor() <= 0) + if (data.device_scale_factor() <= 0) { + viz::SetDeserializationCrashKeyString("Invalid device scale factor"); return false; + } out->device_scale_factor = data.device_scale_factor(); - if (!data.ReadRootScrollOffset(&out->root_scroll_offset)) + if (!data.ReadRootScrollOffset(&out->root_scroll_offset)) { return false; + } out->page_scale_factor = data.page_scale_factor(); if (!data.ReadScrollableViewportSize(&out->scrollable_viewport_size)) @@ -46,16 +50,23 @@ bool StructTraits<viz::mojom::CompositorFrameMetadataDataView, data.top_controls_visible_height()); } - return data.ReadLatencyInfo(&out->latency_info) && - data.ReadReferencedSurfaces(&out->referenced_surfaces) && - data.ReadDeadline(&out->deadline) && - data.ReadActivationDependencies(&out->activation_dependencies) && - data.ReadBeginFrameAck(&out->begin_frame_ack) && - data.ReadLocalSurfaceIdAllocationTime( - &out->local_surface_id_allocation_time) && - !out->local_surface_id_allocation_time.is_null() && - data.ReadPreferredFrameInterval(&out->preferred_frame_interval) && - data.ReadDisplayTransformHint(&out->display_transform_hint); + if (!data.ReadLatencyInfo(&out->latency_info) || + !data.ReadReferencedSurfaces(&out->referenced_surfaces) || + !data.ReadDeadline(&out->deadline) || + !data.ReadActivationDependencies(&out->activation_dependencies) || + !data.ReadBeginFrameAck(&out->begin_frame_ack) || + !data.ReadLocalSurfaceIdAllocationTime( + &out->local_surface_id_allocation_time)) { + return false; + } + if (out->local_surface_id_allocation_time.is_null()) { + viz::SetDeserializationCrashKeyString( + "Null local surface ID allocation time"); + return false; + } + return data.ReadPreferredFrameInterval(&out->preferred_frame_interval) && + data.ReadDisplayTransformHint(&out->display_transform_hint) && + data.ReadDelegatedInkMetadata(&out->delegated_ink_metadata); } } // namespace mojo diff --git a/chromium/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.h b/chromium/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.h index aa5464d8931..84f65fdb54e 100644 --- a/chromium/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.h +++ b/chromium/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.h @@ -10,6 +10,7 @@ #include "build/build_config.h" #include "components/viz/common/quads/compositor_frame_metadata.h" #include "services/viz/public/cpp/compositing/begin_frame_args_mojom_traits.h" +#include "services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.h" #include "services/viz/public/cpp/compositing/frame_deadline_mojom_traits.h" #include "services/viz/public/cpp/compositing/surface_range_mojom_traits.h" #include "services/viz/public/mojom/compositing/compositor_frame_metadata.mojom-shared.h" @@ -126,6 +127,11 @@ struct StructTraits<viz::mojom::CompositorFrameMetadataDataView, return metadata.display_transform_hint; } + static const std::unique_ptr<viz::DelegatedInkMetadata>& + delegated_ink_metadata(const viz::CompositorFrameMetadata& metadata) { + return metadata.delegated_ink_metadata; + } + static bool Read(viz::mojom::CompositorFrameMetadataDataView data, viz::CompositorFrameMetadata* out); }; diff --git a/chromium/services/viz/public/cpp/compositing/compositor_frame_mojom_traits.cc b/chromium/services/viz/public/cpp/compositing/compositor_frame_mojom_traits.cc index f3dc02f553f..20b9ad3d904 100644 --- a/chromium/services/viz/public/cpp/compositing/compositor_frame_mojom_traits.cc +++ b/chromium/services/viz/public/cpp/compositing/compositor_frame_mojom_traits.cc @@ -4,16 +4,37 @@ #include "services/viz/public/cpp/compositing/compositor_frame_mojom_traits.h" +#include "services/viz/public/cpp/crash_keys.h" + namespace mojo { // static bool StructTraits<viz::mojom::CompositorFrameDataView, viz::CompositorFrame>:: Read(viz::mojom::CompositorFrameDataView data, viz::CompositorFrame* out) { - return data.ReadPasses(&out->render_pass_list) && - !out->render_pass_list.empty() && - !out->render_pass_list.back()->output_rect.size().IsEmpty() && - data.ReadMetadata(&out->metadata) && - data.ReadResources(&out->resource_list); + if (!data.ReadPasses(&out->render_pass_list)) + return false; + + if (out->render_pass_list.empty()) { + viz::SetDeserializationCrashKeyString( + "CompositorFrame::render_pass_list empty"); + return false; + } + + if (out->render_pass_list.back()->output_rect.size().IsEmpty()) { + viz::SetDeserializationCrashKeyString("CompositorFrame empty"); + return false; + } + + if (!data.ReadMetadata(&out->metadata)) + return false; + + if (!data.ReadResources(&out->resource_list)) { + viz::SetDeserializationCrashKeyString( + "Failed read CompositorFrame::resource_list"); + return false; + } + + return true; } } // namespace mojo diff --git a/chromium/services/viz/public/cpp/compositing/copy_output_request_mojom_traits.cc b/chromium/services/viz/public/cpp/compositing/copy_output_request_mojom_traits.cc index 34c5039e218..af1dd74b8b3 100644 --- a/chromium/services/viz/public/cpp/compositing/copy_output_request_mojom_traits.cc +++ b/chromium/services/viz/public/cpp/compositing/copy_output_request_mojom_traits.cc @@ -7,10 +7,13 @@ #include <utility> #include "base/bind.h" +#include "base/task/task_traits.h" +#include "base/task/thread_pool.h" #include "base/trace_event/trace_event.h" #include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "services/viz/public/cpp/compositing/copy_output_result_mojom_traits.h" +#include "services/viz/public/cpp/crash_keys.h" namespace { @@ -22,17 +25,21 @@ class CopyOutputResultSenderImpl : public viz::mojom::CopyOutputResultSender { public: CopyOutputResultSenderImpl( viz::CopyOutputRequest::ResultFormat result_format, - viz::CopyOutputRequest::CopyOutputRequestCallback result_callback) + viz::CopyOutputRequest::CopyOutputRequestCallback result_callback, + scoped_refptr<base::SequencedTaskRunner> callback_task_runner) : result_format_(result_format), - result_callback_(std::move(result_callback)) { + result_callback_(std::move(result_callback)), + result_callback_task_runner_(std::move(callback_task_runner)) { DCHECK(result_callback_); + DCHECK(result_callback_task_runner_); } ~CopyOutputResultSenderImpl() override { if (result_callback_) { - std::move(result_callback_) - .Run(std::make_unique<viz::CopyOutputResult>(result_format_, - gfx::Rect())); + result_callback_task_runner_->PostTask( + FROM_HERE, base::BindOnce(std::move(result_callback_), + std::make_unique<viz::CopyOutputResult>( + result_format_, gfx::Rect()))); } } @@ -41,12 +48,15 @@ class CopyOutputResultSenderImpl : public viz::mojom::CopyOutputResultSender { TRACE_EVENT0("viz", "CopyOutputResultSenderImpl::SendResult"); if (!result_callback_) return; - std::move(result_callback_).Run(std::move(result)); + result_callback_task_runner_->PostTask( + FROM_HERE, + base::BindOnce(std::move(result_callback_), std::move(result))); } private: const viz::CopyOutputRequest::ResultFormat result_format_; viz::CopyOutputRequest::CopyOutputRequestCallback result_callback_; + scoped_refptr<base::SequencedTaskRunner> result_callback_task_runner_; }; void SendResult( @@ -68,10 +78,23 @@ StructTraits<viz::mojom::CopyOutputRequestDataView, std::unique_ptr<viz::CopyOutputRequest>>:: result_sender(const std::unique_ptr<viz::CopyOutputRequest>& request) { mojo::PendingRemote<viz::mojom::CopyOutputResultSender> result_sender; + auto pending_receiver = result_sender.InitWithNewPipeAndPassReceiver(); + // Receiving the result requires an expensive deserialize operation, so by + // default we want the pipe to operate on the ThreadPool, and then it will + // PostTask back to the current sequence. auto impl = std::make_unique<CopyOutputResultSenderImpl>( - request->result_format(), std::move(request->result_callback_)); - MakeSelfOwnedReceiver(std::move(impl), - result_sender.InitWithNewPipeAndPassReceiver()); + request->result_format(), std::move(request->result_callback_), + base::SequencedTaskRunnerHandle::Get()); + auto runner = base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()}); + runner->PostTask( + FROM_HERE, + base::BindOnce( + [](std::unique_ptr<CopyOutputResultSenderImpl> impl, + mojo::PendingReceiver<viz::mojom::CopyOutputResultSender> + receiver) { + MakeSelfOwnedReceiver(std::move(impl), std::move(receiver)); + }, + std::move(impl), std::move(pending_receiver))); return result_sender; } @@ -91,12 +114,25 @@ bool StructTraits<viz::mojom::CopyOutputRequestDataView, result_format, base::BindOnce(SendResult, std::move(result_sender))); gfx::Vector2d scale_from; - if (!data.ReadScaleFrom(&scale_from) || scale_from.x() <= 0 || - scale_from.y() <= 0) { + if (!data.ReadScaleFrom(&scale_from)) + return false; + if (scale_from.x() <= 0) { + viz::SetDeserializationCrashKeyString("Invalid readback scale from x"); + return false; + } + if (scale_from.y() <= 0) { + viz::SetDeserializationCrashKeyString("Invalid readback scale from y"); return false; } gfx::Vector2d scale_to; - if (!data.ReadScaleTo(&scale_to) || scale_to.x() <= 0 || scale_to.y() <= 0) { + if (!data.ReadScaleTo(&scale_to)) + return false; + if (scale_to.x() <= 0) { + viz::SetDeserializationCrashKeyString("Invalid readback scale to x"); + return false; + } + if (scale_to.y() <= 0) { + viz::SetDeserializationCrashKeyString("Invalid readback scale to y"); return false; } request->SetScaleRatio(scale_from, scale_to); diff --git a/chromium/services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.cc b/chromium/services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.cc new file mode 100644 index 00000000000..61657009295 --- /dev/null +++ b/chromium/services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.cc @@ -0,0 +1,33 @@ +// Copyright 2020 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 "services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.h" + +namespace mojo { + +// static +bool StructTraits<viz::mojom::DelegatedInkMetadataDataView, + std::unique_ptr<viz::DelegatedInkMetadata>>:: + Read(viz::mojom::DelegatedInkMetadataDataView data, + std::unique_ptr<viz::DelegatedInkMetadata>* out) { + // Diameter isn't expected to ever be below 0, so stop here if it is in order + // to avoid unexpected calculations in viz. + if (data.diameter() < 0) + return false; + + gfx::PointF point; + base::TimeTicks timestamp; + gfx::RectF presentation_area; + SkColor color; + if (!data.ReadPoint(&point) || !data.ReadTimestamp(×tamp) || + !data.ReadPresentationArea(&presentation_area) || + !data.ReadColor(&color)) { + return false; + } + *out = std::make_unique<viz::DelegatedInkMetadata>( + point, data.diameter(), color, timestamp, presentation_area); + return true; +} + +} // namespace mojo diff --git a/chromium/services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.h b/chromium/services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.h new file mode 100644 index 00000000000..bb452750ee3 --- /dev/null +++ b/chromium/services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.h @@ -0,0 +1,58 @@ +// Copyright 2020 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 SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_DELEGATED_INK_METADATA_MOJOM_TRAITS_H_ +#define SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_DELEGATED_INK_METADATA_MOJOM_TRAITS_H_ + +#include "components/viz/common/delegated_ink_metadata.h" +#include "mojo/public/cpp/base/time_mojom_traits.h" +#include "services/viz/public/mojom/compositing/delegated_ink_metadata.mojom-shared.h" +#include "skia/public/mojom/skcolor_mojom_traits.h" +#include "ui/gfx/mojom/rrect_f_mojom_traits.h" + +namespace mojo { + +template <> +struct StructTraits<viz::mojom::DelegatedInkMetadataDataView, + std::unique_ptr<viz::DelegatedInkMetadata>> { + static bool IsNull(const std::unique_ptr<viz::DelegatedInkMetadata>& input) { + return !input; + } + + static void SetToNull(std::unique_ptr<viz::DelegatedInkMetadata>* input) { + input->reset(); + } + + static gfx::PointF point( + const std::unique_ptr<viz::DelegatedInkMetadata>& input) { + return input->point(); + } + + static double diameter( + const std::unique_ptr<viz::DelegatedInkMetadata>& input) { + return input->diameter(); + } + + static SkColor color( + const std::unique_ptr<viz::DelegatedInkMetadata>& input) { + return input->color(); + } + + static base::TimeTicks timestamp( + const std::unique_ptr<viz::DelegatedInkMetadata>& input) { + return input->timestamp(); + } + + static gfx::RectF presentation_area( + const std::unique_ptr<viz::DelegatedInkMetadata>& input) { + return input->presentation_area(); + } + + static bool Read(viz::mojom::DelegatedInkMetadataDataView data, + std::unique_ptr<viz::DelegatedInkMetadata>* out); +}; + +} // namespace mojo + +#endif // SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_DELEGATED_INK_METADATA_MOJOM_TRAITS_H_ diff --git a/chromium/services/viz/public/cpp/compositing/quads_mojom_traits.cc b/chromium/services/viz/public/cpp/compositing/quads_mojom_traits.cc index 80f7b3cc82c..c99d11f218a 100644 --- a/chromium/services/viz/public/cpp/compositing/quads_mojom_traits.cc +++ b/chromium/services/viz/public/cpp/compositing/quads_mojom_traits.cc @@ -4,6 +4,7 @@ #include "services/viz/public/cpp/compositing/quads_mojom_traits.h" +#include "services/viz/public/cpp/crash_keys.h" #include "ui/gfx/mojom/color_space_mojom_traits.h" #include "ui/gfx/mojom/transform_mojom_traits.h" @@ -74,8 +75,10 @@ bool StructTraits<viz::mojom::RenderPassQuadStateDataView, viz::DrawQuad>::Read( quad->resources.count = data.mask_resource_id() ? 1 : 0; quad->render_pass_id = data.render_pass_id(); // RenderPass ids are never zero. - if (!quad->render_pass_id) + if (!quad->render_pass_id) { + viz::SetDeserializationCrashKeyString("Draw quad invalid render pass ID"); return false; + } if (!data.ReadMaskUvRect(&quad->mask_uv_rect) || !data.ReadMaskTextureSize(&quad->mask_texture_size) || !data.ReadFiltersScale(&quad->filters_scale) || @@ -213,8 +216,12 @@ bool StructTraits<viz::mojom::YUVVideoQuadStateDataView, viz::DrawQuad>::Read( quad->resource_offset = data.resource_offset(); quad->resource_multiplier = data.resource_multiplier(); quad->bits_per_channel = data.bits_per_channel(); - if (quad->bits_per_channel < viz::YUVVideoDrawQuad::kMinBitsPerChannel || - quad->bits_per_channel > viz::YUVVideoDrawQuad::kMaxBitsPerChannel) { + if (quad->bits_per_channel < viz::YUVVideoDrawQuad::kMinBitsPerChannel) { + viz::SetDeserializationCrashKeyString("Bits per channel too small"); + return false; + } + if (quad->bits_per_channel > viz::YUVVideoDrawQuad::kMaxBitsPerChannel) { + viz::SetDeserializationCrashKeyString("Bits per channel too big"); return false; } return true; @@ -227,11 +234,10 @@ bool StructTraits<viz::mojom::DrawQuadDataView, viz::DrawQuad>::Read( if (!data.ReadRect(&out->rect) || !data.ReadVisibleRect(&out->visible_rect)) { return false; } - // Reject quads with areas larger than int32. - if (!out->rect.size().GetCheckedArea().IsValid()) - return false; - if (!out->rect.Contains(out->visible_rect)) + if (!out->rect.Contains(out->visible_rect)) { + viz::SetDeserializationCrashKeyString("Rect does not contain visible rect"); return false; + } out->needs_blending = data.needs_blending(); return data.ReadDrawQuadState(out); diff --git a/chromium/services/viz/public/cpp/compositing/quads_mojom_traits.h b/chromium/services/viz/public/cpp/compositing/quads_mojom_traits.h index ea4d147a266..a690016318a 100644 --- a/chromium/services/viz/public/cpp/compositing/quads_mojom_traits.h +++ b/chromium/services/viz/public/cpp/compositing/quads_mojom_traits.h @@ -5,8 +5,9 @@ #ifndef SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_QUADS_MOJOM_TRAITS_H_ #define SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_QUADS_MOJOM_TRAITS_H_ +#include "base/check.h" #include "base/containers/span.h" -#include "base/logging.h" +#include "base/notreached.h" #include "base/unguessable_token.h" #include "components/viz/common/quads/debug_border_draw_quad.h" #include "components/viz/common/quads/picture_draw_quad.h" @@ -197,7 +198,7 @@ struct StructTraits<viz::mojom::DebugBorderQuadStateDataView, viz::DrawQuad> { template <> struct StructTraits<viz::mojom::RenderPassQuadStateDataView, viz::DrawQuad> { - static int32_t render_pass_id(const viz::DrawQuad& input) { + static uint64_t render_pass_id(const viz::DrawQuad& input) { const viz::RenderPassDrawQuad* quad = viz::RenderPassDrawQuad::MaterialCast(&input); DCHECK(quad->render_pass_id); diff --git a/chromium/services/viz/public/cpp/compositing/render_pass_mojom_traits.cc b/chromium/services/viz/public/cpp/compositing/render_pass_mojom_traits.cc index dc84c9b20fa..e704ba1005d 100644 --- a/chromium/services/viz/public/cpp/compositing/render_pass_mojom_traits.cc +++ b/chromium/services/viz/public/cpp/compositing/render_pass_mojom_traits.cc @@ -5,6 +5,7 @@ #include "services/viz/public/cpp/compositing/render_pass_mojom_traits.h" #include "base/numerics/safe_conversions.h" +#include "services/viz/public/cpp/crash_keys.h" #include "ui/gfx/mojom/display_color_spaces_mojom_traits.h" namespace mojo { @@ -27,8 +28,10 @@ bool StructTraits<viz::mojom::RenderPassDataView, } (*out)->id = data.id(); // RenderPass ids are never zero. - if (!(*out)->id) + if (!(*out)->id) { + viz::SetDeserializationCrashKeyString("Invalid render pass ID"); return false; + } (*out)->has_transparent_background = data.has_transparent_background(); (*out)->cache_render_pass = data.cache_render_pass(); (*out)->has_damage_from_contributing_content = @@ -46,8 +49,10 @@ bool StructTraits<viz::mojom::RenderPassDataView, viz::DrawQuad* quad = AllocateAndConstruct(quad_state_data_view.tag(), &(*out)->quad_list); - if (!quad) + if (!quad) { + viz::SetDeserializationCrashKeyString("AllocateAndConstruct quad failed"); return false; + } if (!quads.Read(i, quad)) return false; @@ -62,8 +67,10 @@ bool StructTraits<viz::mojom::RenderPassDataView, return false; } quad->shared_quad_state = last_sqs; - if (!quad->shared_quad_state) + if (!quad->shared_quad_state) { + viz::SetDeserializationCrashKeyString("No shared quad state"); return false; + } } return true; } diff --git a/chromium/services/viz/public/cpp/compositing/render_pass_mojom_traits.h b/chromium/services/viz/public/cpp/compositing/render_pass_mojom_traits.h index bd707618ccf..5284cff3816 100644 --- a/chromium/services/viz/public/cpp/compositing/render_pass_mojom_traits.h +++ b/chromium/services/viz/public/cpp/compositing/render_pass_mojom_traits.h @@ -6,8 +6,9 @@ #define SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_RENDER_PASS_MOJOM_TRAITS_H_ #include <memory> +#include <vector> -#include "base/logging.h" +#include "base/check.h" #include "components/viz/common/quads/render_pass.h" #include "services/viz/public/cpp/compositing/copy_output_request_mojom_traits.h" #include "services/viz/public/cpp/compositing/quads_mojom_traits.h" diff --git a/chromium/services/viz/public/cpp/crash_keys.cc b/chromium/services/viz/public/cpp/crash_keys.cc new file mode 100644 index 00000000000..ab79ea1928c --- /dev/null +++ b/chromium/services/viz/public/cpp/crash_keys.cc @@ -0,0 +1,16 @@ +// Copyright 2020 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 "services/viz/public/cpp/crash_keys.h" + +#include "components/crash/core/common/crash_key.h" + +namespace viz { + +void SetDeserializationCrashKeyString(base::StringPiece str) { + static crash_reporter::CrashKeyString<128> key("viz_deserialization"); + key.Set(str); +} + +} // namespace viz diff --git a/chromium/services/viz/public/cpp/crash_keys.h b/chromium/services/viz/public/cpp/crash_keys.h new file mode 100644 index 00000000000..55288103303 --- /dev/null +++ b/chromium/services/viz/public/cpp/crash_keys.h @@ -0,0 +1,18 @@ +// Copyright 2020 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 SERVICES_VIZ_PUBLIC_CPP_CRASH_KEYS_H_ +#define SERVICES_VIZ_PUBLIC_CPP_CRASH_KEYS_H_ + +#include "base/strings/string_piece.h" + +namespace viz { + +// Sets a crash key to indicate what structure triggered a deserialization error +// in viz mojom code. +void SetDeserializationCrashKeyString(base::StringPiece str); + +} // namespace viz + +#endif // SERVICES_VIZ_PUBLIC_CPP_CRASH_KEYS_H_ diff --git a/chromium/services/viz/public/cpp/hit_test/hit_test_region_list_mojom_traits.cc b/chromium/services/viz/public/cpp/hit_test/hit_test_region_list_mojom_traits.cc index a15ba4b4490..74a0fe44ebf 100644 --- a/chromium/services/viz/public/cpp/hit_test/hit_test_region_list_mojom_traits.cc +++ b/chromium/services/viz/public/cpp/hit_test/hit_test_region_list_mojom_traits.cc @@ -4,18 +4,28 @@ #include "services/viz/public/cpp/hit_test/hit_test_region_list_mojom_traits.h" +#include "services/viz/public/cpp/crash_keys.h" + namespace mojo { // static bool StructTraits<viz::mojom::HitTestRegionDataView, viz::HitTestRegion>::Read( viz::mojom::HitTestRegionDataView data, viz::HitTestRegion* out) { - if (!data.ReadFrameSinkId(&out->frame_sink_id)) + if (!data.ReadFrameSinkId(&out->frame_sink_id)) { + viz::SetDeserializationCrashKeyString( + "Failed read HitTestRegion::frame_sink_id"); return false; - if (!data.ReadRect(&out->rect)) + } + if (!data.ReadRect(&out->rect)) { + viz::SetDeserializationCrashKeyString("Failed read HitTestRegion::rect"); return false; - if (!data.ReadTransform(&out->transform)) + } + if (!data.ReadTransform(&out->transform)) { + viz::SetDeserializationCrashKeyString( + "Failed read HitTestRegion::transform"); return false; + } out->flags = data.flags(); out->async_hit_test_reasons = data.async_hit_test_reasons(); return true; @@ -28,10 +38,16 @@ bool StructTraits< viz::HitTestRegionList* out) { if (!data.ReadRegions(&out->regions)) return false; - if (!data.ReadBounds(&out->bounds)) + if (!data.ReadBounds(&out->bounds)) { + viz::SetDeserializationCrashKeyString( + "Failed read HitTestRegionList::bounds"); return false; - if (!data.ReadTransform(&out->transform)) + } + if (!data.ReadTransform(&out->transform)) { + viz::SetDeserializationCrashKeyString( + "Failed read HitTestRegionList::transform"); return false; + } out->flags = data.flags(); out->async_hit_test_reasons = data.async_hit_test_reasons(); return true; diff --git a/chromium/services/viz/public/mojom/BUILD.gn b/chromium/services/viz/public/mojom/BUILD.gn index 75ef138eab8..d6d676deaba 100644 --- a/chromium/services/viz/public/mojom/BUILD.gn +++ b/chromium/services/viz/public/mojom/BUILD.gn @@ -15,6 +15,7 @@ mojom("mojom") { "compositing/compositor_frame_sink.mojom", "compositing/copy_output_request.mojom", "compositing/copy_output_result.mojom", + "compositing/delegated_ink_metadata.mojom", "compositing/filter_operation.mojom", "compositing/filter_operations.mojom", "compositing/frame_deadline.mojom", @@ -178,7 +179,10 @@ mojom("mojom") { traits_private_headers = [ "//services/viz/public/cpp/compositing/compositor_frame_mojom_traits.h", ] - traits_public_deps = [ "//components/viz/common" ] + traits_public_deps = [ + "//components/viz/common", + "//services/viz/public/cpp:crash_keys", + ] }, { types = [ @@ -223,6 +227,19 @@ mojom("mojom") { { types = [ { + mojom = "viz.mojom.DelegatedInkMetadata" + cpp = "::std::unique_ptr<::viz::DelegatedInkMetadata>" + move_only = true + nullable_is_same_type = true + }, + ] + traits_sources = [ "//services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.cc" ] + traits_headers = [ "//services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.h" ] + traits_public_deps = [ "//components/viz/common" ] + }, + { + types = [ + { mojom = "viz.mojom.FilterOperation" cpp = "::cc::FilterOperation" }, @@ -285,6 +302,7 @@ mojom("mojom") { traits_sources = [ "//services/viz/public/cpp/hit_test/hit_test_region_list_mojom_traits.cc" ] traits_public_deps = [ "//components/viz/common", + "//services/viz/public/cpp:crash_keys", "//ui/gfx/geometry/mojom", ] }, @@ -435,6 +453,46 @@ mojom("mojom") { { types = [ { + mojom = "viz.mojom.HitTestRegion" + cpp = "::viz::HitTestRegion" + }, + { + mojom = "viz.mojom.HitTestRegionList" + cpp = "::viz::HitTestRegionList" + move_only = true + }, + ] + traits_headers = [ "//services/viz/public/cpp/hit_test/hit_test_region_list_mojom_traits.h" ] + traits_public_deps = [ + "//components/viz/common", + "//services/viz/public/cpp:crash_keys", + "//ui/gfx/geometry/mojom", + ] + }, + { + types = [ + { + mojom = "viz.mojom.CompositorFrameMetadata" + cpp = "::viz::CompositorFrameMetadata" + move_only = true + }, + ] + traits_headers = [ "//services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.h" ] + traits_public_deps = [ "//components/viz/common" ] + }, + { + types = [ + { + mojom = "viz.mojom.FrameTimingDetails" + cpp = "::viz::FrameTimingDetails" + }, + ] + traits_headers = [ "//services/viz/public/cpp/compositing/frame_timing_details_mojom_traits.h" ] + traits_public_deps = [ "//components/viz/common" ] + }, + { + types = [ + { mojom = "viz.mojom.CompositorFrame" cpp = "::viz::CompositorFrame" move_only = true diff --git a/chromium/services/viz/public/mojom/compositing/compositor_frame_metadata.mojom b/chromium/services/viz/public/mojom/compositing/compositor_frame_metadata.mojom index 244e8225160..3f3e203607e 100644 --- a/chromium/services/viz/public/mojom/compositing/compositor_frame_metadata.mojom +++ b/chromium/services/viz/public/mojom/compositing/compositor_frame_metadata.mojom @@ -6,6 +6,7 @@ module viz.mojom; import "mojo/public/mojom/base/time.mojom"; import "services/viz/public/mojom/compositing/begin_frame_args.mojom"; +import "services/viz/public/mojom/compositing/delegated_ink_metadata.mojom"; import "services/viz/public/mojom/compositing/frame_deadline.mojom"; import "services/viz/public/mojom/compositing/selection.mojom"; import "services/viz/public/mojom/compositing/surface_id.mojom"; @@ -16,6 +17,8 @@ import "ui/gfx/mojom/overlay_transform.mojom"; import "ui/latency/mojom/latency_info.mojom"; // See components/viz/service/quads/compositor_frame_metadata.h. +// This is sent from viz clients such as the browser and renderer to the viz +// compositor in the GPU process. struct CompositorFrameMetadata { float device_scale_factor; gfx.mojom.Vector2dF root_scroll_offset; @@ -47,4 +50,17 @@ struct CompositorFrameMetadata { mojo_base.mojom.TimeDelta? preferred_frame_interval; gfx.mojom.OverlayTransform display_transform_hint; + + // Contains the metadata required for drawing a delegated ink trail onto the + // end of a rendered ink stroke. This should only be present when two + // conditions are met: + // 1. The JS API |updateInkTrailStartPoint| is used - This gathers the + // metadata and puts it onto a compositor frame to be sent to viz. + // 2. This frame will not be submitted to the root surface - The browser UI + // does not use this, and the frame must be contained within a + // SurfaceDrawQuad. + // The ink trail created with this metadata will only last for a single frame + // before it disappears, regardless of whether or not the next frame contains + // delegated ink metadata. + DelegatedInkMetadata? delegated_ink_metadata; }; diff --git a/chromium/services/viz/public/mojom/compositing/delegated_ink_metadata.mojom b/chromium/services/viz/public/mojom/compositing/delegated_ink_metadata.mojom new file mode 100644 index 00000000000..89843b27ddb --- /dev/null +++ b/chromium/services/viz/public/mojom/compositing/delegated_ink_metadata.mojom @@ -0,0 +1,18 @@ +// Copyright 2020 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. + +module viz.mojom; + +import "mojo/public/mojom/base/time.mojom"; +import "skia/public/mojom/skcolor.mojom"; +import "ui/gfx/geometry/mojom/geometry.mojom"; + +// See components/viz/common/delegated_ink_metadata.h. +struct DelegatedInkMetadata { + gfx.mojom.PointF point; + double diameter; + skia.mojom.SkColor color; + mojo_base.mojom.TimeTicks timestamp; + gfx.mojom.RectF presentation_area; +}; |