| OLD | NEW |
| 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 Loading... |
| 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 26 matching lines...) Expand all Loading... |
| 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 |
| 184 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { | 186 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { |
| 185 tilings_.CloneFrom(other->tilings_); | 187 tilings_.CloneAll(other->tilings_, invalidation_); |
| 188 } |
| 189 |
| 190 void PictureLayerImpl::SyncTilingFromActiveLayer( |
| 191 const PictureLayerTiling* tiling) { |
| 192 tilings_.Clone(tiling, invalidation_); |
| 193 } |
| 194 |
| 195 void PictureLayerImpl::AddTiling(float contents_scale, gfx::Size tile_size) { |
| 196 const PictureLayerTiling* tiling = tilings_.AddTiling( |
| 197 contents_scale, |
| 198 tile_size); |
| 199 |
| 200 // If a new tiling is created on the active tree, sync it to the pending tree |
| 201 // so that it can share the same tiles. |
| 202 if (layerTreeImpl()->IsActiveTree()) |
| 203 return; |
| 204 |
| 205 PictureLayerImpl* pending_twin = static_cast<PictureLayerImpl*>( |
| 206 layerTreeImpl()->PendingTreeLayerById(id())); |
| 207 if (!pending_twin) |
| 208 return; |
| 209 DCHECK_EQ(id(), pending_twin->id()); |
| 210 pending_twin->SyncTilingFromActiveLayer(tiling); |
| 186 } | 211 } |
| 187 | 212 |
| 188 } // namespace cc | 213 } // namespace cc |
| OLD | NEW |