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(
if (pending_ca_renderer_layer_tree_) {
pending_ca_renderer_layer_tree_->CommitScheduledCALayers(
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_);
} else {
TRACE_EVENT0("gpu", "Blank frame: No overlays or CALayers");
......
......@@ -51,6 +51,7 @@ class ACCELERATED_WIDGET_MAC_EXPORT CARendererLayerTree {
// not re-used by |this| will be removed from the CALayer hierarchy.
void CommitScheduledCALayers(CALayer* superlayer,
std::unique_ptr<CARendererLayerTree> old_tree,
const gfx::Size& pixel_size,
float scale_factor);
// Returns the contents used for a given solid color.
......@@ -86,15 +87,12 @@ class ACCELERATED_WIDGET_MAC_EXPORT CARendererLayerTree {
// to nil, so that its destructor will not remove an active CALayer.
void CommitToCA(CALayer* superlayer,
RootLayer* old_layer,
const gfx::Size& pixel_size,
float scale_factor);
// Check to see if the CALayer tree is just a video layer on a black
// background. If so, return true and set background_rect to the
// background's bounding rect, otherwise return false. CommitToCA() calls
// 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);
// Return true if the CALayer tree is just a video layer on a black or
// transparent background, false otherwise.
bool WantsFullcreenLowPowerBackdrop();
std::vector<ClipAndSortingLayer> clip_and_sorting_layers;
base::scoped_nsobject<CALayer> ca_layer;
......
......@@ -220,6 +220,7 @@ bool CARendererLayerTree::ScheduleCALayer(const CARendererLayerParams& params) {
void CARendererLayerTree::CommitScheduledCALayers(
CALayer* superlayer,
std::unique_ptr<CARendererLayerTree> old_tree,
const gfx::Size& pixel_size,
float scale_factor) {
TRACE_EVENT0("gpu", "CARendererLayerTree::CommitScheduledCALayers");
RootLayer* old_root_layer = nullptr;
......@@ -229,7 +230,7 @@ void CARendererLayerTree::CommitScheduledCALayers(
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
// tree, they will be removed from the CALayer tree in this deallocation.
old_tree.reset();
......@@ -237,9 +238,7 @@ void CARendererLayerTree::CommitScheduledCALayers(
scale_factor_ = scale_factor;
}
bool CARendererLayerTree::RootLayer::WantsFullcreenLowPowerBackdrop(
float scale_factor,
gfx::RectF* background_rect) {
bool CARendererLayerTree::RootLayer::WantsFullcreenLowPowerBackdrop() {
bool found_video_layer = false;
for (auto& clip_layer : clip_and_sorting_layers) {
for (auto& transform_layer : clip_layer.transform_layers) {
......@@ -250,7 +249,6 @@ bool CARendererLayerTree::RootLayer::WantsFullcreenLowPowerBackdrop(
// See if this is the video layer.
if (content_layer.use_av_layer) {
background_rect->Union(gfx::RectF(content_layer.rect));
found_video_layer = true;
if (!transform_layer.transform.IsPositiveScaleOrTranslation())
return false;
......@@ -263,15 +261,13 @@ bool CARendererLayerTree::RootLayer::WantsFullcreenLowPowerBackdrop(
// solid black or transparent
if (content_layer.io_surface)
return false;
if (content_layer.background_color == SK_ColorBLACK) {
background_rect->Union(gfx::RectF(content_layer.rect));
} else if (content_layer.background_color != SK_ColorTRANSPARENT) {
if (content_layer.background_color != SK_ColorBLACK &&
content_layer.background_color != SK_ColorTRANSPARENT) {
return false;
}
}
}
}
background_rect->Scale(1 / scale_factor);
return found_video_layer;
}
......@@ -554,6 +550,7 @@ void CARendererLayerTree::TransformLayer::AddContentLayer(
void CARendererLayerTree::RootLayer::CommitToCA(CALayer* superlayer,
RootLayer* old_layer,
const gfx::Size& pixel_size,
float scale_factor) {
if (old_layer) {
DCHECK(old_layer->ca_layer);
......@@ -569,8 +566,9 @@ void CARendererLayerTree::RootLayer::CommitToCA(CALayer* superlayer,
DLOG(ERROR) << "CARendererLayerTree root layer not attached to tree.";
}
gfx::RectF bg_rect;
if (WantsFullcreenLowPowerBackdrop(scale_factor, &bg_rect)) {
if (WantsFullcreenLowPowerBackdrop()) {
const gfx::RectF bg_rect(
ScaleSize(gfx::SizeF(pixel_size), 1 / scale_factor));
if (gfx::RectF([ca_layer frame]) != bg_rect)
[ca_layer setFrame:bg_rect.ToCGRect()];
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