summaryrefslogtreecommitdiff
path: root/chromium/ui/accelerated_widget_mac/ca_renderer_layer_tree.mm
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-30 10:22:43 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-30 12:36:28 +0000
commit271a6c3487a14599023a9106329505597638d793 (patch)
treee040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/ui/accelerated_widget_mac/ca_renderer_layer_tree.mm
parent7b2ffa587235a47d4094787d72f38102089f402a (diff)
downloadqtwebengine-chromium-271a6c3487a14599023a9106329505597638d793.tar.gz
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/ui/accelerated_widget_mac/ca_renderer_layer_tree.mm')
-rw-r--r--chromium/ui/accelerated_widget_mac/ca_renderer_layer_tree.mm88
1 files changed, 67 insertions, 21 deletions
diff --git a/chromium/ui/accelerated_widget_mac/ca_renderer_layer_tree.mm b/chromium/ui/accelerated_widget_mac/ca_renderer_layer_tree.mm
index 30e30cb76ab..8cf753ed60f 100644
--- a/chromium/ui/accelerated_widget_mac/ca_renderer_layer_tree.mm
+++ b/chromium/ui/accelerated_widget_mac/ca_renderer_layer_tree.mm
@@ -331,10 +331,12 @@ CARendererLayerTree::RootLayer::~RootLayer() {
CARendererLayerTree::ClipAndSortingLayer::ClipAndSortingLayer(
bool is_clipped,
gfx::Rect clip_rect,
+ gfx::RRectF rounded_corner_bounds_arg,
unsigned sorting_context_id,
bool is_singleton_sorting_context)
: is_clipped(is_clipped),
clip_rect(clip_rect),
+ rounded_corner_bounds(rounded_corner_bounds_arg),
sorting_context_id(sorting_context_id),
is_singleton_sorting_context(is_singleton_sorting_context) {}
@@ -343,18 +345,22 @@ CARendererLayerTree::ClipAndSortingLayer::ClipAndSortingLayer(
: transform_layers(std::move(layer.transform_layers)),
is_clipped(layer.is_clipped),
clip_rect(layer.clip_rect),
+ rounded_corner_bounds(layer.rounded_corner_bounds),
sorting_context_id(layer.sorting_context_id),
is_singleton_sorting_context(layer.is_singleton_sorting_context),
- ca_layer(layer.ca_layer) {
+ clipping_ca_layer(layer.clipping_ca_layer),
+ rounded_corner_ca_layer(layer.rounded_corner_ca_layer) {
// Ensure that the ca_layer be reset, so that when the destructor is called,
// the layer hierarchy is unaffected.
// TODO(ccameron): Add a move constructor for scoped_nsobject to do this
// automatically.
- layer.ca_layer.reset();
+ layer.clipping_ca_layer.reset();
+ layer.rounded_corner_ca_layer.reset();
}
CARendererLayerTree::ClipAndSortingLayer::~ClipAndSortingLayer() {
- [ca_layer removeFromSuperlayer];
+ [clipping_ca_layer removeFromSuperlayer];
+ [rounded_corner_ca_layer removeFromSuperlayer];
}
CARendererLayerTree::TransformLayer::TransformLayer(
@@ -506,7 +512,8 @@ bool CARendererLayerTree::RootLayer::AddContentLayer(
if (params.sorting_context_id &&
current_layer.sorting_context_id == params.sorting_context_id &&
(current_layer.is_clipped != params.is_clipped ||
- current_layer.clip_rect != params.clip_rect)) {
+ current_layer.clip_rect != params.clip_rect ||
+ current_layer.rounded_corner_bounds != params.rounded_corner_bounds)) {
DLOG(ERROR) << "CALayer changed clip inside non-zero sorting context.";
return false;
}
@@ -514,14 +521,15 @@ bool CARendererLayerTree::RootLayer::AddContentLayer(
!current_layer.is_singleton_sorting_context &&
current_layer.is_clipped == params.is_clipped &&
current_layer.clip_rect == params.clip_rect &&
+ current_layer.rounded_corner_bounds == params.rounded_corner_bounds &&
current_layer.sorting_context_id == params.sorting_context_id) {
needs_new_clip_and_sorting_layer = false;
}
}
if (needs_new_clip_and_sorting_layer) {
clip_and_sorting_layers.push_back(ClipAndSortingLayer(
- params.is_clipped, params.clip_rect, params.sorting_context_id,
- is_singleton_sorting_context));
+ params.is_clipped, params.clip_rect, params.rounded_corner_bounds,
+ params.sorting_context_id, is_singleton_sorting_context));
}
clip_and_sorting_layers.back().AddContentLayer(tree, params);
return true;
@@ -618,36 +626,74 @@ void CARendererLayerTree::ClipAndSortingLayer::CommitToCA(
bool update_is_clipped = true;
bool update_clip_rect = true;
if (old_layer) {
- DCHECK(old_layer->ca_layer);
- std::swap(ca_layer, old_layer->ca_layer);
+ DCHECK(old_layer->clipping_ca_layer);
+ DCHECK(old_layer->rounded_corner_ca_layer);
+ std::swap(clipping_ca_layer, old_layer->clipping_ca_layer);
+ std::swap(rounded_corner_ca_layer, old_layer->rounded_corner_ca_layer);
update_is_clipped = old_layer->is_clipped != is_clipped;
update_clip_rect = update_is_clipped || old_layer->clip_rect != clip_rect;
} else {
- ca_layer.reset([[CALayer alloc] init]);
- [ca_layer setAnchorPoint:CGPointZero];
- [superlayer addSublayer:ca_layer];
+ clipping_ca_layer.reset([[CALayer alloc] init]);
+ [clipping_ca_layer setAnchorPoint:CGPointZero];
+ [superlayer addSublayer:clipping_ca_layer];
+ rounded_corner_ca_layer.reset([[CALayer alloc] init]);
+ [rounded_corner_ca_layer setAnchorPoint:CGPointZero];
+ [clipping_ca_layer addSublayer:rounded_corner_ca_layer];
+ }
+
+ if (!rounded_corner_bounds.IsEmpty()) {
+ if (!old_layer ||
+ old_layer->rounded_corner_bounds != rounded_corner_bounds) {
+ gfx::RectF dip_rounded_corner_bounds =
+ gfx::RectF(rounded_corner_bounds.rect());
+ dip_rounded_corner_bounds.Scale(1 / scale_factor);
+
+ [rounded_corner_ca_layer setMasksToBounds:true];
+
+ [rounded_corner_ca_layer
+ setPosition:CGPointMake(dip_rounded_corner_bounds.x(),
+ dip_rounded_corner_bounds.y())];
+ [rounded_corner_ca_layer
+ setBounds:CGRectMake(0, 0, dip_rounded_corner_bounds.width(),
+ dip_rounded_corner_bounds.height())];
+ [rounded_corner_ca_layer
+ setSublayerTransform:CATransform3DMakeTranslation(
+ -dip_rounded_corner_bounds.x(),
+ -dip_rounded_corner_bounds.y(), 0)];
+
+ [rounded_corner_ca_layer
+ setCornerRadius:rounded_corner_bounds.GetSimpleRadius() /
+ scale_factor];
+ }
+ } else {
+ [rounded_corner_ca_layer setMasksToBounds:false];
+ [rounded_corner_ca_layer setPosition:CGPointZero];
+ [rounded_corner_ca_layer setBounds:CGRectZero];
+ [rounded_corner_ca_layer setSublayerTransform:CATransform3DIdentity];
+ [rounded_corner_ca_layer setCornerRadius:0];
}
- if ([ca_layer superlayer] != superlayer) {
+ if ([clipping_ca_layer superlayer] != superlayer) {
DLOG(ERROR) << "CARendererLayerTree root layer not attached to tree.";
}
if (update_is_clipped)
- [ca_layer setMasksToBounds:is_clipped];
+ [clipping_ca_layer setMasksToBounds:is_clipped];
if (update_clip_rect) {
if (is_clipped) {
gfx::RectF dip_clip_rect = gfx::RectF(clip_rect);
dip_clip_rect.Scale(1 / scale_factor);
- [ca_layer setPosition:CGPointMake(dip_clip_rect.x(), dip_clip_rect.y())];
- [ca_layer setBounds:CGRectMake(0, 0, dip_clip_rect.width(),
- dip_clip_rect.height())];
- [ca_layer
+ [clipping_ca_layer
+ setPosition:CGPointMake(dip_clip_rect.x(), dip_clip_rect.y())];
+ [clipping_ca_layer setBounds:CGRectMake(0, 0, dip_clip_rect.width(),
+ dip_clip_rect.height())];
+ [clipping_ca_layer
setSublayerTransform:CATransform3DMakeTranslation(
-dip_clip_rect.x(), -dip_clip_rect.y(), 0)];
} else {
- [ca_layer setPosition:CGPointZero];
- [ca_layer setBounds:CGRectZero];
- [ca_layer setSublayerTransform:CATransform3DIdentity];
+ [clipping_ca_layer setPosition:CGPointZero];
+ [clipping_ca_layer setBounds:CGRectZero];
+ [clipping_ca_layer setSublayerTransform:CATransform3DIdentity];
}
}
@@ -655,7 +701,7 @@ void CARendererLayerTree::ClipAndSortingLayer::CommitToCA(
TransformLayer* old_transform_layer = nullptr;
if (old_layer && i < old_layer->transform_layers.size())
old_transform_layer = &old_layer->transform_layers[i];
- transform_layers[i].CommitToCA(ca_layer.get(), old_transform_layer,
+ transform_layers[i].CommitToCA(rounded_corner_ca_layer, old_transform_layer,
scale_factor);
}
}