Commit f190dbab authored by Mario Bianucci's avatar Mario Bianucci Committed by Commit Bot

Forward delegated ink point from browser to viz

Start forwarding points from the browser process directly to viz via the
UI compositor when delegated ink trails are being drawn. This CL gets
the point to Display, the next CL will start storing the points and
using them as they arrive.

This CL only supports aura, follow up CLs will add support for Android
and Mac.

Bug: 1052145
Change-Id: Ic36d45bd960d358ececaf0312ce801da33686966
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2259015Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarJonathan Ross <jonross@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Reviewed-by: default avatarDaniel Libby <dlibby@microsoft.com>
Commit-Queue: Mario Bianucci <mabian@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#792419}
parent 8660836a
...@@ -144,6 +144,8 @@ viz_component("common") { ...@@ -144,6 +144,8 @@ viz_component("common") {
"constants.h", "constants.h",
"delegated_ink_metadata.cc", "delegated_ink_metadata.cc",
"delegated_ink_metadata.h", "delegated_ink_metadata.h",
"delegated_ink_point.cc",
"delegated_ink_point.h",
"display/de_jelly.cc", "display/de_jelly.cc",
"display/de_jelly.h", "display/de_jelly.h",
"display/overlay_strategy.cc", "display/overlay_strategy.cc",
......
// 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 "components/viz/common/delegated_ink_point.h"
#include <inttypes.h>
#include "base/strings/stringprintf.h"
namespace viz {
std::string DelegatedInkPoint::ToString() const {
return base::StringPrintf("point: %s, timestamp: %" PRId64,
point_.ToString().c_str(),
timestamp_.since_origin().InMicroseconds());
}
} // namespace viz
// 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 COMPONENTS_VIZ_COMMON_DELEGATED_INK_POINT_H_
#define COMPONENTS_VIZ_COMMON_DELEGATED_INK_POINT_H_
#include <string>
#include "base/time/time.h"
#include "components/viz/common/viz_common_export.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "ui/gfx/geometry/point_f.h"
namespace viz {
namespace mojom {
class DelegatedInkPointDataView;
} // namespace mojom
// This class stores the information required to draw a single point of a
// delegated ink trail. When the WebAPI |updateInkTrailStartPoint| is called,
// the renderer requests that the browser begin sending these to viz. Viz
// will collect them, and then during |DrawAndSwap| will use the
// DelegatedInkPoints that have arrived from the browser along with the
// DelegatedInkMetadata that the renderer sent to draw a delegated ink trail on
// the screen, connected to the end of the already rendered ink stroke.
//
// Explainer for the feature:
// https://github.com/WICG/ink-enhancement/blob/master/README.md
class VIZ_COMMON_EXPORT DelegatedInkPoint {
public:
DelegatedInkPoint() = default;
DelegatedInkPoint(const gfx::PointF& pt, base::TimeTicks timestamp)
: point_(pt), timestamp_(timestamp) {}
const gfx::PointF& point() const { return point_; }
base::TimeTicks timestamp() const { return timestamp_; }
std::string ToString() const;
private:
friend struct mojo::StructTraits<mojom::DelegatedInkPointDataView,
DelegatedInkPoint>;
// Location of the input event relative to the root window in device pixels.
// Scale is device scale factor at time of input.
gfx::PointF point_;
// Timestamp from the input event.
base::TimeTicks timestamp_;
};
} // namespace viz
#endif // COMPONENTS_VIZ_COMMON_DELEGATED_INK_POINT_H_
...@@ -20,6 +20,8 @@ viz_component("service") { ...@@ -20,6 +20,8 @@ viz_component("service") {
"display/bsp_walk_action.h", "display/bsp_walk_action.h",
"display/damage_frame_annotator.cc", "display/damage_frame_annotator.cc",
"display/damage_frame_annotator.h", "display/damage_frame_annotator.h",
"display/delegated_ink_point_renderer.cc",
"display/delegated_ink_point_renderer.h",
"display/direct_renderer.cc", "display/direct_renderer.cc",
"display/direct_renderer.h", "display/direct_renderer.h",
"display/display.cc", "display/display.cc",
......
...@@ -64,4 +64,7 @@ specific_include_rules = { ...@@ -64,4 +64,7 @@ specific_include_rules = {
"+third_party/libyuv", "+third_party/libyuv",
"+ui/gl/gl_implementation.h", "+ui/gl/gl_implementation.h",
], ],
"delegated_ink_point_renderer\.*" : [
"+mojo/public/cpp/bindings",
],
} }
// 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 "components/viz/service/display/delegated_ink_point_renderer.h"
#include <utility>
#include "base/trace_event/trace_event.h"
namespace viz {
DelegatedInkPointRendererImpl::DelegatedInkPointRendererImpl(
mojo::PendingReceiver<mojom::DelegatedInkPointRenderer> receiver)
: receiver_(this, std::move(receiver)) {}
DelegatedInkPointRendererImpl::~DelegatedInkPointRendererImpl() = default;
void DelegatedInkPointRendererImpl::StoreDelegatedInkPoint(
const DelegatedInkPoint& point) {
TRACE_EVENT_INSTANT1(
"viz",
"DelegatedInkPointRendererImpl::StoreDelegatedInkPoint - "
"Point arrived in viz",
TRACE_EVENT_SCOPE_THREAD, "point", point.ToString());
// TODO(1052145): Start storing these points in something to be used during
// |Display::DrawAndSwap()| to draw the delegated ink trail. These points will
// need to be cleared when |device_scale_factor_| changes.
}
} // namespace viz
// 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 COMPONENTS_VIZ_SERVICE_DISPLAY_DELEGATED_INK_POINT_RENDERER_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_DELEGATED_INK_POINT_RENDERER_H_
#include "components/viz/service/viz_service_export.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "services/viz/public/mojom/compositing/delegated_ink_point.mojom.h"
namespace viz {
// This class is used for rendering delegated ink trails on the end of strokes
// to reduce user perceived latency. On initialization, it binds the mojo
// interface required for receiving delegated ink points that are made and sent
// from the browser process.
// TODO(1052145): Expand on this comment as more functionality is added to this
// function - it will ultimately be where the rendering actually occurs.
//
// For more information on the feature, please see the explainer:
// https://github.com/WICG/ink-enhancement/blob/master/README.md
class VIZ_SERVICE_EXPORT DelegatedInkPointRendererImpl
: public mojom::DelegatedInkPointRenderer {
public:
explicit DelegatedInkPointRendererImpl(
mojo::PendingReceiver<mojom::DelegatedInkPointRenderer> receiver);
~DelegatedInkPointRendererImpl() override;
DelegatedInkPointRendererImpl(const DelegatedInkPointRendererImpl&) = delete;
DelegatedInkPointRendererImpl& operator=(
const DelegatedInkPointRendererImpl&) = delete;
void StoreDelegatedInkPoint(const DelegatedInkPoint& point) override;
private:
mojo::Receiver<mojom::DelegatedInkPointRenderer> receiver_;
};
} // namespace viz
#endif // COMPONENTS_VIZ_SERVICE_DISPLAY_DELEGATED_INK_POINT_RENDERER_H_
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define COMPONENTS_VIZ_SERVICE_DISPLAY_DISPLAY_H_ #define COMPONENTS_VIZ_SERVICE_DISPLAY_DISPLAY_H_
#include <memory> #include <memory>
#include <utility>
#include <vector> #include <vector>
#include "base/containers/circular_deque.h" #include "base/containers/circular_deque.h"
...@@ -19,6 +20,7 @@ ...@@ -19,6 +20,7 @@
#include "components/viz/common/resources/returned_resource.h" #include "components/viz/common/resources/returned_resource.h"
#include "components/viz/common/surfaces/frame_sink_id.h" #include "components/viz/common/surfaces/frame_sink_id.h"
#include "components/viz/common/surfaces/surface_id.h" #include "components/viz/common/surfaces/surface_id.h"
#include "components/viz/service/display/delegated_ink_point_renderer.h"
#include "components/viz/service/display/display_resource_provider.h" #include "components/viz/service/display/display_resource_provider.h"
#include "components/viz/service/display/display_scheduler.h" #include "components/viz/service/display/display_scheduler.h"
#include "components/viz/service/display/frame_rate_decider.h" #include "components/viz/service/display/frame_rate_decider.h"
...@@ -183,6 +185,14 @@ class VIZ_SERVICE_EXPORT Display : public DisplaySchedulerClient, ...@@ -183,6 +185,14 @@ class VIZ_SERVICE_EXPORT Display : public DisplaySchedulerClient,
bool IsRootFrameMissing() const; bool IsRootFrameMissing() const;
bool HasPendingSurfaces(const BeginFrameArgs& args) const; bool HasPendingSurfaces(const BeginFrameArgs& args) const;
// Set the delegated ink renderer, which will be responsible for rendering
// the delegated ink trails. This should only be called when the delegated
// ink trails feature is being used.
void set_delegated_ink_point_renderer(
std::unique_ptr<DelegatedInkPointRendererImpl> ink_renderer) {
delegated_ink_point_renderer_ = std::move(ink_renderer);
}
private: private:
friend class DisplayTest; friend class DisplayTest;
// PresentationGroupTiming stores rendering pipeline stage timings associated // PresentationGroupTiming stores rendering pipeline stage timings associated
...@@ -286,6 +296,10 @@ class VIZ_SERVICE_EXPORT Display : public DisplaySchedulerClient, ...@@ -286,6 +296,10 @@ class VIZ_SERVICE_EXPORT Display : public DisplaySchedulerClient,
// The height of the top-controls in the previously drawn frame. // The height of the top-controls in the previously drawn frame.
float last_top_controls_visible_height_ = 0.f; float last_top_controls_visible_height_ = 0.f;
// The renderer responsible for drawing delegated ink trails to the screen
// before swapping the buffers in DrawAndSwap().
std::unique_ptr<DelegatedInkPointRendererImpl> delegated_ink_point_renderer_;
DISALLOW_COPY_AND_ASSIGN(Display); DISALLOW_COPY_AND_ASSIGN(Display);
}; };
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/viz/common/frame_sinks/begin_frame_source.h" #include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/service/display/delegated_ink_point_renderer.h"
#include "components/viz/service/display/display.h" #include "components/viz/service/display/display.h"
#include "components/viz/service/display/output_surface.h" #include "components/viz/service/display/output_surface.h"
#include "components/viz/service/display_embedder/output_surface_provider.h" #include "components/viz/service/display_embedder/output_surface_provider.h"
...@@ -303,6 +304,12 @@ void RootCompositorFrameSinkImpl::AddVSyncParameterObserver( ...@@ -303,6 +304,12 @@ void RootCompositorFrameSinkImpl::AddVSyncParameterObserver(
std::make_unique<VSyncParameterListener>(std::move(observer)); std::make_unique<VSyncParameterListener>(std::move(observer));
} }
void RootCompositorFrameSinkImpl::SetDelegatedInkPointRenderer(
mojo::PendingReceiver<mojom::DelegatedInkPointRenderer> receiver) {
display_->set_delegated_ink_point_renderer(
std::make_unique<DelegatedInkPointRendererImpl>(std::move(receiver)));
}
void RootCompositorFrameSinkImpl::SetNeedsBeginFrame(bool needs_begin_frame) { void RootCompositorFrameSinkImpl::SetNeedsBeginFrame(bool needs_begin_frame) {
support_->SetNeedsBeginFrame(needs_begin_frame); support_->SetNeedsBeginFrame(needs_begin_frame);
} }
......
...@@ -71,6 +71,10 @@ class RootCompositorFrameSinkImpl : public mojom::CompositorFrameSink, ...@@ -71,6 +71,10 @@ class RootCompositorFrameSinkImpl : public mojom::CompositorFrameSink,
void AddVSyncParameterObserver( void AddVSyncParameterObserver(
mojo::PendingRemote<mojom::VSyncParameterObserver> observer) override; mojo::PendingRemote<mojom::VSyncParameterObserver> observer) override;
void SetDelegatedInkPointRenderer(
mojo::PendingReceiver<mojom::DelegatedInkPointRenderer> receiver)
override;
// mojom::CompositorFrameSink: // mojom::CompositorFrameSink:
void SetNeedsBeginFrame(bool needs_begin_frame) override; void SetNeedsBeginFrame(bool needs_begin_frame) override;
void SetWantsAnimateOnlyBeginFrames() override; void SetWantsAnimateOnlyBeginFrames() override;
......
...@@ -539,6 +539,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase ...@@ -539,6 +539,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase
void reset_is_evicted() { is_evicted_ = false; } void reset_is_evicted() { is_evicted_ = false; }
bool is_evicted() { return is_evicted_; } bool is_evicted() { return is_evicted_; }
bool is_drawing_delegated_ink_trails() const {
return is_drawing_delegated_ink_trails_;
}
protected: protected:
explicit RenderWidgetHostViewBase(RenderWidgetHost* host); explicit RenderWidgetHostViewBase(RenderWidgetHost* host);
...@@ -628,6 +632,9 @@ class CONTENT_EXPORT RenderWidgetHostViewBase ...@@ -628,6 +632,9 @@ class CONTENT_EXPORT RenderWidgetHostViewBase
FlagGetsSetFromRenderFrameMetadata); FlagGetsSetFromRenderFrameMetadata);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostInputEventRouterTest, FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostInputEventRouterTest,
QueryResultAfterChildViewDead); QueryResultAfterChildViewDead);
FRIEND_TEST_ALL_PREFIXES(DelegatedInkPointTest, EventForwardedToCompositor);
FRIEND_TEST_ALL_PREFIXES(DelegatedInkPointTest,
MojoInterfaceReboundOnDisconnect);
void SynchronizeVisualProperties(); void SynchronizeVisualProperties();
...@@ -649,6 +656,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase ...@@ -649,6 +656,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase
return view_stopped_flinging_for_test_; return view_stopped_flinging_for_test_;
} }
void SetIsDrawingDelegatedInkTrailsForTest(bool b) {
is_drawing_delegated_ink_trails_ = b;
}
gfx::Rect current_display_area_; gfx::Rect current_display_area_;
uint32_t renderer_frame_number_ = 0; uint32_t renderer_frame_number_ = 0;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/metrics/user_metrics_action.h" #include "base/metrics/user_metrics_action.h"
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/viz/common/delegated_ink_point.h"
#include "components/viz/common/features.h" #include "components/viz/common/features.h"
#include "content/browser/renderer_host/hit_test_debug_key_event_observer.h" #include "content/browser/renderer_host/hit_test_debug_key_event_observer.h"
#include "content/browser/renderer_host/input/touch_selection_controller_client_aura.h" #include "content/browser/renderer_host/input/touch_selection_controller_client_aura.h"
...@@ -30,6 +31,7 @@ ...@@ -30,6 +31,7 @@
#include "ui/aura/window_delegate.h" #include "ui/aura/window_delegate.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/base/ime/text_input_client.h" #include "ui/base/ime/text_input_client.h"
#include "ui/compositor/compositor.h"
#include "ui/events/blink/blink_event_util.h" #include "ui/events/blink/blink_event_util.h"
#include "ui/events/blink/web_input_event.h" #include "ui/events/blink/web_input_event.h"
#include "ui/events/keycodes/dom/dom_code.h" #include "ui/events/keycodes/dom/dom_code.h"
...@@ -378,6 +380,46 @@ void RenderWidgetHostViewEventHandler::HandleMouseWheelEvent( ...@@ -378,6 +380,46 @@ void RenderWidgetHostViewEventHandler::HandleMouseWheelEvent(
} }
} }
void RenderWidgetHostViewEventHandler::ForwardDelegatedInkPoint(
ui::LocatedEvent* event) {
if (host_view_->is_drawing_delegated_ink_trails()) {
if (!delegated_ink_point_renderer_.is_bound()) {
ui::Compositor* compositor = window_ && window_->layer()
? window_->layer()->GetCompositor()
: nullptr;
// The remote can't be bound if the compositor is null, so bail if that
// is the case so we don't crash by trying to use an unbound remote.
if (!compositor)
return;
TRACE_EVENT_INSTANT0("input",
"Binding mojo interface for delegated ink points.",
TRACE_EVENT_SCOPE_THREAD);
compositor->SetDelegatedInkPointRenderer(
delegated_ink_point_renderer_.BindNewPipeAndPassReceiver());
delegated_ink_point_renderer_.reset_on_disconnect();
}
gfx::PointF point = event->root_location_f();
point.Scale(host_view_->GetDeviceScaleFactor());
viz::DelegatedInkPoint delegated_ink_point(point, event->time_stamp());
TRACE_EVENT_INSTANT1("input",
"Forwarding delegated ink point from browser.",
TRACE_EVENT_SCOPE_THREAD, "delegated point",
delegated_ink_point.ToString());
// Calling this will result in IPC calls to get |delegated_ink_point| to
// viz. The decision to do this here was made with the understanding that
// the IPC overhead will result in a minor increase in latency for getting
// this event to the renderer. However, by sending it here, the event is
// given the greatest possible chance to make it to viz before
// DrawAndSwap() is called, allowing more points to be drawn as part of
// the delegated ink trail, and thus reducing user perceived latency.
delegated_ink_point_renderer_->StoreDelegatedInkPoint(delegated_ink_point);
}
}
void RenderWidgetHostViewEventHandler::OnMouseEvent(ui::MouseEvent* event) { void RenderWidgetHostViewEventHandler::OnMouseEvent(ui::MouseEvent* event) {
TRACE_EVENT0("input", "RenderWidgetHostViewBase::OnMouseEvent"); TRACE_EVENT0("input", "RenderWidgetHostViewBase::OnMouseEvent");
...@@ -421,6 +463,8 @@ void RenderWidgetHostViewEventHandler::OnMouseEvent(ui::MouseEvent* event) { ...@@ -421,6 +463,8 @@ void RenderWidgetHostViewEventHandler::OnMouseEvent(ui::MouseEvent* event) {
bool is_selection_popup = NeedsInputGrab(popup_child_host_view_); bool is_selection_popup = NeedsInputGrab(popup_child_host_view_);
if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) &&
!(event->flags() & ui::EF_FROM_TOUCH)) { !(event->flags() & ui::EF_FROM_TOUCH)) {
ForwardDelegatedInkPoint(event);
// Confirm existing composition text on mouse press, to make sure // Confirm existing composition text on mouse press, to make sure
// the input caret won't be moved with an ongoing composition text. // the input caret won't be moved with an ongoing composition text.
if (event->type() == ui::ET_MOUSE_PRESSED) if (event->type() == ui::ET_MOUSE_PRESSED)
...@@ -544,6 +588,8 @@ void RenderWidgetHostViewEventHandler::OnTouchEvent(ui::TouchEvent* event) { ...@@ -544,6 +588,8 @@ void RenderWidgetHostViewEventHandler::OnTouchEvent(ui::TouchEvent* event) {
if (handled) if (handled)
return; return;
ForwardDelegatedInkPoint(event);
if (had_no_pointer) if (had_no_pointer)
delegate_->selection_controller_client()->OnTouchDown(); delegate_->selection_controller_client()->OnTouchDown();
if (!pointer_state_.GetPointerCount()) if (!pointer_state_.GetPointerCount())
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "content/browser/renderer_host/input/mouse_wheel_phase_handler.h" #include "content/browser/renderer_host/input/mouse_wheel_phase_handler.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/native_web_keyboard_event.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/viz/public/mojom/compositing/delegated_ink_point.mojom.h"
#include "third_party/blink/public/mojom/input/pointer_lock_result.mojom.h" #include "third_party/blink/public/mojom/input/pointer_lock_result.mojom.h"
#include "ui/aura/scoped_enable_unadjusted_mouse_events.h" #include "ui/aura/scoped_enable_unadjusted_mouse_events.h"
#include "ui/aura/scoped_keyboard_hook.h" #include "ui/aura/scoped_keyboard_hook.h"
...@@ -194,6 +196,7 @@ class CONTENT_EXPORT RenderWidgetHostViewEventHandler ...@@ -194,6 +196,7 @@ class CONTENT_EXPORT RenderWidgetHostViewEventHandler
RenderWidgetHostViewAuraTest, RenderWidgetHostViewAuraTest,
KeyEventRoutingKeyboardLockAndChildPopupWithoutInputGrab); KeyEventRoutingKeyboardLockAndChildPopupWithoutInputGrab);
friend class MockPointerLockRenderWidgetHostView; friend class MockPointerLockRenderWidgetHostView;
friend class FakeRenderWidgetHostViewAura;
// Returns true if the |event| passed in can be forwarded to the renderer. // Returns true if the |event| passed in can be forwarded to the renderer.
bool CanRendererHandleEvent(const ui::MouseEvent* event, bool CanRendererHandleEvent(const ui::MouseEvent* event,
...@@ -253,6 +256,13 @@ class CONTENT_EXPORT RenderWidgetHostViewEventHandler ...@@ -253,6 +256,13 @@ class CONTENT_EXPORT RenderWidgetHostViewEventHandler
void HandleMouseWheelEvent(ui::MouseEvent* event); void HandleMouseWheelEvent(ui::MouseEvent* event);
// Forward the location and timestamp of the event to viz if a delegated ink
// trail is requested.
void ForwardDelegatedInkPoint(ui::LocatedEvent* event);
// Flush the remote for testing purposes.
void FlushForTest() { delegated_ink_point_renderer_.FlushForTesting(); }
// Whether return characters should be passed on to the RenderWidgetHostImpl. // Whether return characters should be passed on to the RenderWidgetHostImpl.
bool accept_return_character_ = false; bool accept_return_character_ = false;
...@@ -319,6 +329,11 @@ class CONTENT_EXPORT RenderWidgetHostViewEventHandler ...@@ -319,6 +329,11 @@ class CONTENT_EXPORT RenderWidgetHostViewEventHandler
std::unique_ptr<HitTestDebugKeyEventObserver> debug_observer_; std::unique_ptr<HitTestDebugKeyEventObserver> debug_observer_;
// Remote end of the connection for sending delegated ink points to viz to
// support the delegated ink trails feature.
mojo::Remote<viz::mojom::DelegatedInkPointRenderer>
delegated_ink_point_renderer_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewEventHandler); DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewEventHandler);
}; };
......
...@@ -14,6 +14,7 @@ import "ui/gfx/geometry/mojom/geometry.mojom"; ...@@ -14,6 +14,7 @@ import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/latency/mojom/latency_info.mojom"; import "ui/latency/mojom/latency_info.mojom";
import "services/viz/privileged/mojom/compositing/layered_window_updater.mojom"; import "services/viz/privileged/mojom/compositing/layered_window_updater.mojom";
import "services/viz/privileged/mojom/compositing/vsync_parameter_observer.mojom"; import "services/viz/privileged/mojom/compositing/vsync_parameter_observer.mojom";
import "services/viz/public/mojom/compositing/delegated_ink_point.mojom";
// The DisplayPrivate is used by privileged clients to talk to Display. // The DisplayPrivate is used by privileged clients to talk to Display.
interface DisplayPrivate { interface DisplayPrivate {
...@@ -71,6 +72,11 @@ interface DisplayPrivate { ...@@ -71,6 +72,11 @@ interface DisplayPrivate {
// support multiple observers. // support multiple observers.
AddVSyncParameterObserver( AddVSyncParameterObserver(
pending_remote<VSyncParameterObserver> observer); pending_remote<VSyncParameterObserver> observer);
// Bind an interface between browser process and viz for ink points to be
// sent to viz and stored, to be used when drawing a delegated ink trail.
SetDelegatedInkPointRenderer(
pending_receiver<DelegatedInkPointRenderer> receiver);
}; };
interface DisplayClient { interface DisplayClient {
......
// 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_point_mojom_traits.h"
namespace mojo {
// static
bool StructTraits<
viz::mojom::DelegatedInkPointDataView,
viz::DelegatedInkPoint>::Read(viz::mojom::DelegatedInkPointDataView data,
viz::DelegatedInkPoint* out) {
return data.ReadPoint(&out->point_) && data.ReadTimestamp(&out->timestamp_);
}
} // namespace mojo
// 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_POINT_MOJOM_TRAITS_H_
#define SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_DELEGATED_INK_POINT_MOJOM_TRAITS_H_
#include "components/viz/common/delegated_ink_point.h"
#include "mojo/public/cpp/base/time_mojom_traits.h"
#include "services/viz/public/mojom/compositing/delegated_ink_point.mojom-shared.h"
#include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"
namespace mojo {
template <>
struct StructTraits<viz::mojom::DelegatedInkPointDataView,
viz::DelegatedInkPoint> {
static const gfx::PointF& point(const viz::DelegatedInkPoint& input) {
return input.point();
}
static base::TimeTicks timestamp(const viz::DelegatedInkPoint& input) {
return input.timestamp();
}
static bool Read(viz::mojom::DelegatedInkPointDataView data,
viz::DelegatedInkPoint* out);
};
} // namespace mojo
#endif // SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_DELEGATED_INK_POINT_MOJOM_TRAITS_H_
...@@ -16,6 +16,7 @@ mojom("mojom") { ...@@ -16,6 +16,7 @@ mojom("mojom") {
"compositing/copy_output_request.mojom", "compositing/copy_output_request.mojom",
"compositing/copy_output_result.mojom", "compositing/copy_output_result.mojom",
"compositing/delegated_ink_metadata.mojom", "compositing/delegated_ink_metadata.mojom",
"compositing/delegated_ink_point.mojom",
"compositing/filter_operation.mojom", "compositing/filter_operation.mojom",
"compositing/filter_operations.mojom", "compositing/filter_operations.mojom",
"compositing/frame_deadline.mojom", "compositing/frame_deadline.mojom",
...@@ -248,6 +249,17 @@ mojom("mojom") { ...@@ -248,6 +249,17 @@ mojom("mojom") {
traits_headers = [ "//services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.h" ] traits_headers = [ "//services/viz/public/cpp/compositing/delegated_ink_metadata_mojom_traits.h" ]
traits_public_deps = [ "//components/viz/common" ] traits_public_deps = [ "//components/viz/common" ]
}, },
{
types = [
{
mojom = "viz.mojom.DelegatedInkPoint"
cpp = "::viz::DelegatedInkPoint"
},
]
traits_sources = [ "//services/viz/public/cpp/compositing/delegated_ink_point_mojom_traits.cc" ]
traits_headers = [ "//services/viz/public/cpp/compositing/delegated_ink_point_mojom_traits.h" ]
traits_public_deps = [ "//components/viz/common" ]
},
{ {
types = [ types = [
{ {
......
// 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 "ui/gfx/geometry/mojom/geometry.mojom";
// See components/viz/common/delegated_ink_point.h.
struct DelegatedInkPoint {
gfx.mojom.PointF point;
mojo_base.mojom.TimeTicks timestamp;
};
// This interface is used to connect the browser process to viz to support
// delegated ink trails. A delegated ink point will be produced in the
// browser process and sent to viz to be held until DrawAndSwap occurs, at
// which point any delegated ink points that arrived may be used to draw the
// ink trail.
interface DelegatedInkPointRenderer {
// Used to send the DelegatedInkPoint that was created in the browser process
// to viz in order to be drawn as part of the delegated ink trail.
StoreDelegatedInkPoint(DelegatedInkPoint point);
};
...@@ -769,4 +769,10 @@ void Compositor::ReportThroughputForTracker( ...@@ -769,4 +769,10 @@ void Compositor::ReportThroughputForTracker(
throughput_tracker_map_.erase(it); throughput_tracker_map_.erase(it);
} }
void Compositor::SetDelegatedInkPointRenderer(
mojo::PendingReceiver<viz::mojom::DelegatedInkPointRenderer> receiver) {
if (display_private_)
display_private_->SetDelegatedInkPointRenderer(std::move(receiver));
}
} // namespace ui } // namespace ui
...@@ -72,6 +72,7 @@ namespace viz { ...@@ -72,6 +72,7 @@ namespace viz {
namespace mojom { namespace mojom {
class DisplayPrivate; class DisplayPrivate;
class ExternalBeginFrameController; class ExternalBeginFrameController;
class DelegatedInkPointRenderer;
} // namespace mojom } // namespace mojom
class ContextProvider; class ContextProvider;
class HostFrameSinkManager; class HostFrameSinkManager;
...@@ -404,6 +405,9 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient, ...@@ -404,6 +405,9 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
return scroll_input_handler_.get(); return scroll_input_handler_.get();
} }
virtual void SetDelegatedInkPointRenderer(
mojo::PendingReceiver<viz::mojom::DelegatedInkPointRenderer> receiver);
private: private:
friend class base::RefCounted<Compositor>; friend class base::RefCounted<Compositor>;
......
...@@ -509,6 +509,10 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate, ...@@ -509,6 +509,10 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate,
bool ContainsMirrorForTest(Layer* mirror) const; bool ContainsMirrorForTest(Layer* mirror) const;
void SetCompositorForTesting(Compositor* compositor) {
compositor_ = compositor;
}
private: private:
friend class LayerOwner; friend class LayerOwner;
class LayerMirror; class LayerMirror;
......
...@@ -193,6 +193,10 @@ class InProcessContextFactory::PerCompositorData ...@@ -193,6 +193,10 @@ class InProcessContextFactory::PerCompositorData
const std::vector<float>& refresh_rates) override {} const std::vector<float>& refresh_rates) override {}
#endif #endif
void SetDelegatedInkPointRenderer(
mojo::PendingReceiver<viz::mojom::DelegatedInkPointRenderer> receiver)
override {}
void SetSurfaceHandle(gpu::SurfaceHandle surface_handle) { void SetSurfaceHandle(gpu::SurfaceHandle surface_handle) {
surface_handle_ = surface_handle; surface_handle_ = surface_handle;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment