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/resources/picture_pile.h" |
| 6 |
5 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> |
6 | 9 |
7 #include "cc/base/region.h" | 10 #include "cc/base/region.h" |
8 #include "cc/resources/picture_pile.h" | |
9 #include "cc/resources/picture_pile_impl.h" | 11 #include "cc/resources/picture_pile_impl.h" |
10 | 12 |
11 namespace { | 13 namespace { |
12 // Maximum number of pictures that can overlap before we collapse them into | 14 // Maximum number of pictures that can overlap before we collapse them into |
13 // a larger one. | 15 // a larger one. |
14 const int kMaxOverlapping = 2; | 16 const int kMaxOverlapping = 2; |
15 // Maximum percentage area of the base picture another picture in the picture | 17 // Maximum percentage area of the base picture another picture in the picture |
16 // list can be. If higher, we destroy the list and recreate from scratch. | 18 // list can be. If higher, we destroy the list and recreate from scratch. |
17 const float kResetThreshold = 0.7f; | 19 const float kResetThreshold = 0.7f; |
18 // Layout pixel buffer around the visible layer rect to record. Any base | 20 // Layout pixel buffer around the visible layer rect to record. Any base |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 (*pic)->CloneForDrawing(num_raster_threads_); | 107 (*pic)->CloneForDrawing(num_raster_threads_); |
106 } | 108 } |
107 } | 109 } |
108 } | 110 } |
109 | 111 |
110 UpdateRecordedRegion(); | 112 UpdateRecordedRegion(); |
111 } | 113 } |
112 | 114 |
113 class FullyContainedPredicate { | 115 class FullyContainedPredicate { |
114 public: | 116 public: |
115 FullyContainedPredicate(gfx::Rect rect) : layer_rect_(rect) {} | 117 explicit FullyContainedPredicate(gfx::Rect rect) : layer_rect_(rect) {} |
116 bool operator()(const scoped_refptr<Picture>& picture) { | 118 bool operator()(const scoped_refptr<Picture>& picture) { |
117 return layer_rect_.Contains(picture->LayerRect()); | 119 return layer_rect_.Contains(picture->LayerRect()); |
118 } | 120 } |
119 gfx::Rect layer_rect_; | 121 gfx::Rect layer_rect_; |
120 }; | 122 }; |
121 | 123 |
122 void PicturePile::InvalidateRect( | 124 void PicturePile::InvalidateRect( |
123 PictureList& picture_list, | 125 PictureList& picture_list, |
124 gfx::Rect invalidation) { | 126 gfx::Rect invalidation) { |
125 DCHECK(!picture_list.empty()); | 127 DCHECK(!picture_list.empty()); |
(...skipping 23 matching lines...) Expand all Loading... |
149 | 151 |
150 FullyContainedPredicate pred(picture_rect); | 152 FullyContainedPredicate pred(picture_rect); |
151 picture_list.erase(std::remove_if(picture_list.begin(), | 153 picture_list.erase(std::remove_if(picture_list.begin(), |
152 picture_list.end(), | 154 picture_list.end(), |
153 pred), | 155 pred), |
154 picture_list.end()); | 156 picture_list.end()); |
155 picture_list.push_back(Picture::Create(picture_rect)); | 157 picture_list.push_back(Picture::Create(picture_rect)); |
156 } | 158 } |
157 | 159 |
158 } // namespace cc | 160 } // namespace cc |
OLD | NEW |