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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/base/util.h" | 9 #include "cc/base/util.h" |
10 #include "cc/debug/debug_colors.h" | 10 #include "cc/debug/debug_colors.h" |
11 #include "cc/layers/append_quads_data.h" | 11 #include "cc/layers/append_quads_data.h" |
12 #include "cc/layers/quad_sink.h" | 12 #include "cc/layers/quad_sink.h" |
13 #include "cc/quads/checkerboard_draw_quad.h" | 13 #include "cc/quads/checkerboard_draw_quad.h" |
14 #include "cc/quads/debug_border_draw_quad.h" | 14 #include "cc/quads/debug_border_draw_quad.h" |
| 15 #include "cc/quads/picture_draw_quad.h" |
15 #include "cc/quads/solid_color_draw_quad.h" | 16 #include "cc/quads/solid_color_draw_quad.h" |
16 #include "cc/quads/tile_draw_quad.h" | 17 #include "cc/quads/tile_draw_quad.h" |
17 #include "cc/trees/layer_tree_impl.h" | 18 #include "cc/trees/layer_tree_impl.h" |
18 #include "ui/gfx/quad_f.h" | 19 #include "ui/gfx/quad_f.h" |
19 #include "ui/gfx/rect_conversions.h" | 20 #include "ui/gfx/rect_conversions.h" |
20 #include "ui/gfx/size_conversions.h" | 21 #include "ui/gfx/size_conversions.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 const float kMaxScaleRatioDuringPinch = 2.0f; | 24 const float kMaxScaleRatioDuringPinch = 2.0f; |
24 } | 25 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 iter; | 105 iter; |
105 ++iter) { | 106 ++iter) { |
106 SkColor color; | 107 SkColor color; |
107 float width; | 108 float width; |
108 if (*iter && iter->drawing_info().IsReadyToDraw()) { | 109 if (*iter && iter->drawing_info().IsReadyToDraw()) { |
109 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); | 110 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); |
110 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || | 111 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || |
111 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { | 112 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { |
112 color = DebugColors::SolidColorTileBorderColor(); | 113 color = DebugColors::SolidColorTileBorderColor(); |
113 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 114 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
| 115 } else if (mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) { |
| 116 color = DebugColors::PictureTileBorderColor(); |
| 117 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
114 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 118 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
115 color = DebugColors::HighResTileBorderColor(); | 119 color = DebugColors::HighResTileBorderColor(); |
116 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 120 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
117 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 121 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
118 color = DebugColors::LowResTileBorderColor(); | 122 color = DebugColors::LowResTileBorderColor(); |
119 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 123 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
120 } else if (iter->contents_scale() > contents_scale_x()) { | 124 } else if (iter->contents_scale() > contents_scale_x()) { |
121 color = DebugColors::ExtraHighResTileBorderColor(); | 125 color = DebugColors::ExtraHighResTileBorderColor(); |
122 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 126 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
123 } else { | 127 } else { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 quad->SetNew(sharedQuadState, geometry_rect, background_color()); | 166 quad->SetNew(sharedQuadState, geometry_rect, background_color()); |
163 if (quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 167 if (quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData)) |
164 appendQuadsData->numMissingTiles++; | 168 appendQuadsData->numMissingTiles++; |
165 } | 169 } |
166 | 170 |
167 appendQuadsData->hadIncompleteTile = true; | 171 appendQuadsData->hadIncompleteTile = true; |
168 continue; | 172 continue; |
169 } | 173 } |
170 | 174 |
171 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); | 175 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); |
172 switch (drawing_info.mode()) { | 176 ManagedTileState::DrawingInfo::Mode mode = drawing_info.mode(); |
| 177 if (mode == ManagedTileState::DrawingInfo::TEXTURE_MODE || |
| 178 mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) { |
| 179 if (iter->contents_scale() != ideal_contents_scale_) |
| 180 appendQuadsData->hadIncompleteTile = true; |
| 181 } |
| 182 |
| 183 switch (mode) { |
173 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { | 184 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { |
174 if (iter->contents_scale() != ideal_contents_scale_) | |
175 appendQuadsData->hadIncompleteTile = true; | |
176 | |
177 gfx::RectF texture_rect = iter.texture_rect(); | 185 gfx::RectF texture_rect = iter.texture_rect(); |
178 gfx::Rect opaque_rect = iter->opaque_rect(); | 186 gfx::Rect opaque_rect = iter->opaque_rect(); |
179 opaque_rect.Intersect(content_rect); | 187 opaque_rect.Intersect(content_rect); |
180 | 188 |
181 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); | 189 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); |
182 quad->SetNew(sharedQuadState, | 190 quad->SetNew(sharedQuadState, |
183 geometry_rect, | 191 geometry_rect, |
184 opaque_rect, | 192 opaque_rect, |
185 drawing_info.get_resource_id(), | 193 drawing_info.get_resource_id(), |
186 texture_rect, | 194 texture_rect, |
187 iter.texture_size(), | 195 iter.texture_size(), |
188 drawing_info.contents_swizzled()); | 196 drawing_info.contents_swizzled()); |
189 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); | 197 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); |
190 break; | 198 break; |
191 } | 199 } |
| 200 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: { |
| 201 gfx::RectF texture_rect = iter.texture_rect(); |
| 202 gfx::Rect opaque_rect = iter->opaque_rect(); |
| 203 opaque_rect.Intersect(content_rect); |
| 204 |
| 205 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 206 quad->SetNew(sharedQuadState, |
| 207 geometry_rect, |
| 208 opaque_rect, |
| 209 texture_rect, |
| 210 iter.texture_size(), |
| 211 drawing_info.contents_swizzled(), |
| 212 iter->content_rect(), |
| 213 iter->contents_scale(), |
| 214 pile_); |
| 215 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 216 break; |
| 217 } |
192 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { | 218 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
193 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 219 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
194 quad->SetNew(sharedQuadState, | 220 quad->SetNew(sharedQuadState, |
195 geometry_rect, | 221 geometry_rect, |
196 drawing_info.get_solid_color()); | 222 drawing_info.get_solid_color()); |
197 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); | 223 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); |
198 break; | 224 break; |
199 } | 225 } |
200 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: | 226 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: |
201 break; | 227 break; |
202 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: | |
203 // TODO: crbug.com/173011 would fill this part in. | |
204 default: | 228 default: |
205 NOTREACHED(); | 229 NOTREACHED(); |
206 } | 230 } |
207 | 231 |
208 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | 232 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) |
209 seen_tilings.push_back(iter.CurrentTiling()); | 233 seen_tilings.push_back(iter.CurrentTiling()); |
210 } | 234 } |
211 | 235 |
212 // Aggressively remove any tilings that are not seen to save memory. Note | 236 // Aggressively remove any tilings that are not seen to save memory. Note |
213 // that this is at the expense of doing cause more frequent re-painting. A | 237 // that this is at the expense of doing cause more frequent re-painting. A |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 825 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
802 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 826 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
803 LayerImpl::AsValueInto(state.get()); | 827 LayerImpl::AsValueInto(state.get()); |
804 | 828 |
805 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 829 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
806 state->Set("tilings", tilings_->AsValue().release()); | 830 state->Set("tilings", tilings_->AsValue().release()); |
807 return state.PassAs<base::Value>(); | 831 return state.PassAs<base::Value>(); |
808 } | 832 } |
809 | 833 |
810 } // namespace cc | 834 } // namespace cc |
OLD | NEW |