Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/dc_layer_overlay.h" | 5 #include "cc/output/dc_layer_overlay.h" |
| 6 | 6 |
| 7 #include "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
| 8 #include "cc/quads/solid_color_draw_quad.h" | 8 #include "cc/quads/solid_color_draw_quad.h" |
| 9 #include "cc/quads/yuv_video_draw_quad.h" | 9 #include "cc/quads/yuv_video_draw_quad.h" |
| 10 #include "cc/resources/resource_provider.h" | 10 #include "cc/resources/resource_provider.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 overlay_shared_state->transform = | 110 overlay_shared_state->transform = |
| 111 quad->shared_quad_state->quad_to_target_transform.matrix(); | 111 quad->shared_quad_state->quad_to_target_transform.matrix(); |
| 112 | 112 |
| 113 ca_layer_overlay->shared_state = overlay_shared_state; | 113 ca_layer_overlay->shared_state = overlay_shared_state; |
| 114 ca_layer_overlay->bounds_rect = gfx::RectF(quad->rect); | 114 ca_layer_overlay->bounds_rect = gfx::RectF(quad->rect); |
| 115 | 115 |
| 116 return result; | 116 return result; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void DCLayerOverlayProcessor::Process(ResourceProvider* resource_provider, | 119 void DCLayerOverlayProcessor::Process(ResourceProvider* resource_provider, |
| 120 bool was_reshaped, | |
| 120 const gfx::RectF& display_rect, | 121 const gfx::RectF& display_rect, |
| 121 QuadList* quad_list, | 122 QuadList* quad_list, |
| 122 gfx::Rect* overlay_damage_rect, | 123 gfx::Rect* overlay_damage_rect, |
| 123 gfx::Rect* damage_rect, | 124 gfx::Rect* damage_rect, |
| 124 DCLayerOverlayList* ca_layer_overlays) { | 125 DCLayerOverlayList* ca_layer_overlays) { |
|
ccameron
2017/05/11 08:49:17
This function is doing both the "overlay" strategy
| |
| 125 gfx::Rect this_frame_underlay_rect; | 126 gfx::Rect this_frame_underlay_rect; |
| 126 bool display_rect_changed = (display_rect != previous_display_rect_); | |
| 127 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) { | 127 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) { |
| 128 DCLayerOverlay ca_layer; | 128 DCLayerOverlay ca_layer; |
| 129 DCLayerResult result = FromDrawQuad(resource_provider, display_rect, | 129 DCLayerResult result = FromDrawQuad(resource_provider, display_rect, |
| 130 quad_list->begin(), it, &ca_layer); | 130 quad_list->begin(), it, &ca_layer); |
| 131 if (result != DC_LAYER_SUCCESS) | 131 if (result != DC_LAYER_SUCCESS) |
| 132 continue; | 132 continue; |
| 133 | 133 |
| 134 if (!it->shared_quad_state->quad_to_target_transform | 134 if (!it->shared_quad_state->quad_to_target_transform |
| 135 .Preserves2dAxisAlignment() && | 135 .Preserves2dAxisAlignment() && |
| 136 !base::FeatureList::IsEnabled( | 136 !base::FeatureList::IsEnabled( |
| 137 features::kDirectCompositionComplexOverlays)) { | 137 features::kDirectCompositionComplexOverlays)) { |
| 138 continue; | 138 continue; |
| 139 } | 139 } |
| 140 | 140 |
| 141 gfx::Rect quad_rectangle = gfx::ToEnclosingRect(ClippedQuadRectangle(*it)); | 141 gfx::Rect quad_rectangle = gfx::ToEnclosingRect(ClippedQuadRectangle(*it)); |
| 142 gfx::RectF occlusion_bounding_box = | 142 gfx::RectF occlusion_bounding_box = |
| 143 GetOcclusionBounds(gfx::RectF(quad_rectangle), quad_list->begin(), it); | 143 GetOcclusionBounds(gfx::RectF(quad_rectangle), quad_list->begin(), it); |
| 144 if (occlusion_bounding_box.IsEmpty()) { | 144 if (occlusion_bounding_box.IsEmpty()) { |
| 145 // The quad is on top, so promote it to an overlay and remove all damage | 145 // The quad is on top, so promote it to an overlay and remove all damage |
| 146 // underneath it. | 146 // underneath it. |
| 147 if (it->shared_quad_state->quad_to_target_transform | 147 if (it->shared_quad_state->quad_to_target_transform |
| 148 .Preserves2dAxisAlignment() && | 148 .Preserves2dAxisAlignment() && |
| 149 !display_rect_changed && !it->ShouldDrawWithBlending()) { | 149 !was_reshaped && !it->ShouldDrawWithBlending()) { |
| 150 damage_rect->Subtract(quad_rectangle); | 150 damage_rect->Subtract(quad_rectangle); |
| 151 } | 151 } |
| 152 quad_list->EraseAndInvalidateAllPointers(it); | 152 quad_list->EraseAndInvalidateAllPointers(it); |
| 153 } else if (!base::FeatureList::IsEnabled( | 153 } else if (!base::FeatureList::IsEnabled( |
| 154 features::kDirectCompositionUnderlays)) { | 154 features::kDirectCompositionUnderlays)) { |
| 155 continue; | 155 continue; |
| 156 } else { | 156 } else { |
| 157 // The quad is occluded, so replace it with a black solid color quad and | 157 // The quad is occluded, so replace it with a black solid color quad and |
| 158 // place the overlay itself under the quad. | 158 // place the overlay itself under the quad. |
| 159 if (it->shared_quad_state->quad_to_target_transform | 159 if (it->shared_quad_state->quad_to_target_transform |
| 160 .IsIdentityOrIntegerTranslation()) { | 160 .IsIdentityOrIntegerTranslation()) { |
| 161 this_frame_underlay_rect = quad_rectangle; | 161 this_frame_underlay_rect = quad_rectangle; |
| 162 } | 162 } |
| 163 ca_layer.shared_state->z_order = -1; | 163 ca_layer.shared_state->z_order = -1; |
| 164 const SharedQuadState* shared_quad_state = it->shared_quad_state; | 164 const SharedQuadState* shared_quad_state = it->shared_quad_state; |
| 165 gfx::Rect rect = it->visible_rect; | 165 gfx::Rect rect = it->visible_rect; |
| 166 SolidColorDrawQuad* replacement = | 166 SolidColorDrawQuad* replacement = |
| 167 quad_list->ReplaceExistingElement<SolidColorDrawQuad>(it); | 167 quad_list->ReplaceExistingElement<SolidColorDrawQuad>(it); |
| 168 replacement->SetAll(shared_quad_state, rect, rect, rect, false, | 168 replacement->SetAll(shared_quad_state, rect, rect, rect, false, |
| 169 SK_ColorTRANSPARENT, true); | 169 SK_ColorTRANSPARENT, true); |
| 170 | 170 |
| 171 if (this_frame_underlay_rect == previous_frame_underlay_rect_) { | 171 if (this_frame_underlay_rect == previous_frame_underlay_rect_) { |
| 172 // If this underlay rect is the same as for last frame, subtract its | 172 // If this underlay rect is the same as for last frame, subtract its |
| 173 // area from the damage of the main surface, as the cleared area was | 173 // area from the damage of the main surface, as the cleared area was |
| 174 // already cleared last frame. Add back the damage from the occluded | 174 // already cleared last frame. Add back the damage from the occluded |
| 175 // area for this and last frame, as that may have changed. | 175 // area for this and last frame, as that may have changed. |
| 176 if (it->shared_quad_state->quad_to_target_transform | 176 if (it->shared_quad_state->quad_to_target_transform |
| 177 .Preserves2dAxisAlignment() && | 177 .Preserves2dAxisAlignment() && |
| 178 !display_rect_changed) { | 178 !was_reshaped) { |
|
ccameron
2017/05/11 08:49:17
Drive-by comment -- is this if missing a
else {
| |
| 179 gfx::Rect occluding_damage_rect = *damage_rect; | 179 gfx::Rect occluding_damage_rect = *damage_rect; |
| 180 occluding_damage_rect.Intersect(quad_rectangle); | 180 occluding_damage_rect.Intersect(quad_rectangle); |
| 181 damage_rect->Subtract(quad_rectangle); | 181 damage_rect->Subtract(quad_rectangle); |
| 182 gfx::Rect new_occlusion_bounding_box = | 182 gfx::Rect new_occlusion_bounding_box = |
| 183 gfx::ToEnclosingRect(occlusion_bounding_box); | 183 gfx::ToEnclosingRect(occlusion_bounding_box); |
| 184 new_occlusion_bounding_box.Union(previous_occlusion_bounding_box_); | 184 new_occlusion_bounding_box.Union(previous_occlusion_bounding_box_); |
| 185 occluding_damage_rect.Intersect(new_occlusion_bounding_box); | 185 occluding_damage_rect.Intersect(new_occlusion_bounding_box); |
| 186 | 186 |
| 187 damage_rect->Union(occluding_damage_rect); | 187 damage_rect->Union(occluding_damage_rect); |
| 188 } | 188 } |
| 189 } else { | 189 } else { |
| 190 // Entire replacement quad must be redrawn. | 190 // Entire replacement quad must be redrawn. |
| 191 damage_rect->Union(quad_rectangle); | 191 damage_rect->Union(quad_rectangle); |
| 192 } | 192 } |
| 193 previous_occlusion_bounding_box_ = | 193 previous_occlusion_bounding_box_ = |
| 194 gfx::ToEnclosingRect(occlusion_bounding_box); | 194 gfx::ToEnclosingRect(occlusion_bounding_box); |
| 195 } | 195 } |
| 196 overlay_damage_rect->Union(quad_rectangle); | 196 overlay_damage_rect->Union(quad_rectangle); |
| 197 | 197 |
| 198 ca_layer_overlays->push_back(ca_layer); | 198 ca_layer_overlays->push_back(ca_layer); |
| 199 // Only allow one overlay for now. | 199 // Only allow one overlay for now. |
| 200 break; | 200 break; |
| 201 } | 201 } |
| 202 damage_rect->Intersect(gfx::ToEnclosingRect(display_rect)); | 202 damage_rect->Intersect(gfx::ToEnclosingRect(display_rect)); |
| 203 previous_frame_underlay_rect_ = this_frame_underlay_rect; | 203 previous_frame_underlay_rect_ = this_frame_underlay_rect; |
| 204 previous_display_rect_ = display_rect; | |
| 205 } | 204 } |
| 206 | 205 |
| 207 } // namespace cc | 206 } // namespace cc |
| OLD | NEW |