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 "cc/append_quads_data.h" | 8 #include "cc/append_quads_data.h" |
8 #include "cc/checkerboard_draw_quad.h" | 9 #include "cc/checkerboard_draw_quad.h" |
9 #include "cc/debug_border_draw_quad.h" | 10 #include "cc/debug_border_draw_quad.h" |
10 #include "cc/debug_colors.h" | 11 #include "cc/debug_colors.h" |
11 #include "cc/layer_tree_host_impl.h" | 12 #include "cc/layer_tree_host_impl.h" |
12 #include "cc/math_util.h" | 13 #include "cc/math_util.h" |
13 #include "cc/quad_sink.h" | 14 #include "cc/quad_sink.h" |
14 #include "cc/solid_color_draw_quad.h" | 15 #include "cc/solid_color_draw_quad.h" |
15 #include "cc/tile_draw_quad.h" | 16 #include "cc/tile_draw_quad.h" |
16 | 17 |
17 namespace cc { | 18 namespace cc { |
18 | 19 |
19 PictureLayerImpl::PictureLayerImpl(int id) : | 20 PictureLayerImpl::PictureLayerImpl(int id) : |
20 LayerImpl(id), | 21 LayerImpl(id), |
21 tilings_(this), | 22 tilings_(this), |
22 pile_(PicturePileImpl::Create()) { | 23 pile_(PicturePileImpl::Create()), |
| 24 last_update_time_(0) { |
23 } | 25 } |
24 | 26 |
25 PictureLayerImpl::~PictureLayerImpl() { | 27 PictureLayerImpl::~PictureLayerImpl() { |
26 } | 28 } |
27 | 29 |
28 const char* PictureLayerImpl::layerTypeAsString() const { | 30 const char* PictureLayerImpl::layerTypeAsString() const { |
29 return "PictureLayer"; | 31 return "PictureLayer"; |
30 } | 32 } |
31 | 33 |
32 void PictureLayerImpl::appendQuads(QuadSink& quadSink, | 34 void PictureLayerImpl::appendQuads(QuadSink& quadSink, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 127 } |
126 | 128 |
127 void PictureLayerImpl::didUpdateTransforms() { | 129 void PictureLayerImpl::didUpdateTransforms() { |
128 tilings_.SetLayerBounds(bounds()); | 130 tilings_.SetLayerBounds(bounds()); |
129 // TODO(enne): Add more tilings during pinch zoom. | 131 // TODO(enne): Add more tilings during pinch zoom. |
130 if (!tilings_.num_tilings()) { | 132 if (!tilings_.num_tilings()) { |
131 gfx::Size tile_size = layerTreeHostImpl()->settings().defaultTileSize; | 133 gfx::Size tile_size = layerTreeHostImpl()->settings().defaultTileSize; |
132 tilings_.AddTiling(contentsScaleX(), tile_size); | 134 tilings_.AddTiling(contentsScaleX(), tile_size); |
133 // TODO(enne): handle invalidations, create new tiles | 135 // TODO(enne): handle invalidations, create new tiles |
134 } | 136 } |
| 137 |
| 138 gfx::Transform current_screen_space_transform = screenSpaceTransform(); |
| 139 double current_time = |
| 140 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
| 141 double time_delta = 0; |
| 142 if (last_update_time_ != 0 && last_bounds_ == bounds() && |
| 143 last_content_bounds_ == contentBounds() && |
| 144 last_content_scale_x_ == contentsScaleX() && |
| 145 last_content_scale_y_ == contentsScaleY()) { |
| 146 time_delta = current_time - last_update_time_; |
| 147 } |
| 148 tilings_.UpdateTilePriorities(layerTreeHostImpl()->deviceViewportSize(), |
| 149 contentsScaleX(), |
| 150 contentsScaleY(), |
| 151 last_screen_space_transform_, |
| 152 current_screen_space_transform, |
| 153 time_delta); |
| 154 |
| 155 last_screen_space_transform_ = current_screen_space_transform; |
| 156 last_update_time_ = current_time; |
| 157 last_bounds_ = bounds(); |
| 158 last_content_bounds_ = contentBounds(); |
| 159 last_content_scale_x_ = contentsScaleX(); |
| 160 last_content_scale_y_ = contentsScaleY(); |
135 } | 161 } |
136 | 162 |
137 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*, | 163 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*, |
138 gfx::Rect rect) { | 164 gfx::Rect rect) { |
139 TileManager* tile_manager = layerTreeHostImpl()->tileManager(); | 165 TileManager* tile_manager = layerTreeHostImpl()->tileManager(); |
140 | 166 |
141 return make_scoped_refptr(new Tile( | 167 return make_scoped_refptr(new Tile( |
142 tile_manager, | 168 tile_manager, |
143 pile_.get(), | 169 pile_.get(), |
144 rect.size(), | 170 rect.size(), |
145 GL_RGBA, | 171 GL_RGBA, |
146 rect)); | 172 rect)); |
147 } | 173 } |
148 | 174 |
149 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { | 175 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { |
150 tilings_.CloneFrom(other->tilings_); | 176 tilings_.CloneFrom(other->tilings_); |
151 } | 177 } |
152 | 178 |
153 } // namespace cc | 179 } // namespace cc |
OLD | NEW |