OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "cc/quad_culler.h" | 26 #include "cc/quad_culler.h" |
27 #include "cc/render_pass_draw_quad.h" | 27 #include "cc/render_pass_draw_quad.h" |
28 #include "cc/rendering_stats.h" | 28 #include "cc/rendering_stats.h" |
29 #include "cc/scrollbar_animation_controller.h" | 29 #include "cc/scrollbar_animation_controller.h" |
30 #include "cc/scrollbar_layer_impl.h" | 30 #include "cc/scrollbar_layer_impl.h" |
31 #include "cc/shared_quad_state.h" | 31 #include "cc/shared_quad_state.h" |
32 #include "cc/single_thread_proxy.h" | 32 #include "cc/single_thread_proxy.h" |
33 #include "cc/software_renderer.h" | 33 #include "cc/software_renderer.h" |
34 #include "cc/solid_color_draw_quad.h" | 34 #include "cc/solid_color_draw_quad.h" |
35 #include "cc/texture_uploader.h" | 35 #include "cc/texture_uploader.h" |
| 36 #include "cc/util.h" |
36 #include "ui/gfx/size_conversions.h" | 37 #include "ui/gfx/size_conversions.h" |
37 #include "ui/gfx/vector2d_conversions.h" | 38 #include "ui/gfx/vector2d_conversions.h" |
38 | 39 |
39 namespace { | 40 namespace { |
40 | 41 |
41 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) | 42 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) |
42 { | 43 { |
43 if (visible) { | 44 if (visible) { |
44 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id,
"LayerTreeHostImpl", id); | 45 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id,
"LayerTreeHostImpl", id); |
45 return; | 46 return; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 PriorityCalculator::allowNothingCutoff()) | 217 PriorityCalculator::allowNothingCutoff()) |
217 , m_backgroundColor(0) | 218 , m_backgroundColor(0) |
218 , m_hasTransparentBackground(false) | 219 , m_hasTransparentBackground(false) |
219 , m_pinchGestureActive(false) | 220 , m_pinchGestureActive(false) |
220 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) | 221 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) |
221 , m_debugRectHistory(DebugRectHistory::create()) | 222 , m_debugRectHistory(DebugRectHistory::create()) |
222 , m_numImplThreadScrolls(0) | 223 , m_numImplThreadScrolls(0) |
223 , m_numMainThreadScrolls(0) | 224 , m_numMainThreadScrolls(0) |
224 , m_cumulativeNumLayersDrawn(0) | 225 , m_cumulativeNumLayersDrawn(0) |
225 , m_cumulativeNumMissingTiles(0) | 226 , m_cumulativeNumMissingTiles(0) |
| 227 , m_lastSentMemoryVisibleBytes(0) |
| 228 , m_lastSentMemoryVisibleAndNearbyBytes(0) |
| 229 , m_lastSentMemoryUseBytes(0) |
226 { | 230 { |
227 DCHECK(m_proxy->isImplThread()); | 231 DCHECK(m_proxy->isImplThread()); |
228 didVisibilityChange(this, m_visible); | 232 didVisibilityChange(this, m_visible); |
229 | 233 |
230 // TODO(nduca): For now, assume we have an active tree. This will be removed | 234 // TODO(nduca): For now, assume we have an active tree. This will be removed |
231 // in future patches. | 235 // in future patches. |
232 m_activeTree = LayerTreeImpl::create(this); | 236 m_activeTree = LayerTreeImpl::create(this); |
233 } | 237 } |
234 | 238 |
235 LayerTreeHostImpl::~LayerTreeHostImpl() | 239 LayerTreeHostImpl::~LayerTreeHostImpl() |
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); | 1581 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); |
1578 stats->numImplThreadScrolls = m_numImplThreadScrolls; | 1582 stats->numImplThreadScrolls = m_numImplThreadScrolls; |
1579 stats->numMainThreadScrolls = m_numMainThreadScrolls; | 1583 stats->numMainThreadScrolls = m_numMainThreadScrolls; |
1580 stats->numLayersDrawn = m_cumulativeNumLayersDrawn; | 1584 stats->numLayersDrawn = m_cumulativeNumLayersDrawn; |
1581 stats->numMissingTiles = m_cumulativeNumMissingTiles; | 1585 stats->numMissingTiles = m_cumulativeNumMissingTiles; |
1582 | 1586 |
1583 if (m_tileManager) | 1587 if (m_tileManager) |
1584 m_tileManager->renderingStats(stats); | 1588 m_tileManager->renderingStats(stats); |
1585 } | 1589 } |
1586 | 1590 |
| 1591 void LayerTreeHostImpl::sendManagedMemoryStats( |
| 1592 size_t memoryVisibleBytes, |
| 1593 size_t memoryVisibleAndNearbyBytes, |
| 1594 size_t memoryUseBytes) |
| 1595 { |
| 1596 if (!renderer()) |
| 1597 return; |
| 1598 |
| 1599 // Round the numbers being sent up to the next 8MB, to throttle the rate |
| 1600 // at which we spam the GPU process. |
| 1601 static const size_t roundingStep = 8 * 1024 * 1024; |
| 1602 memoryVisibleBytes = RoundUp(memoryVisibleBytes, roundingStep); |
| 1603 memoryVisibleAndNearbyBytes = RoundUp(memoryVisibleAndNearbyBytes, roundingS
tep); |
| 1604 memoryUseBytes = RoundUp(memoryUseBytes, roundingStep); |
| 1605 if (m_lastSentMemoryVisibleBytes == memoryVisibleBytes && |
| 1606 m_lastSentMemoryVisibleAndNearbyBytes == memoryVisibleAndNearbyBytes && |
| 1607 m_lastSentMemoryUseBytes == memoryUseBytes) { |
| 1608 return; |
| 1609 } |
| 1610 m_lastSentMemoryVisibleBytes = memoryVisibleBytes; |
| 1611 m_lastSentMemoryVisibleAndNearbyBytes = memoryVisibleAndNearbyBytes; |
| 1612 m_lastSentMemoryUseBytes = memoryUseBytes; |
| 1613 |
| 1614 renderer()->sendManagedMemoryStats(m_lastSentMemoryVisibleBytes, |
| 1615 m_lastSentMemoryVisibleAndNearbyBytes, |
| 1616 m_lastSentMemoryUseBytes); |
| 1617 } |
| 1618 |
1587 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) | 1619 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) |
1588 { | 1620 { |
1589 animateScrollbarsRecursive(rootLayer(), time); | 1621 animateScrollbarsRecursive(rootLayer(), time); |
1590 } | 1622 } |
1591 | 1623 |
1592 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT
icks time) | 1624 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT
icks time) |
1593 { | 1625 { |
1594 if (!layer) | 1626 if (!layer) |
1595 return; | 1627 return; |
1596 | 1628 |
(...skipping 23 matching lines...) Expand all Loading... |
1620 | 1652 |
1621 void LayerTreeHostImpl::UnregisterAnimationController(LayerAnimationController*
controller) { | 1653 void LayerTreeHostImpl::UnregisterAnimationController(LayerAnimationController*
controller) { |
1622 #if !defined(NDEBUG) | 1654 #if !defined(NDEBUG) |
1623 if (ContainsKey(m_allAnimationControllers, controller)) | 1655 if (ContainsKey(m_allAnimationControllers, controller)) |
1624 m_allAnimationControllers.erase(controller); | 1656 m_allAnimationControllers.erase(controller); |
1625 #endif | 1657 #endif |
1626 DidDeactivateAnimationController(controller); | 1658 DidDeactivateAnimationController(controller); |
1627 } | 1659 } |
1628 | 1660 |
1629 } // namespace cc | 1661 } // namespace cc |
OLD | NEW |