| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "base/trace_event/trace_event_argument.h" | 14 #include "base/trace_event/trace_event_argument.h" |
| 15 #include "cc/base/math_util.h" | 15 #include "cc/base/math_util.h" |
| 16 #include "cc/debug/picture_debug_util.h" | 16 #include "cc/debug/picture_debug_util.h" |
| 17 #include "cc/debug/traced_display_item_list.h" | 17 #include "cc/debug/traced_display_item_list.h" |
| 18 #include "cc/debug/traced_value.h" | 18 #include "cc/debug/traced_value.h" |
| 19 #include "cc/playback/clip_display_item.h" |
| 20 #include "cc/playback/clip_path_display_item.h" |
| 21 #include "cc/playback/compositing_display_item.h" |
| 19 #include "cc/playback/display_item_list_settings.h" | 22 #include "cc/playback/display_item_list_settings.h" |
| 20 #include "cc/playback/display_item_proto_factory.h" | 23 #include "cc/playback/display_item_proto_factory.h" |
| 21 #include "cc/playback/drawing_display_item.h" | 24 #include "cc/playback/drawing_display_item.h" |
| 25 #include "cc/playback/filter_display_item.h" |
| 26 #include "cc/playback/float_clip_display_item.h" |
| 22 #include "cc/playback/largest_display_item.h" | 27 #include "cc/playback/largest_display_item.h" |
| 28 #include "cc/playback/transform_display_item.h" |
| 23 #include "cc/proto/display_item.pb.h" | 29 #include "cc/proto/display_item.pb.h" |
| 24 #include "cc/proto/gfx_conversions.h" | 30 #include "cc/proto/gfx_conversions.h" |
| 25 #include "third_party/skia/include/core/SkCanvas.h" | 31 #include "third_party/skia/include/core/SkCanvas.h" |
| 26 #include "third_party/skia/include/core/SkPictureRecorder.h" | 32 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 27 #include "third_party/skia/include/utils/SkPictureUtils.h" | 33 #include "third_party/skia/include/utils/SkPictureUtils.h" |
| 28 #include "ui/gfx/geometry/rect.h" | 34 #include "ui/gfx/geometry/rect.h" |
| 29 #include "ui/gfx/geometry/rect_conversions.h" | 35 #include "ui/gfx/geometry/rect_conversions.h" |
| 30 #include "ui/gfx/skia_util.h" | 36 #include "ui/gfx/skia_util.h" |
| 31 | 37 |
| 32 namespace cc { | 38 namespace cc { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // none of the items might individually trigger a veto even though they | 182 // none of the items might individually trigger a veto even though they |
| 177 // collectively have enough "bad" operations that a corresponding Picture | 183 // collectively have enough "bad" operations that a corresponding Picture |
| 178 // would get vetoed. See crbug.com/513016. | 184 // would get vetoed. See crbug.com/513016. |
| 179 return inputs_.all_items_are_suitable_for_gpu_rasterization; | 185 return inputs_.all_items_are_suitable_for_gpu_rasterization; |
| 180 } | 186 } |
| 181 | 187 |
| 182 int DisplayItemList::ApproximateOpCount() const { | 188 int DisplayItemList::ApproximateOpCount() const { |
| 183 return approximate_op_count_; | 189 return approximate_op_count_; |
| 184 } | 190 } |
| 185 | 191 |
| 186 DISABLE_CFI_PERF | |
| 187 size_t DisplayItemList::ApproximateMemoryUsage() const { | 192 size_t DisplayItemList::ApproximateMemoryUsage() const { |
| 188 size_t memory_usage = sizeof(*this); | 193 size_t memory_usage = sizeof(*this); |
| 189 | 194 |
| 190 size_t external_memory_usage = 0; | 195 size_t external_memory_usage = 0; |
| 191 // Warning: this double-counts SkPicture data if use_cached_picture is | 196 // Warning: this double-counts SkPicture data if use_cached_picture is |
| 192 // also true. | 197 // also true. |
| 193 for (const auto& item : inputs_.items) { | 198 for (const auto& item : inputs_.items) { |
| 194 external_memory_usage += item.ExternalMemoryUsage(); | 199 size_t bytes = 0; |
| 200 switch (item.type()) { |
| 201 case DisplayItem::CLIP: |
| 202 bytes = static_cast<const ClipDisplayItem&>(item).ExternalMemoryUsage(); |
| 203 break; |
| 204 case DisplayItem::CLIP_PATH: |
| 205 bytes = |
| 206 static_cast<const ClipPathDisplayItem&>(item).ExternalMemoryUsage(); |
| 207 break; |
| 208 case DisplayItem::COMPOSITING: |
| 209 bytes = static_cast<const CompositingDisplayItem&>(item) |
| 210 .ExternalMemoryUsage(); |
| 211 break; |
| 212 case DisplayItem::DRAWING: |
| 213 bytes = |
| 214 static_cast<const DrawingDisplayItem&>(item).ExternalMemoryUsage(); |
| 215 break; |
| 216 case DisplayItem::FLOAT_CLIP: |
| 217 bytes = static_cast<const FloatClipDisplayItem&>(item) |
| 218 .ExternalMemoryUsage(); |
| 219 break; |
| 220 case DisplayItem::FILTER: |
| 221 bytes = |
| 222 static_cast<const FilterDisplayItem&>(item).ExternalMemoryUsage(); |
| 223 break; |
| 224 case DisplayItem::TRANSFORM: |
| 225 bytes = static_cast<const TransformDisplayItem&>(item) |
| 226 .ExternalMemoryUsage(); |
| 227 break; |
| 228 case DisplayItem::END_CLIP: |
| 229 case DisplayItem::END_CLIP_PATH: |
| 230 case DisplayItem::END_COMPOSITING: |
| 231 case DisplayItem::END_FLOAT_CLIP: |
| 232 case DisplayItem::END_FILTER: |
| 233 case DisplayItem::END_TRANSFORM: |
| 234 break; |
| 235 } |
| 236 external_memory_usage += bytes; |
| 195 } | 237 } |
| 196 | 238 |
| 197 // Memory outside this class due to |items_|. | 239 // Memory outside this class due to |items_|. |
| 198 memory_usage += inputs_.items.GetCapacityInBytes() + external_memory_usage; | 240 memory_usage += inputs_.items.GetCapacityInBytes() + external_memory_usage; |
| 199 | 241 |
| 200 // TODO(jbroman): Does anything else owned by this class substantially | 242 // TODO(jbroman): Does anything else owned by this class substantially |
| 201 // contribute to memory usage? | 243 // contribute to memory usage? |
| 202 // TODO(vmpstr): Probably DiscardableImageMap is worth counting here. | 244 // TODO(vmpstr): Probably DiscardableImageMap is worth counting here. |
| 203 | 245 |
| 204 return memory_usage; | 246 return memory_usage; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 307 } |
| 266 | 308 |
| 267 void DisplayItemList::GetDiscardableImagesInRect( | 309 void DisplayItemList::GetDiscardableImagesInRect( |
| 268 const gfx::Rect& rect, | 310 const gfx::Rect& rect, |
| 269 const gfx::SizeF& raster_scales, | 311 const gfx::SizeF& raster_scales, |
| 270 std::vector<DrawImage>* images) { | 312 std::vector<DrawImage>* images) { |
| 271 image_map_.GetDiscardableImagesInRect(rect, raster_scales, images); | 313 image_map_.GetDiscardableImagesInRect(rect, raster_scales, images); |
| 272 } | 314 } |
| 273 | 315 |
| 274 } // namespace cc | 316 } // namespace cc |
| OLD | NEW |