| 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/picture_layer_impl.h" | 5 #include "cc/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "cc/append_quads_data.h" | 8 #include "cc/append_quads_data.h" |
| 9 #include "cc/checkerboard_draw_quad.h" | 9 #include "cc/checkerboard_draw_quad.h" |
| 10 #include "cc/debug_border_draw_quad.h" | 10 #include "cc/debug_border_draw_quad.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 // pile. | 404 // pile. |
| 405 if (PictureLayerImpl* active_twin = ActiveTwin()) | 405 if (PictureLayerImpl* active_twin = ActiveTwin()) |
| 406 SyncFromActiveLayer(active_twin); | 406 SyncFromActiveLayer(active_twin); |
| 407 } | 407 } |
| 408 | 408 |
| 409 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { | 409 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { |
| 410 raster_page_scale_ = other->raster_page_scale_; | 410 raster_page_scale_ = other->raster_page_scale_; |
| 411 raster_device_scale_ = other->raster_device_scale_; | 411 raster_device_scale_ = other->raster_device_scale_; |
| 412 raster_source_scale_ = other->raster_source_scale_; | 412 raster_source_scale_ = other->raster_source_scale_; |
| 413 | 413 |
| 414 // Add synthetic invalidations for any recordings that were dropped. As |
| 415 // tiles are updated to point to this new pile, this will force the dropping |
| 416 // of tiles that can no longer be rastered. This is not ideal, but is a |
| 417 // trade-off for memory (use the same pile as much as possible, by switching |
| 418 // during DidBecomeActive) and for time (don't bother checking every tile |
| 419 // during activation to see if the new pile can still raster it). |
| 420 // |
| 421 // TODO(enne): Clean up this double loop. |
| 422 for (int x = 0; x < pile_->num_tiles_x(); ++x) { |
| 423 for (int y = 0; y < pile_->num_tiles_y(); ++y) { |
| 424 bool previously_had = other->pile_->HasRecordingAt(x, y); |
| 425 bool now_has = pile_->HasRecordingAt(x, y); |
| 426 if (now_has || !previously_had) |
| 427 continue; |
| 428 gfx::Rect layer_rect = pile_->tile_bounds(x, y); |
| 429 invalidation_.Union(layer_rect); |
| 430 } |
| 431 } |
| 432 |
| 433 |
| 414 tilings_->CloneAll(*other->tilings_, invalidation_); | 434 tilings_->CloneAll(*other->tilings_, invalidation_); |
| 415 DCHECK(bounds() == tilings_->LayerBounds()); | 435 DCHECK(bounds() == tilings_->LayerBounds()); |
| 416 | 436 |
| 417 // It's a sad but unfortunate fact that PicturePile tiling edges do not line | 437 // It's a sad but unfortunate fact that PicturePile tiling edges do not line |
| 418 // up with PictureLayerTiling edges. Tiles can only be added if they are | 438 // up with PictureLayerTiling edges. Tiles can only be added if they are |
| 419 // entirely covered by recordings (that may come from multiple PicturePile | 439 // entirely covered by recordings (that may come from multiple PicturePile |
| 420 // tiles). This check happens in this class's CreateTile() call. Tiles | 440 // tiles). This check happens in this class's CreateTile() call. |
| 421 // are not removed (even if they cannot be rerecorded) unless they are | |
| 422 // invalidated. | |
| 423 for (int x = 0; x < pile_->num_tiles_x(); ++x) { | 441 for (int x = 0; x < pile_->num_tiles_x(); ++x) { |
| 424 for (int y = 0; y < pile_->num_tiles_y(); ++y) { | 442 for (int y = 0; y < pile_->num_tiles_y(); ++y) { |
| 425 bool previously_had = other->pile_->HasRecordingAt(x, y); | 443 bool previously_had = other->pile_->HasRecordingAt(x, y); |
| 426 bool now_has = pile_->HasRecordingAt(x, y); | 444 bool now_has = pile_->HasRecordingAt(x, y); |
| 427 if (!now_has || previously_had) | 445 if (!now_has || previously_had) |
| 428 continue; | 446 continue; |
| 429 gfx::Rect layer_rect = pile_->tile_bounds(x, y); | 447 gfx::Rect layer_rect = pile_->tile_bounds(x, y); |
| 430 tilings_->CreateTilesFromLayerRect(layer_rect); | 448 tilings_->CreateTilesFromLayerRect(layer_rect); |
| 431 } | 449 } |
| 432 } | 450 } |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 770 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
| 753 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 771 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 754 LayerImpl::AsValueInto(state.get()); | 772 LayerImpl::AsValueInto(state.get()); |
| 755 | 773 |
| 756 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 774 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 757 state->Set("tilings", tilings_->AsValue().release()); | 775 state->Set("tilings", tilings_->AsValue().release()); |
| 758 return state.PassAs<base::Value>(); | 776 return state.PassAs<base::Value>(); |
| 759 } | 777 } |
| 760 | 778 |
| 761 } // namespace cc | 779 } // namespace cc |
| OLD | NEW |