Commit 94b94d9e authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

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/1142962Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576521}
parent dfb8fb50
...@@ -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");
......
...@@ -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