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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 tilings_.get(), max_contents_scale, | 218 tilings_.get(), max_contents_scale, |
219 shared_quad_state->visible_content_rect, ideal_contents_scale_); | 219 shared_quad_state->visible_content_rect, ideal_contents_scale_); |
220 iter; ++iter) { | 220 iter; ++iter) { |
221 SkColor color; | 221 SkColor color; |
222 float width; | 222 float width; |
223 if (*iter && iter->IsReadyToDraw()) { | 223 if (*iter && iter->IsReadyToDraw()) { |
224 TileDrawInfo::Mode mode = iter->draw_info().mode(); | 224 TileDrawInfo::Mode mode = iter->draw_info().mode(); |
225 if (mode == TileDrawInfo::SOLID_COLOR_MODE) { | 225 if (mode == TileDrawInfo::SOLID_COLOR_MODE) { |
226 color = DebugColors::SolidColorTileBorderColor(); | 226 color = DebugColors::SolidColorTileBorderColor(); |
227 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 227 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
228 } else if (mode == TileDrawInfo::OOM_MODE) { | 228 } else if (mode == TileDrawInfo::PICTURE_PILE_MODE) { |
229 color = DebugColors::OOMTileBorderColor(); | 229 color = DebugColors::PictureTileBorderColor(); |
230 width = DebugColors::OOMTileBorderWidth(layer_tree_impl()); | 230 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
231 } else if (iter.resolution() == HIGH_RESOLUTION) { | 231 } else if (iter.resolution() == HIGH_RESOLUTION) { |
232 color = DebugColors::HighResTileBorderColor(); | 232 color = DebugColors::HighResTileBorderColor(); |
233 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 233 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
234 } else if (iter.resolution() == LOW_RESOLUTION) { | 234 } else if (iter.resolution() == LOW_RESOLUTION) { |
235 color = DebugColors::LowResTileBorderColor(); | 235 color = DebugColors::LowResTileBorderColor(); |
236 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 236 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
237 } else if (iter->contents_scale() > max_contents_scale) { | 237 } else if (iter->contents_scale() > max_contents_scale) { |
238 color = DebugColors::ExtraHighResTileBorderColor(); | 238 color = DebugColors::ExtraHighResTileBorderColor(); |
239 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 239 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
240 } else { | 240 } else { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 306 |
307 TileDrawQuad* quad = | 307 TileDrawQuad* quad = |
308 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 308 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
309 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, | 309 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
310 visible_geometry_rect, draw_info.resource_id(), | 310 visible_geometry_rect, draw_info.resource_id(), |
311 texture_rect, draw_info.resource_size(), | 311 texture_rect, draw_info.resource_size(), |
312 draw_info.contents_swizzled(), nearest_neighbor_); | 312 draw_info.contents_swizzled(), nearest_neighbor_); |
313 has_draw_quad = true; | 313 has_draw_quad = true; |
314 break; | 314 break; |
315 } | 315 } |
| 316 case TileDrawInfo::PICTURE_PILE_MODE: { |
| 317 if (!layer_tree_impl() |
| 318 ->GetRendererCapabilities() |
| 319 .allow_rasterize_on_demand) { |
| 320 ++on_demand_missing_tile_count; |
| 321 break; |
| 322 } |
| 323 |
| 324 gfx::RectF texture_rect = iter.texture_rect(); |
| 325 |
| 326 ResourceProvider* resource_provider = |
| 327 layer_tree_impl()->resource_provider(); |
| 328 ResourceFormat format = |
| 329 resource_provider->memory_efficient_texture_format(); |
| 330 PictureDrawQuad* quad = |
| 331 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); |
| 332 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
| 333 visible_geometry_rect, texture_rect, |
| 334 iter->desired_texture_size(), nearest_neighbor_, format, |
| 335 iter->content_rect(), iter->contents_scale(), |
| 336 raster_source_); |
| 337 has_draw_quad = true; |
| 338 break; |
| 339 } |
316 case TileDrawInfo::SOLID_COLOR_MODE: { | 340 case TileDrawInfo::SOLID_COLOR_MODE: { |
317 SolidColorDrawQuad* quad = | 341 SolidColorDrawQuad* quad = |
318 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 342 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
319 quad->SetNew(shared_quad_state, geometry_rect, visible_geometry_rect, | 343 quad->SetNew(shared_quad_state, geometry_rect, visible_geometry_rect, |
320 draw_info.solid_color(), false); | 344 draw_info.solid_color(), false); |
321 has_draw_quad = true; | 345 has_draw_quad = true; |
322 break; | 346 break; |
323 } | 347 } |
324 case TileDrawInfo::OOM_MODE: | |
325 break; // Checkerboard. | |
326 } | 348 } |
327 } | 349 } |
328 | 350 |
329 if (!has_draw_quad) { | 351 if (!has_draw_quad) { |
330 if (draw_checkerboard_for_missing_tiles()) { | 352 if (draw_checkerboard_for_missing_tiles()) { |
331 CheckerboardDrawQuad* quad = | 353 CheckerboardDrawQuad* quad = |
332 render_pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | 354 render_pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |
333 SkColor color = DebugColors::DefaultCheckerboardColor(); | 355 SkColor color = DebugColors::DefaultCheckerboardColor(); |
334 quad->SetNew( | 356 quad->SetNew( |
335 shared_quad_state, geometry_rect, visible_geometry_rect, color); | 357 shared_quad_state, geometry_rect, visible_geometry_rect, color); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 } | 558 } |
537 | 559 |
538 // We could do this after doing UpdateTiles, which would avoid doing this for | 560 // We could do this after doing UpdateTiles, which would avoid doing this for |
539 // tilings that are going to disappear on the pending tree (if scale changed). | 561 // tilings that are going to disappear on the pending tree (if scale changed). |
540 // But that would also be more complicated, so we just do it here for now. | 562 // But that would also be more complicated, so we just do it here for now. |
541 tilings_->UpdateTilingsToCurrentRasterSource( | 563 tilings_->UpdateTilingsToCurrentRasterSource( |
542 raster_source_, pending_set, invalidation_, MinimumContentsScale(), | 564 raster_source_, pending_set, invalidation_, MinimumContentsScale(), |
543 MaximumContentsScale()); | 565 MaximumContentsScale()); |
544 } | 566 } |
545 | 567 |
546 void PictureLayerImpl::UpdateCanUseLCDTextAfterCommit() { | |
547 // This function is only allowed to be called after commit, due to it not | |
548 // being smart about sharing tiles and because otherwise it would cause | |
549 // flashes by switching out tiles in place that may be currently on screen. | |
550 DCHECK(layer_tree_impl()->IsSyncTree()); | |
551 | |
552 // Don't allow the LCD text state to change once disabled. | |
553 if (!RasterSourceUsesLCDText()) | |
554 return; | |
555 if (can_use_lcd_text() == RasterSourceUsesLCDText()) | |
556 return; | |
557 | |
558 // Raster sources are considered const, so in order to update the state | |
559 // a new one must be created and all tiles recreated. | |
560 scoped_refptr<RasterSource> new_raster_source = | |
561 raster_source_->CreateCloneWithoutLCDText(); | |
562 // Synthetically invalidate everything. | |
563 gfx::Rect bounds_rect(bounds()); | |
564 Region invalidation(bounds_rect); | |
565 UpdateRasterSource(new_raster_source, &invalidation, nullptr); | |
566 SetUpdateRect(bounds_rect); | |
567 | |
568 DCHECK(!RasterSourceUsesLCDText()); | |
569 } | |
570 | |
571 bool PictureLayerImpl::RasterSourceUsesLCDText() const { | |
572 return raster_source_ ? raster_source_->CanUseLCDText() | |
573 : layer_tree_impl()->settings().can_use_lcd_text; | |
574 } | |
575 | |
576 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 568 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
577 if (layer_tree_impl()->IsActiveTree()) { | 569 if (layer_tree_impl()->IsActiveTree()) { |
578 gfx::RectF layer_damage_rect = | 570 gfx::RectF layer_damage_rect = |
579 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); | 571 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
580 AddDamageRect(layer_damage_rect); | 572 AddDamageRect(layer_damage_rect); |
581 } | 573 } |
582 } | 574 } |
583 | 575 |
584 void PictureLayerImpl::DidBeginTracing() { | 576 void PictureLayerImpl::DidBeginTracing() { |
585 raster_source_->DidBeginTracing(); | 577 raster_source_->DidBeginTracing(); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 | 1211 |
1220 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1212 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1221 return !layer_tree_impl()->IsRecycleTree(); | 1213 return !layer_tree_impl()->IsRecycleTree(); |
1222 } | 1214 } |
1223 | 1215 |
1224 bool PictureLayerImpl::HasValidTilePriorities() const { | 1216 bool PictureLayerImpl::HasValidTilePriorities() const { |
1225 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1217 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1226 } | 1218 } |
1227 | 1219 |
1228 } // namespace cc | 1220 } // namespace cc |
OLD | NEW |