| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ca_layer_overlay.h" | 5 #include "cc/output/ca_layer_overlay.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "cc/quads/render_pass_draw_quad.h" | 8 #include "cc/quads/render_pass_draw_quad.h" |
| 9 #include "cc/quads/solid_color_draw_quad.h" | 9 #include "cc/quads/solid_color_draw_quad.h" |
| 10 #include "cc/quads/stream_video_draw_quad.h" | 10 #include "cc/quads/stream_video_draw_quad.h" |
| 11 #include "cc/quads/texture_draw_quad.h" | 11 #include "cc/quads/texture_draw_quad.h" |
| 12 #include "cc/quads/tile_draw_quad.h" | 12 #include "cc/quads/tile_draw_quad.h" |
| 13 #include "cc/resources/resource_provider.h" | 13 #include "cc/resources/resource_provider.h" |
| 14 #include "gpu/GLES2/gl2extchromium.h" | 14 #include "gpu/GLES2/gl2extchromium.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 bool g_allow_rpdq_quad_conversion = false; |
| 21 |
| 20 // This enum is used for histogram states and should only have new values added | 22 // This enum is used for histogram states and should only have new values added |
| 21 // to the end before COUNT. | 23 // to the end before COUNT. |
| 22 enum CALayerResult { | 24 enum CALayerResult { |
| 23 CA_LAYER_SUCCESS = 0, | 25 CA_LAYER_SUCCESS = 0, |
| 24 CA_LAYER_FAILED_UNKNOWN, | 26 CA_LAYER_FAILED_UNKNOWN, |
| 25 CA_LAYER_FAILED_IO_SURFACE_NOT_CANDIDATE, | 27 CA_LAYER_FAILED_IO_SURFACE_NOT_CANDIDATE, |
| 26 CA_LAYER_FAILED_STREAM_VIDEO_NOT_CANDIDATE, | 28 CA_LAYER_FAILED_STREAM_VIDEO_NOT_CANDIDATE, |
| 27 CA_LAYER_FAILED_STREAM_VIDEO_TRANSFORM, | 29 CA_LAYER_FAILED_STREAM_VIDEO_TRANSFORM, |
| 28 CA_LAYER_FAILED_TEXTURE_NOT_CANDIDATE, | 30 CA_LAYER_FAILED_TEXTURE_NOT_CANDIDATE, |
| 29 CA_LAYER_FAILED_TEXTURE_Y_FLIPPED, | 31 CA_LAYER_FAILED_TEXTURE_Y_FLIPPED, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 for (const FilterOperation& operation : quad->filters.operations()) { | 115 for (const FilterOperation& operation : quad->filters.operations()) { |
| 114 bool success = ConvertAndAppendFilterOperation( | 116 bool success = ConvertAndAppendFilterOperation( |
| 115 operation, &ca_layer_overlay->filter_effects); | 117 operation, &ca_layer_overlay->filter_effects); |
| 116 if (!success) | 118 if (!success) |
| 117 return CA_LAYER_FAILED_RENDER_PASS_FILTER_OPERATION; | 119 return CA_LAYER_FAILED_RENDER_PASS_FILTER_OPERATION; |
| 118 } | 120 } |
| 119 | 121 |
| 120 ca_layer_overlay->render_pass_id = quad->render_pass_id; | 122 ca_layer_overlay->render_pass_id = quad->render_pass_id; |
| 121 ca_layer_overlay->contents_rect = gfx::RectF(0, 0, 1, 1); | 123 ca_layer_overlay->contents_rect = gfx::RectF(0, 0, 1, 1); |
| 122 | 124 |
| 123 return CA_LAYER_SUCCESS; | 125 // TODO(erikchen): Enable this when RenderPassDrawQuad promotion to CALayer |
| 126 // is fully functional. https://crbug.com/581526. |
| 127 if (g_allow_rpdq_quad_conversion) |
| 128 return CA_LAYER_SUCCESS; |
| 129 return CA_LAYER_FAILED_RENDER_PASS; |
| 124 } | 130 } |
| 125 | 131 |
| 126 CALayerResult FromStreamVideoQuad(ResourceProvider* resource_provider, | 132 CALayerResult FromStreamVideoQuad(ResourceProvider* resource_provider, |
| 127 const StreamVideoDrawQuad* quad, | 133 const StreamVideoDrawQuad* quad, |
| 128 CALayerOverlay* ca_layer_overlay) { | 134 CALayerOverlay* ca_layer_overlay) { |
| 129 unsigned resource_id = quad->resource_id(); | 135 unsigned resource_id = quad->resource_id(); |
| 130 if (!resource_provider->IsOverlayCandidate(resource_id)) | 136 if (!resource_provider->IsOverlayCandidate(resource_id)) |
| 131 return CA_LAYER_FAILED_STREAM_VIDEO_NOT_CANDIDATE; | 137 return CA_LAYER_FAILED_STREAM_VIDEO_NOT_CANDIDATE; |
| 132 ca_layer_overlay->contents_resource_id = resource_id; | 138 ca_layer_overlay->contents_resource_id = resource_id; |
| 133 // TODO(ccameron): Support merging at least some basic transforms into the | 139 // TODO(ccameron): Support merging at least some basic transforms into the |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 UMA_HISTOGRAM_ENUMERATION("Compositing.Renderer.CALayerResult", result, | 335 UMA_HISTOGRAM_ENUMERATION("Compositing.Renderer.CALayerResult", result, |
| 330 CA_LAYER_FAILED_COUNT); | 336 CA_LAYER_FAILED_COUNT); |
| 331 | 337 |
| 332 if (result != CA_LAYER_SUCCESS) { | 338 if (result != CA_LAYER_SUCCESS) { |
| 333 ca_layer_overlays->clear(); | 339 ca_layer_overlays->clear(); |
| 334 return false; | 340 return false; |
| 335 } | 341 } |
| 336 return true; | 342 return true; |
| 337 } | 343 } |
| 338 | 344 |
| 345 void EnableRenderPassDrawQuadForTesting() { |
| 346 g_allow_rpdq_quad_conversion = true; |
| 347 } |
| 348 |
| 339 } // namespace cc | 349 } // namespace cc |
| OLD | NEW |