Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: cc/layers/surface_layer_impl.cc

Issue 2673813002: Changes the bounds being sent for occlusion from physical pixels to DIP (Closed)
Patch Set: Resolving comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/layers/surface_layer_impl_unittest.cc » ('j') | cc/test/layer_test_common.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 layer_to_content_scale_x, layer_to_content_scale_y;
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 layer_to_content_scale_x =
66 bounds().width(); 68 static_cast<float>(surface_info_.size_in_pixels().width()) /
67 float scale_y = 69 bounds().width();
70 layer_to_content_scale_y =
68 static_cast<float>(surface_info_.size_in_pixels().height()) / 71 static_cast<float>(surface_info_.size_in_pixels().height()) /
69 bounds().height(); 72 bounds().height();
70 PopulateScaledSharedQuadState(shared_quad_state, scale_x, scale_y);
71 } else { 73 } else {
72 PopulateScaledSharedQuadState(shared_quad_state, 74 layer_to_content_scale_x = layer_to_content_scale_y =
73 surface_info_.device_scale_factor(), 75 surface_info_.device_scale_factor();
74 surface_info_.device_scale_factor());
75 } 76 }
77 PopulateScaledSharedQuadState(shared_quad_state, layer_to_content_scale_x,
78 layer_to_content_scale_y);
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 = gfx::ScaleToEnclosedRect(
89 visible_quad_rect, layer_to_content_scale_x, layer_to_content_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
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
OLDNEW
« no previous file with comments | « no previous file | cc/layers/surface_layer_impl_unittest.cc » ('j') | cc/test/layer_test_common.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698