Chromium Code Reviews| 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 "base/trace_event/trace_event_argument.h" | 7 #include "base/trace_event/trace_event_argument.h" |
| 8 #include "cc/debug/debug_colors.h" | 8 #include "cc/debug/debug_colors.h" |
| 9 #include "cc/quads/surface_draw_quad.h" | 9 #include "cc/quads/surface_draw_quad.h" |
| 10 #include "cc/trees/occlusion.h" | 10 #include "cc/trees/occlusion.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 } | 23 } |
| 24 | 24 |
| 25 void SurfaceLayerImpl::SetSurfaceId(SurfaceId surface_id) { | 25 void SurfaceLayerImpl::SetSurfaceId(SurfaceId surface_id) { |
| 26 if (surface_id_ == surface_id) | 26 if (surface_id_ == surface_id) |
| 27 return; | 27 return; |
| 28 | 28 |
| 29 surface_id_ = surface_id; | 29 surface_id_ = surface_id; |
| 30 NoteLayerPropertyChanged(); | 30 NoteLayerPropertyChanged(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void SurfaceLayerImpl::SetSurfaceScale(float scale) { | |
| 34 if (surface_scale_ == scale) | |
| 35 return; | |
| 36 | |
| 37 surface_scale_ = scale; | |
| 38 NoteLayerPropertyChanged(); | |
| 39 } | |
| 40 | |
| 41 void SurfaceLayerImpl::SetSurfaceSize(const gfx::Size& size) { | |
| 42 if (surface_size_ == size) | |
| 43 return; | |
| 44 | |
| 45 surface_size_ = size; | |
| 46 NoteLayerPropertyChanged(); | |
| 47 } | |
| 48 | |
| 33 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 49 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 34 LayerImpl::PushPropertiesTo(layer); | 50 LayerImpl::PushPropertiesTo(layer); |
| 35 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); | 51 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); |
| 36 | 52 |
| 37 layer_impl->SetSurfaceId(surface_id_); | 53 layer_impl->SetSurfaceId(surface_id_); |
| 54 layer_impl->SetSurfaceSize(surface_size_); | |
| 55 layer_impl->SetSurfaceScale(surface_scale_); | |
| 38 } | 56 } |
| 39 | 57 |
| 40 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, | 58 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, |
| 41 AppendQuadsData* append_quads_data) { | 59 AppendQuadsData* append_quads_data) { |
| 42 SharedQuadState* shared_quad_state = | 60 SharedQuadState* shared_quad_state = |
| 43 render_pass->CreateAndAppendSharedQuadState(); | 61 render_pass->CreateAndAppendSharedQuadState(); |
| 44 PopulateSharedQuadState(shared_quad_state); | 62 PopulateScaledSharedQuadState(shared_quad_state, surface_scale_); |
| 45 | 63 |
| 46 AppendDebugBorderQuad( | 64 AppendDebugBorderQuad( |
| 47 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 65 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
|
danakj
2015/06/04 21:25:18
i thin this should match the size of the quad.
| |
| 48 | 66 |
| 49 if (surface_id_.is_null()) | 67 if (surface_id_.is_null()) |
| 50 return; | 68 return; |
| 51 | 69 |
| 52 gfx::Rect quad_rect(content_bounds()); | 70 gfx::Rect quad_rect(surface_size_); |
| 53 gfx::Rect visible_quad_rect = | 71 gfx::Rect visible_quad_rect = |
| 54 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( | 72 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 55 quad_rect); | 73 quad_rect); |
| 56 if (visible_quad_rect.IsEmpty()) | 74 if (visible_quad_rect.IsEmpty()) |
| 57 return; | 75 return; |
| 58 SurfaceDrawQuad* quad = | 76 SurfaceDrawQuad* quad = |
| 59 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 77 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 60 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_); | 78 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_); |
| 61 } | 79 } |
| 62 | 80 |
| 63 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, | 81 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, |
| 64 float* width) const { | 82 float* width) const { |
| 65 *color = DebugColors::SurfaceLayerBorderColor(); | 83 *color = DebugColors::SurfaceLayerBorderColor(); |
| 66 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); | 84 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); |
| 67 } | 85 } |
| 68 | 86 |
| 69 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { | 87 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { |
| 70 LayerImpl::AsValueInto(dict); | 88 LayerImpl::AsValueInto(dict); |
| 71 dict->SetInteger("surface_id", surface_id_.id); | 89 dict->SetInteger("surface_id", surface_id_.id); |
| 72 } | 90 } |
| 73 | 91 |
| 74 const char* SurfaceLayerImpl::LayerTypeAsString() const { | 92 const char* SurfaceLayerImpl::LayerTypeAsString() const { |
| 75 return "cc::SurfaceLayerImpl"; | 93 return "cc::SurfaceLayerImpl"; |
| 76 } | 94 } |
| 77 | 95 |
| 78 } // namespace cc | 96 } // namespace cc |
| OLD | NEW |