| 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/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/debug/traced_value.h" |
| 12 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 15 #include "cc/debug/devtools_instrumentation.h" | 16 #include "cc/debug/devtools_instrumentation.h" |
| 16 #include "cc/debug/frame_viewer_instrumentation.h" | 17 #include "cc/debug/frame_viewer_instrumentation.h" |
| 17 #include "cc/debug/traced_value.h" | |
| 18 #include "cc/layers/picture_layer_impl.h" | 18 #include "cc/layers/picture_layer_impl.h" |
| 19 #include "cc/resources/raster_worker_pool.h" | 19 #include "cc/resources/raster_worker_pool.h" |
| 20 #include "cc/resources/rasterizer_delegate.h" | 20 #include "cc/resources/rasterizer_delegate.h" |
| 21 #include "cc/resources/tile.h" | 21 #include "cc/resources/tile.h" |
| 22 #include "skia/ext/paint_simplifier.h" | 22 #include "skia/ext/paint_simplifier.h" |
| 23 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
| 24 #include "third_party/skia/include/core/SkPixelRef.h" | 24 #include "third_party/skia/include/core/SkPixelRef.h" |
| 25 #include "ui/gfx/rect_conversions.h" | 25 #include "ui/gfx/rect_conversions.h" |
| 26 | 26 |
| 27 namespace cc { | 27 namespace cc { |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 | 703 |
| 704 UpdatePrioritizedTileSetIfNeeded(); | 704 UpdatePrioritizedTileSetIfNeeded(); |
| 705 | 705 |
| 706 TileVector tiles_that_need_to_be_rasterized; | 706 TileVector tiles_that_need_to_be_rasterized; |
| 707 AssignGpuMemoryToTiles(&prioritized_tiles_, | 707 AssignGpuMemoryToTiles(&prioritized_tiles_, |
| 708 &tiles_that_need_to_be_rasterized); | 708 &tiles_that_need_to_be_rasterized); |
| 709 | 709 |
| 710 // Finally, schedule rasterizer tasks. | 710 // Finally, schedule rasterizer tasks. |
| 711 ScheduleTasks(tiles_that_need_to_be_rasterized); | 711 ScheduleTasks(tiles_that_need_to_be_rasterized); |
| 712 | 712 |
| 713 TRACE_EVENT_INSTANT1("cc", | 713 TRACE_EVENT_INSTANT1( |
| 714 "DidManage", | 714 "cc", |
| 715 TRACE_EVENT_SCOPE_THREAD, | 715 "DidManage", |
| 716 "state", | 716 TRACE_EVENT_SCOPE_THREAD, |
| 717 TracedValue::FromValue(BasicStateAsValue().release())); | 717 "state", |
| 718 base::debug::TracedValue::FromValue(BasicStateAsValue().release())); |
| 718 | 719 |
| 719 TRACE_COUNTER_ID1("cc", | 720 TRACE_COUNTER_ID1("cc", |
| 720 "unused_memory_bytes", | 721 "unused_memory_bytes", |
| 721 this, | 722 this, |
| 722 resource_pool_->total_memory_usage_bytes() - | 723 resource_pool_->total_memory_usage_bytes() - |
| 723 resource_pool_->acquired_memory_usage_bytes()); | 724 resource_pool_->acquired_memory_usage_bytes()); |
| 724 } | 725 } |
| 725 | 726 |
| 726 bool TileManager::UpdateVisibleTiles() { | 727 bool TileManager::UpdateVisibleTiles() { |
| 727 TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles"); | 728 TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles"); |
| 728 | 729 |
| 729 rasterizer_delegate_->CheckForCompletedTasks(); | 730 rasterizer_delegate_->CheckForCompletedTasks(); |
| 730 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 731 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 731 | 732 |
| 732 TRACE_EVENT_INSTANT1( | 733 TRACE_EVENT_INSTANT1("cc", |
| 733 "cc", | 734 "DidUpdateVisibleTiles", |
| 734 "DidUpdateVisibleTiles", | 735 TRACE_EVENT_SCOPE_THREAD, |
| 735 TRACE_EVENT_SCOPE_THREAD, | 736 "stats", |
| 736 "stats", | 737 base::debug::TracedValue::FromValue( |
| 737 TracedValue::FromValue(RasterTaskCompletionStatsAsValue( | 738 RasterTaskCompletionStatsAsValue( |
| 738 update_visible_tiles_stats_).release())); | 739 update_visible_tiles_stats_).release())); |
| 739 update_visible_tiles_stats_ = RasterTaskCompletionStats(); | 740 update_visible_tiles_stats_ = RasterTaskCompletionStats(); |
| 740 | 741 |
| 741 bool did_initialize_visible_tile = did_initialize_visible_tile_; | 742 bool did_initialize_visible_tile = did_initialize_visible_tile_; |
| 742 did_initialize_visible_tile_ = false; | 743 did_initialize_visible_tile_ = false; |
| 743 return did_initialize_visible_tile; | 744 return did_initialize_visible_tile; |
| 744 } | 745 } |
| 745 | 746 |
| 746 void TileManager::GetMemoryStats(size_t* memory_required_bytes, | 747 void TileManager::GetMemoryStats(size_t* memory_required_bytes, |
| 747 size_t* memory_nice_to_have_bytes, | 748 size_t* memory_nice_to_have_bytes, |
| 748 size_t* memory_allocated_bytes, | 749 size_t* memory_allocated_bytes, |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 | 1627 |
| 1627 if (b_priority.resolution != a_priority.resolution) { | 1628 if (b_priority.resolution != a_priority.resolution) { |
| 1628 return (prioritize_low_res && b_priority.resolution == LOW_RESOLUTION) || | 1629 return (prioritize_low_res && b_priority.resolution == LOW_RESOLUTION) || |
| 1629 (!prioritize_low_res && b_priority.resolution == HIGH_RESOLUTION) || | 1630 (!prioritize_low_res && b_priority.resolution == HIGH_RESOLUTION) || |
| 1630 (a_priority.resolution == NON_IDEAL_RESOLUTION); | 1631 (a_priority.resolution == NON_IDEAL_RESOLUTION); |
| 1631 } | 1632 } |
| 1632 return a_priority.IsHigherPriorityThan(b_priority); | 1633 return a_priority.IsHigherPriorityThan(b_priority); |
| 1633 } | 1634 } |
| 1634 | 1635 |
| 1635 } // namespace cc | 1636 } // namespace cc |
| OLD | NEW |