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()) { |
danakj
2013/01/09 00:31:57
you could also rect.Intersect(gfx::Rect(contentBou
| |
55 // Clamp invalidation to the layer bounds. | |
56 gfx::Rect clamped_rect = gfx::IntersectRects( | |
57 rect, | |
58 gfx::Rect(contentBounds())); | |
59 if (!clamped_rect.IsEmpty()) | |
60 pending_invalidation_.Union(clamped_rect); | |
danakj
2013/01/09 00:31:57
union with an empty rect is a no-op, so you probab
| |
61 } | |
55 Layer::setNeedsDisplayRect(layer_rect); | 62 Layer::setNeedsDisplayRect(layer_rect); |
56 } | 63 } |
57 | 64 |
58 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, | 65 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, |
59 RenderingStats& stats) { | 66 RenderingStats& stats) { |
60 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty()) | 67 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty()) |
61 return; | 68 return; |
62 | 69 |
63 pile_.Resize(bounds()); | 70 pile_.Resize(bounds()); |
64 | 71 |
65 // Calling paint in WebKit can sometimes cause invalidations, so save | 72 // Calling paint in WebKit can sometimes cause invalidations, so save |
66 // off the invalidation prior to calling update. | 73 // off the invalidation prior to calling update. |
67 pile_invalidation_.Swap(pending_invalidation_); | 74 pile_invalidation_.Swap(pending_invalidation_); |
68 pending_invalidation_.Clear(); | 75 pending_invalidation_.Clear(); |
69 | 76 |
70 pile_.Update(client_, pile_invalidation_, stats); | 77 pile_.Update(client_, pile_invalidation_, stats); |
71 } | 78 } |
72 | 79 |
73 void PictureLayer::setIsMask(bool is_mask) { | 80 void PictureLayer::setIsMask(bool is_mask) { |
74 is_mask_ = is_mask; | 81 is_mask_ = is_mask; |
75 } | 82 } |
76 | 83 |
77 } // namespace cc | 84 } // namespace cc |
OLD | NEW |