| 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; | 20 bool g_allow_rpdq_quad_conversion = true; |
| 21 | 21 |
| 22 // 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 |
| 23 // to the end before COUNT. | 23 // to the end before COUNT. |
| 24 enum CALayerResult { | 24 enum CALayerResult { |
| 25 CA_LAYER_SUCCESS = 0, | 25 CA_LAYER_SUCCESS = 0, |
| 26 CA_LAYER_FAILED_UNKNOWN, | 26 CA_LAYER_FAILED_UNKNOWN, |
| 27 CA_LAYER_FAILED_IO_SURFACE_NOT_CANDIDATE, | 27 CA_LAYER_FAILED_IO_SURFACE_NOT_CANDIDATE, |
| 28 CA_LAYER_FAILED_STREAM_VIDEO_NOT_CANDIDATE, | 28 CA_LAYER_FAILED_STREAM_VIDEO_NOT_CANDIDATE, |
| 29 CA_LAYER_FAILED_STREAM_VIDEO_TRANSFORM, | 29 CA_LAYER_FAILED_STREAM_VIDEO_TRANSFORM, |
| 30 CA_LAYER_FAILED_TEXTURE_NOT_CANDIDATE, | 30 CA_LAYER_FAILED_TEXTURE_NOT_CANDIDATE, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 default: | 63 default: |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 CALayerResult FromRenderPassQuad(ResourceProvider* resource_provider, | 68 CALayerResult FromRenderPassQuad(ResourceProvider* resource_provider, |
| 69 const RenderPassDrawQuad* quad, | 69 const RenderPassDrawQuad* quad, |
| 70 CALayerOverlay* ca_layer_overlay) { | 70 CALayerOverlay* ca_layer_overlay) { |
| 71 if (quad->background_filters.size() != 0) | 71 if (quad->background_filters.size() != 0) |
| 72 return CA_LAYER_FAILED_RENDER_PASS_BACKGROUND_FILTERS; | 72 return CA_LAYER_FAILED_RENDER_PASS_BACKGROUND_FILTERS; |
| 73 if (quad->mask_resource_id() != 0) | |
| 74 return CA_LAYER_FAILED_RENDER_PASS_MASK; | |
| 75 | 73 |
| 76 for (const FilterOperation& operation : quad->filters.operations()) { | 74 for (const FilterOperation& operation : quad->filters.operations()) { |
| 77 bool success = FilterOperationSupported(operation); | 75 bool success = FilterOperationSupported(operation); |
| 78 if (!success) | 76 if (!success) |
| 79 return CA_LAYER_FAILED_RENDER_PASS_FILTER_OPERATION; | 77 return CA_LAYER_FAILED_RENDER_PASS_FILTER_OPERATION; |
| 80 } | 78 } |
| 81 | 79 |
| 82 if (quad->filters_scale != gfx::Vector2dF(1, 1)) { | 80 ca_layer_overlay->rpdq = quad; |
| 83 for (const FilterOperation& operation : quad->filters.operations()) { | |
| 84 if (operation.type() == FilterOperation::BLUR || | |
| 85 operation.type() == FilterOperation::DROP_SHADOW) { | |
| 86 return CA_LAYER_FAILED_RENDER_PASS_FILTER_SCALE; | |
| 87 } | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 ca_layer_overlay->contents_rect = gfx::RectF(0, 0, 1, 1); | 81 ca_layer_overlay->contents_rect = gfx::RectF(0, 0, 1, 1); |
| 92 | 82 |
| 93 // TODO(erikchen): Enable this when RenderPassDrawQuad promotion to CALayer | 83 // TODO(erikchen): Enable this when RenderPassDrawQuad promotion to CALayer |
| 94 // is fully functional. https://crbug.com/581526. | 84 // is fully functional. https://crbug.com/581526. |
| 95 if (g_allow_rpdq_quad_conversion) | 85 if (g_allow_rpdq_quad_conversion) |
| 96 return CA_LAYER_SUCCESS; | 86 return CA_LAYER_SUCCESS; |
| 97 return CA_LAYER_FAILED_RENDER_PASS; | 87 return CA_LAYER_FAILED_RENDER_PASS; |
| 98 } | 88 } |
| 99 | 89 |
| 100 CALayerResult FromStreamVideoQuad(ResourceProvider* resource_provider, | 90 CALayerResult FromStreamVideoQuad(ResourceProvider* resource_provider, |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 return false; | 298 return false; |
| 309 } | 299 } |
| 310 return true; | 300 return true; |
| 311 } | 301 } |
| 312 | 302 |
| 313 void EnableRenderPassDrawQuadForTesting() { | 303 void EnableRenderPassDrawQuadForTesting() { |
| 314 g_allow_rpdq_quad_conversion = true; | 304 g_allow_rpdq_quad_conversion = true; |
| 315 } | 305 } |
| 316 | 306 |
| 317 } // namespace cc | 307 } // namespace cc |
| OLD | NEW |