forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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/+/2259015 Reviewed-by: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Jonathan Ross <jonross@chromium.org> Reviewed-by: kylechar <kylechar@chromium.org> Reviewed-by: Daniel Libby <dlibby@microsoft.com> Commit-Queue: Mario Bianucci <mabian@microsoft.com> Cr-Commit-Position: refs/heads/master@{#792419}
- Loading branch information
Showing
23 changed files
with
630 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// 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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
components/viz/service/display/delegated_ink_point_renderer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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 |
41 changes: 41 additions & 0 deletions
41
components/viz/service/display/delegated_ink_point_renderer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// 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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.