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 "base/metrics/histogram_macros.h" | |
| 7 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 8 #include "cc/quads/solid_color_draw_quad.h" | 9 #include "cc/quads/solid_color_draw_quad.h" |
| 9 #include "cc/quads/yuv_video_draw_quad.h" | 10 #include "cc/quads/yuv_video_draw_quad.h" |
| 10 #include "cc/resources/resource_provider.h" | 11 #include "cc/resources/resource_provider.h" |
| 11 #include "gpu/GLES2/gl2extchromium.h" | 12 #include "gpu/GLES2/gl2extchromium.h" |
| 12 #include "ui/gfx/geometry/rect_conversions.h" | 13 #include "ui/gfx/geometry/rect_conversions.h" |
| 13 #include "ui/gl/gl_switches.h" | 14 #include "ui/gl/gl_switches.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 | 17 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 | 79 |
| 79 DCLayerOverlayProcessor::DCLayerResult DCLayerOverlayProcessor::FromDrawQuad( | 80 DCLayerOverlayProcessor::DCLayerResult DCLayerOverlayProcessor::FromDrawQuad( |
| 80 ResourceProvider* resource_provider, | 81 ResourceProvider* resource_provider, |
| 81 const gfx::RectF& display_rect, | 82 const gfx::RectF& display_rect, |
| 82 QuadList::ConstIterator quad_list_begin, | 83 QuadList::ConstIterator quad_list_begin, |
| 83 QuadList::ConstIterator quad, | 84 QuadList::ConstIterator quad, |
| 84 DCLayerOverlay* ca_layer_overlay) { | 85 DCLayerOverlay* ca_layer_overlay) { |
| 85 if (quad->shared_quad_state->blend_mode != SkBlendMode::kSrcOver) | 86 if (quad->shared_quad_state->blend_mode != SkBlendMode::kSrcOver) |
| 86 return DC_LAYER_FAILED_QUAD_BLEND_MODE; | 87 return DC_LAYER_FAILED_QUAD_BLEND_MODE; |
| 87 | 88 |
| 88 DCLayerResult result = DC_LAYER_FAILED_UNKNOWN; | 89 DCLayerResult result; |
| 89 switch (quad->material) { | 90 switch (quad->material) { |
| 90 case DrawQuad::YUV_VIDEO_CONTENT: | 91 case DrawQuad::YUV_VIDEO_CONTENT: |
| 91 result = | 92 result = |
| 92 FromYUVQuad(resource_provider, YUVVideoDrawQuad::MaterialCast(*quad), | 93 FromYUVQuad(resource_provider, YUVVideoDrawQuad::MaterialCast(*quad), |
| 93 ca_layer_overlay); | 94 ca_layer_overlay); |
| 94 break; | 95 break; |
| 95 default: | 96 default: |
| 96 return DC_LAYER_FAILED_UNKNOWN; | 97 return DC_LAYER_FAILED_UNSUPPORTED_QUAD; |
| 97 } | 98 } |
| 98 if (result != DC_LAYER_SUCCESS) | 99 if (result != DC_LAYER_SUCCESS) |
| 99 return result; | 100 return result; |
| 100 | 101 |
| 101 scoped_refptr<DCLayerOverlaySharedState> overlay_shared_state( | 102 scoped_refptr<DCLayerOverlaySharedState> overlay_shared_state( |
| 102 new DCLayerOverlaySharedState); | 103 new DCLayerOverlaySharedState); |
| 103 overlay_shared_state->z_order = 1; | 104 overlay_shared_state->z_order = 1; |
| 104 | 105 |
| 105 overlay_shared_state->is_clipped = quad->shared_quad_state->is_clipped; | 106 overlay_shared_state->is_clipped = quad->shared_quad_state->is_clipped; |
| 106 overlay_shared_state->clip_rect = | 107 overlay_shared_state->clip_rect = |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 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) { |
| 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 bool display_rect_changed = (display_rect != previous_display_rect_); |
| 127 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) { | 128 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) { |
| 128 DCLayerOverlay ca_layer; | 129 DCLayerOverlay ca_layer; |
| 129 DCLayerResult result = FromDrawQuad(resource_provider, display_rect, | 130 DCLayerResult result = FromDrawQuad(resource_provider, display_rect, |
| 130 quad_list->begin(), it, &ca_layer); | 131 quad_list->begin(), it, &ca_layer); |
| 131 if (result != DC_LAYER_SUCCESS) | 132 if (result != DC_LAYER_SUCCESS) { |
| 133 UMA_HISTOGRAM_ENUMERATION("GPU.DirectComposition.DCLayerResult", result, | |
| 134 DC_LAYER_FAILED_MAX); | |
| 132 continue; | 135 continue; |
| 136 } | |
| 133 | 137 |
| 134 if (!it->shared_quad_state->quad_to_target_transform | 138 if (!it->shared_quad_state->quad_to_target_transform |
| 135 .Preserves2dAxisAlignment() && | 139 .Preserves2dAxisAlignment() && |
| 136 !base::FeatureList::IsEnabled( | 140 !base::FeatureList::IsEnabled( |
| 137 features::kDirectCompositionComplexOverlays)) { | 141 features::kDirectCompositionComplexOverlays)) { |
| 142 UMA_HISTOGRAM_ENUMERATION("GPU.DirectComposition.DCLayerResult", | |
| 143 DC_LAYER_FAILED_COMPLEX_TRANSFORM, | |
| 144 DC_LAYER_FAILED_MAX); | |
|
Ilya Sherman
2017/05/24 23:52:49
nit: The UMA_HISTOGRAM macros expand to a fair bit
| |
| 138 continue; | 145 continue; |
| 139 } | 146 } |
| 140 | 147 |
| 141 gfx::Rect quad_rectangle = gfx::ToEnclosingRect(ClippedQuadRectangle(*it)); | 148 gfx::Rect quad_rectangle = gfx::ToEnclosingRect(ClippedQuadRectangle(*it)); |
| 142 gfx::RectF occlusion_bounding_box = | 149 gfx::RectF occlusion_bounding_box = |
| 143 GetOcclusionBounds(gfx::RectF(quad_rectangle), quad_list->begin(), it); | 150 GetOcclusionBounds(gfx::RectF(quad_rectangle), quad_list->begin(), it); |
| 144 if (occlusion_bounding_box.IsEmpty()) { | 151 if (occlusion_bounding_box.IsEmpty()) { |
| 145 // The quad is on top, so promote it to an overlay and remove all damage | 152 // The quad is on top, so promote it to an overlay and remove all damage |
| 146 // underneath it. | 153 // underneath it. |
| 147 if (it->shared_quad_state->quad_to_target_transform | 154 if (it->shared_quad_state->quad_to_target_transform |
| 148 .Preserves2dAxisAlignment() && | 155 .Preserves2dAxisAlignment() && |
| 149 !display_rect_changed && !it->ShouldDrawWithBlending()) { | 156 !display_rect_changed && !it->ShouldDrawWithBlending()) { |
| 150 damage_rect->Subtract(quad_rectangle); | 157 damage_rect->Subtract(quad_rectangle); |
| 151 } | 158 } |
| 152 quad_list->EraseAndInvalidateAllPointers(it); | 159 quad_list->EraseAndInvalidateAllPointers(it); |
| 153 } else if (!base::FeatureList::IsEnabled( | 160 } else if (!base::FeatureList::IsEnabled( |
| 154 features::kDirectCompositionUnderlays)) { | 161 features::kDirectCompositionUnderlays)) { |
| 162 UMA_HISTOGRAM_ENUMERATION("GPU.DirectComposition.DCLayerResult", | |
| 163 DC_LAYER_FAILED_OCCLUDED, DC_LAYER_FAILED_MAX); | |
| 155 continue; | 164 continue; |
| 156 } else { | 165 } else { |
| 157 // The quad is occluded, so replace it with a black solid color quad and | 166 // The quad is occluded, so replace it with a black solid color quad and |
| 158 // place the overlay itself under the quad. | 167 // place the overlay itself under the quad. |
| 159 if (it->shared_quad_state->quad_to_target_transform | 168 if (it->shared_quad_state->quad_to_target_transform |
| 160 .IsIdentityOrIntegerTranslation()) { | 169 .IsIdentityOrIntegerTranslation()) { |
| 161 this_frame_underlay_rect = quad_rectangle; | 170 this_frame_underlay_rect = quad_rectangle; |
| 162 } | 171 } |
| 163 ca_layer.shared_state->z_order = -1; | 172 ca_layer.shared_state->z_order = -1; |
| 164 const SharedQuadState* shared_quad_state = it->shared_quad_state; | 173 const SharedQuadState* shared_quad_state = it->shared_quad_state; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 ca_layer_overlays->push_back(ca_layer); | 207 ca_layer_overlays->push_back(ca_layer); |
| 199 // Only allow one overlay for now. | 208 // Only allow one overlay for now. |
| 200 break; | 209 break; |
| 201 } | 210 } |
| 202 damage_rect->Intersect(gfx::ToEnclosingRect(display_rect)); | 211 damage_rect->Intersect(gfx::ToEnclosingRect(display_rect)); |
| 203 previous_frame_underlay_rect_ = this_frame_underlay_rect; | 212 previous_frame_underlay_rect_ = this_frame_underlay_rect; |
| 204 previous_display_rect_ = display_rect; | 213 previous_display_rect_ = display_rect; |
| 205 } | 214 } |
| 206 | 215 |
| 207 } // namespace cc | 216 } // namespace cc |
| OLD | NEW |