OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/playback/display_item_list.h" | 5 #include "cc/playback/display_item_list.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // operations. | 28 // operations. |
29 const int kOpCountThatIsOkToAnalyze = 10; | 29 const int kOpCountThatIsOkToAnalyze = 10; |
30 | 30 |
31 bool DisplayItemsTracingEnabled() { | 31 bool DisplayItemsTracingEnabled() { |
32 bool tracing_enabled; | 32 bool tracing_enabled; |
33 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 33 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
34 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items"), &tracing_enabled); | 34 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items"), &tracing_enabled); |
35 return tracing_enabled; | 35 return tracing_enabled; |
36 } | 36 } |
37 | 37 |
38 const int kDefaultNumDisplayItemsToReserve = 100; | 38 // 16 "typically sized items" is the same as this many large items: |
| 39 const int kDefaultNumDisplayItemsToReserve = |
| 40 8 * TypicalDisplayItemSize() / LargestDisplayItemSize() + 1; |
39 | 41 |
40 } // namespace | 42 } // namespace |
41 | 43 |
42 scoped_refptr<DisplayItemList> DisplayItemList::Create( | 44 scoped_refptr<DisplayItemList> DisplayItemList::Create( |
43 const gfx::Rect& layer_rect, | 45 const gfx::Rect& layer_rect, |
44 const DisplayItemListSettings& settings) { | 46 const DisplayItemListSettings& settings) { |
45 return make_scoped_refptr(new DisplayItemList( | 47 return make_scoped_refptr(new DisplayItemList( |
46 layer_rect, settings, | 48 layer_rect, settings, |
47 !settings.use_cached_picture || DisplayItemsTracingEnabled())); | 49 !settings.use_cached_picture || DisplayItemsTracingEnabled())); |
48 } | 50 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // entire picture on the canvas instead of parsing the skia operations. | 103 // entire picture on the canvas instead of parsing the skia operations. |
102 canvas->drawPicture(picture_.get()); | 104 canvas->drawPicture(picture_.get()); |
103 } | 105 } |
104 canvas->restore(); | 106 canvas->restore(); |
105 } | 107 } |
106 } | 108 } |
107 | 109 |
108 void DisplayItemList::ProcessAppendedItemsOnTheFly() { | 110 void DisplayItemList::ProcessAppendedItemsOnTheFly() { |
109 if (retain_individual_display_items_) | 111 if (retain_individual_display_items_) |
110 return; | 112 return; |
111 if (items_.size() >= kDefaultNumDisplayItemsToReserve) { | 113 if (items_.size() >= static_cast<size_t>(kDefaultNumDisplayItemsToReserve)) { |
112 ProcessAppendedItems(); | 114 ProcessAppendedItems(); |
113 // This function exists to keep the |items_| from growing indefinitely if | 115 // This function exists to keep the |items_| from growing indefinitely if |
114 // we're not going to store them anyway. So the items better be deleted | 116 // we're not going to store them anyway. So the items better be deleted |
115 // after |items_| grows too large and we process it. | 117 // after |items_| grows too large and we process it. |
116 DCHECK(items_.empty()); | 118 DCHECK(items_.empty()); |
117 } | 119 } |
118 } | 120 } |
119 | 121 |
120 void DisplayItemList::ProcessAppendedItems() { | 122 void DisplayItemList::ProcessAppendedItems() { |
121 #if DCHECK_IS_ON() | 123 #if DCHECK_IS_ON() |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 generator.canvas()->drawPicture(picture_.get()); | 288 generator.canvas()->drawPicture(picture_.get()); |
287 } | 289 } |
288 | 290 |
289 void DisplayItemList::GetDiscardableImagesInRect( | 291 void DisplayItemList::GetDiscardableImagesInRect( |
290 const gfx::Rect& rect, | 292 const gfx::Rect& rect, |
291 std::vector<PositionImage>* images) { | 293 std::vector<PositionImage>* images) { |
292 image_map_.GetDiscardableImagesInRect(rect, images); | 294 image_map_.GetDiscardableImagesInRect(rect, images); |
293 } | 295 } |
294 | 296 |
295 } // namespace cc | 297 } // namespace cc |
OLD | NEW |