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

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: remove unused variable 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
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 89
89 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( 90 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl(
90 LayerTreeImpl* tree_impl) { 91 LayerTreeImpl* tree_impl) {
91 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); 92 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
92 } 93 }
93 94
94 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { 95 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
95 // It's possible this layer was never drawn or updated (e.g. because it was 96 // It's possible this layer was never drawn or updated (e.g. because it was
96 // a descendant of an opacity 0 layer). 97 // a descendant of an opacity 0 layer).
97 DoPostCommitInitializationIfNeeded(); 98 DoPostCommitInitializationIfNeeded();
99
98 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 100 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
99 101
100 // We have already synced the important bits from the the active layer, and 102 // We have already synced the important bits from the the active layer, and
101 // we will soon swap out its tilings and use them for recycling. However, 103 // we will soon swap out its tilings and use them for recycling. However,
102 // there are now tiles in this layer's tilings that were unref'd and replaced 104 // there are now tiles in this layer's tilings that were unref'd and replaced
103 // with new tiles (due to invalidation). This resets all active priorities on 105 // with new tiles (due to invalidation). This resets all active priorities on
104 // the to-be-recycled tiling to ensure replaced tiles don't linger and take 106 // the to-be-recycled tiling to ensure replaced tiles don't linger and take
105 // memory (due to a stale 'active' priority). 107 // memory (due to a stale 'active' priority).
106 if (layer_impl->tilings_) 108 if (layer_impl->tilings_)
107 layer_impl->tilings_->DidBecomeRecycled(); 109 layer_impl->tilings_->DidBecomeRecycled();
108 110
109 LayerImpl::PushPropertiesTo(base_layer); 111 LayerImpl::PushPropertiesTo(base_layer);
110 112
111 // When the pending tree pushes to the active tree, the pending twin 113 // When the pending tree pushes to the active tree, the pending twin
112 // becomes recycled. 114 // becomes recycled.
113 layer_impl->twin_layer_ = NULL; 115 layer_impl->twin_layer_ = NULL;
114 twin_layer_ = NULL; 116 twin_layer_ = NULL;
115 117
116 layer_impl->pile_ = pile_; 118 layer_impl->pile_ = pile_;
117 119
120 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings());
vmpstr 2014/09/15 15:45:07 I like this dcheck, and I think you should put it
hendrikw 2014/09/15 16:59:40 This is the only place in the code that the state
121
118 // Tilings would be expensive to push, so we swap. 122 // Tilings would be expensive to push, so we swap.
119 layer_impl->tilings_.swap(tilings_); 123 layer_impl->tilings_.swap(tilings_);
vmpstr 2014/09/15 15:45:07 In the case where a non-solid layer becomes solid,
danakj 2014/09/15 16:26:35 Please add a test for that also.
hendrikw 2014/09/15 16:59:40 We had discussed this a couple of weeks ago, you s
vmpstr 2014/09/15 18:30:38 Yeah, in retrospect, this is important to do right
120 layer_impl->tilings_->SetClient(layer_impl); 124 layer_impl->tilings_->SetClient(layer_impl);
121 if (tilings_) 125 if (tilings_)
122 tilings_->SetClient(this); 126 tilings_->SetClient(this);
123 127
124 // Remove invalidated tiles from what will become a recycle tree. 128 // Remove invalidated tiles from what will become a recycle tree.
125 if (tilings_) 129 if (tilings_)
126 tilings_->RemoveTilesInRegion(invalidation_); 130 tilings_->RemoveTilesInRegion(invalidation_);
127 131
128 layer_impl->raster_page_scale_ = raster_page_scale_; 132 layer_impl->raster_page_scale_ = raster_page_scale_;
129 layer_impl->raster_device_scale_ = raster_device_scale_; 133 layer_impl->raster_device_scale_ = raster_device_scale_;
(...skipping 13 matching lines...) Expand all
143 // See http://crbug.com/303943 147 // See http://crbug.com/303943
144 needs_push_properties_ = true; 148 needs_push_properties_ = true;
145 } 149 }
146 150
147 void PictureLayerImpl::AppendQuads( 151 void PictureLayerImpl::AppendQuads(
148 RenderPass* render_pass, 152 RenderPass* render_pass,
149 const OcclusionTracker<LayerImpl>& occlusion_tracker, 153 const OcclusionTracker<LayerImpl>& occlusion_tracker,
150 AppendQuadsData* append_quads_data) { 154 AppendQuadsData* append_quads_data) {
151 DCHECK(!needs_post_commit_initialization_); 155 DCHECK(!needs_post_commit_initialization_);
152 156
157 SharedQuadState* shared_quad_state =
158 render_pass->CreateAndAppendSharedQuadState();
159
160 if (pile_->is_solid_color()) {
161 PopulateSharedQuadState(shared_quad_state);
162
163 AppendDebugBorderQuad(
164 render_pass, content_bounds(), shared_quad_state, append_quads_data);
165
166 SolidColorLayerImpl::AppendSolidQuads(
167 render_pass,
168 occlusion_tracker,
169 append_quads_data,
170 shared_quad_state,
171 content_bounds(),
172 draw_properties().target_space_transform,
vmpstr 2014/09/15 15:45:07 Here we pass a target_space_transform, but below w
danakj 2014/09/15 16:26:35 This is cool. The transform is consistent with the
173 pile_->get_solid_color());
174 return;
175 }
176
153 float max_contents_scale = MaximumTilingContentsScale(); 177 float max_contents_scale = MaximumTilingContentsScale();
154 gfx::Transform scaled_draw_transform = draw_transform(); 178 gfx::Transform scaled_draw_transform = draw_transform();
155 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, 179 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale,
156 SK_MScalar1 / max_contents_scale); 180 SK_MScalar1 / max_contents_scale);
157 gfx::Size scaled_content_bounds = 181 gfx::Size scaled_content_bounds =
158 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale)); 182 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale));
159 183
160 gfx::Rect scaled_visible_content_rect = 184 gfx::Rect scaled_visible_content_rect =
161 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); 185 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale);
162 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); 186 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds));
163 187
164 SharedQuadState* shared_quad_state =
165 render_pass->CreateAndAppendSharedQuadState();
166 shared_quad_state->SetAll(scaled_draw_transform, 188 shared_quad_state->SetAll(scaled_draw_transform,
167 scaled_content_bounds, 189 scaled_content_bounds,
168 scaled_visible_content_rect, 190 scaled_visible_content_rect,
169 draw_properties().clip_rect, 191 draw_properties().clip_rect,
170 draw_properties().is_clipped, 192 draw_properties().is_clipped,
171 draw_properties().opacity, 193 draw_properties().opacity,
172 blend_mode(), 194 blend_mode(),
173 sorting_context_id_); 195 sorting_context_id_);
174 196
175 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { 197 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // to force tilings to get managed. 585 // to force tilings to get managed.
564 layer_tree_impl()->set_needs_update_draw_properties(); 586 layer_tree_impl()->set_needs_update_draw_properties();
565 } 587 }
566 588
567 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { 589 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
568 return pile_->GetFlattenedPicture(); 590 return pile_->GetFlattenedPicture();
569 } 591 }
570 592
571 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, 593 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
572 const gfx::Rect& content_rect) { 594 const gfx::Rect& content_rect) {
595 DCHECK(!pile_->is_solid_color());
573 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) 596 if (!pile_->CanRaster(tiling->contents_scale(), content_rect))
574 return scoped_refptr<Tile>(); 597 return scoped_refptr<Tile>();
575 598
576 int flags = 0; 599 int flags = 0;
577 600
578 // 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
579 // 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
580 // 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
581 // 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
582 // 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
1288 raster_contents_scale_ = 0.f; 1311 raster_contents_scale_ = 0.f;
1289 low_res_raster_contents_scale_ = 0.f; 1312 low_res_raster_contents_scale_ = 0.f;
1290 raster_source_scale_is_fixed_ = false; 1313 raster_source_scale_is_fixed_ = false;
1291 1314
1292 // 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
1293 // this layer has been updated via UpdateDrawProperties. 1316 // this layer has been updated via UpdateDrawProperties.
1294 should_update_tile_priorities_ = false; 1317 should_update_tile_priorities_ = false;
1295 } 1318 }
1296 1319
1297 bool PictureLayerImpl::CanHaveTilings() const { 1320 bool PictureLayerImpl::CanHaveTilings() const {
1321 if (pile_->is_solid_color())
1322 return false;
1298 if (!DrawsContent()) 1323 if (!DrawsContent())
1299 return false; 1324 return false;
1300 if (!pile_->HasRecordings()) 1325 if (!pile_->HasRecordings())
1301 return false; 1326 return false;
1302 return true; 1327 return true;
1303 } 1328 }
1304 1329
1305 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { 1330 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const {
1306 if (!CanHaveTilings()) 1331 if (!CanHaveTilings())
1307 return false; 1332 return false;
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1787 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1763 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1788 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1764 return tiling_range.end - 1 - current_tiling_range_offset; 1789 return tiling_range.end - 1 - current_tiling_range_offset;
1765 } 1790 }
1766 } 1791 }
1767 NOTREACHED(); 1792 NOTREACHED();
1768 return 0; 1793 return 0;
1769 } 1794 }
1770 1795
1771 } // namespace cc 1796 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/picture_layer_impl_unittest.cc » ('j') | cc/layers/picture_layer_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698