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

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

Issue 2582823002: WIP: Surface Synchronization System
Patch Set: Only create ClientSurfaceEmbedder if window is visible. Trash it otherwise. Created 3 years, 11 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
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 11 matching lines...) Expand all
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::SetSurfaceInfo(const SurfaceInfo& surface_info) { 32 void SurfaceLayerImpl::SetPrimarySurfaceInfo(const SurfaceInfo& surface_info) {
33 if (surface_info_ == surface_info) 33 if (primary_surface_info_ == surface_info)
34 return; 34 return;
35 35
36 surface_info_ = surface_info; 36 primary_surface_info_ = surface_info;
37 NoteLayerPropertyChanged(); 37 NoteLayerPropertyChanged();
38 } 38 }
39 39
40 void SurfaceLayerImpl::SetFallbackSurfaceInfo(const SurfaceInfo& surface_info) {
41 if (fallback_surface_info_ == surface_info)
42 return;
43
44 fallback_surface_info_ = surface_info;
45 NoteLayerPropertyChanged();
46 }
47
40 void SurfaceLayerImpl::SetStretchContentToFillBounds(bool stretch_content) { 48 void SurfaceLayerImpl::SetStretchContentToFillBounds(bool stretch_content) {
41 if (stretch_content_to_fill_bounds_ == stretch_content) 49 if (stretch_content_to_fill_bounds_ == stretch_content)
42 return; 50 return;
43 51
44 stretch_content_to_fill_bounds_ = stretch_content; 52 stretch_content_to_fill_bounds_ = stretch_content;
45 NoteLayerPropertyChanged(); 53 NoteLayerPropertyChanged();
46 } 54 }
47 55
48 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { 56 void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) {
49 LayerImpl::PushPropertiesTo(layer); 57 LayerImpl::PushPropertiesTo(layer);
50 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); 58 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer);
51 layer_impl->SetSurfaceInfo(surface_info_); 59 layer_impl->SetPrimarySurfaceInfo(primary_surface_info_);
60 layer_impl->SetFallbackSurfaceInfo(fallback_surface_info_);
52 layer_impl->SetStretchContentToFillBounds(stretch_content_to_fill_bounds_); 61 layer_impl->SetStretchContentToFillBounds(stretch_content_to_fill_bounds_);
53 } 62 }
54 63
55 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass, 64 void SurfaceLayerImpl::AppendQuads(RenderPass* render_pass,
56 AppendQuadsData* append_quads_data) { 65 AppendQuadsData* append_quads_data) {
66 SurfaceDrawQuad* primary_draw_quad =
67 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
68 SurfaceDrawQuad* fallback_draw_quad = nullptr;
69 if (fallback_surface_info_.id().is_valid()) {
70 fallback_draw_quad =
71 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
72 }
73 PopulateSurfaceDrawQuad(render_pass, primary_draw_quad, fallback_draw_quad,
74 SurfaceDrawQuadType::PRIMARY, primary_surface_info_);
75 if (fallback_draw_quad) {
76 PopulateSurfaceDrawQuad(render_pass, fallback_draw_quad, nullptr,
77 SurfaceDrawQuadType::FALLBACK,
78 fallback_surface_info_);
79 }
80 }
81
82 void SurfaceLayerImpl::PopulateSurfaceDrawQuad(
83 RenderPass* render_pass,
84 SurfaceDrawQuad* surface_draw_quad,
85 SurfaceDrawQuad* fallback_surface_draw_quad,
86 SurfaceDrawQuadType surface_draw_quad_type,
87 const SurfaceInfo& surface_info) {
88 if (!surface_info.id().is_valid())
89 return;
90
57 AppendRainbowDebugBorder(render_pass); 91 AppendRainbowDebugBorder(render_pass);
58 92
59 SharedQuadState* shared_quad_state = 93 SharedQuadState* shared_quad_state =
60 render_pass->CreateAndAppendSharedQuadState(); 94 render_pass->CreateAndAppendSharedQuadState();
61 95
62 if (stretch_content_to_fill_bounds_) { 96 if (stretch_content_to_fill_bounds_) {
63 // Stretches the surface contents to exactly fill the layer bounds, 97 // Stretches the surface contents to exactly fill the layer bounds,
64 // regardless of scale or aspect ratio differences. 98 // regardless of scale or aspect ratio differences.
65 float scale_x = static_cast<float>(surface_info_.size_in_pixels().width()) / 99 float scale_x = static_cast<float>(surface_info.size_in_pixels().width()) /
66 bounds().width(); 100 bounds().width();
67 float scale_y = 101 float scale_y = static_cast<float>(surface_info.size_in_pixels().height()) /
68 static_cast<float>(surface_info_.size_in_pixels().height()) / 102 bounds().height();
69 bounds().height();
70 PopulateScaledSharedQuadState(shared_quad_state, scale_x, scale_y); 103 PopulateScaledSharedQuadState(shared_quad_state, scale_x, scale_y);
71 } else { 104 } else {
72 PopulateScaledSharedQuadState(shared_quad_state, 105 PopulateScaledSharedQuadState(shared_quad_state,
73 surface_info_.device_scale_factor(), 106 surface_info.device_scale_factor(),
74 surface_info_.device_scale_factor()); 107 surface_info.device_scale_factor());
75 } 108 }
76 109
77 if (!surface_info_.id().is_valid()) 110 gfx::Rect quad_rect(surface_info.size_in_pixels());
78 return;
79
80 gfx::Rect quad_rect(surface_info_.size_in_pixels());
81 gfx::Rect visible_quad_rect = 111 gfx::Rect visible_quad_rect =
82 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( 112 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect(
83 quad_rect); 113 quad_rect);
84 114
85 if (visible_quad_rect.IsEmpty()) 115 if (visible_quad_rect.IsEmpty())
86 return; 116 return;
87 SurfaceDrawQuad* quad = 117
88 render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 118 surface_draw_quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect,
89 quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, 119 surface_info.id(), surface_draw_quad_type,
90 surface_info_.id()); 120 fallback_surface_draw_quad);
91 } 121 }
92 122
93 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, 123 void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color,
94 float* width) const { 124 float* width) const {
95 *color = DebugColors::SurfaceLayerBorderColor(); 125 *color = DebugColors::SurfaceLayerBorderColor();
96 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); 126 *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl());
97 } 127 }
98 128
99 void SurfaceLayerImpl::AppendRainbowDebugBorder(RenderPass* render_pass) { 129 void SurfaceLayerImpl::AppendRainbowDebugBorder(RenderPass* render_pass) {
100 if (!ShowDebugBorders()) 130 if (!ShowDebugBorders())
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 SolidColorDrawQuad* right_quad = 208 SolidColorDrawQuad* right_quad =
179 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 209 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
180 right_quad->SetNew(shared_quad_state, right, right, 210 right_quad->SetNew(shared_quad_state, right, right,
181 colors[i % kNumColors], force_anti_aliasing_off); 211 colors[i % kNumColors], force_anti_aliasing_off);
182 } 212 }
183 } 213 }
184 } 214 }
185 215
186 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const { 216 void SurfaceLayerImpl::AsValueInto(base::trace_event::TracedValue* dict) const {
187 LayerImpl::AsValueInto(dict); 217 LayerImpl::AsValueInto(dict);
188 dict->SetString("surface_id", surface_info_.id().ToString()); 218 dict->SetString("surface_id", primary_surface_info_.id().ToString());
189 } 219 }
190 220
191 const char* SurfaceLayerImpl::LayerTypeAsString() const { 221 const char* SurfaceLayerImpl::LayerTypeAsString() const {
192 return "cc::SurfaceLayerImpl"; 222 return "cc::SurfaceLayerImpl";
193 } 223 }
194 224
195 } // namespace cc 225 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698