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

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

Issue 519583003: Use the solid color detection to create solid layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final merge Created 6 years, 3 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/picture_layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
11 #include "base/debug/trace_event_argument.h" 11 #include "base/debug/trace_event_argument.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "cc/base/math_util.h" 13 #include "cc/base/math_util.h"
14 #include "cc/base/util.h" 14 #include "cc/base/util.h"
15 #include "cc/debug/debug_colors.h" 15 #include "cc/debug/debug_colors.h"
16 #include "cc/debug/micro_benchmark_impl.h" 16 #include "cc/debug/micro_benchmark_impl.h"
17 #include "cc/debug/traced_value.h" 17 #include "cc/debug/traced_value.h"
18 #include "cc/layers/append_quads_data.h" 18 #include "cc/layers/append_quads_data.h"
19 #include "cc/layers/solid_color_layer_impl.h"
19 #include "cc/output/begin_frame_args.h" 20 #include "cc/output/begin_frame_args.h"
20 #include "cc/quads/checkerboard_draw_quad.h" 21 #include "cc/quads/checkerboard_draw_quad.h"
21 #include "cc/quads/debug_border_draw_quad.h" 22 #include "cc/quads/debug_border_draw_quad.h"
22 #include "cc/quads/picture_draw_quad.h" 23 #include "cc/quads/picture_draw_quad.h"
23 #include "cc/quads/solid_color_draw_quad.h" 24 #include "cc/quads/solid_color_draw_quad.h"
24 #include "cc/quads/tile_draw_quad.h" 25 #include "cc/quads/tile_draw_quad.h"
25 #include "cc/resources/tile_manager.h" 26 #include "cc/resources/tile_manager.h"
26 #include "cc/trees/layer_tree_impl.h" 27 #include "cc/trees/layer_tree_impl.h"
27 #include "cc/trees/occlusion_tracker.h" 28 #include "cc/trees/occlusion_tracker.h"
28 #include "ui/gfx/quad_f.h" 29 #include "ui/gfx/quad_f.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 109
109 LayerImpl::PushPropertiesTo(base_layer); 110 LayerImpl::PushPropertiesTo(base_layer);
110 111
111 // When the pending tree pushes to the active tree, the pending twin 112 // When the pending tree pushes to the active tree, the pending twin
112 // becomes recycled. 113 // becomes recycled.
113 layer_impl->twin_layer_ = NULL; 114 layer_impl->twin_layer_ = NULL;
114 twin_layer_ = NULL; 115 twin_layer_ = NULL;
115 116
116 layer_impl->pile_ = pile_; 117 layer_impl->pile_ = pile_;
117 118
119 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings());
118 // Tilings would be expensive to push, so we swap. 120 // Tilings would be expensive to push, so we swap.
119 layer_impl->tilings_.swap(tilings_); 121 layer_impl->tilings_.swap(tilings_);
120 layer_impl->tilings_->SetClient(layer_impl); 122 layer_impl->tilings_->SetClient(layer_impl);
121 if (tilings_) 123 if (tilings_)
122 tilings_->SetClient(this); 124 tilings_->SetClient(this);
123 125
126 // Ensure that the recycle tree doesn't have any unshared tiles.
127 if (tilings_ && pile_->is_solid_color())
128 tilings_->RemoveAllTilings();
129
124 // Remove invalidated tiles from what will become a recycle tree. 130 // Remove invalidated tiles from what will become a recycle tree.
125 if (tilings_) 131 if (tilings_)
126 tilings_->RemoveTilesInRegion(invalidation_); 132 tilings_->RemoveTilesInRegion(invalidation_);
127 133
128 layer_impl->raster_page_scale_ = raster_page_scale_; 134 layer_impl->raster_page_scale_ = raster_page_scale_;
129 layer_impl->raster_device_scale_ = raster_device_scale_; 135 layer_impl->raster_device_scale_ = raster_device_scale_;
130 layer_impl->raster_source_scale_ = raster_source_scale_; 136 layer_impl->raster_source_scale_ = raster_source_scale_;
131 layer_impl->raster_contents_scale_ = raster_contents_scale_; 137 layer_impl->raster_contents_scale_ = raster_contents_scale_;
132 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; 138 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_;
133 layer_impl->needs_post_commit_initialization_ = false; 139 layer_impl->needs_post_commit_initialization_ = false;
134 140
135 // The invalidation on this soon-to-be-recycled layer must be cleared to 141 // The invalidation on this soon-to-be-recycled layer must be cleared to
136 // mirror clearing the invalidation in PictureLayer's version of this function 142 // mirror clearing the invalidation in PictureLayer's version of this function
137 // in case push properties is skipped. 143 // in case push properties is skipped.
138 layer_impl->invalidation_.Swap(&invalidation_); 144 layer_impl->invalidation_.Swap(&invalidation_);
139 invalidation_.Clear(); 145 invalidation_.Clear();
140 needs_post_commit_initialization_ = true; 146 needs_post_commit_initialization_ = true;
141 147
142 // We always need to push properties. 148 // We always need to push properties.
143 // See http://crbug.com/303943 149 // See http://crbug.com/303943
144 needs_push_properties_ = true; 150 needs_push_properties_ = true;
145 } 151 }
146 152
147 void PictureLayerImpl::AppendQuads( 153 void PictureLayerImpl::AppendQuads(
148 RenderPass* render_pass, 154 RenderPass* render_pass,
149 const OcclusionTracker<LayerImpl>& occlusion_tracker, 155 const OcclusionTracker<LayerImpl>& occlusion_tracker,
150 AppendQuadsData* append_quads_data) { 156 AppendQuadsData* append_quads_data) {
151 DCHECK(!needs_post_commit_initialization_); 157 DCHECK(!needs_post_commit_initialization_);
152 158
159 SharedQuadState* shared_quad_state =
160 render_pass->CreateAndAppendSharedQuadState();
161
162 if (pile_->is_solid_color()) {
163 PopulateSharedQuadState(shared_quad_state);
164
165 AppendDebugBorderQuad(
166 render_pass, content_bounds(), shared_quad_state, append_quads_data);
167
168 SolidColorLayerImpl::AppendSolidQuads(
169 render_pass,
170 occlusion_tracker,
171 shared_quad_state,
172 content_bounds(),
173 draw_properties().target_space_transform,
174 pile_->solid_color());
175 return;
176 }
177
153 float max_contents_scale = MaximumTilingContentsScale(); 178 float max_contents_scale = MaximumTilingContentsScale();
154 gfx::Transform scaled_draw_transform = draw_transform(); 179 gfx::Transform scaled_draw_transform = draw_transform();
155 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, 180 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale,
156 SK_MScalar1 / max_contents_scale); 181 SK_MScalar1 / max_contents_scale);
157 gfx::Size scaled_content_bounds = 182 gfx::Size scaled_content_bounds =
158 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale)); 183 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale));
159 184
160 gfx::Rect scaled_visible_content_rect = 185 gfx::Rect scaled_visible_content_rect =
161 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); 186 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale);
162 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); 187 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds));
163 188
164 Occlusion occlusion = 189 Occlusion occlusion =
165 occlusion_tracker.GetCurrentOcclusionForLayer(scaled_draw_transform); 190 occlusion_tracker.GetCurrentOcclusionForLayer(scaled_draw_transform);
166 191
167 SharedQuadState* shared_quad_state =
168 render_pass->CreateAndAppendSharedQuadState();
169 shared_quad_state->SetAll(scaled_draw_transform, 192 shared_quad_state->SetAll(scaled_draw_transform,
170 scaled_content_bounds, 193 scaled_content_bounds,
171 scaled_visible_content_rect, 194 scaled_visible_content_rect,
172 draw_properties().clip_rect, 195 draw_properties().clip_rect,
173 draw_properties().is_clipped, 196 draw_properties().is_clipped,
174 draw_properties().opacity, 197 draw_properties().opacity,
175 blend_mode(), 198 blend_mode(),
176 sorting_context_id_); 199 sorting_context_id_);
177 200
178 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { 201 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 should_update_tile_priorities_ = true; 485 should_update_tile_priorities_ = true;
463 486
464 UpdateTilePriorities(occlusion_in_content_space); 487 UpdateTilePriorities(occlusion_in_content_space);
465 488
466 if (layer_tree_impl()->IsPendingTree()) 489 if (layer_tree_impl()->IsPendingTree())
467 MarkVisibleResourcesAsRequired(); 490 MarkVisibleResourcesAsRequired();
468 } 491 }
469 492
470 void PictureLayerImpl::UpdateTilePriorities( 493 void PictureLayerImpl::UpdateTilePriorities(
471 const Occlusion& occlusion_in_content_space) { 494 const Occlusion& occlusion_in_content_space) {
495 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings());
496
472 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); 497 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities");
473 498
474 double current_frame_time_in_seconds = 499 double current_frame_time_in_seconds =
475 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - 500 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time -
476 base::TimeTicks()).InSecondsF(); 501 base::TimeTicks()).InSecondsF();
477 502
478 bool tiling_needs_update = false; 503 bool tiling_needs_update = false;
479 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { 504 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
480 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( 505 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime(
481 current_frame_time_in_seconds)) { 506 current_frame_time_in_seconds)) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // to force tilings to get managed. 585 // to force tilings to get managed.
561 layer_tree_impl()->set_needs_update_draw_properties(); 586 layer_tree_impl()->set_needs_update_draw_properties();
562 } 587 }
563 588
564 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { 589 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
565 return pile_->GetFlattenedPicture(); 590 return pile_->GetFlattenedPicture();
566 } 591 }
567 592
568 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, 593 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
569 const gfx::Rect& content_rect) { 594 const gfx::Rect& content_rect) {
595 DCHECK(!pile_->is_solid_color());
570 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) 596 if (!pile_->CanRaster(tiling->contents_scale(), content_rect))
571 return scoped_refptr<Tile>(); 597 return scoped_refptr<Tile>();
572 598
573 int flags = 0; 599 int flags = 0;
574 600
575 // TODO(vmpstr): Revisit this. For now, enabling analysis means that we get as 601 // TODO(vmpstr): Revisit this. For now, enabling analysis means that we get as
576 // much savings on memory as we can. However, for some cases like ganesh or 602 // much savings on memory as we can. However, for some cases like ganesh or
577 // small layers, the amount of time we spend analyzing might not justify 603 // small layers, the amount of time we spend analyzing might not justify
578 // memory savings that we can get. Note that we don't handle solid color 604 // memory savings that we can get. Note that we don't handle solid color
579 // masks, so we shouldn't bother analyzing those. 605 // masks, so we shouldn't bother analyzing those.
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 raster_contents_scale_ = 0.f; 1311 raster_contents_scale_ = 0.f;
1286 low_res_raster_contents_scale_ = 0.f; 1312 low_res_raster_contents_scale_ = 0.f;
1287 raster_source_scale_is_fixed_ = false; 1313 raster_source_scale_is_fixed_ = false;
1288 1314
1289 // When raster scales aren't valid, don't update tile priorities until 1315 // When raster scales aren't valid, don't update tile priorities until
1290 // this layer has been updated via UpdateDrawProperties. 1316 // this layer has been updated via UpdateDrawProperties.
1291 should_update_tile_priorities_ = false; 1317 should_update_tile_priorities_ = false;
1292 } 1318 }
1293 1319
1294 bool PictureLayerImpl::CanHaveTilings() const { 1320 bool PictureLayerImpl::CanHaveTilings() const {
1321 if (pile_->is_solid_color())
1322 return false;
1295 if (!DrawsContent()) 1323 if (!DrawsContent())
1296 return false; 1324 return false;
1297 if (!pile_->HasRecordings()) 1325 if (!pile_->HasRecordings())
1298 return false; 1326 return false;
1299 return true; 1327 return true;
1300 } 1328 }
1301 1329
1302 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { 1330 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const {
1303 if (!CanHaveTilings()) 1331 if (!CanHaveTilings())
1304 return false; 1332 return false;
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1787 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1760 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1788 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1761 return tiling_range.end - 1 - current_tiling_range_offset; 1789 return tiling_range.end - 1 - current_tiling_range_offset;
1762 } 1790 }
1763 } 1791 }
1764 NOTREACHED(); 1792 NOTREACHED();
1765 return 0; 1793 return 0;
1766 } 1794 }
1767 1795
1768 } // namespace cc 1796 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698