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::PICTURE_PILE_MODE) { | 228 } else if (mode == TileDrawInfo::OOM_MODE) { |
229 color = DebugColors::PictureTileBorderColor(); | 229 color = DebugColors::OOMTileBorderColor(); |
230 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | 230 width = DebugColors::OOMTileBorderWidth(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 } | |
340 case TileDrawInfo::SOLID_COLOR_MODE: { | 316 case TileDrawInfo::SOLID_COLOR_MODE: { |
341 SolidColorDrawQuad* quad = | 317 SolidColorDrawQuad* quad = |
342 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 318 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
343 quad->SetNew(shared_quad_state, geometry_rect, visible_geometry_rect, | 319 quad->SetNew(shared_quad_state, geometry_rect, visible_geometry_rect, |
344 draw_info.solid_color(), false); | 320 draw_info.solid_color(), false); |
345 has_draw_quad = true; | 321 has_draw_quad = true; |
346 break; | 322 break; |
347 } | 323 } |
| 324 case TileDrawInfo::OOM_MODE: |
| 325 break; // Checkerboard. |
348 } | 326 } |
349 } | 327 } |
350 | 328 |
351 if (!has_draw_quad) { | 329 if (!has_draw_quad) { |
352 if (draw_checkerboard_for_missing_tiles()) { | 330 if (draw_checkerboard_for_missing_tiles()) { |
353 CheckerboardDrawQuad* quad = | 331 CheckerboardDrawQuad* quad = |
354 render_pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | 332 render_pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |
355 SkColor color = DebugColors::DefaultCheckerboardColor(); | 333 SkColor color = DebugColors::DefaultCheckerboardColor(); |
356 quad->SetNew( | 334 quad->SetNew( |
357 shared_quad_state, geometry_rect, visible_geometry_rect, color); | 335 shared_quad_state, geometry_rect, visible_geometry_rect, color); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 536 } |
559 | 537 |
560 // We could do this after doing UpdateTiles, which would avoid doing this for | 538 // We could do this after doing UpdateTiles, which would avoid doing this for |
561 // tilings that are going to disappear on the pending tree (if scale changed). | 539 // tilings that are going to disappear on the pending tree (if scale changed). |
562 // But that would also be more complicated, so we just do it here for now. | 540 // But that would also be more complicated, so we just do it here for now. |
563 tilings_->UpdateTilingsToCurrentRasterSource( | 541 tilings_->UpdateTilingsToCurrentRasterSource( |
564 raster_source_, pending_set, invalidation_, MinimumContentsScale(), | 542 raster_source_, pending_set, invalidation_, MinimumContentsScale(), |
565 MaximumContentsScale()); | 543 MaximumContentsScale()); |
566 } | 544 } |
567 | 545 |
| 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 |
568 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 576 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
569 if (layer_tree_impl()->IsActiveTree()) { | 577 if (layer_tree_impl()->IsActiveTree()) { |
570 gfx::RectF layer_damage_rect = | 578 gfx::RectF layer_damage_rect = |
571 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); | 579 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
572 AddDamageRect(layer_damage_rect); | 580 AddDamageRect(layer_damage_rect); |
573 } | 581 } |
574 } | 582 } |
575 | 583 |
576 void PictureLayerImpl::DidBeginTracing() { | 584 void PictureLayerImpl::DidBeginTracing() { |
577 raster_source_->DidBeginTracing(); | 585 raster_source_->DidBeginTracing(); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 | 1219 |
1212 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1220 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1213 return !layer_tree_impl()->IsRecycleTree(); | 1221 return !layer_tree_impl()->IsRecycleTree(); |
1214 } | 1222 } |
1215 | 1223 |
1216 bool PictureLayerImpl::HasValidTilePriorities() const { | 1224 bool PictureLayerImpl::HasValidTilePriorities() const { |
1217 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1225 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1218 } | 1226 } |
1219 | 1227 |
1220 } // namespace cc | 1228 } // namespace cc |
OLD | NEW |