| 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.h" | 5 #include "cc/picture_layer.h" |
| 6 | 6 |
| 7 #include "cc/devtools_instrumentation.h" | 7 #include "cc/devtools_instrumentation.h" |
| 8 #include "cc/layer_tree_impl.h" | 8 #include "cc/layer_tree_impl.h" |
| 9 #include "cc/picture_layer_impl.h" | 9 #include "cc/picture_layer_impl.h" |
| 10 #include "ui/gfx/rect_conversions.h" | 10 #include "ui/gfx/rect_conversions.h" |
| 11 | 11 |
| 12 namespace cc { | 12 namespace cc { |
| 13 | 13 |
| 14 scoped_refptr<PictureLayer> PictureLayer::create(ContentLayerClient* client) { | 14 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { |
| 15 return make_scoped_refptr(new PictureLayer(client)); | 15 return make_scoped_refptr(new PictureLayer(client)); |
| 16 } | 16 } |
| 17 | 17 |
| 18 PictureLayer::PictureLayer(ContentLayerClient* client) : | 18 PictureLayer::PictureLayer(ContentLayerClient* client) : |
| 19 client_(client), | 19 client_(client), |
| 20 pile_(make_scoped_refptr(new PicturePile())), | 20 pile_(make_scoped_refptr(new PicturePile())), |
| 21 instrumentation_object_tracker_(id()), | 21 instrumentation_object_tracker_(id()), |
| 22 is_mask_(false) { | 22 is_mask_(false) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 PictureLayer::~PictureLayer() { | 25 PictureLayer::~PictureLayer() { |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool PictureLayer::drawsContent() const { | 28 bool PictureLayer::DrawsContent() const { |
| 29 return Layer::drawsContent() && client_; | 29 return Layer::DrawsContent() && client_; |
| 30 } | 30 } |
| 31 | 31 |
| 32 scoped_ptr<LayerImpl> PictureLayer::createLayerImpl(LayerTreeImpl* treeImpl) { | 32 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* treeImpl) { |
| 33 return PictureLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>(); | 33 return PictureLayerImpl::Create(treeImpl, id()).PassAs<LayerImpl>(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void PictureLayer::pushPropertiesTo(LayerImpl* base_layer) { | 36 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { |
| 37 Layer::pushPropertiesTo(base_layer); | 37 Layer::PushPropertiesTo(base_layer); |
| 38 | 38 |
| 39 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); | 39 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); |
| 40 layer_impl->SetIsMask(is_mask_); | 40 layer_impl->SetIsMask(is_mask_); |
| 41 layer_impl->CreateTilingSet(); | 41 layer_impl->CreateTilingSet(); |
| 42 layer_impl->invalidation_.Clear(); | 42 layer_impl->invalidation_.Clear(); |
| 43 layer_impl->invalidation_.Swap(pile_invalidation_); | 43 layer_impl->invalidation_.Swap(pile_invalidation_); |
| 44 pile_->PushPropertiesTo(layer_impl->pile_); | 44 pile_->PushPropertiesTo(layer_impl->pile_); |
| 45 | 45 |
| 46 layer_impl->SyncFromActiveLayer(); | 46 layer_impl->SyncFromActiveLayer(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void PictureLayer::setLayerTreeHost(LayerTreeHost* host) { | 49 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 50 Layer::setLayerTreeHost(host); | 50 Layer::SetLayerTreeHost(host); |
| 51 if (host) { | 51 if (host) { |
| 52 pile_->SetMinContentsScale(host->settings().minimumContentsScale); | 52 pile_->SetMinContentsScale(host->settings().minimumContentsScale); |
| 53 pile_->SetTileGridSize(host->settings().defaultTileSize); | 53 pile_->SetTileGridSize(host->settings().defaultTileSize); |
| 54 pile_->set_num_raster_threads(host->settings().numRasterThreads); | 54 pile_->set_num_raster_threads(host->settings().numRasterThreads); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) { | 58 void PictureLayer::SetNeedsDisplayRect(const gfx::RectF& layer_rect) { |
| 59 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); | 59 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); |
| 60 if (!rect.IsEmpty()) { | 60 if (!rect.IsEmpty()) { |
| 61 // Clamp invalidation to the layer bounds. | 61 // Clamp invalidation to the layer bounds. |
| 62 rect.Intersect(gfx::Rect(bounds())); | 62 rect.Intersect(gfx::Rect(bounds())); |
| 63 pending_invalidation_.Union(rect); | 63 pending_invalidation_.Union(rect); |
| 64 } | 64 } |
| 65 Layer::setNeedsDisplayRect(layer_rect); | 65 Layer::SetNeedsDisplayRect(layer_rect); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, | 68 void PictureLayer::Update(ResourceUpdateQueue*, |
| 69 const OcclusionTracker*, |
| 69 RenderingStats* stats) { | 70 RenderingStats* stats) { |
| 70 // Do not early-out of this function so that PicturePile::Update has a chance | 71 // Do not early-out of this function so that PicturePile::Update has a chance |
| 71 // to record pictures due to changing visibility of this layer. | 72 // to record pictures due to changing visibility of this layer. |
| 72 | 73 |
| 73 pile_->Resize(bounds()); | 74 pile_->Resize(bounds()); |
| 74 | 75 |
| 75 // Calling paint in WebKit can sometimes cause invalidations, so save | 76 // Calling paint in WebKit can sometimes cause invalidations, so save |
| 76 // off the invalidation prior to calling update. | 77 // off the invalidation prior to calling update. |
| 77 pile_invalidation_.Swap(pending_invalidation_); | 78 pile_invalidation_.Swap(pending_invalidation_); |
| 78 pending_invalidation_.Clear(); | 79 pending_invalidation_.Clear(); |
| 79 | 80 |
| 80 gfx::Rect visible_layer_rect = gfx::ToEnclosingRect( | 81 gfx::Rect visible_layer_rect = gfx::ToEnclosingRect( |
| 81 gfx::ScaleRect(visibleContentRect(), 1.f / contentsScaleX())); | 82 gfx::ScaleRect(visible_content_rect(), 1.f / contents_scale_x())); |
| 82 devtools_instrumentation::ScopedPaintLayer paint_layer(id()); | 83 devtools_instrumentation::ScopedPaintLayer paint_layer(id()); |
| 83 pile_->Update(client_, | 84 pile_->Update(client_, |
| 84 backgroundColor(), | 85 background_color(), |
| 85 pile_invalidation_, | 86 pile_invalidation_, |
| 86 visible_layer_rect, | 87 visible_layer_rect, |
| 87 stats); | 88 stats); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void PictureLayer::setIsMask(bool is_mask) { | 91 void PictureLayer::SetIsMask(bool is_mask) { |
| 91 is_mask_ = is_mask; | 92 is_mask_ = is_mask; |
| 92 } | 93 } |
| 93 | 94 |
| 94 } // namespace cc | 95 } // namespace cc |
| OLD | NEW |