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

Side by Side Diff: cc/picture_layer_impl.cc

Issue 11574026: cc: Add some more infrastructure for two trees (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/picture_layer_impl.h ('k') | cc/picture_layer_tiling_set.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/picture_layer_impl.h" 5 #include "cc/picture_layer_impl.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "cc/append_quads_data.h" 8 #include "cc/append_quads_data.h"
9 #include "cc/checkerboard_draw_quad.h" 9 #include "cc/checkerboard_draw_quad.h"
10 #include "cc/debug_border_draw_quad.h" 10 #include "cc/debug_border_draw_quad.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); 122 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
123 } 123 }
124 } 124 }
125 125
126 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { 126 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const {
127 // TODO(enne): implement me 127 // TODO(enne): implement me
128 } 128 }
129 129
130 void PictureLayerImpl::didUpdateTransforms() { 130 void PictureLayerImpl::didUpdateTransforms() {
131 if (drawsContent()) { 131 if (drawsContent()) {
132 // TODO(enne): Add more tilings during pinch zoom. 132 // TODO(enne): Add tilings during pinch zoom
133 // TODO(enne): Consider culling old tilings after pinch finishes.
133 if (!tilings_.num_tilings()) { 134 if (!tilings_.num_tilings()) {
134 gfx::Size tile_size = layerTreeImpl()->settings().defaultTileSize; 135 gfx::Size tile_size = layerTreeImpl()->settings().defaultTileSize;
135 tilings_.AddTiling(contentsScaleX(), tile_size); 136 AddTiling(contentsScaleX(), tile_size);
136 // TODO(enne): handle invalidations, create new tiles 137 // TODO(enne): Add a low-res tiling as well.
137 } 138 }
138 } else { 139 } else {
140 // TODO(enne): This should be unnecessary once there are two trees.
139 tilings_.Reset(); 141 tilings_.Reset();
140 } 142 }
141 143
142 gfx::Transform current_screen_space_transform = screenSpaceTransform(); 144 gfx::Transform current_screen_space_transform = screenSpaceTransform();
143 double current_time = 145 double current_time =
144 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); 146 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
145 double time_delta = 0; 147 double time_delta = 0;
146 if (last_update_time_ != 0 && last_bounds_ == bounds() && 148 if (last_update_time_ != 0 && last_bounds_ == bounds() &&
147 last_content_bounds_ == contentBounds() && 149 last_content_bounds_ == contentBounds() &&
148 last_content_scale_x_ == contentsScaleX() && 150 last_content_scale_x_ == contentsScaleX() &&
(...skipping 25 matching lines...) Expand all
174 176
175 return make_scoped_refptr(new Tile( 177 return make_scoped_refptr(new Tile(
176 tile_manager, 178 tile_manager,
177 pile_.get(), 179 pile_.get(),
178 rect.size(), 180 rect.size(),
179 GL_RGBA, 181 GL_RGBA,
180 rect, 182 rect,
181 tiling->contents_scale())); 183 tiling->contents_scale()));
182 } 184 }
183 185
186 void PictureLayerImpl::SyncFromActiveLayer() {
187 DCHECK(layerTreeImpl()->IsPendingTree());
188 if (!drawsContent())
189 return;
190
191 // If there is an active tree version of this layer, get a copy of its
192 // tiles. This needs to be done last, after setting invalidation and the
193 // pile.
194 PictureLayerImpl* active_twin = static_cast<PictureLayerImpl*>(
195 layerTreeImpl()->FindActiveTreeLayerById(id()));
196 if (!active_twin)
197 return;
198 SyncFromActiveLayer(active_twin);
199 }
200
184 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { 201 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
185 tilings_.CloneFrom(other->tilings_); 202 tilings_.CloneAll(other->tilings_, invalidation_);
203 }
204
205 void PictureLayerImpl::SyncTiling(
206 const PictureLayerTiling* tiling) {
207 tilings_.Clone(tiling, invalidation_);
208 }
209
210 void PictureLayerImpl::AddTiling(float contents_scale, gfx::Size tile_size) {
211 const PictureLayerTiling* tiling = tilings_.AddTiling(
212 contents_scale,
213 tile_size);
214
215 // If a new tiling is created on the active tree, sync it to the pending tree
216 // so that it can share the same tiles.
217 if (layerTreeImpl()->IsActiveTree())
218 return;
219
220 PictureLayerImpl* pending_twin = static_cast<PictureLayerImpl*>(
221 layerTreeImpl()->FindPendingTreeLayerById(id()));
222 if (!pending_twin)
223 return;
224 DCHECK_EQ(id(), pending_twin->id());
225 pending_twin->SyncTiling(tiling);
186 } 226 }
187 227
188 } // namespace cc 228 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_layer_impl.h ('k') | cc/picture_layer_tiling_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698