[TreesInViz] Add wire support for solid color scrollbar layers
This change wires the SolidColorScrollbarLayerImpl type to the Viz LayerContextImpl. Bug: 388877791 Change-Id: I938f624f02414c86442c61f7c78c014710e19e77 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6542132 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Jonathan Ross <jonross@chromium.org> Commit-Queue: Victor Miura <vmiura@chromium.org> Cr-Commit-Position: refs/heads/main@{#1460099}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
04e905c113
commit
8831035e2c
cc
components/viz/service/layers
services/viz/public/mojom/compositing
@ -37,6 +37,10 @@ class CC_EXPORT SolidColorScrollbarLayerImpl : public ScrollbarLayerImplBase {
|
||||
|
||||
void set_color(SkColor4f color) { color_ = color; }
|
||||
|
||||
int thumb_thickness() const { return thumb_thickness_; }
|
||||
int track_start() const { return track_start_; }
|
||||
SkColor4f color() const { return color_; }
|
||||
|
||||
protected:
|
||||
SolidColorScrollbarLayerImpl(LayerTreeImpl* tree_impl,
|
||||
int id,
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "cc/layers/nine_patch_thumb_scrollbar_layer_impl.h"
|
||||
#include "cc/layers/painted_scrollbar_layer_impl.h"
|
||||
#include "cc/layers/picture_layer_impl.h"
|
||||
#include "cc/layers/solid_color_scrollbar_layer_impl.h"
|
||||
#include "cc/layers/surface_layer_impl.h"
|
||||
#include "cc/layers/texture_layer_impl.h"
|
||||
#include "cc/tiles/picture_layer_tiling.h"
|
||||
@ -626,6 +627,16 @@ void SerializePaintedScrollbarLayerExtra(
|
||||
extra->track_and_buttons_aperture = layer.track_and_buttons_aperture();
|
||||
}
|
||||
|
||||
void SerializeSolidColorScrollbarLayerExtra(
|
||||
SolidColorScrollbarLayerImpl& layer,
|
||||
viz::mojom::SolidColorScrollbarLayerExtraPtr& extra) {
|
||||
SerializeScrollbarLayerBaseExtra(static_cast<ScrollbarLayerImplBase&>(layer),
|
||||
extra->scrollbar_base_extra);
|
||||
extra->thumb_thickness = layer.thumb_thickness();
|
||||
extra->track_start = layer.track_start();
|
||||
extra->color = layer.color();
|
||||
}
|
||||
|
||||
void SerializeSurfaceLayerExtra(SurfaceLayerImpl& layer,
|
||||
viz::mojom::SurfaceLayerExtraPtr& extra) {
|
||||
extra->surface_range = layer.range();
|
||||
@ -709,6 +720,17 @@ void SerializeLayer(LayerImpl& layer,
|
||||
std::move(painted_scrollbar_layer_extra));
|
||||
break;
|
||||
}
|
||||
case mojom::LayerType::kSolidColorScrollbar: {
|
||||
auto solid_color_scrollbar_layer_extra =
|
||||
viz::mojom::SolidColorScrollbarLayerExtra::New();
|
||||
SerializeSolidColorScrollbarLayerExtra(
|
||||
static_cast<SolidColorScrollbarLayerImpl&>(layer),
|
||||
solid_color_scrollbar_layer_extra);
|
||||
wire.layer_extra =
|
||||
viz::mojom::LayerExtra::NewSolidColorScrollbarLayerExtra(
|
||||
std::move(solid_color_scrollbar_layer_extra));
|
||||
break;
|
||||
}
|
||||
case mojom::LayerType::kSurface: {
|
||||
auto surface_layer_extra = viz::mojom::SurfaceLayerExtra::New();
|
||||
SerializeSurfaceLayerExtra(static_cast<SurfaceLayerImpl&>(layer),
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "cc/layers/nine_patch_thumb_scrollbar_layer_impl.h"
|
||||
#include "cc/layers/painted_scrollbar_layer_impl.h"
|
||||
#include "cc/layers/solid_color_layer_impl.h"
|
||||
#include "cc/layers/solid_color_scrollbar_layer_impl.h"
|
||||
#include "cc/layers/surface_layer_impl.h"
|
||||
#include "cc/layers/texture_layer_impl.h"
|
||||
#include "cc/layers/tile_display_layer_impl.h"
|
||||
@ -97,6 +98,17 @@ std::unique_ptr<cc::LayerImpl> CreateLayer(cc::LayerTreeHostImpl& host_impl,
|
||||
case cc::mojom::LayerType::kPicture:
|
||||
return std::make_unique<cc::TileDisplayLayerImpl>(tree, id);
|
||||
|
||||
case cc::mojom::LayerType::kSolidColorScrollbar: {
|
||||
auto& extra = wire.layer_extra->get_solid_color_scrollbar_layer_extra();
|
||||
cc::ScrollbarOrientation orientation =
|
||||
extra->scrollbar_base_extra->is_horizontal_orientation
|
||||
? cc::ScrollbarOrientation::kHorizontal
|
||||
: cc::ScrollbarOrientation::kVertical;
|
||||
return cc::SolidColorScrollbarLayerImpl::Create(
|
||||
&tree, id, orientation, extra->thumb_thickness, extra->track_start,
|
||||
extra->scrollbar_base_extra->is_left_side_vertical_scrollbar);
|
||||
}
|
||||
|
||||
case cc::mojom::LayerType::kSurface:
|
||||
// The callback is triggered in the renderer side during WillDraw(),
|
||||
// and there is no need to do it in viz.
|
||||
@ -513,6 +525,14 @@ void UpdatePaintedScrollbarLayerExtra(
|
||||
layer.SetTrackAndButtonsAperture(extra->track_and_buttons_aperture);
|
||||
}
|
||||
|
||||
void UpdateSolidColorScrollbarLayerExtra(
|
||||
const mojom::SolidColorScrollbarLayerExtraPtr& extra,
|
||||
cc::SolidColorScrollbarLayerImpl& layer) {
|
||||
UpdateScrollbarLayerBaseExtra(
|
||||
extra->scrollbar_base_extra,
|
||||
static_cast<cc::ScrollbarLayerImplBase&>(layer));
|
||||
}
|
||||
|
||||
void UpdateSurfaceLayerExtra(const mojom::SurfaceLayerExtraPtr& extra,
|
||||
cc::SurfaceLayerImpl& layer) {
|
||||
layer.SetRange(extra->surface_range, extra->deadline_in_frames);
|
||||
@ -608,6 +628,11 @@ base::expected<void, std::string> UpdateLayer(const mojom::Layer& wire,
|
||||
wire.layer_extra->get_painted_scrollbar_layer_extra(),
|
||||
static_cast<cc::PaintedScrollbarLayerImpl&>(layer));
|
||||
break;
|
||||
case cc::mojom::LayerType::kSolidColorScrollbar:
|
||||
UpdateSolidColorScrollbarLayerExtra(
|
||||
wire.layer_extra->get_solid_color_scrollbar_layer_extra(),
|
||||
static_cast<cc::SolidColorScrollbarLayerImpl&>(layer));
|
||||
break;
|
||||
case cc::mojom::LayerType::kSurface:
|
||||
UpdateSurfaceLayerExtra(wire.layer_extra->get_surface_layer_extra(),
|
||||
static_cast<cc::SurfaceLayerImpl&>(layer));
|
||||
|
@ -124,6 +124,8 @@ struct NinePatchThumbScrollbarLayerExtra {
|
||||
cc.mojom.UIResourceId track_and_buttons_ui_resource_id;
|
||||
};
|
||||
|
||||
// Extra fields in a cc::PaintedScrollbarLayerImpl that has been added
|
||||
// to a tree or modified in some interesting way since a prior tree update.
|
||||
struct PaintedScrollbarLayerExtra {
|
||||
ScrollbarLayerBaseExtra scrollbar_base_extra;
|
||||
|
||||
@ -145,6 +147,16 @@ struct PaintedScrollbarLayerExtra {
|
||||
cc.mojom.UIResourceId thumb_ui_resource_id;
|
||||
};
|
||||
|
||||
// Extra fields in a cc::SolidColorScrollbarLayerImpl that has been added
|
||||
// to a tree or modified in some interesting way since a prior tree update.
|
||||
struct SolidColorScrollbarLayerExtra {
|
||||
ScrollbarLayerBaseExtra scrollbar_base_extra;
|
||||
|
||||
int32 thumb_thickness;
|
||||
int32 track_start;
|
||||
skia.mojom.SkColor4f color;
|
||||
};
|
||||
|
||||
// Extra properties that are specific to a LayerImpl type.
|
||||
union LayerExtra {
|
||||
// Extra properties that are specific to MirrorLayerImpl.
|
||||
@ -153,6 +165,8 @@ union LayerExtra {
|
||||
NinePatchThumbScrollbarLayerExtra nine_patch_thumb_scrollbar_layer_extra;
|
||||
// Extra properties that are specific to PaintedScrollbarLayerImpl.
|
||||
PaintedScrollbarLayerExtra painted_scrollbar_layer_extra;
|
||||
// Extra properties that are specific to SolidColorScrollbarLayerImpl.
|
||||
SolidColorScrollbarLayerExtra solid_color_scrollbar_layer_extra;
|
||||
// Extra properties that are specific to SurfaceLayerImpl.
|
||||
SurfaceLayerExtra surface_layer_extra;
|
||||
// Extra properties that are specific to TextureLayerImpl.
|
||||
|
Reference in New Issue
Block a user