Commit 02d58f7d authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

Reland "Simplify how the FSLP background rect is chosen."

This is a reland of 94b94d9e

Original change's description:
> Simplify how the FSLP background rect is chosen.
> 
> Before, the background size was reconstituted from the layer tree by
> taking the union of of black and video layers. Now, the actual size is
> plumbed through.
> 
> Change-Id: I0cb643b350ef7e4fca06e3bfd419e24861a2e3c6
> Reviewed-on: https://chromium-review.googlesource.com/1142962
> Reviewed-by: ccameron <ccameron@chromium.org>
> Commit-Queue: Sidney San Martín <sdy@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#576521}

Change-Id: Idf5199a2aeb8be08b34e0594142c33b3ebed5b78
Reviewed-on: https://chromium-review.googlesource.com/1143960Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577590}
parent 79d4727b
...@@ -48,7 +48,7 @@ void CALayerTreeCoordinator::CommitPendingTreesToCA( ...@@ -48,7 +48,7 @@ void CALayerTreeCoordinator::CommitPendingTreesToCA(
if (pending_ca_renderer_layer_tree_) { if (pending_ca_renderer_layer_tree_) {
pending_ca_renderer_layer_tree_->CommitScheduledCALayers( pending_ca_renderer_layer_tree_->CommitScheduledCALayers(
root_ca_layer_.get(), std::move(current_ca_renderer_layer_tree_), root_ca_layer_.get(), std::move(current_ca_renderer_layer_tree_),
scale_factor_); pixel_size_, scale_factor_);
current_ca_renderer_layer_tree_.swap(pending_ca_renderer_layer_tree_); current_ca_renderer_layer_tree_.swap(pending_ca_renderer_layer_tree_);
} else { } else {
TRACE_EVENT0("gpu", "Blank frame: No overlays or CALayers"); TRACE_EVENT0("gpu", "Blank frame: No overlays or CALayers");
......
...@@ -80,7 +80,8 @@ void UpdateCALayerTree(std::unique_ptr<ui::CARendererLayerTree>& ca_layer_tree, ...@@ -80,7 +80,8 @@ void UpdateCALayerTree(std::unique_ptr<ui::CARendererLayerTree>& ca_layer_tree,
bool result = ScheduleCALayer(new_ca_layer_tree.get(), properties); bool result = ScheduleCALayer(new_ca_layer_tree.get(), properties);
EXPECT_TRUE(result); EXPECT_TRUE(result);
new_ca_layer_tree->CommitScheduledCALayers( new_ca_layer_tree->CommitScheduledCALayers(
superlayer, std::move(ca_layer_tree), properties->scale_factor); superlayer, std::move(ca_layer_tree), properties->rect.size(),
properties->scale_factor);
std::swap(new_ca_layer_tree, ca_layer_tree); std::swap(new_ca_layer_tree, ca_layer_tree);
} }
...@@ -508,8 +509,8 @@ TEST_F(CALayerTreeTest, SplitSortingContextZero) { ...@@ -508,8 +509,8 @@ TEST_F(CALayerTreeTest, SplitSortingContextZero) {
bool result = ScheduleCALayer(ca_layer_tree.get(), &properties); bool result = ScheduleCALayer(ca_layer_tree.get(), &properties);
EXPECT_TRUE(result); EXPECT_TRUE(result);
} }
ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, ca_layer_tree->CommitScheduledCALayers(
properties.scale_factor); superlayer_, nullptr, properties.rect.size(), properties.scale_factor);
// Validate the root layer. // Validate the root layer.
EXPECT_EQ(1u, [[superlayer_ sublayers] count]); EXPECT_EQ(1u, [[superlayer_ sublayers] count]);
...@@ -588,8 +589,8 @@ TEST_F(CALayerTreeTest, SortingContexts) { ...@@ -588,8 +589,8 @@ TEST_F(CALayerTreeTest, SortingContexts) {
bool result = ScheduleCALayer(ca_layer_tree.get(), &properties); bool result = ScheduleCALayer(ca_layer_tree.get(), &properties);
EXPECT_TRUE(result); EXPECT_TRUE(result);
} }
ca_layer_tree->CommitScheduledCALayers(superlayer_, nullptr, ca_layer_tree->CommitScheduledCALayers(
properties.scale_factor); superlayer_, nullptr, properties.rect.size(), properties.scale_factor);
// Validate the root layer. // Validate the root layer.
EXPECT_EQ(1u, [[superlayer_ sublayers] count]); EXPECT_EQ(1u, [[superlayer_ sublayers] count]);
...@@ -882,7 +883,8 @@ TEST_F(CALayerTreeTest, FullscreenLowPower) { ...@@ -882,7 +883,8 @@ TEST_F(CALayerTreeTest, FullscreenLowPower) {
bool result = ScheduleCALayer(new_ca_layer_tree.get(), &properties); bool result = ScheduleCALayer(new_ca_layer_tree.get(), &properties);
EXPECT_TRUE(result); EXPECT_TRUE(result);
new_ca_layer_tree->CommitScheduledCALayers( new_ca_layer_tree->CommitScheduledCALayers(
superlayer_, std::move(ca_layer_tree), properties.scale_factor); superlayer_, std::move(ca_layer_tree), properties.rect.size(),
properties.scale_factor);
std::swap(new_ca_layer_tree, ca_layer_tree); std::swap(new_ca_layer_tree, ca_layer_tree);
// Validate the tree structure. // Validate the tree structure.
...@@ -896,7 +898,7 @@ TEST_F(CALayerTreeTest, FullscreenLowPower) { ...@@ -896,7 +898,7 @@ TEST_F(CALayerTreeTest, FullscreenLowPower) {
EXPECT_EQ(1u, [[transform_layer sublayers] count]); EXPECT_EQ(1u, [[transform_layer sublayers] count]);
// Validate the content layer and fullscreen low power mode. // Validate the content layer and fullscreen low power mode.
EXPECT_TRUE(CGRectEqualToRect([root_layer frame], CGRectZero)); EXPECT_FALSE(CGRectEqualToRect([root_layer frame], CGRectZero));
EXPECT_NE([root_layer backgroundColor], nil); EXPECT_NE([root_layer backgroundColor], nil);
} }
...@@ -909,7 +911,8 @@ TEST_F(CALayerTreeTest, FullscreenLowPower) { ...@@ -909,7 +911,8 @@ TEST_F(CALayerTreeTest, FullscreenLowPower) {
result = ScheduleCALayer(new_ca_layer_tree.get(), &properties); result = ScheduleCALayer(new_ca_layer_tree.get(), &properties);
EXPECT_TRUE(result); EXPECT_TRUE(result);
new_ca_layer_tree->CommitScheduledCALayers( new_ca_layer_tree->CommitScheduledCALayers(
superlayer_, std::move(ca_layer_tree), properties.scale_factor); superlayer_, std::move(ca_layer_tree), properties.rect.size(),
properties.scale_factor);
std::swap(new_ca_layer_tree, ca_layer_tree); std::swap(new_ca_layer_tree, ca_layer_tree);
// Validate the tree structure. // Validate the tree structure.
...@@ -936,7 +939,8 @@ TEST_F(CALayerTreeTest, FullscreenLowPower) { ...@@ -936,7 +939,8 @@ TEST_F(CALayerTreeTest, FullscreenLowPower) {
result = ScheduleCALayer(new_ca_layer_tree.get(), &properties); result = ScheduleCALayer(new_ca_layer_tree.get(), &properties);
EXPECT_TRUE(result); EXPECT_TRUE(result);
new_ca_layer_tree->CommitScheduledCALayers( new_ca_layer_tree->CommitScheduledCALayers(
superlayer_, std::move(ca_layer_tree), properties.scale_factor); superlayer_, std::move(ca_layer_tree), properties.rect.size(),
properties.scale_factor);
std::swap(new_ca_layer_tree, ca_layer_tree); std::swap(new_ca_layer_tree, ca_layer_tree);
// Validate the tree structure. // Validate the tree structure.
...@@ -963,7 +967,8 @@ TEST_F(CALayerTreeTest, FullscreenLowPower) { ...@@ -963,7 +967,8 @@ TEST_F(CALayerTreeTest, FullscreenLowPower) {
result = ScheduleCALayer(new_ca_layer_tree.get(), &properties_black); result = ScheduleCALayer(new_ca_layer_tree.get(), &properties_black);
EXPECT_TRUE(result); EXPECT_TRUE(result);
new_ca_layer_tree->CommitScheduledCALayers( new_ca_layer_tree->CommitScheduledCALayers(
superlayer_, std::move(ca_layer_tree), properties.scale_factor); superlayer_, std::move(ca_layer_tree), properties.rect.size(),
properties.scale_factor);
std::swap(new_ca_layer_tree, ca_layer_tree); std::swap(new_ca_layer_tree, ca_layer_tree);
// Validate the tree structure. // Validate the tree structure.
......
...@@ -51,6 +51,7 @@ class ACCELERATED_WIDGET_MAC_EXPORT CARendererLayerTree { ...@@ -51,6 +51,7 @@ class ACCELERATED_WIDGET_MAC_EXPORT CARendererLayerTree {
// not re-used by |this| will be removed from the CALayer hierarchy. // not re-used by |this| will be removed from the CALayer hierarchy.
void CommitScheduledCALayers(CALayer* superlayer, void CommitScheduledCALayers(CALayer* superlayer,
std::unique_ptr<CARendererLayerTree> old_tree, std::unique_ptr<CARendererLayerTree> old_tree,
const gfx::Size& pixel_size,
float scale_factor); float scale_factor);
// Returns the contents used for a given solid color. // Returns the contents used for a given solid color.
...@@ -86,15 +87,12 @@ class ACCELERATED_WIDGET_MAC_EXPORT CARendererLayerTree { ...@@ -86,15 +87,12 @@ class ACCELERATED_WIDGET_MAC_EXPORT CARendererLayerTree {
// to nil, so that its destructor will not remove an active CALayer. // to nil, so that its destructor will not remove an active CALayer.
void CommitToCA(CALayer* superlayer, void CommitToCA(CALayer* superlayer,
RootLayer* old_layer, RootLayer* old_layer,
const gfx::Size& pixel_size,
float scale_factor); float scale_factor);
// Check to see if the CALayer tree is just a video layer on a black // Return true if the CALayer tree is just a video layer on a black or
// background. If so, return true and set background_rect to the // transparent background, false otherwise.
// background's bounding rect, otherwise return false. CommitToCA() calls bool WantsFullcreenLowPowerBackdrop();
// this function and, based on its return value, either gives the root
// layer this frame and a black background color or clears them.
bool WantsFullcreenLowPowerBackdrop(float scale_factor,
gfx::RectF* background_rect);
std::vector<ClipAndSortingLayer> clip_and_sorting_layers; std::vector<ClipAndSortingLayer> clip_and_sorting_layers;
base::scoped_nsobject<CALayer> ca_layer; base::scoped_nsobject<CALayer> ca_layer;
......
...@@ -220,6 +220,7 @@ bool CARendererLayerTree::ScheduleCALayer(const CARendererLayerParams& params) { ...@@ -220,6 +220,7 @@ bool CARendererLayerTree::ScheduleCALayer(const CARendererLayerParams& params) {
void CARendererLayerTree::CommitScheduledCALayers( void CARendererLayerTree::CommitScheduledCALayers(
CALayer* superlayer, CALayer* superlayer,
std::unique_ptr<CARendererLayerTree> old_tree, std::unique_ptr<CARendererLayerTree> old_tree,
const gfx::Size& pixel_size,
float scale_factor) { float scale_factor) {
TRACE_EVENT0("gpu", "CARendererLayerTree::CommitScheduledCALayers"); TRACE_EVENT0("gpu", "CARendererLayerTree::CommitScheduledCALayers");
RootLayer* old_root_layer = nullptr; RootLayer* old_root_layer = nullptr;
...@@ -229,7 +230,7 @@ void CARendererLayerTree::CommitScheduledCALayers( ...@@ -229,7 +230,7 @@ void CARendererLayerTree::CommitScheduledCALayers(
old_root_layer = &old_tree->root_layer_; old_root_layer = &old_tree->root_layer_;
} }
root_layer_.CommitToCA(superlayer, old_root_layer, scale_factor); root_layer_.CommitToCA(superlayer, old_root_layer, pixel_size, scale_factor);
// If there are any extra CALayers in |old_tree| that were not stolen by this // If there are any extra CALayers in |old_tree| that were not stolen by this
// tree, they will be removed from the CALayer tree in this deallocation. // tree, they will be removed from the CALayer tree in this deallocation.
old_tree.reset(); old_tree.reset();
...@@ -237,9 +238,7 @@ void CARendererLayerTree::CommitScheduledCALayers( ...@@ -237,9 +238,7 @@ void CARendererLayerTree::CommitScheduledCALayers(
scale_factor_ = scale_factor; scale_factor_ = scale_factor;
} }
bool CARendererLayerTree::RootLayer::WantsFullcreenLowPowerBackdrop( bool CARendererLayerTree::RootLayer::WantsFullcreenLowPowerBackdrop() {
float scale_factor,
gfx::RectF* background_rect) {
bool found_video_layer = false; bool found_video_layer = false;
for (auto& clip_layer : clip_and_sorting_layers) { for (auto& clip_layer : clip_and_sorting_layers) {
for (auto& transform_layer : clip_layer.transform_layers) { for (auto& transform_layer : clip_layer.transform_layers) {
...@@ -250,7 +249,6 @@ bool CARendererLayerTree::RootLayer::WantsFullcreenLowPowerBackdrop( ...@@ -250,7 +249,6 @@ bool CARendererLayerTree::RootLayer::WantsFullcreenLowPowerBackdrop(
// See if this is the video layer. // See if this is the video layer.
if (content_layer.use_av_layer) { if (content_layer.use_av_layer) {
background_rect->Union(gfx::RectF(content_layer.rect));
found_video_layer = true; found_video_layer = true;
if (!transform_layer.transform.IsPositiveScaleOrTranslation()) if (!transform_layer.transform.IsPositiveScaleOrTranslation())
return false; return false;
...@@ -263,15 +261,13 @@ bool CARendererLayerTree::RootLayer::WantsFullcreenLowPowerBackdrop( ...@@ -263,15 +261,13 @@ bool CARendererLayerTree::RootLayer::WantsFullcreenLowPowerBackdrop(
// solid black or transparent // solid black or transparent
if (content_layer.io_surface) if (content_layer.io_surface)
return false; return false;
if (content_layer.background_color == SK_ColorBLACK) { if (content_layer.background_color != SK_ColorBLACK &&
background_rect->Union(gfx::RectF(content_layer.rect)); content_layer.background_color != SK_ColorTRANSPARENT) {
} else if (content_layer.background_color != SK_ColorTRANSPARENT) {
return false; return false;
} }
} }
} }
} }
background_rect->Scale(1 / scale_factor);
return found_video_layer; return found_video_layer;
} }
...@@ -554,6 +550,7 @@ void CARendererLayerTree::TransformLayer::AddContentLayer( ...@@ -554,6 +550,7 @@ void CARendererLayerTree::TransformLayer::AddContentLayer(
void CARendererLayerTree::RootLayer::CommitToCA(CALayer* superlayer, void CARendererLayerTree::RootLayer::CommitToCA(CALayer* superlayer,
RootLayer* old_layer, RootLayer* old_layer,
const gfx::Size& pixel_size,
float scale_factor) { float scale_factor) {
if (old_layer) { if (old_layer) {
DCHECK(old_layer->ca_layer); DCHECK(old_layer->ca_layer);
...@@ -569,8 +566,9 @@ void CARendererLayerTree::RootLayer::CommitToCA(CALayer* superlayer, ...@@ -569,8 +566,9 @@ void CARendererLayerTree::RootLayer::CommitToCA(CALayer* superlayer,
DLOG(ERROR) << "CARendererLayerTree root layer not attached to tree."; DLOG(ERROR) << "CARendererLayerTree root layer not attached to tree.";
} }
gfx::RectF bg_rect; if (WantsFullcreenLowPowerBackdrop()) {
if (WantsFullcreenLowPowerBackdrop(scale_factor, &bg_rect)) { const gfx::RectF bg_rect(
ScaleSize(gfx::SizeF(pixel_size), 1 / scale_factor));
if (gfx::RectF([ca_layer frame]) != bg_rect) if (gfx::RectF([ca_layer frame]) != bg_rect)
[ca_layer setFrame:bg_rect.ToCGRect()]; [ca_layer setFrame:bg_rect.ToCGRect()];
if (![ca_layer backgroundColor]) if (![ca_layer backgroundColor])
......
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