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 <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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 layer_impl->SetStretchContentToFillBounds(stretch_content_to_fill_bounds_); | 52 layer_impl->SetStretchContentToFillBounds(stretch_content_to_fill_bounds_); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, | 55 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, |
| 56 AppendQuadsData* append_quads_data) { | 56 AppendQuadsData* append_quads_data) { |
| 57 AppendRainbowDebugBorder(render_pass); | 57 AppendRainbowDebugBorder(render_pass); |
| 58 | 58 |
| 59 SharedQuadState* shared_quad_state = | 59 SharedQuadState* shared_quad_state = |
| 60 render_pass->CreateAndAppendSharedQuadState(); | 60 render_pass->CreateAndAppendSharedQuadState(); |
| 61 | 61 |
| 62 float scale_x, scale_y; | |
|
danakj
2017/02/10 16:32:22
Can you give this a name that describes what the s
malaykeshav
2017/02/10 20:24:58
Done
| |
| 63 | |
| 62 if (stretch_content_to_fill_bounds_) { | 64 if (stretch_content_to_fill_bounds_) { |
| 63 // Stretches the surface contents to exactly fill the layer bounds, | 65 // Stretches the surface contents to exactly fill the layer bounds, |
| 64 // regardless of scale or aspect ratio differences. | 66 // regardless of scale or aspect ratio differences. |
| 65 float scale_x = static_cast<float>(surface_info_.size_in_pixels().width()) / | 67 scale_x = static_cast<float>(surface_info_.size_in_pixels().width()) / |
| 66 bounds().width(); | 68 bounds().width(); |
| 67 float scale_y = | 69 scale_y = static_cast<float>(surface_info_.size_in_pixels().height()) / |
| 68 static_cast<float>(surface_info_.size_in_pixels().height()) / | 70 bounds().height(); |
| 69 bounds().height(); | |
| 70 PopulateScaledSharedQuadState(shared_quad_state, scale_x, scale_y); | 71 PopulateScaledSharedQuadState(shared_quad_state, scale_x, scale_y); |
| 71 } else { | 72 } else { |
| 72 PopulateScaledSharedQuadState(shared_quad_state, | 73 PopulateScaledSharedQuadState(shared_quad_state, |
|
danakj
2017/02/10 16:32:22
We don't need 2 calls to Populate anymore, if we h
malaykeshav
2017/02/10 20:24:58
Done
| |
| 73 surface_info_.device_scale_factor(), | 74 surface_info_.device_scale_factor(), |
| 74 surface_info_.device_scale_factor()); | 75 surface_info_.device_scale_factor()); |
| 76 | |
| 77 scale_x = scale_y = surface_info_.device_scale_factor(); | |
| 75 } | 78 } |
| 76 | 79 |
| 77 if (!surface_info_.id().is_valid()) | 80 if (!surface_info_.id().is_valid()) |
| 78 return; | 81 return; |
| 79 | 82 |
| 80 gfx::Rect quad_rect(surface_info_.size_in_pixels()); | 83 gfx::Rect quad_rect(surface_info_.size_in_pixels()); |
| 81 gfx::Rect visible_quad_rect = | 84 gfx::Rect visible_quad_rect = |
| 82 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( | 85 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 83 quad_rect); | 86 gfx::Rect(bounds())); |
| 87 | |
| 88 visible_quad_rect = | |
| 89 gfx::ScaleToEnclosedRect(visible_quad_rect, scale_x, scale_y); | |
| 90 visible_quad_rect = gfx::IntersectRects(quad_rect, visible_quad_rect); | |
| 84 | 91 |
| 85 if (visible_quad_rect.IsEmpty()) | 92 if (visible_quad_rect.IsEmpty()) |
| 86 return; | 93 return; |
| 87 SurfaceDrawQuad* quad = | 94 SurfaceDrawQuad* quad = |
| 88 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 95 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 89 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, | 96 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, |
| 90 surface_info_.id()); | 97 surface_info_.id()); |
| 91 } | 98 } |
| 92 | 99 |
| 93 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, | 100 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { | 193 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { |
| 187 LayerImpl::AsValueInto(dict); | 194 LayerImpl::AsValueInto(dict); |
| 188 dict->SetString("surface_id", surface_info_.id().ToString()); | 195 dict->SetString("surface_id", surface_info_.id().ToString()); |
| 189 } | 196 } |
| 190 | 197 |
| 191 const char* SurfaceLayerImpl::LayerTypeAsString() const { | 198 const char* SurfaceLayerImpl::LayerTypeAsString() const { |
| 192 return "cc::SurfaceLayerImpl"; | 199 return "cc::SurfaceLayerImpl"; |
| 193 } | 200 } |
| 194 | 201 |
| 195 } // namespace cc | 202 } // namespace cc |
| OLD | NEW |