summaryrefslogtreecommitdiffstats
path: root/chromium/cc/layers/painted_overlay_scrollbar_layer.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-12 15:59:20 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-25 06:57:22 +0000
commitf7eaed5286974984ba5f9e3189d8f49d03e99f81 (patch)
treecaed19b2af2024f35449fb0b781d0a25e09d4f8f /chromium/cc/layers/painted_overlay_scrollbar_layer.cc
parent9729c4479fe23554eae6e6dd1f30ff488f470c84 (diff)
BASELINE: Update Chromium to 100.0.4896.167
Change-Id: I98cbeb5d7543d966ffe04d8cefded0c493a11333 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/cc/layers/painted_overlay_scrollbar_layer.cc')
-rw-r--r--chromium/cc/layers/painted_overlay_scrollbar_layer.cc88
1 files changed, 48 insertions, 40 deletions
diff --git a/chromium/cc/layers/painted_overlay_scrollbar_layer.cc b/chromium/cc/layers/painted_overlay_scrollbar_layer.cc
index c28b1152882..33ff15fb04b 100644
--- a/chromium/cc/layers/painted_overlay_scrollbar_layer.cc
+++ b/chromium/cc/layers/painted_overlay_scrollbar_layer.cc
@@ -26,7 +26,7 @@
namespace cc {
std::unique_ptr<LayerImpl> PaintedOverlayScrollbarLayer::CreateLayerImpl(
- LayerTreeImpl* tree_impl) {
+ LayerTreeImpl* tree_impl) const {
return PaintedOverlayScrollbarLayerImpl::Create(
tree_impl, id(), orientation(), is_left_side_vertical_scrollbar());
}
@@ -35,7 +35,8 @@ scoped_refptr<PaintedOverlayScrollbarLayer>
PaintedOverlayScrollbarLayer::CreateOrReuse(
scoped_refptr<Scrollbar> scrollbar,
PaintedOverlayScrollbarLayer* existing_layer) {
- if (existing_layer && existing_layer->scrollbar_->IsSame(*scrollbar))
+ if (existing_layer &&
+ existing_layer->scrollbar_.Read(*existing_layer)->IsSame(*scrollbar))
return existing_layer;
return Create(std::move(scrollbar));
}
@@ -51,9 +52,9 @@ PaintedOverlayScrollbarLayer::PaintedOverlayScrollbarLayer(
: ScrollbarLayerBase(scrollbar->Orientation(),
scrollbar->IsLeftSideVerticalScrollbar()),
scrollbar_(std::move(scrollbar)) {
- DCHECK(scrollbar_->HasThumb());
- DCHECK(scrollbar_->IsOverlay());
- DCHECK(scrollbar_->UsesNinePatchThumbResource());
+ DCHECK(scrollbar_.Read(*this)->HasThumb());
+ DCHECK(scrollbar_.Read(*this)->IsOverlay());
+ DCHECK(scrollbar_.Read(*this)->UsesNinePatchThumbResource());
}
PaintedOverlayScrollbarLayer::~PaintedOverlayScrollbarLayer() = default;
@@ -72,33 +73,36 @@ void PaintedOverlayScrollbarLayer::PushPropertiesTo(
static_cast<PaintedOverlayScrollbarLayerImpl*>(layer);
if (orientation() == ScrollbarOrientation::HORIZONTAL) {
- scrollbar_layer->SetThumbThickness(thumb_size_.height());
- scrollbar_layer->SetThumbLength(thumb_size_.width());
- scrollbar_layer->SetTrackStart(track_rect_.x());
- scrollbar_layer->SetTrackLength(track_rect_.width());
+ scrollbar_layer->SetThumbThickness(thumb_size_.Read(*this).height());
+ scrollbar_layer->SetThumbLength(thumb_size_.Read(*this).width());
+ scrollbar_layer->SetTrackStart(track_rect_.Read(*this).x());
+ scrollbar_layer->SetTrackLength(track_rect_.Read(*this).width());
} else {
- scrollbar_layer->SetThumbThickness(thumb_size_.width());
- scrollbar_layer->SetThumbLength(thumb_size_.height());
- scrollbar_layer->SetTrackStart(track_rect_.y());
- scrollbar_layer->SetTrackLength(track_rect_.height());
+ scrollbar_layer->SetThumbThickness(thumb_size_.Read(*this).width());
+ scrollbar_layer->SetThumbLength(thumb_size_.Read(*this).height());
+ scrollbar_layer->SetTrackStart(track_rect_.Read(*this).y());
+ scrollbar_layer->SetTrackLength(track_rect_.Read(*this).height());
}
- if (thumb_resource_.get()) {
- auto iter = commit_state.ui_resource_sizes.find(thumb_resource_->id());
+ if (thumb_resource_.Read(*this)) {
+ auto iter =
+ commit_state.ui_resource_sizes.find(thumb_resource_.Read(*this)->id());
gfx::Size image_bounds = (iter == commit_state.ui_resource_sizes.end())
? gfx::Size()
: iter->second;
scrollbar_layer->SetImageBounds(image_bounds);
- scrollbar_layer->SetAperture(aperture_);
- scrollbar_layer->set_thumb_ui_resource_id(thumb_resource_->id());
+ scrollbar_layer->SetAperture(aperture_.Read(*this));
+ scrollbar_layer->set_thumb_ui_resource_id(
+ thumb_resource_.Read(*this)->id());
} else {
scrollbar_layer->SetImageBounds(gfx::Size());
scrollbar_layer->SetAperture(gfx::Rect());
scrollbar_layer->set_thumb_ui_resource_id(0);
}
- if (track_resource_.get())
- scrollbar_layer->set_track_ui_resource_id(track_resource_->id());
+ if (track_resource_.Read(*this))
+ scrollbar_layer->set_track_ui_resource_id(
+ track_resource_.Read(*this)->id());
else
scrollbar_layer->set_track_ui_resource_id(0);
}
@@ -107,8 +111,8 @@ void PaintedOverlayScrollbarLayer::SetLayerTreeHost(LayerTreeHost* host) {
// When the LTH is set to null or has changed, then this layer should remove
// all of its associated resources.
if (host != layer_tree_host()) {
- thumb_resource_.reset();
- track_resource_.reset();
+ thumb_resource_.Write(*this).reset();
+ track_resource_.Write(*this).reset();
}
ScrollbarLayerBase::SetLayerTreeHost(host);
@@ -116,20 +120,22 @@ void PaintedOverlayScrollbarLayer::SetLayerTreeHost(LayerTreeHost* host) {
bool PaintedOverlayScrollbarLayer::Update() {
// These properties should never change.
- DCHECK_EQ(orientation(), scrollbar_->Orientation());
+ DCHECK_EQ(orientation(), scrollbar_.Read(*this)->Orientation());
DCHECK_EQ(is_left_side_vertical_scrollbar(),
- scrollbar_->IsLeftSideVerticalScrollbar());
- DCHECK(scrollbar_->HasThumb());
- DCHECK(scrollbar_->IsOverlay());
- DCHECK(scrollbar_->UsesNinePatchThumbResource());
+ scrollbar_.Read(*this)->IsLeftSideVerticalScrollbar());
+ DCHECK(scrollbar_.Read(*this)->HasThumb());
+ DCHECK(scrollbar_.Read(*this)->IsOverlay());
+ DCHECK(scrollbar_.Read(*this)->UsesNinePatchThumbResource());
bool updated = false;
updated |= Layer::Update();
- updated |= UpdateProperty(scrollbar_->TrackRect(), &track_rect_);
+ updated |= UpdateProperty(scrollbar_.Read(*this)->TrackRect(),
+ &track_rect_.Write(*this));
// Ignore ThumbRect's location because the PaintedOverlayScrollbarLayerImpl
// will compute it from scroll offset.
- updated |= UpdateProperty(scrollbar_->ThumbRect().size(), &thumb_size_);
+ updated |= UpdateProperty(scrollbar_.Read(*this)->ThumbRect().size(),
+ &thumb_size_.Write(*this));
updated |= PaintThumbIfNeeded();
updated |= PaintTickmarks();
@@ -137,24 +143,26 @@ bool PaintedOverlayScrollbarLayer::Update() {
}
bool PaintedOverlayScrollbarLayer::PaintThumbIfNeeded() {
- if (!scrollbar_->NeedsRepaintPart(ScrollbarPart::THUMB) && thumb_resource_)
+ auto& scrollbar = scrollbar_.Read(*this);
+ if (!scrollbar->NeedsRepaintPart(ScrollbarPart::THUMB) &&
+ thumb_resource_.Read(*this))
return false;
- gfx::Size paint_size = scrollbar_->NinePatchThumbCanvasSize();
+ gfx::Size paint_size = scrollbar->NinePatchThumbCanvasSize();
DCHECK(!paint_size.IsEmpty());
- aperture_ = scrollbar_->NinePatchThumbAperture();
+ aperture_.Write(*this) = scrollbar->NinePatchThumbAperture();
SkBitmap skbitmap;
skbitmap.allocN32Pixels(paint_size.width(), paint_size.height());
SkiaPaintCanvas canvas(skbitmap);
canvas.clear(SK_ColorTRANSPARENT);
- scrollbar_->PaintPart(&canvas, ScrollbarPart::THUMB, gfx::Rect(paint_size));
+ scrollbar->PaintPart(&canvas, ScrollbarPart::THUMB, gfx::Rect(paint_size));
// Make sure that the pixels are no longer mutable to unavoid unnecessary
// allocation and copying.
skbitmap.setImmutable();
- thumb_resource_ = ScopedUIResource::Create(
+ thumb_resource_.Write(*this) = ScopedUIResource::Create(
layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap));
SetNeedsPushProperties();
@@ -163,18 +171,18 @@ bool PaintedOverlayScrollbarLayer::PaintThumbIfNeeded() {
}
bool PaintedOverlayScrollbarLayer::PaintTickmarks() {
- if (!scrollbar_->HasTickmarks()) {
- if (!track_resource_) {
+ if (!scrollbar_.Read(*this)->HasTickmarks()) {
+ if (!track_resource_.Read(*this)) {
return false;
} else {
// Remove previous tickmarks.
- track_resource_.reset();
+ track_resource_.Write(*this).reset();
SetNeedsPushProperties();
return true;
}
}
- gfx::Size paint_size = track_rect_.size();
+ gfx::Size paint_size = track_rect_.Read(*this).size();
DCHECK(!paint_size.IsEmpty());
SkBitmap skbitmap;
@@ -182,13 +190,13 @@ bool PaintedOverlayScrollbarLayer::PaintTickmarks() {
SkiaPaintCanvas canvas(skbitmap);
canvas.clear(SK_ColorTRANSPARENT);
- scrollbar_->PaintPart(&canvas, ScrollbarPart::TRACK_BUTTONS_TICKMARKS,
- gfx::Rect(paint_size));
+ scrollbar_.Write(*this)->PaintPart(
+ &canvas, ScrollbarPart::TRACK_BUTTONS_TICKMARKS, gfx::Rect(paint_size));
// Make sure that the pixels are no longer mutable to unavoid unnecessary
// allocation and copying.
skbitmap.setImmutable();
- track_resource_ = ScopedUIResource::Create(
+ track_resource_.Write(*this) = ScopedUIResource::Create(
layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap));
SetNeedsPushProperties();