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" |
11 #include "cc/debug_colors.h" | 11 #include "cc/debug_colors.h" |
12 #include "cc/layer_tree_host_impl.h" | 12 #include "cc/layer_tree_impl.h" |
13 #include "cc/math_util.h" | 13 #include "cc/math_util.h" |
14 #include "cc/quad_sink.h" | 14 #include "cc/quad_sink.h" |
15 #include "cc/solid_color_draw_quad.h" | 15 #include "cc/solid_color_draw_quad.h" |
16 #include "cc/tile_draw_quad.h" | 16 #include "cc/tile_draw_quad.h" |
17 #include "ui/gfx/quad_f.h" | 17 #include "ui/gfx/quad_f.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id) | 21 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id) |
22 : LayerImpl(treeImpl, id), | 22 : LayerImpl(treeImpl, id), |
(...skipping 28 matching lines...) Expand all Loading... |
51 if (showDebugBorders()) { | 51 if (showDebugBorders()) { |
52 for (PictureLayerTilingSet::Iterator iter(&tilings_, | 52 for (PictureLayerTilingSet::Iterator iter(&tilings_, |
53 contentsScaleX(), | 53 contentsScaleX(), |
54 rect); | 54 rect); |
55 iter; | 55 iter; |
56 ++iter) { | 56 ++iter) { |
57 SkColor color; | 57 SkColor color; |
58 float width; | 58 float width; |
59 if (*iter && iter->GetResourceId()) { | 59 if (*iter && iter->GetResourceId()) { |
60 color = DebugColors::TileBorderColor(); | 60 color = DebugColors::TileBorderColor(); |
61 width = DebugColors::TileBorderWidth(layerTreeHostImpl()); | 61 width = DebugColors::TileBorderWidth(layerTreeImpl()); |
62 } else { | 62 } else { |
63 color = DebugColors::MissingTileBorderColor(); | 63 color = DebugColors::MissingTileBorderColor(); |
64 width = DebugColors::MissingTileBorderWidth(layerTreeHostImpl()); | 64 width = DebugColors::MissingTileBorderWidth(layerTreeImpl()); |
65 } | 65 } |
66 | 66 |
67 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = | 67 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = |
68 DebugBorderDrawQuad::Create(); | 68 DebugBorderDrawQuad::Create(); |
69 gfx::Rect geometry_rect = iter.geometry_rect(); | 69 gfx::Rect geometry_rect = iter.geometry_rect(); |
70 debugBorderQuad->SetNew(sharedQuadState, geometry_rect, color, width); | 70 debugBorderQuad->SetNew(sharedQuadState, geometry_rect, color, width); |
71 quadSink.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); | 71 quadSink.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 more tilings during pinch zoom. |
133 if (!tilings_.num_tilings()) { | 133 if (!tilings_.num_tilings()) { |
134 gfx::Size tile_size = layerTreeHostImpl()->settings().defaultTileSize; | 134 gfx::Size tile_size = layerTreeImpl()->settings().defaultTileSize; |
135 tilings_.AddTiling(contentsScaleX(), tile_size); | 135 tilings_.AddTiling(contentsScaleX(), tile_size); |
136 // TODO(enne): handle invalidations, create new tiles | 136 // TODO(enne): handle invalidations, create new tiles |
137 } | 137 } |
138 } else { | 138 } else { |
139 tilings_.Reset(); | 139 tilings_.Reset(); |
140 } | 140 } |
141 | 141 |
142 gfx::Transform current_screen_space_transform = screenSpaceTransform(); | 142 gfx::Transform current_screen_space_transform = screenSpaceTransform(); |
143 double current_time = | 143 double current_time = |
144 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); | 144 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
145 double time_delta = 0; | 145 double time_delta = 0; |
146 if (last_update_time_ != 0 && last_bounds_ == bounds() && | 146 if (last_update_time_ != 0 && last_bounds_ == bounds() && |
147 last_content_bounds_ == contentBounds() && | 147 last_content_bounds_ == contentBounds() && |
148 last_content_scale_x_ == contentsScaleX() && | 148 last_content_scale_x_ == contentsScaleX() && |
149 last_content_scale_y_ == contentsScaleY()) { | 149 last_content_scale_y_ == contentsScaleY()) { |
150 time_delta = current_time - last_update_time_; | 150 time_delta = current_time - last_update_time_; |
151 } | 151 } |
152 tilings_.UpdateTilePriorities(layerTreeHostImpl()->deviceViewportSize(), | 152 tilings_.UpdateTilePriorities(layerTreeImpl()->device_viewport_size(), |
153 contentsScaleX(), | 153 contentsScaleX(), |
154 contentsScaleY(), | 154 contentsScaleY(), |
155 last_screen_space_transform_, | 155 last_screen_space_transform_, |
156 current_screen_space_transform, | 156 current_screen_space_transform, |
157 time_delta); | 157 time_delta); |
158 | 158 |
159 last_screen_space_transform_ = current_screen_space_transform; | 159 last_screen_space_transform_ = current_screen_space_transform; |
160 last_update_time_ = current_time; | 160 last_update_time_ = current_time; |
161 last_bounds_ = bounds(); | 161 last_bounds_ = bounds(); |
162 last_content_bounds_ = contentBounds(); | 162 last_content_bounds_ = contentBounds(); |
163 last_content_scale_x_ = contentsScaleX(); | 163 last_content_scale_x_ = contentsScaleX(); |
164 last_content_scale_y_ = contentsScaleY(); | 164 last_content_scale_y_ = contentsScaleY(); |
165 } | 165 } |
166 | 166 |
167 void PictureLayerImpl::didUpdateBounds() { | 167 void PictureLayerImpl::didUpdateBounds() { |
168 tilings_.SetLayerBounds(bounds()); | 168 tilings_.SetLayerBounds(bounds()); |
169 } | 169 } |
170 | 170 |
171 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 171 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
172 gfx::Rect rect) { | 172 gfx::Rect rect) { |
173 TileManager* tile_manager = layerTreeHostImpl()->tileManager(); | 173 TileManager* tile_manager = layerTreeImpl()->tile_manager(); |
174 | 174 |
175 return make_scoped_refptr(new Tile( | 175 return make_scoped_refptr(new Tile( |
176 tile_manager, | 176 tile_manager, |
177 pile_.get(), | 177 pile_.get(), |
178 rect.size(), | 178 rect.size(), |
179 GL_RGBA, | 179 GL_RGBA, |
180 rect, | 180 rect, |
181 tiling->contents_scale())); | 181 tiling->contents_scale())); |
182 } | 182 } |
183 | 183 |
184 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { | 184 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { |
185 tilings_.CloneFrom(other->tilings_); | 185 tilings_.CloneFrom(other->tilings_); |
186 } | 186 } |
187 | 187 |
188 } // namespace cc | 188 } // namespace cc |
OLD | NEW |