| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 iter; | 107 iter; |
| 107 ++iter) { | 108 ++iter) { |
| 108 SkColor color; | 109 SkColor color; |
| 109 float width; | 110 float width; |
| 110 if (*iter && iter->drawing_info().IsReadyToDraw()) { | 111 if (*iter && iter->drawing_info().IsReadyToDraw()) { |
| 111 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); | 112 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); |
| 112 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || | 113 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || |
| 113 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { | 114 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { |
| 114 color = DebugColors::SolidColorTileBorderColor(); | 115 color = DebugColors::SolidColorTileBorderColor(); |
| 115 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 116 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
| 117 } else if (mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) { |
| 118 color = DebugColors::PictureTileBorderColor(); |
| 119 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
| 116 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 120 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
| 117 color = DebugColors::HighResTileBorderColor(); | 121 color = DebugColors::HighResTileBorderColor(); |
| 118 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 122 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
| 119 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 123 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
| 120 color = DebugColors::LowResTileBorderColor(); | 124 color = DebugColors::LowResTileBorderColor(); |
| 121 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 125 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
| 122 } else if (iter->contents_scale() > contents_scale_x()) { | 126 } else if (iter->contents_scale() > contents_scale_x()) { |
| 123 color = DebugColors::ExtraHighResTileBorderColor(); | 127 color = DebugColors::ExtraHighResTileBorderColor(); |
| 124 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 128 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
| 125 } else { | 129 } else { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 quad->SetNew(shared_quad_state, geometry_rect, background_color()); | 169 quad->SetNew(shared_quad_state, geometry_rect, background_color()); |
| 166 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) | 170 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
| 167 append_quads_data->numMissingTiles++; | 171 append_quads_data->numMissingTiles++; |
| 168 } | 172 } |
| 169 | 173 |
| 170 append_quads_data->hadIncompleteTile = true; | 174 append_quads_data->hadIncompleteTile = true; |
| 171 continue; | 175 continue; |
| 172 } | 176 } |
| 173 | 177 |
| 174 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); | 178 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); |
| 175 switch (drawing_info.mode()) { | 179 ManagedTileState::DrawingInfo::Mode mode = drawing_info.mode(); |
| 176 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { | 180 if (mode == ManagedTileState::DrawingInfo::RESOURCE_MODE || |
| 177 if (iter->contents_scale() != ideal_contents_scale_) | 181 mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) { |
| 178 append_quads_data->hadIncompleteTile = true; | 182 if (iter->contents_scale() != ideal_contents_scale_) |
| 183 append_quads_data->hadIncompleteTile = true; |
| 184 } |
| 179 | 185 |
| 186 switch (mode) { |
| 187 case ManagedTileState::DrawingInfo::RESOURCE_MODE: { |
| 180 gfx::RectF texture_rect = iter.texture_rect(); | 188 gfx::RectF texture_rect = iter.texture_rect(); |
| 181 gfx::Rect opaque_rect = iter->opaque_rect(); | 189 gfx::Rect opaque_rect = iter->opaque_rect(); |
| 182 opaque_rect.Intersect(content_rect); | 190 opaque_rect.Intersect(content_rect); |
| 183 | 191 |
| 184 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); | 192 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); |
| 185 quad->SetNew(shared_quad_state, | 193 quad->SetNew(shared_quad_state, |
| 186 geometry_rect, | 194 geometry_rect, |
| 187 opaque_rect, | 195 opaque_rect, |
| 188 drawing_info.get_resource_id(), | 196 drawing_info.get_resource_id(), |
| 189 texture_rect, | 197 texture_rect, |
| 190 iter.texture_size(), | 198 iter.texture_size(), |
| 191 drawing_info.contents_swizzled()); | 199 drawing_info.contents_swizzled()); |
| 192 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 200 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 193 break; | 201 break; |
| 194 } | 202 } |
| 203 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: { |
| 204 gfx::RectF texture_rect = iter.texture_rect(); |
| 205 gfx::Rect opaque_rect = iter->opaque_rect(); |
| 206 opaque_rect.Intersect(content_rect); |
| 207 |
| 208 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 209 quad->SetNew(shared_quad_state, |
| 210 geometry_rect, |
| 211 opaque_rect, |
| 212 texture_rect, |
| 213 iter.texture_size(), |
| 214 drawing_info.contents_swizzled(), |
| 215 iter->content_rect(), |
| 216 iter->contents_scale(), |
| 217 pile_); |
| 218 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 219 break; |
| 220 } |
| 195 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { | 221 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
| 196 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 222 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 197 quad->SetNew(shared_quad_state, | 223 quad->SetNew(shared_quad_state, |
| 198 geometry_rect, | 224 geometry_rect, |
| 199 drawing_info.get_solid_color()); | 225 drawing_info.get_solid_color()); |
| 200 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 226 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 201 break; | 227 break; |
| 202 } | 228 } |
| 203 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: | 229 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: |
| 204 break; | 230 break; |
| 205 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: | |
| 206 // TODO: crbug.com/173011 would fill this part in. | |
| 207 default: | 231 default: |
| 208 NOTREACHED(); | 232 NOTREACHED(); |
| 209 } | 233 } |
| 210 | 234 |
| 211 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | 235 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) |
| 212 seen_tilings.push_back(iter.CurrentTiling()); | 236 seen_tilings.push_back(iter.CurrentTiling()); |
| 213 } | 237 } |
| 214 | 238 |
| 215 // Aggressively remove any tilings that are not seen to save memory. Note | 239 // Aggressively remove any tilings that are not seen to save memory. Note |
| 216 // that this is at the expense of doing cause more frequent re-painting. A | 240 // that this is at the expense of doing cause more frequent re-painting. A |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 494 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
| 471 gfx::Rect content_rect(content_bounds()); | 495 gfx::Rect content_rect(content_bounds()); |
| 472 float scale = contents_scale_x(); | 496 float scale = contents_scale_x(); |
| 473 for (PictureLayerTilingSet::Iterator | 497 for (PictureLayerTilingSet::Iterator |
| 474 iter(tilings_.get(), scale, content_rect, ideal_contents_scale_); | 498 iter(tilings_.get(), scale, content_rect, ideal_contents_scale_); |
| 475 iter; | 499 iter; |
| 476 ++iter) { | 500 ++iter) { |
| 477 // Mask resource not ready yet. | 501 // Mask resource not ready yet. |
| 478 if (!*iter || | 502 if (!*iter || |
| 479 iter->drawing_info().mode() != | 503 iter->drawing_info().mode() != |
| 480 ManagedTileState::DrawingInfo::TEXTURE_MODE || | 504 ManagedTileState::DrawingInfo::RESOURCE_MODE || |
| 481 !iter->drawing_info().IsReadyToDraw()) | 505 !iter->drawing_info().IsReadyToDraw()) |
| 482 return 0; | 506 return 0; |
| 483 // Masks only supported if they fit on exactly one tile. | 507 // Masks only supported if they fit on exactly one tile. |
| 484 if (iter.geometry_rect() != content_rect) | 508 if (iter.geometry_rect() != content_rect) |
| 485 return 0; | 509 return 0; |
| 486 return iter->drawing_info().get_resource_id(); | 510 return iter->drawing_info().get_resource_id(); |
| 487 } | 511 } |
| 488 return 0; | 512 return 0; |
| 489 } | 513 } |
| 490 | 514 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 870 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
| 847 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 871 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 848 LayerImpl::AsValueInto(state.get()); | 872 LayerImpl::AsValueInto(state.get()); |
| 849 | 873 |
| 850 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 874 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 851 state->Set("tilings", tilings_->AsValue().release()); | 875 state->Set("tilings", tilings_->AsValue().release()); |
| 852 return state.PassAs<base::Value>(); | 876 return state.PassAs<base::Value>(); |
| 853 } | 877 } |
| 854 | 878 |
| 855 } // namespace cc | 879 } // namespace cc |
| OLD | NEW |