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/layer_tree_impl.h" | 7 #include "cc/layer_tree_impl.h" |
8 #include "cc/picture_layer_impl.h" | 8 #include "cc/picture_layer_impl.h" |
9 #include "ui/gfx/rect_conversions.h" | 9 #include "ui/gfx/rect_conversions.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 void PictureLayer::setLayerTreeHost(LayerTreeHost* host) { | 46 void PictureLayer::setLayerTreeHost(LayerTreeHost* host) { |
47 Layer::setLayerTreeHost(host); | 47 Layer::setLayerTreeHost(host); |
48 if (host) | 48 if (host) |
49 pile_.SetMinContentsScale(host->settings().minimumContentsScale); | 49 pile_.SetMinContentsScale(host->settings().minimumContentsScale); |
50 } | 50 } |
51 | 51 |
52 void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) { | 52 void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) { |
53 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); | 53 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); |
54 pending_invalidation_.Union(rect); | 54 if (!rect.IsEmpty()) { |
| 55 // Clamp invalidation to the layer bounds. |
| 56 rect.Intersect(gfx::Rect(bounds())); |
| 57 pending_invalidation_.Union(rect); |
| 58 } |
55 Layer::setNeedsDisplayRect(layer_rect); | 59 Layer::setNeedsDisplayRect(layer_rect); |
56 } | 60 } |
57 | 61 |
58 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, | 62 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, |
59 RenderingStats& stats) { | 63 RenderingStats& stats) { |
60 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty()) | 64 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty()) |
61 return; | 65 return; |
62 | 66 |
63 pile_.Resize(bounds()); | 67 pile_.Resize(bounds()); |
64 | 68 |
65 // Calling paint in WebKit can sometimes cause invalidations, so save | 69 // Calling paint in WebKit can sometimes cause invalidations, so save |
66 // off the invalidation prior to calling update. | 70 // off the invalidation prior to calling update. |
67 pile_invalidation_.Swap(pending_invalidation_); | 71 pile_invalidation_.Swap(pending_invalidation_); |
68 pending_invalidation_.Clear(); | 72 pending_invalidation_.Clear(); |
69 | 73 |
70 pile_.Update(client_, pile_invalidation_, stats); | 74 pile_.Update(client_, pile_invalidation_, stats); |
71 } | 75 } |
72 | 76 |
73 void PictureLayer::setIsMask(bool is_mask) { | 77 void PictureLayer::setIsMask(bool is_mask) { |
74 is_mask_ = is_mask; | 78 is_mask_ = is_mask; |
75 } | 79 } |
76 | 80 |
77 } // namespace cc | 81 } // namespace cc |
OLD | NEW |