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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 77 |
76 for (const FilterOperation& operation : quad->filters.operations()) { | 78 for (const FilterOperation& operation : quad->filters.operations()) { |
77 bool success = FilterOperationSupported(operation); | 79 bool success = FilterOperationSupported(operation); |
78 if (!success) | 80 if (!success) |
79 return CA_LAYER_FAILED_RENDER_PASS_FILTER_OPERATION; | 81 return CA_LAYER_FAILED_RENDER_PASS_FILTER_OPERATION; |
80 } | 82 } |
81 | 83 |
82 ca_layer_overlay->rpdq = quad; | 84 ca_layer_overlay->rpdq = quad; |
83 ca_layer_overlay->contents_rect = gfx::RectF(0, 0, 1, 1); | 85 ca_layer_overlay->contents_rect = gfx::RectF(0, 0, 1, 1); |
84 | 86 |
85 return CA_LAYER_SUCCESS; | 87 // TODO(erikchen): Enable this when RenderPassDrawQuad promotion to CALayer |
| 88 // is fully functional. https://crbug.com/581526. |
| 89 if (g_allow_rpdq_quad_conversion) |
| 90 return CA_LAYER_SUCCESS; |
| 91 return CA_LAYER_FAILED_RENDER_PASS; |
86 } | 92 } |
87 | 93 |
88 CALayerResult FromStreamVideoQuad(ResourceProvider* resource_provider, | 94 CALayerResult FromStreamVideoQuad(ResourceProvider* resource_provider, |
89 const StreamVideoDrawQuad* quad, | 95 const StreamVideoDrawQuad* quad, |
90 CALayerOverlay* ca_layer_overlay) { | 96 CALayerOverlay* ca_layer_overlay) { |
91 unsigned resource_id = quad->resource_id(); | 97 unsigned resource_id = quad->resource_id(); |
92 if (!resource_provider->IsOverlayCandidate(resource_id)) | 98 if (!resource_provider->IsOverlayCandidate(resource_id)) |
93 return CA_LAYER_FAILED_STREAM_VIDEO_NOT_CANDIDATE; | 99 return CA_LAYER_FAILED_STREAM_VIDEO_NOT_CANDIDATE; |
94 ca_layer_overlay->contents_resource_id = resource_id; | 100 ca_layer_overlay->contents_resource_id = resource_id; |
95 // TODO(ccameron): Support merging at least some basic transforms into the | 101 // TODO(ccameron): Support merging at least some basic transforms into the |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 UMA_HISTOGRAM_ENUMERATION("Compositing.Renderer.CALayerResult", result, | 297 UMA_HISTOGRAM_ENUMERATION("Compositing.Renderer.CALayerResult", result, |
292 CA_LAYER_FAILED_COUNT); | 298 CA_LAYER_FAILED_COUNT); |
293 | 299 |
294 if (result != CA_LAYER_SUCCESS) { | 300 if (result != CA_LAYER_SUCCESS) { |
295 ca_layer_overlays->clear(); | 301 ca_layer_overlays->clear(); |
296 return false; | 302 return false; |
297 } | 303 } |
298 return true; | 304 return true; |
299 } | 305 } |
300 | 306 |
| 307 void EnableRenderPassDrawQuadForTesting() { |
| 308 g_allow_rpdq_quad_conversion = true; |
| 309 } |
| 310 |
301 } // namespace cc | 311 } // namespace cc |
OLD | NEW |