| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 iter; | 114 iter; |
| 114 ++iter) { | 115 ++iter) { |
| 115 SkColor color; | 116 SkColor color; |
| 116 float width; | 117 float width; |
| 117 if (*iter && iter->drawing_info().IsReadyToDraw()) { | 118 if (*iter && iter->drawing_info().IsReadyToDraw()) { |
| 118 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); | 119 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); |
| 119 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || | 120 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || |
| 120 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { | 121 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { |
| 121 color = DebugColors::SolidColorTileBorderColor(); | 122 color = DebugColors::SolidColorTileBorderColor(); |
| 122 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 123 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
| 124 } else if (mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) { |
| 125 color = DebugColors::PictureTileBorderColor(); |
| 126 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
| 123 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 127 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
| 124 color = DebugColors::HighResTileBorderColor(); | 128 color = DebugColors::HighResTileBorderColor(); |
| 125 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 129 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
| 126 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 130 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
| 127 color = DebugColors::LowResTileBorderColor(); | 131 color = DebugColors::LowResTileBorderColor(); |
| 128 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 132 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
| 129 } else if (iter->contents_scale() > contents_scale_x()) { | 133 } else if (iter->contents_scale() > contents_scale_x()) { |
| 130 color = DebugColors::ExtraHighResTileBorderColor(); | 134 color = DebugColors::ExtraHighResTileBorderColor(); |
| 131 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 135 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
| 132 } else { | 136 } else { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 if (quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 177 if (quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData)) |
| 174 appendQuadsData->numMissingTiles++; | 178 appendQuadsData->numMissingTiles++; |
| 175 } | 179 } |
| 176 | 180 |
| 177 appendQuadsData->hadIncompleteTile = true; | 181 appendQuadsData->hadIncompleteTile = true; |
| 178 continue; | 182 continue; |
| 179 } | 183 } |
| 180 | 184 |
| 181 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); | 185 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); |
| 182 switch (drawing_info.mode()) { | 186 switch (drawing_info.mode()) { |
| 183 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { | 187 case ManagedTileState::DrawingInfo::TEXTURE_MODE: |
| 188 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: { |
| 184 if (iter->contents_scale() != ideal_contents_scale_) | 189 if (iter->contents_scale() != ideal_contents_scale_) |
| 185 appendQuadsData->hadIncompleteTile = true; | 190 appendQuadsData->hadIncompleteTile = true; |
| 186 | 191 |
| 187 gfx::RectF texture_rect = iter.texture_rect(); | 192 gfx::RectF texture_rect = iter.texture_rect(); |
| 188 gfx::Rect opaque_rect = iter->opaque_rect(); | 193 gfx::Rect opaque_rect = iter->opaque_rect(); |
| 189 opaque_rect.Intersect(content_rect); | 194 opaque_rect.Intersect(content_rect); |
| 190 | 195 |
| 191 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); | 196 if (drawing_info.mode() == |
| 192 quad->SetNew(sharedQuadState, | 197 ManagedTileState::DrawingInfo::TEXTURE_MODE) { |
| 193 geometry_rect, | 198 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); |
| 194 opaque_rect, | 199 quad->SetNew(sharedQuadState, |
| 195 drawing_info.get_resource_id(), | 200 geometry_rect, |
| 196 texture_rect, | 201 opaque_rect, |
| 197 iter.texture_size(), | 202 drawing_info.get_resource_id(), |
| 198 drawing_info.contents_swizzled()); | 203 texture_rect, |
| 199 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); | 204 iter.texture_size(), |
| 205 drawing_info.contents_swizzled()); |
| 206 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 207 } else { |
| 208 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 209 quad->SetNew(sharedQuadState, |
| 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 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 219 } |
| 200 break; | 220 break; |
| 201 } | 221 } |
| 202 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { | 222 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
| 203 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 223 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 204 quad->SetNew(sharedQuadState, | 224 quad->SetNew(sharedQuadState, |
| 205 geometry_rect, | 225 geometry_rect, |
| 206 drawing_info.get_solid_color()); | 226 drawing_info.get_solid_color()); |
| 207 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); | 227 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 208 break; | 228 break; |
| 209 } | 229 } |
| 210 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: | 230 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: |
| 211 break; | 231 break; |
| 212 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: | |
| 213 // TODO: crbug.com/173011 would fill this part in. | |
| 214 default: | 232 default: |
| 215 NOTREACHED(); | 233 NOTREACHED(); |
| 216 } | 234 } |
| 217 | 235 |
| 218 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | 236 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) |
| 219 seen_tilings.push_back(iter.CurrentTiling()); | 237 seen_tilings.push_back(iter.CurrentTiling()); |
| 220 } | 238 } |
| 221 | 239 |
| 222 // Aggressively remove any tilings that are not seen to save memory. Note | 240 // Aggressively remove any tilings that are not seen to save memory. Note |
| 223 // that this is at the expense of doing cause more frequent re-painting. A | 241 // that this is at the expense of doing cause more frequent re-painting. A |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 837 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
| 820 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 838 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 821 LayerImpl::AsValueInto(state.get()); | 839 LayerImpl::AsValueInto(state.get()); |
| 822 | 840 |
| 823 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 841 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 824 state->Set("tilings", tilings_->AsValue().release()); | 842 state->Set("tilings", tilings_->AsValue().release()); |
| 825 return state.PassAs<base::Value>(); | 843 return state.PassAs<base::Value>(); |
| 826 } | 844 } |
| 827 | 845 |
| 828 } // namespace cc | 846 } // namespace cc |
| OLD | NEW |