Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 #include "cc/quad_culler.h" | 25 #include "cc/quad_culler.h" |
| 26 #include "cc/render_pass_draw_quad.h" | 26 #include "cc/render_pass_draw_quad.h" |
| 27 #include "cc/rendering_stats.h" | 27 #include "cc/rendering_stats.h" |
| 28 #include "cc/scrollbar_animation_controller.h" | 28 #include "cc/scrollbar_animation_controller.h" |
| 29 #include "cc/scrollbar_layer_impl.h" | 29 #include "cc/scrollbar_layer_impl.h" |
| 30 #include "cc/shared_quad_state.h" | 30 #include "cc/shared_quad_state.h" |
| 31 #include "cc/single_thread_proxy.h" | 31 #include "cc/single_thread_proxy.h" |
| 32 #include "cc/software_renderer.h" | 32 #include "cc/software_renderer.h" |
| 33 #include "cc/solid_color_draw_quad.h" | 33 #include "cc/solid_color_draw_quad.h" |
| 34 #include "cc/texture_uploader.h" | 34 #include "cc/texture_uploader.h" |
| 35 #include "cc/util.h" | |
| 35 #include "ui/gfx/size_conversions.h" | 36 #include "ui/gfx/size_conversions.h" |
| 36 #include "ui/gfx/vector2d_conversions.h" | 37 #include "ui/gfx/vector2d_conversions.h" |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) | 41 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) |
| 41 { | 42 { |
| 42 if (visible) { | 43 if (visible) { |
| 43 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id, "LayerTreeHostImpl", id); | 44 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id, "LayerTreeHostImpl", id); |
| 44 return; | 45 return; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 PriorityCalculator::allowNothingCutoff()) | 221 PriorityCalculator::allowNothingCutoff()) |
| 221 , m_backgroundColor(0) | 222 , m_backgroundColor(0) |
| 222 , m_hasTransparentBackground(false) | 223 , m_hasTransparentBackground(false) |
| 223 , m_needsAnimateLayers(false) | 224 , m_needsAnimateLayers(false) |
| 224 , m_pinchGestureActive(false) | 225 , m_pinchGestureActive(false) |
| 225 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) | 226 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) |
| 226 , m_debugRectHistory(DebugRectHistory::create()) | 227 , m_debugRectHistory(DebugRectHistory::create()) |
| 227 , m_numImplThreadScrolls(0) | 228 , m_numImplThreadScrolls(0) |
| 228 , m_numMainThreadScrolls(0) | 229 , m_numMainThreadScrolls(0) |
| 229 , m_cumulativeNumLayersDrawn(0) | 230 , m_cumulativeNumLayersDrawn(0) |
| 231 , m_lastSentMemoryVisibleBytes(0) | |
| 232 , m_lastSentMemoryVisibleAndNearbyBytes(0) | |
| 233 , m_lastSentMemoryUseBytes(0) | |
| 230 { | 234 { |
| 231 DCHECK(m_proxy->isImplThread()); | 235 DCHECK(m_proxy->isImplThread()); |
| 232 didVisibilityChange(this, m_visible); | 236 didVisibilityChange(this, m_visible); |
| 233 } | 237 } |
| 234 | 238 |
| 235 LayerTreeHostImpl::~LayerTreeHostImpl() | 239 LayerTreeHostImpl::~LayerTreeHostImpl() |
| 236 { | 240 { |
| 237 DCHECK(m_proxy->isImplThread()); | 241 DCHECK(m_proxy->isImplThread()); |
| 238 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 242 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
| 239 | 243 |
| (...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1612 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); | 1616 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); |
| 1613 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); | 1617 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); |
| 1614 stats->numImplThreadScrolls = m_numImplThreadScrolls; | 1618 stats->numImplThreadScrolls = m_numImplThreadScrolls; |
| 1615 stats->numMainThreadScrolls = m_numMainThreadScrolls; | 1619 stats->numMainThreadScrolls = m_numMainThreadScrolls; |
| 1616 stats->numLayersDrawn = m_cumulativeNumLayersDrawn; | 1620 stats->numLayersDrawn = m_cumulativeNumLayersDrawn; |
| 1617 | 1621 |
| 1618 if (m_tileManager) | 1622 if (m_tileManager) |
| 1619 m_tileManager->renderingStats(stats); | 1623 m_tileManager->renderingStats(stats); |
| 1620 } | 1624 } |
| 1621 | 1625 |
| 1626 void LayerTreeHostImpl::sendManagedMemoryStats( | |
| 1627 size_t memoryVisibleBytes, | |
| 1628 size_t memoryVisibleAndNearbyBytes, | |
| 1629 size_t memoryUseBytes) | |
| 1630 { | |
| 1631 if (!renderer()) | |
| 1632 return; | |
| 1633 | |
| 1634 // Round the numbers being sent up to the next 8MB, to throttle the rate | |
| 1635 // at which we spam the GPU process. | |
| 1636 const size_t roundingStep = 8 * 1024 * 1024; | |
|
jamesr
2012/12/07 23:19:12
nit: "static const ...", so you don't get another
ccameron
2012/12/08 00:21:15
Done.
| |
| 1637 memoryVisibleBytes = RoundUp(memoryVisibleBytes, roundingStep); | |
| 1638 memoryVisibleAndNearbyBytes = RoundUp(memoryVisibleAndNearbyBytes, roundingS tep); | |
| 1639 memoryUseBytes = RoundUp(memoryUseBytes, roundingStep); | |
| 1640 if (m_lastSentMemoryVisibleBytes == memoryVisibleBytes && | |
| 1641 m_lastSentMemoryVisibleAndNearbyBytes == memoryVisibleAndNearbyBytes && | |
| 1642 m_lastSentMemoryUseBytes == memoryUseBytes) { | |
| 1643 return; | |
| 1644 } | |
| 1645 m_lastSentMemoryVisibleBytes = memoryVisibleBytes; | |
| 1646 m_lastSentMemoryVisibleAndNearbyBytes = memoryVisibleAndNearbyBytes; | |
| 1647 m_lastSentMemoryUseBytes = memoryUseBytes; | |
| 1648 | |
| 1649 renderer()->sendManagedMemoryStats(m_lastSentMemoryVisibleBytes, | |
| 1650 m_lastSentMemoryVisibleAndNearbyBytes, | |
| 1651 m_lastSentMemoryUseBytes); | |
| 1652 } | |
| 1653 | |
| 1622 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) | 1654 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) |
| 1623 { | 1655 { |
| 1624 animateScrollbarsRecursive(m_rootLayerImpl.get(), time); | 1656 animateScrollbarsRecursive(m_rootLayerImpl.get(), time); |
| 1625 } | 1657 } |
| 1626 | 1658 |
| 1627 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT icks time) | 1659 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT icks time) |
| 1628 { | 1660 { |
| 1629 if (!layer) | 1661 if (!layer) |
| 1630 return; | 1662 return; |
| 1631 | 1663 |
| 1632 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); | 1664 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); |
| 1633 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1665 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1634 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1666 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
| 1635 m_client->setNeedsRedrawOnImplThread(); | 1667 m_client->setNeedsRedrawOnImplThread(); |
| 1636 | 1668 |
| 1637 for (size_t i = 0; i < layer->children().size(); ++i) | 1669 for (size_t i = 0; i < layer->children().size(); ++i) |
| 1638 animateScrollbarsRecursive(layer->children()[i], time); | 1670 animateScrollbarsRecursive(layer->children()[i], time); |
| 1639 } | 1671 } |
| 1640 | 1672 |
| 1641 } // namespace cc | 1673 } // namespace cc |
| OLD | NEW |