| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/layers/surface_layer_impl.h" | 5 #include "cc/layers/surface_layer_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event_argument.h" | 9 #include "base/trace_event/trace_event_argument.h" |
| 10 #include "cc/debug/debug_colors.h" | 10 #include "cc/debug/debug_colors.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); | 59 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); |
| 60 layer_impl->SetPrimarySurfaceInfo(primary_surface_info_); | 60 layer_impl->SetPrimarySurfaceInfo(primary_surface_info_); |
| 61 layer_impl->SetFallbackSurfaceInfo(fallback_surface_info_); | 61 layer_impl->SetFallbackSurfaceInfo(fallback_surface_info_); |
| 62 layer_impl->SetStretchContentToFillBounds(stretch_content_to_fill_bounds_); | 62 layer_impl->SetStretchContentToFillBounds(stretch_content_to_fill_bounds_); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, | 65 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, |
| 66 AppendQuadsData* append_quads_data) { | 66 AppendQuadsData* append_quads_data) { |
| 67 AppendRainbowDebugBorder(render_pass); | 67 AppendRainbowDebugBorder(render_pass); |
| 68 SharedQuadState* common_shared_quad_state = nullptr; | 68 SharedQuadState* common_shared_quad_state = nullptr; |
| 69 auto* primary = CreateSurfaceDrawQuad( | 69 auto* primary = |
| 70 render_pass, SurfaceDrawQuadType::PRIMARY, primary_surface_info_, | 70 CreateSurfaceDrawQuad(render_pass, SurfaceDrawQuadType::PRIMARY, |
| 71 &append_quads_data->embedded_surfaces, &common_shared_quad_state); | 71 primary_surface_info_, &common_shared_quad_state); |
| 72 // Emitting a fallback SurfaceDrawQuad is unnecessary if the primary and | 72 // Emitting a fallback SurfaceDrawQuad is unnecessary if the primary and |
| 73 // fallback surface Ids match. | 73 // fallback surface Ids match. |
| 74 if (primary && fallback_surface_info_.id() != primary_surface_info_.id()) { | 74 bool needs_fallback = |
| 75 fallback_surface_info_.id() != primary_surface_info_.id(); |
| 76 if (primary && needs_fallback) { |
| 77 // Add the primary surface ID as a dependency. |
| 78 append_quads_data->embedded_surfaces.push_back(primary_surface_info_.id()); |
| 75 // We can use the same SharedQuadState as the primary SurfaceDrawQuad if | 79 // We can use the same SharedQuadState as the primary SurfaceDrawQuad if |
| 76 // we don't need a different transform on the fallback. | 80 // we don't need a different transform on the fallback. |
| 77 bool use_common_shared_quad_state = | 81 bool use_common_shared_quad_state = |
| 78 !stretch_content_to_fill_bounds_ && | 82 !stretch_content_to_fill_bounds_ && |
| 79 primary_surface_info_.device_scale_factor() == | 83 primary_surface_info_.device_scale_factor() == |
| 80 fallback_surface_info_.device_scale_factor(); | 84 fallback_surface_info_.device_scale_factor(); |
| 81 primary->fallback_quad = CreateSurfaceDrawQuad( | 85 primary->fallback_quad = CreateSurfaceDrawQuad( |
| 82 render_pass, SurfaceDrawQuadType::FALLBACK, fallback_surface_info_, | 86 render_pass, SurfaceDrawQuadType::FALLBACK, fallback_surface_info_, |
| 83 nullptr /* embedded_surfaces */, | |
| 84 use_common_shared_quad_state ? &common_shared_quad_state : nullptr); | 87 use_common_shared_quad_state ? &common_shared_quad_state : nullptr); |
| 85 } | 88 } |
| 86 } | 89 } |
| 87 | 90 |
| 88 SurfaceDrawQuad* SurfaceLayerImpl::CreateSurfaceDrawQuad( | 91 SurfaceDrawQuad* SurfaceLayerImpl::CreateSurfaceDrawQuad( |
| 89 RenderPass* render_pass, | 92 RenderPass* render_pass, |
| 90 SurfaceDrawQuadType surface_draw_quad_type, | 93 SurfaceDrawQuadType surface_draw_quad_type, |
| 91 const SurfaceInfo& surface_info, | 94 const SurfaceInfo& surface_info, |
| 92 std::vector<SurfaceId>* embedded_surfaces, | |
| 93 SharedQuadState** common_shared_quad_state) { | 95 SharedQuadState** common_shared_quad_state) { |
| 94 if (!surface_info.is_valid()) | 96 if (!surface_info.is_valid()) |
| 95 return nullptr; | 97 return nullptr; |
| 96 | 98 |
| 97 gfx::Rect quad_rect(surface_info.size_in_pixels()); | 99 gfx::Rect quad_rect(surface_info.size_in_pixels()); |
| 98 gfx::Rect visible_quad_rect = | 100 gfx::Rect visible_quad_rect = |
| 99 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( | 101 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 100 gfx::Rect(bounds())); | 102 gfx::Rect(bounds())); |
| 101 | 103 |
| 102 float layer_to_content_scale_x, layer_to_content_scale_y; | 104 float layer_to_content_scale_x, layer_to_content_scale_y; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 132 PopulateScaledSharedQuadState(shared_quad_state, layer_to_content_scale_x, | 134 PopulateScaledSharedQuadState(shared_quad_state, layer_to_content_scale_x, |
| 133 layer_to_content_scale_y); | 135 layer_to_content_scale_y); |
| 134 } | 136 } |
| 135 if (common_shared_quad_state) | 137 if (common_shared_quad_state) |
| 136 *common_shared_quad_state = shared_quad_state; | 138 *common_shared_quad_state = shared_quad_state; |
| 137 | 139 |
| 138 SurfaceDrawQuad* surface_draw_quad = | 140 SurfaceDrawQuad* surface_draw_quad = |
| 139 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 141 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 140 surface_draw_quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, | 142 surface_draw_quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, |
| 141 surface_info.id(), surface_draw_quad_type, nullptr); | 143 surface_info.id(), surface_draw_quad_type, nullptr); |
| 142 if (embedded_surfaces) | |
| 143 embedded_surfaces->push_back(surface_info.id()); | |
| 144 | 144 |
| 145 return surface_draw_quad; | 145 return surface_draw_quad; |
| 146 } | 146 } |
| 147 | 147 |
| 148 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, | 148 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, |
| 149 float* width) const { | 149 float* width) const { |
| 150 *color = DebugColors::SurfaceLayerBorderColor(); | 150 *color = DebugColors::SurfaceLayerBorderColor(); |
| 151 *width = DebugColors::SurfaceLayerBorderWidth( | 151 *width = DebugColors::SurfaceLayerBorderWidth( |
| 152 layer_tree_impl() ? layer_tree_impl()->device_scale_factor() : 1); | 152 layer_tree_impl() ? layer_tree_impl()->device_scale_factor() : 1); |
| 153 } | 153 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 dict->SetString("surface_id", primary_surface_info_.id().ToString()); | 244 dict->SetString("surface_id", primary_surface_info_.id().ToString()); |
| 245 dict->SetString("fallback_surface_id", | 245 dict->SetString("fallback_surface_id", |
| 246 fallback_surface_info_.id().ToString()); | 246 fallback_surface_info_.id().ToString()); |
| 247 } | 247 } |
| 248 | 248 |
| 249 const char* SurfaceLayerImpl::LayerTypeAsString() const { | 249 const char* SurfaceLayerImpl::LayerTypeAsString() const { |
| 250 return "cc::SurfaceLayerImpl"; | 250 return "cc::SurfaceLayerImpl"; |
| 251 } | 251 } |
| 252 | 252 |
| 253 } // namespace cc | 253 } // namespace cc |
| OLD | NEW |