| 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" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 layer_impl->TransferTilingSet(tilings_.Pass()); | 75 layer_impl->TransferTilingSet(tilings_.Pass()); |
| 76 layer_impl->pile_ = pile_; | 76 layer_impl->pile_ = pile_; |
| 77 pile_ = PicturePileImpl::Create(); | 77 pile_ = PicturePileImpl::Create(); |
| 78 | 78 |
| 79 layer_impl->raster_page_scale_ = raster_page_scale_; | 79 layer_impl->raster_page_scale_ = raster_page_scale_; |
| 80 layer_impl->raster_device_scale_ = raster_device_scale_; | 80 layer_impl->raster_device_scale_ = raster_device_scale_; |
| 81 layer_impl->raster_source_scale_ = raster_source_scale_; | 81 layer_impl->raster_source_scale_ = raster_source_scale_; |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 void PictureLayerImpl::AppendQuads(QuadSink* quadSink, | 85 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, |
| 86 AppendQuadsData* appendQuadsData) { | 86 AppendQuadsData* append_quads_data) { |
| 87 const gfx::Rect& rect = visible_content_rect(); | 87 const gfx::Rect& rect = visible_content_rect(); |
| 88 gfx::Rect content_rect(content_bounds()); | 88 gfx::Rect content_rect(content_bounds()); |
| 89 | 89 |
| 90 SharedQuadState* sharedQuadState = | 90 SharedQuadState* shared_quad_state = |
| 91 quadSink->UseSharedQuadState(CreateSharedQuadState()); | 91 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
| 92 AppendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 92 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
| 93 | 93 |
| 94 bool clipped = false; | 94 bool clipped = false; |
| 95 gfx::QuadF target_quad = MathUtil::MapQuad( | 95 gfx::QuadF target_quad = MathUtil::MapQuad( |
| 96 draw_transform(), | 96 draw_transform(), |
| 97 gfx::QuadF(rect), | 97 gfx::QuadF(rect), |
| 98 &clipped); | 98 &clipped); |
| 99 if (ShowDebugBorders()) { | 99 if (ShowDebugBorders()) { |
| 100 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 100 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
| 101 contents_scale_x(), | 101 contents_scale_x(), |
| 102 rect, | 102 rect, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 122 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 122 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
| 123 } else { | 123 } else { |
| 124 color = DebugColors::ExtraLowResTileBorderColor(); | 124 color = DebugColors::ExtraLowResTileBorderColor(); |
| 125 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); | 125 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); |
| 126 } | 126 } |
| 127 } else { | 127 } else { |
| 128 color = DebugColors::MissingTileBorderColor(); | 128 color = DebugColors::MissingTileBorderColor(); |
| 129 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); | 129 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); |
| 130 } | 130 } |
| 131 | 131 |
| 132 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = | 132 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = |
| 133 DebugBorderDrawQuad::Create(); | 133 DebugBorderDrawQuad::Create(); |
| 134 gfx::Rect geometry_rect = iter.geometry_rect(); | 134 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 135 debugBorderQuad->SetNew(sharedQuadState, geometry_rect, color, width); | 135 debug_border_quad->SetNew(shared_quad_state, geometry_rect, color, width); |
| 136 quadSink->Append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); | 136 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>(), |
| 137 append_quads_data); |
| 137 } | 138 } |
| 138 } | 139 } |
| 139 | 140 |
| 140 // Keep track of the tilings that were used so that tilings that are | 141 // Keep track of the tilings that were used so that tilings that are |
| 141 // unused can be considered for removal. | 142 // unused can be considered for removal. |
| 142 std::vector<PictureLayerTiling*> seen_tilings; | 143 std::vector<PictureLayerTiling*> seen_tilings; |
| 143 | 144 |
| 144 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 145 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
| 145 contents_scale_x(), | 146 contents_scale_x(), |
| 146 rect, | 147 rect, |
| 147 ideal_contents_scale_); | 148 ideal_contents_scale_); |
| 148 iter; | 149 iter; |
| 149 ++iter) { | 150 ++iter) { |
| 150 | 151 |
| 151 gfx::Rect geometry_rect = iter.geometry_rect(); | 152 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 152 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { | 153 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { |
| 153 if (DrawCheckerboardForMissingTiles()) { | 154 if (DrawCheckerboardForMissingTiles()) { |
| 154 // TODO(enne): Figure out how to show debug "invalidated checker" color | 155 // TODO(enne): Figure out how to show debug "invalidated checker" color |
| 155 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); | 156 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); |
| 156 SkColor color = DebugColors::DefaultCheckerboardColor(); | 157 SkColor color = DebugColors::DefaultCheckerboardColor(); |
| 157 quad->SetNew(sharedQuadState, geometry_rect, color); | 158 quad->SetNew(shared_quad_state, geometry_rect, color); |
| 158 if (quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 159 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
| 159 appendQuadsData->numMissingTiles++; | 160 append_quads_data->numMissingTiles++; |
| 160 } else { | 161 } else { |
| 161 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 162 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 162 quad->SetNew(sharedQuadState, geometry_rect, background_color()); | 163 quad->SetNew(shared_quad_state, geometry_rect, background_color()); |
| 163 if (quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 164 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
| 164 appendQuadsData->numMissingTiles++; | 165 append_quads_data->numMissingTiles++; |
| 165 } | 166 } |
| 166 | 167 |
| 167 appendQuadsData->hadIncompleteTile = true; | 168 append_quads_data->hadIncompleteTile = true; |
| 168 continue; | 169 continue; |
| 169 } | 170 } |
| 170 | 171 |
| 171 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); | 172 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); |
| 172 switch (drawing_info.mode()) { | 173 switch (drawing_info.mode()) { |
| 173 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { | 174 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { |
| 174 if (iter->contents_scale() != ideal_contents_scale_) | 175 if (iter->contents_scale() != ideal_contents_scale_) |
| 175 appendQuadsData->hadIncompleteTile = true; | 176 append_quads_data->hadIncompleteTile = true; |
| 176 | 177 |
| 177 gfx::RectF texture_rect = iter.texture_rect(); | 178 gfx::RectF texture_rect = iter.texture_rect(); |
| 178 gfx::Rect opaque_rect = iter->opaque_rect(); | 179 gfx::Rect opaque_rect = iter->opaque_rect(); |
| 179 opaque_rect.Intersect(content_rect); | 180 opaque_rect.Intersect(content_rect); |
| 180 | 181 |
| 181 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); | 182 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); |
| 182 quad->SetNew(sharedQuadState, | 183 quad->SetNew(shared_quad_state, |
| 183 geometry_rect, | 184 geometry_rect, |
| 184 opaque_rect, | 185 opaque_rect, |
| 185 drawing_info.get_resource_id(), | 186 drawing_info.get_resource_id(), |
| 186 texture_rect, | 187 texture_rect, |
| 187 iter.texture_size(), | 188 iter.texture_size(), |
| 188 drawing_info.contents_swizzled()); | 189 drawing_info.contents_swizzled()); |
| 189 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); | 190 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 190 break; | 191 break; |
| 191 } | 192 } |
| 192 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { | 193 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
| 193 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 194 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 194 quad->SetNew(sharedQuadState, | 195 quad->SetNew(shared_quad_state, |
| 195 geometry_rect, | 196 geometry_rect, |
| 196 drawing_info.get_solid_color()); | 197 drawing_info.get_solid_color()); |
| 197 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); | 198 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 198 break; | 199 break; |
| 199 } | 200 } |
| 200 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: | 201 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: |
| 201 break; | 202 break; |
| 202 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: | 203 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: |
| 203 // TODO: crbug.com/173011 would fill this part in. | 204 // TODO: crbug.com/173011 would fill this part in. |
| 204 default: | 205 default: |
| 205 NOTREACHED(); | 206 NOTREACHED(); |
| 206 } | 207 } |
| 207 | 208 |
| 208 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | 209 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) |
| 209 seen_tilings.push_back(iter.CurrentTiling()); | 210 seen_tilings.push_back(iter.CurrentTiling()); |
| 210 } | 211 } |
| 211 | 212 |
| 212 // Aggressively remove any tilings that are not seen to save memory. Note | 213 // 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 | 214 // that this is at the expense of doing cause more frequent re-painting. A |
| 214 // better scheme would be to maintain a tighter visibleContentRect for the | 215 // better scheme would be to maintain a tighter visible_content_rect for the |
| 215 // finer tilings. | 216 // finer tilings. |
| 216 CleanUpTilingsOnActiveLayer(seen_tilings); | 217 CleanUpTilingsOnActiveLayer(seen_tilings); |
| 217 } | 218 } |
| 218 | 219 |
| 219 void PictureLayerImpl::DumpLayerProperties(std::string*, int indent) const { | 220 void PictureLayerImpl::DumpLayerProperties(std::string*, int indent) const { |
| 220 // TODO(enne): implement me | 221 // TODO(enne): implement me |
| 221 } | 222 } |
| 222 | 223 |
| 223 void PictureLayerImpl::UpdateTilePriorities() { | 224 void PictureLayerImpl::UpdateTilePriorities() { |
| 224 int current_source_frame_number = layer_tree_impl()->source_frame_number(); | 225 int current_source_frame_number = layer_tree_impl()->source_frame_number(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 if (any_dimension_one_tile || !any_dimension_too_large) { | 369 if (any_dimension_one_tile || !any_dimension_too_large) { |
| 369 int width = | 370 int width = |
| 370 std::min(max_untiled_content_size.width(), content_bounds.width()); | 371 std::min(max_untiled_content_size.width(), content_bounds.width()); |
| 371 int height = | 372 int height = |
| 372 std::min(max_untiled_content_size.height(), content_bounds.height()); | 373 std::min(max_untiled_content_size.height(), content_bounds.height()); |
| 373 // Round width and height up to the closest multiple of 64, or 56 if | 374 // Round width and height up to the closest multiple of 64, or 56 if |
| 374 // we should avoid power-of-two textures. This helps reduce the number | 375 // we should avoid power-of-two textures. This helps reduce the number |
| 375 // of different textures sizes to help recycling, and also keeps all | 376 // of different textures sizes to help recycling, and also keeps all |
| 376 // textures multiple-of-eight, which is preferred on some drivers (IMG). | 377 // textures multiple-of-eight, which is preferred on some drivers (IMG). |
| 377 bool avoid_pow2 = | 378 bool avoid_pow2 = |
| 378 layer_tree_impl()->rendererCapabilities().avoid_pow2_textures; | 379 layer_tree_impl()->GetRendererCapabilities().avoid_pow2_textures; |
| 379 int round_up_to = avoid_pow2 ? 56 : 64; | 380 int round_up_to = avoid_pow2 ? 56 : 64; |
| 380 width = RoundUp(width, round_up_to); | 381 width = RoundUp(width, round_up_to); |
| 381 height = RoundUp(height, round_up_to); | 382 height = RoundUp(height, round_up_to); |
| 382 return gfx::Size(width, height); | 383 return gfx::Size(width, height); |
| 383 } | 384 } |
| 384 | 385 |
| 385 return default_tile_size; | 386 return default_tile_size; |
| 386 } | 387 } |
| 387 | 388 |
| 388 void PictureLayerImpl::SyncFromActiveLayer() { | 389 void PictureLayerImpl::SyncFromActiveLayer() { |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 802 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
| 802 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 803 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 803 LayerImpl::AsValueInto(state.get()); | 804 LayerImpl::AsValueInto(state.get()); |
| 804 | 805 |
| 805 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 806 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 806 state->Set("tilings", tilings_->AsValue().release()); | 807 state->Set("tilings", tilings_->AsValue().release()); |
| 807 return state.PassAs<base::Value>(); | 808 return state.PassAs<base::Value>(); |
| 808 } | 809 } |
| 809 | 810 |
| 810 } // namespace cc | 811 } // namespace cc |
| OLD | NEW |