| 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" |
| 11 #include "cc/quads/solid_color_draw_quad.h" | 11 #include "cc/quads/solid_color_draw_quad.h" |
| 12 #include "cc/quads/surface_draw_quad.h" | 12 #include "cc/quads/surface_draw_quad.h" |
| 13 #include "cc/trees/layer_tree_impl.h" | 13 #include "cc/trees/layer_tree_impl.h" |
| 14 #include "cc/trees/occlusion.h" | 14 #include "cc/trees/occlusion.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) | 18 SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 19 : LayerImpl(tree_impl, id), surface_scale_(0.f) { | 19 : LayerImpl(tree_impl, id) { |
| 20 layer_tree_impl()->AddSurfaceLayer(this); | 20 layer_tree_impl()->AddSurfaceLayer(this); |
| 21 } | 21 } |
| 22 | 22 |
| 23 SurfaceLayerImpl::~SurfaceLayerImpl() { | 23 SurfaceLayerImpl::~SurfaceLayerImpl() { |
| 24 layer_tree_impl()->RemoveSurfaceLayer(this); | 24 layer_tree_impl()->RemoveSurfaceLayer(this); |
| 25 } | 25 } |
| 26 | 26 |
| 27 std::unique_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( | 27 std::unique_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( |
| 28 LayerTreeImpl* tree_impl) { | 28 LayerTreeImpl* tree_impl) { |
| 29 return SurfaceLayerImpl::Create(tree_impl, id()); | 29 return SurfaceLayerImpl::Create(tree_impl, id()); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void SurfaceLayerImpl::SetSurfaceId(const SurfaceId& surface_id) { | 32 void SurfaceLayerImpl::SetSurfaceInfo(SurfaceInfo surface_info) { |
| 33 if (surface_id_ == surface_id) | 33 if (surface_info.id() == surface_info_.id() && |
| 34 surface_info.scale() == surface_info_.scale() && |
| 35 surface_info.size() == surface_info_.size()) { |
| 34 return; | 36 return; |
| 35 | 37 } |
| 36 surface_id_ = surface_id; | 38 surface_info_ = surface_info; |
| 37 NoteLayerPropertyChanged(); | 39 NoteLayerPropertyChanged(); |
| 38 } | 40 } |
| 39 | 41 |
| 40 void SurfaceLayerImpl::SetSurfaceScale(float scale) { | |
| 41 if (surface_scale_ == scale) | |
| 42 return; | |
| 43 | |
| 44 surface_scale_ = scale; | |
| 45 NoteLayerPropertyChanged(); | |
| 46 } | |
| 47 | |
| 48 void SurfaceLayerImpl::SetSurfaceSize(const gfx::Size& size) { | |
| 49 if (surface_size_ == size) | |
| 50 return; | |
| 51 | |
| 52 surface_size_ = size; | |
| 53 NoteLayerPropertyChanged(); | |
| 54 } | |
| 55 | |
| 56 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 42 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 57 LayerImpl::PushPropertiesTo(layer); | 43 LayerImpl::PushPropertiesTo(layer); |
| 58 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); | 44 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); |
| 59 | 45 |
| 60 layer_impl->SetSurfaceId(surface_id_); | 46 layer_impl->SetSurfaceInfo(surface_info_); |
| 61 layer_impl->SetSurfaceSize(surface_size_); | |
| 62 layer_impl->SetSurfaceScale(surface_scale_); | |
| 63 } | 47 } |
| 64 | 48 |
| 65 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, | 49 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, |
| 66 AppendQuadsData* append_quads_data) { | 50 AppendQuadsData* append_quads_data) { |
| 67 AppendRainbowDebugBorder(render_pass); | 51 AppendRainbowDebugBorder(render_pass); |
| 68 | 52 |
| 69 SharedQuadState* shared_quad_state = | 53 SharedQuadState* shared_quad_state = |
| 70 render_pass->CreateAndAppendSharedQuadState(); | 54 render_pass->CreateAndAppendSharedQuadState(); |
| 71 PopulateScaledSharedQuadState(shared_quad_state, surface_scale_); | 55 PopulateScaledSharedQuadState(shared_quad_state, surface_info_.scale()); |
| 72 | 56 |
| 73 if (!surface_id_.is_valid()) | 57 if (!surface_info_.id().is_valid()) |
| 74 return; | 58 return; |
| 75 | 59 |
| 76 gfx::Rect quad_rect(surface_size_); | 60 gfx::Rect quad_rect(surface_info_.size()); |
| 77 gfx::Rect visible_quad_rect = | 61 gfx::Rect visible_quad_rect = |
| 78 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( | 62 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 79 quad_rect); | 63 quad_rect); |
| 80 if (visible_quad_rect.IsEmpty()) | 64 if (visible_quad_rect.IsEmpty()) |
| 81 return; | 65 return; |
| 82 SurfaceDrawQuad* quad = | 66 SurfaceDrawQuad* quad = |
| 83 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 67 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 84 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_); | 68 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, |
| 69 surface_info_.id()); |
| 85 } | 70 } |
| 86 | 71 |
| 87 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, | 72 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, |
| 88 float* width) const { | 73 float* width) const { |
| 89 *color = DebugColors::SurfaceLayerBorderColor(); | 74 *color = DebugColors::SurfaceLayerBorderColor(); |
| 90 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); | 75 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); |
| 91 } | 76 } |
| 92 | 77 |
| 93 void SurfaceLayerImpl::AppendRainbowDebugBorder(RenderPass* render_pass) { | 78 void SurfaceLayerImpl::AppendRainbowDebugBorder(RenderPass* render_pass) { |
| 94 if (!ShowDebugBorders()) | 79 if (!ShowDebugBorders()) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 SolidColorDrawQuad* right_quad = | 157 SolidColorDrawQuad* right_quad = |
| 173 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 158 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 174 right_quad->SetNew(shared_quad_state, right, right, | 159 right_quad->SetNew(shared_quad_state, right, right, |
| 175 colors[i % kNumColors], force_anti_aliasing_off); | 160 colors[i % kNumColors], force_anti_aliasing_off); |
| 176 } | 161 } |
| 177 } | 162 } |
| 178 } | 163 } |
| 179 | 164 |
| 180 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { | 165 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { |
| 181 LayerImpl::AsValueInto(dict); | 166 LayerImpl::AsValueInto(dict); |
| 182 dict->SetString("surface_id", surface_id_.ToString()); | 167 dict->SetString("surface_id", surface_info_.id().ToString()); |
| 183 } | 168 } |
| 184 | 169 |
| 185 const char* SurfaceLayerImpl::LayerTypeAsString() const { | 170 const char* SurfaceLayerImpl::LayerTypeAsString() const { |
| 186 return "cc::SurfaceLayerImpl"; | 171 return "cc::SurfaceLayerImpl"; |
| 187 } | 172 } |
| 188 | 173 |
| 189 } // namespace cc | 174 } // namespace cc |
| OLD | NEW |