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

Side by Side Diff: cc/resources/picture_layer_tiling_set.cc

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 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 | « cc/resources/picture_layer_tiling_set.h ('k') | cc/resources/picture_pile.h » ('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/resources/picture_layer_tiling_set.h" 5 #include "cc/resources/picture_layer_tiling_set.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 : max_tiles_for_interest_area_(max_tiles_for_interest_area), 46 : max_tiles_for_interest_area_(max_tiles_for_interest_area),
47 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), 47 skewport_target_time_in_seconds_(skewport_target_time_in_seconds),
48 skewport_extrapolation_limit_in_content_pixels_( 48 skewport_extrapolation_limit_in_content_pixels_(
49 skewport_extrapolation_limit_in_content_pixels), 49 skewport_extrapolation_limit_in_content_pixels),
50 client_(client) { 50 client_(client) {
51 } 51 }
52 52
53 PictureLayerTilingSet::~PictureLayerTilingSet() { 53 PictureLayerTilingSet::~PictureLayerTilingSet() {
54 } 54 }
55 55
56 void PictureLayerTilingSet::CopyTilingsFromPendingTwin(
57 const PictureLayerTilingSet* pending_twin_set,
58 const scoped_refptr<RasterSource>& raster_source) {
59 if (pending_twin_set->tilings_.empty()) {
60 // If the twin (pending) tiling set is empty, it was not updated for the
61 // current frame. So we drop tilings from our set as well, instead of
62 // leaving behind unshared tilings that are all non-ideal.
63 RemoveAllTilings();
64 }
65
66 for (PictureLayerTiling* pending_twin_tiling : pending_twin_set->tilings_) {
67 float contents_scale = pending_twin_tiling->contents_scale();
68 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale);
69 if (!this_tiling) {
70 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create(
71 contents_scale, raster_source, client_, max_tiles_for_interest_area_,
72 skewport_target_time_in_seconds_,
73 skewport_extrapolation_limit_in_content_pixels_);
74 tilings_.push_back(new_tiling.Pass());
75 this_tiling = tilings_.back();
76 }
77 this_tiling->CloneTilesAndPropertiesFrom(*pending_twin_tiling);
78 }
79 }
80
56 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( 81 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource(
57 scoped_refptr<RasterSource> raster_source, 82 scoped_refptr<RasterSource> raster_source,
58 const PictureLayerTilingSet* twin_set, 83 const PictureLayerTilingSet* pending_twin_set,
59 const Region& layer_invalidation, 84 const Region& layer_invalidation,
60 float minimum_contents_scale, 85 float minimum_contents_scale,
61 float maximum_contents_scale) { 86 float maximum_contents_scale) {
62 RemoveTilingsBelowScale(minimum_contents_scale); 87 RemoveTilingsBelowScale(minimum_contents_scale);
63 RemoveTilingsAboveScale(maximum_contents_scale); 88 RemoveTilingsAboveScale(maximum_contents_scale);
64 89
65 // Copy over tilings that are shared with the |twin_set| tiling set (if it 90 // Copy over tilings that are shared with the |pending_twin_set| tiling set
66 // exists). 91 // (if it exists).
67 if (twin_set) { 92 if (pending_twin_set)
68 if (twin_set->tilings_.empty()) { 93 CopyTilingsFromPendingTwin(pending_twin_set, raster_source);
69 // If the twin (pending) tiling set is empty, it was not updated for the 94
70 // current frame. So we drop tilings from our set as well, instead of 95 // If the tiling is not shared (FindTilingWithScale returns nullptr) or if
71 // leaving behind unshared tilings that are all non-ideal. 96 // |this| is the sync set (pending_twin_set is nullptr), then invalidate
72 RemoveAllTilings(); 97 // tiles and update them to the new raster source.
98 for (PictureLayerTiling* tiling : tilings_) {
99 if (pending_twin_set &&
100 pending_twin_set->FindTilingWithScale(tiling->contents_scale())) {
101 continue;
73 } 102 }
74 103
75 for (PictureLayerTiling* twin_tiling : twin_set->tilings_) {
76 float contents_scale = twin_tiling->contents_scale();
77 DCHECK_GE(contents_scale, minimum_contents_scale);
78 DCHECK_LE(contents_scale, maximum_contents_scale);
79
80 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale);
81 if (!this_tiling) {
82 scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create(
83 contents_scale, raster_source, client_,
84 max_tiles_for_interest_area_, skewport_target_time_in_seconds_,
85 skewport_extrapolation_limit_in_content_pixels_);
86 tilings_.push_back(new_tiling.Pass());
87 this_tiling = tilings_.back();
88 }
89 this_tiling->CloneTilesAndPropertiesFrom(*twin_tiling);
90 }
91 }
92
93 // For unshared tilings, invalidate tiles and update them to the new raster
94 // source.
95 for (PictureLayerTiling* tiling : tilings_) {
96 if (twin_set && twin_set->FindTilingWithScale(tiling->contents_scale()))
97 continue;
98
99 tiling->SetRasterSourceAndResize(raster_source); 104 tiling->SetRasterSourceAndResize(raster_source);
100 tiling->Invalidate(layer_invalidation); 105 tiling->Invalidate(layer_invalidation);
101 tiling->SetRasterSourceOnTiles(); 106 tiling->SetRasterSourceOnTiles();
102 // This is needed for cases where the live tiles rect didn't change but 107 // This is needed for cases where the live tiles rect didn't change but
103 // recordings exist in the raster source that did not exist on the last 108 // recordings exist in the raster source that did not exist on the last
104 // raster source. 109 // raster source.
105 tiling->CreateMissingTilesInLiveTilesRect(); 110 tiling->CreateMissingTilesInLiveTilesRect();
106 111
107 // If |twin_set| is present, use the resolutions from there. Otherwise leave 112 // If |pending_twin_set| is present, then |this| is active and |tiling| is
108 // all resolutions as they are. 113 // not in the pending set, which means it is now NON_IDEAL_RESOLUTION.
109 if (twin_set) 114 if (pending_twin_set)
110 tiling->set_resolution(NON_IDEAL_RESOLUTION); 115 tiling->set_resolution(NON_IDEAL_RESOLUTION);
111 } 116 }
112 117
113 tilings_.sort(LargestToSmallestScaleFunctor()); 118 tilings_.sort(LargestToSmallestScaleFunctor());
114 119
115 #if DCHECK_IS_ON() 120 #if DCHECK_IS_ON()
116 for (PictureLayerTiling* tiling : tilings_) { 121 for (PictureLayerTiling* tiling : tilings_) {
117 DCHECK(tiling->tile_size() == 122 DCHECK(tiling->tile_size() ==
118 client_->CalculateTileSize(tiling->tiling_size())) 123 client_->CalculateTileSize(tiling->tiling_size()))
119 << "tile_size: " << tiling->tile_size().ToString() 124 << "tile_size: " << tiling->tile_size().ToString()
120 << " tiling_size: " << tiling->tiling_size().ToString() 125 << " tiling_size: " << tiling->tiling_size().ToString()
121 << " CalculateTileSize: " 126 << " CalculateTileSize: "
122 << client_->CalculateTileSize(tiling->tiling_size()).ToString(); 127 << client_->CalculateTileSize(tiling->tiling_size()).ToString();
123 } 128 }
124 129
125 if (!tilings_.empty()) { 130 if (!tilings_.empty()) {
126 DCHECK_LE(NumHighResTilings(), 1); 131 DCHECK_LE(NumHighResTilings(), 1);
127 // When commiting from the main thread the high res tiling may get dropped, 132 // When commiting from the main thread the high res tiling may get dropped,
128 // but when cloning to the active tree, there should always be one. 133 // but when cloning to the active tree, there should always be one.
129 if (twin_set) { 134 if (pending_twin_set) {
130 DCHECK_EQ(1, NumHighResTilings()) 135 DCHECK_EQ(1, NumHighResTilings())
131 << " num tilings on active: " << tilings_.size() 136 << " num tilings on active: " << tilings_.size()
132 << " num tilings on pending: " << twin_set->tilings_.size() 137 << " num tilings on pending: " << pending_twin_set->tilings_.size()
133 << " num high res on pending: " << twin_set->NumHighResTilings() 138 << " num high res on pending: "
139 << pending_twin_set->NumHighResTilings()
134 << " are on active tree: " << (client_->GetTree() == ACTIVE_TREE); 140 << " are on active tree: " << (client_->GetTree() == ACTIVE_TREE);
135 } 141 }
136 } 142 }
137 #endif 143 #endif
138 } 144 }
139 145
140 void PictureLayerTilingSet::CleanUpTilings( 146 void PictureLayerTilingSet::CleanUpTilings(
141 float min_acceptable_high_res_scale, 147 float min_acceptable_high_res_scale,
142 float max_acceptable_high_res_scale, 148 float max_acceptable_high_res_scale,
143 const std::vector<PictureLayerTiling*>& needed_tilings, 149 const std::vector<PictureLayerTiling*>& needed_tilings,
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 case LOWER_THAN_LOW_RES: 549 case LOWER_THAN_LOW_RES:
544 range = TilingRange(low_res_range.end, tilings_.size()); 550 range = TilingRange(low_res_range.end, tilings_.size());
545 break; 551 break;
546 } 552 }
547 553
548 DCHECK_LE(range.start, range.end); 554 DCHECK_LE(range.start, range.end);
549 return range; 555 return range;
550 } 556 }
551 557
552 } // namespace cc 558 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling_set.h ('k') | cc/resources/picture_pile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698