| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 | 26 |
| 27 #include "cc/CCLayerTreeHostImpl.h" | 27 #include "cc/CCLayerTreeHostImpl.h" |
| 28 | 28 |
| 29 #include "Extensions3D.h" | 29 #include "Extensions3D.h" |
| 30 #include "LayerRendererChromium.h" | 30 #include "LayerRendererChromium.h" |
| 31 #include "TraceEvent.h" | 31 #include "TraceEvent.h" |
| 32 #include "TrackingTextureAllocator.h" |
| 32 #include "cc/CCActiveGestureAnimation.h" | 33 #include "cc/CCActiveGestureAnimation.h" |
| 33 #include "cc/CCDamageTracker.h" | 34 #include "cc/CCDamageTracker.h" |
| 34 #include "cc/CCDebugRectHistory.h" | 35 #include "cc/CCDebugRectHistory.h" |
| 35 #include "cc/CCDelayBasedTimeSource.h" | 36 #include "cc/CCDelayBasedTimeSource.h" |
| 36 #include "cc/CCDrawQuad.h" | 37 #include "cc/CCDrawQuad.h" |
| 37 #include "cc/CCFontAtlas.h" | 38 #include "cc/CCFontAtlas.h" |
| 38 #include "cc/CCFrameRateCounter.h" | 39 #include "cc/CCFrameRateCounter.h" |
| 39 #include "cc/CCGestureCurve.h" | 40 #include "cc/CCGestureCurve.h" |
| 40 #include "cc/CCHeadsUpDisplay.h" | 41 #include "cc/CCHeadsUpDisplay.h" |
| 41 #include "cc/CCLayerIterator.h" | 42 #include "cc/CCLayerIterator.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCLayerTreeSettings& settings, CC
LayerTreeHostImplClient* client) | 116 CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCLayerTreeSettings& settings, CC
LayerTreeHostImplClient* client) |
| 116 : m_client(client) | 117 : m_client(client) |
| 117 , m_sourceFrameNumber(-1) | 118 , m_sourceFrameNumber(-1) |
| 118 , m_frameNumber(0) | 119 , m_frameNumber(0) |
| 119 , m_rootScrollLayerImpl(0) | 120 , m_rootScrollLayerImpl(0) |
| 120 , m_currentlyScrollingLayerImpl(0) | 121 , m_currentlyScrollingLayerImpl(0) |
| 121 , m_scrollingLayerIdFromPreviousTree(-1) | 122 , m_scrollingLayerIdFromPreviousTree(-1) |
| 122 , m_settings(settings) | 123 , m_settings(settings) |
| 123 , m_deviceScaleFactor(1) | 124 , m_deviceScaleFactor(1) |
| 124 , m_visible(true) | 125 , m_visible(true) |
| 125 , m_sourceFrameCanBeDrawn(true) | 126 , m_contentsTexturesWerePurgedSinceLastCommit(false) |
| 127 , m_memoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize()
)) |
| 126 , m_headsUpDisplay(CCHeadsUpDisplay::create()) | 128 , m_headsUpDisplay(CCHeadsUpDisplay::create()) |
| 127 , m_pageScale(1) | 129 , m_pageScale(1) |
| 128 , m_pageScaleDelta(1) | 130 , m_pageScaleDelta(1) |
| 129 , m_sentPageScaleDelta(1) | 131 , m_sentPageScaleDelta(1) |
| 130 , m_minPageScale(0) | 132 , m_minPageScale(0) |
| 131 , m_maxPageScale(0) | 133 , m_maxPageScale(0) |
| 132 , m_hasTransparentBackground(false) | 134 , m_hasTransparentBackground(false) |
| 133 , m_needsAnimateLayers(false) | 135 , m_needsAnimateLayers(false) |
| 134 , m_pinchGestureActive(false) | 136 , m_pinchGestureActive(false) |
| 135 , m_fpsCounter(CCFrameRateCounter::create()) | 137 , m_fpsCounter(CCFrameRateCounter::create()) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 150 | 152 |
| 151 void CCLayerTreeHostImpl::beginCommit() | 153 void CCLayerTreeHostImpl::beginCommit() |
| 152 { | 154 { |
| 153 } | 155 } |
| 154 | 156 |
| 155 void CCLayerTreeHostImpl::commitComplete() | 157 void CCLayerTreeHostImpl::commitComplete() |
| 156 { | 158 { |
| 157 // Recompute max scroll position; must be after layer content bounds are | 159 // Recompute max scroll position; must be after layer content bounds are |
| 158 // updated. | 160 // updated. |
| 159 updateMaxScrollPosition(); | 161 updateMaxScrollPosition(); |
| 162 m_contentsTexturesWerePurgedSinceLastCommit = false; |
| 160 } | 163 } |
| 161 | 164 |
| 162 bool CCLayerTreeHostImpl::canDraw() | 165 bool CCLayerTreeHostImpl::canDraw() |
| 163 { | 166 { |
| 164 if (!m_rootLayerImpl) | 167 if (!m_rootLayerImpl) |
| 165 return false; | 168 return false; |
| 166 if (viewportSize().isEmpty()) | 169 if (viewportSize().isEmpty()) |
| 167 return false; | 170 return false; |
| 168 if (!m_layerRenderer) | 171 if (!m_layerRenderer) |
| 169 return false; | 172 return false; |
| 170 if (!m_sourceFrameCanBeDrawn) | 173 if (m_contentsTexturesWerePurgedSinceLastCommit) |
| 171 return false; | 174 return false; |
| 172 return true; | 175 return true; |
| 173 } | 176 } |
| 174 | 177 |
| 175 CCGraphicsContext* CCLayerTreeHostImpl::context() | 178 CCGraphicsContext* CCLayerTreeHostImpl::context() const |
| 176 { | 179 { |
| 177 return m_context.get(); | 180 return m_context.get(); |
| 178 } | 181 } |
| 179 | 182 |
| 180 void CCLayerTreeHostImpl::animate(double monotonicTime, double wallClockTime) | 183 void CCLayerTreeHostImpl::animate(double monotonicTime, double wallClockTime) |
| 181 { | 184 { |
| 182 animatePageScale(monotonicTime); | 185 animatePageScale(monotonicTime); |
| 183 animateLayers(monotonicTime, wallClockTime); | 186 animateLayers(monotonicTime, wallClockTime); |
| 184 animateGestures(monotonicTime); | 187 animateGestures(monotonicTime); |
| 185 } | 188 } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 frame.renderSurfaceLayerList->clear(); | 398 frame.renderSurfaceLayerList->clear(); |
| 396 frame.willDrawLayers.clear(); | 399 frame.willDrawLayers.clear(); |
| 397 | 400 |
| 398 if (!calculateRenderPasses(frame.renderPasses, *frame.renderSurfaceLayerList
, frame.willDrawLayers)) | 401 if (!calculateRenderPasses(frame.renderPasses, *frame.renderSurfaceLayerList
, frame.willDrawLayers)) |
| 399 return false; | 402 return false; |
| 400 | 403 |
| 401 // If we return true, then we expect drawLayers() to be called before this f
unction is called again. | 404 // If we return true, then we expect drawLayers() to be called before this f
unction is called again. |
| 402 return true; | 405 return true; |
| 403 } | 406 } |
| 404 | 407 |
| 405 void CCLayerTreeHostImpl::setContentsMemoryAllocationLimitBytes(size_t bytes) | 408 void CCLayerTreeHostImpl::releaseContentsTextures() |
| 406 { | 409 { |
| 407 m_client->postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThread(
bytes); | 410 contentsTextureAllocator()->deleteAllTextures(); |
| 411 m_contentsTexturesWerePurgedSinceLastCommit = true; |
| 412 } |
| 413 |
| 414 void CCLayerTreeHostImpl::setMemoryAllocationLimitBytes(size_t bytes) |
| 415 { |
| 416 if (m_memoryAllocationLimitBytes == bytes) |
| 417 return; |
| 418 m_memoryAllocationLimitBytes = bytes; |
| 419 |
| 420 ASSERT(bytes); |
| 421 m_client->setNeedsCommitOnImplThread(); |
| 408 } | 422 } |
| 409 | 423 |
| 410 void CCLayerTreeHostImpl::drawLayers(const FrameData& frame) | 424 void CCLayerTreeHostImpl::drawLayers(const FrameData& frame) |
| 411 { | 425 { |
| 412 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::drawLayers"); | 426 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::drawLayers"); |
| 413 ASSERT(canDraw()); | 427 ASSERT(canDraw()); |
| 414 ASSERT(!frame.renderPasses.isEmpty()); | 428 ASSERT(!frame.renderPasses.isEmpty()); |
| 415 | 429 |
| 416 // FIXME: use the frame begin time from the overall compositor scheduler. | 430 // FIXME: use the frame begin time from the overall compositor scheduler. |
| 417 // This value is currently inaccessible because it is up in Chromium's | 431 // This value is currently inaccessible because it is up in Chromium's |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 return; | 1084 return; |
| 1071 | 1085 |
| 1072 bool isContinuing = m_activeGestureAnimation->animate(monotonicTime); | 1086 bool isContinuing = m_activeGestureAnimation->animate(monotonicTime); |
| 1073 if (isContinuing) | 1087 if (isContinuing) |
| 1074 m_client->setNeedsRedrawOnImplThread(); | 1088 m_client->setNeedsRedrawOnImplThread(); |
| 1075 else | 1089 else |
| 1076 m_activeGestureAnimation.clear(); | 1090 m_activeGestureAnimation.clear(); |
| 1077 } | 1091 } |
| 1078 | 1092 |
| 1079 } // namespace WebCore | 1093 } // namespace WebCore |
| OLD | NEW |