Changeset 121076 in webkit
- Timestamp:
- Jun 22, 2012 4:57:43 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r121072 r121076 1 2012-06-22 James Robinson <jamesr@chromium.org> 2 3 [chromium] LayerRendererChromium is not getting visibility messages in single threaded compositing mode. 4 https://bugs.webkit.org/show_bug.cgi?id=89045 5 6 Reviewed by Adrienne Walker. 7 8 Based on patch by Michal Mocny <mmocny@google.com>. 9 10 Invariants: 11 12 1.) We never commit (paint, animate, any of it) when not visible on the main thread -except- for 13 compositeAndReadback, regardless of threaded vs non-threaded mode 14 2.) CCLayerTreeHost::m_contentsTextureManager's memory budget is only set by updateLayers() when we are going to 15 make a frame and is always set to a non-zero value 16 3.) Zero-sized allocations from the GPU process are always serviced immediately on the impl thread. Non-zero 17 allocations are met in the next frame, whenever we would produce that frame according to our usual frame 18 scheduling logic. 19 4.) The impl thread always knows the set of currently-allocated managed texture IDs and can delete them all 20 whenever it likes without needing the main thread to be responsive. 21 22 Details: 23 24 There are two main changes - tweaking how the contents texture manager's budget is handled and tweaking frame 25 scheduling for the !visible case. 26 27 The scheduling change is a bit more subtle but it unifies the single and multi threaded paths and is really 28 important. Except for compositeAndReadback (which I'll talk about below), we simply won't produce frames when 29 not visible. This already happens in the single threaded path thanks to render_widget so the only change is to 30 the threaded path. The difficulty here is we might post a beginFrame task from the impl thread and then get a 31 setVisible(false) call on the main thread before the beginFrame task runs. Since I'm making the setVisible() 32 call a blocking call from main thread -> impl thread, when the beginFrame task eventually does run on the main 33 thread we can know that the impl thread's notion of visibility is in sync with the main threads. Thus I'm 34 planning to simply abort the frame before doing any processing on the main thread. The scheduler will know if 35 it gets a beginFrameAborted and COMMIT_STATE_IDLE. 36 37 compositeAndReadback is special - this call currently does come in when we aren't visible (in single and 38 threaded mode) and we need to service it. In particular, we need to send a beginFrame over and have it 39 not be ignored on the main thread. For this I'm thinking of having the proxy keep track of whether it's 40 servicing a compositeAndReadback() and use that bit on the main thread to know to process the beginFrame 41 normally. On the impl side, we need a few changes. First, we have to allocate a default framebuffer 42 (ensureFramebufferCHROMIUM) even if we've dropped it previously and remember to discard it after the 43 readPixels(). Second, we have to provide a non-zero contents texture allocation on the beginFrame message, and 44 again remember to delete the textures after the readPixels(). Third, we have to know that the beginFrame is a 45 forced frame so when we get the beginFrameComplete we go ahead with the rest of the frame. For this, I think 46 I'll have to add ACTION_BEGIN_FORCED_FRAME and a corresponding COMMIT_STATE_FORCED_FRAME_IN_PROGRESS so the 47 scheduler can keep track of the magicness of this frame, and then add some logic after the readpixels call to 48 drop resources after the readback. It's probably a good time to stop swapping on readbacks too.... 49 50 The contents texture manager's budget is only relevant when we want to make a frame, so it's now passed in on 51 the updateLayers(). Since we only make frames when we are visible and we never have a zero allocation when 52 visible (thanks to the frame scheduling changes above), this value is always non-zero. The other thing the 53 texture manager needs to know about is if we've killed all of the underlying textures from the impl thread - 54 this bit is passed in by the proxy before the updateLayers() call. This means if we're running while visible 55 and the manager wants to decrease our budget to something other than zero, we'll get a new (non-zero) allocation 56 on the impl thread, schedule a frame, then when it's time to make the frame pass the new lower limit in to 57 updateLayers(), then have the contents texture manager evict down to our new limit and make a frame with the new 58 budget. When the commit completes we'll get notified on the impl thread of which textures the contents texture 59 manager decided to evict and issue the deleteTexture() calls on them. 60 61 The texture budget we pass in will be based on the most recent non-zero memory allocation we received from the 62 GPU memory manager, or some default value I'll pull out my ass if we haven't heard anything yet. On compositor 63 initialization, we can't afford to wait for a round-trip through the GPU process to get a budget for the first 64 frame. I don't think handling a decrease to a non-zero budget on a visible tab needs to be terribly urgent - we 65 can get to it when we get to making the next frame. If we wanted to satisfy reduced texture budgets directly 66 from the impl thread, we could keep a priority-list ordered set of textures once we have priorities and delete 67 based on that. Let's worry about that later. 68 69 * platform/graphics/chromium/LayerRendererChromium.cpp: 70 (WebCore::LayerRendererGpuMemoryAllocationChangedCallbackAdapter::onGpuMemoryAllocationChangedOnImpl): 71 (WebCore::LayerRendererChromium::LayerRendererChromium): 72 (WebCore::LayerRendererChromium::initialize): 73 (WebCore::LayerRendererChromium::setVisible): 74 (WebCore::LayerRendererChromium::setGpuMemoryAllocation): 75 (WebCore): 76 (WebCore::LayerRendererChromium::swapBuffers): 77 (WebCore::LayerRendererChromium::getFramebufferPixels): 78 * platform/graphics/chromium/LayerRendererChromium.h: 79 (WebCore): 80 (LayerRendererChromium): 81 * platform/graphics/chromium/TextureManager.cpp: 82 (WebCore::TextureManager::evictAndRemoveAllDeletedTextures): 83 (WebCore): 84 * platform/graphics/chromium/TextureManager.h: 85 (TextureAllocator): 86 (TextureManager): 87 * platform/graphics/chromium/TrackingTextureAllocator.cpp: 88 (WebCore::TrackingTextureAllocator::createTexture): 89 (WebCore::TrackingTextureAllocator::deleteTexture): 90 (WebCore): 91 (WebCore::TrackingTextureAllocator::deleteAllTextures): 92 * platform/graphics/chromium/TrackingTextureAllocator.h: 93 (TrackingTextureAllocator): 94 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: 95 (WebCore::CCLayerTreeHost::CCLayerTreeHost): 96 (WebCore::CCLayerTreeHost::initializeLayerRenderer): 97 (WebCore::CCLayerTreeHost::finishCommitOnImplThread): 98 (WebCore::CCLayerTreeHost::setVisible): 99 (WebCore::CCLayerTreeHost::evictAllContentTextures): 100 (WebCore::CCLayerTreeHost::updateLayers): 101 * platform/graphics/chromium/cc/CCLayerTreeHost.h: 102 (CCLayerTreeHost): 103 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: 104 (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl): 105 (WebCore::CCLayerTreeHostImpl::commitComplete): 106 (WebCore::CCLayerTreeHostImpl::canDraw): 107 (WebCore::CCLayerTreeHostImpl::context): 108 (WebCore::CCLayerTreeHostImpl::releaseContentsTextures): 109 (WebCore): 110 (WebCore::CCLayerTreeHostImpl::setMemoryAllocationLimitBytes): 111 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h: 112 (CCLayerTreeHostImplClient): 113 (WebCore::CCLayerTreeHostImpl::contentsTexturesWerePurgedSinceLastCommit): 114 (WebCore::CCLayerTreeHostImpl::memoryAllocationLimitBytes): 115 (CCLayerTreeHostImpl): 116 * platform/graphics/chromium/cc/CCProxy.h: 117 (CCProxy): 118 * platform/graphics/chromium/cc/CCRenderer.h: 119 (CCRendererClient): 120 * platform/graphics/chromium/cc/CCScheduler.cpp: 121 (WebCore::CCScheduler::beginFrameComplete): 122 (WebCore::CCScheduler::beginFrameAborted): 123 (WebCore): 124 (WebCore::CCScheduler::didSwapBuffersComplete): 125 (WebCore::CCScheduler::didLoseContext): 126 (WebCore::CCScheduler::didRecreateContext): 127 (WebCore::CCScheduler::vsyncTick): 128 * platform/graphics/chromium/cc/CCScheduler.h: 129 (CCScheduler): 130 * platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp: 131 (WebCore::CCSchedulerStateMachine::beginFrameAborted): 132 (WebCore): 133 * platform/graphics/chromium/cc/CCSchedulerStateMachine.h: 134 * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: 135 (WebCore::CCSingleThreadProxy::setVisible): 136 (WebCore): 137 (WebCore::CCSingleThreadProxy::stop): 138 (WebCore::CCSingleThreadProxy::commitAndComposite): 139 * platform/graphics/chromium/cc/CCSingleThreadProxy.h: 140 (CCSingleThreadProxy): 141 * platform/graphics/chromium/cc/CCThreadProxy.cpp: 142 (WebCore::CCThreadProxy::CCThreadProxy): 143 (WebCore::CCThreadProxy::compositeAndReadback): 144 (WebCore::CCThreadProxy::setVisible): 145 (WebCore): 146 (WebCore::CCThreadProxy::setVisibleOnImplThread): 147 (WebCore::CCThreadProxy::scheduledActionBeginFrame): 148 (WebCore::CCThreadProxy::beginFrame): 149 (WebCore::CCThreadProxy::beginFrameAbortedOnImplThread): 150 (WebCore::CCThreadProxy::scheduledActionDrawAndSwapInternal): 151 (WebCore::CCThreadProxy::layerTreeHostClosedOnImplThread): 152 * platform/graphics/chromium/cc/CCThreadProxy.h: 153 (CCThreadProxy): 154 (BeginFrameAndCommitState): 155 * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp: 156 (WebCore::CCVideoLayerImpl::~CCVideoLayerImpl): 157 (WebCore::CCVideoLayerImpl::willDraw): 158 (WebCore::CCVideoLayerImpl::willDrawInternal): 159 (WebCore::CCVideoLayerImpl::FramePlane::allocateData): 160 (WebCore::CCVideoLayerImpl::FramePlane::freeData): 161 (WebCore::CCVideoLayerImpl::allocatePlaneData): 162 (WebCore::CCVideoLayerImpl::freePlaneData): 163 (WebCore::CCVideoLayerImpl::freeUnusedPlaneData): 164 (WebCore::CCVideoLayerImpl::didLoseContext): 165 * platform/graphics/chromium/cc/CCVideoLayerImpl.h: 166 (FramePlane): 167 1 168 2012-06-22 Julien Chaffraix <jchaffraix@webkit.org> 2 169 -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r121005 r121076 36 36 37 37 #include "Extensions3D.h" 38 #include "Extensions3DChromium.h"39 38 #include "FloatQuad.h" 40 39 #include "GeometryBinding.h" … … 220 219 { 221 220 ASSERT(CCProxy::isImplThread()); 222 if (!allocation.suggestHaveBackbuffer) 223 m_layerRenderer->discardFramebuffer(); 224 else 225 m_layerRenderer->ensureFramebuffer(); 226 m_layerRenderer->m_client->setContentsMemoryAllocationLimitBytes(allocation.gpuResourceSizeInBytes); 221 m_layerRenderer->setGpuMemoryAllocation(allocation); 227 222 } 228 223 … … 252 247 , m_isViewportChanged(false) 253 248 , m_isFramebufferDiscarded(false) 249 , m_visible(true) 254 250 , m_textureUploaderSetting(textureUploaderSetting) 255 251 { … … 335 331 extensions3DChromium->setGpuMemoryAllocationChangedCallbackCHROMIUM(LayerRendererGpuMemoryAllocationChangedCallbackAdapter::create(this)); 336 332 } else { 337 m_client->set ContentsMemoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize()));333 m_client->setMemoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize())); 338 334 } 339 335 … … 376 372 void LayerRendererChromium::setVisible(bool visible) 377 373 { 378 if (!visible) 379 releaseRenderPassTextures(); 374 if (m_visible == visible) 375 return; 376 m_visible = visible; 380 377 381 378 // TODO: Replace setVisibilityCHROMIUM with an extension to explicitly manage front/backbuffers … … 1271 1268 } 1272 1269 1270 void LayerRendererChromium::setGpuMemoryAllocation(Extensions3DChromium::GpuMemoryAllocationCHROMIUM allocation) 1271 { 1272 if (m_visible && !allocation.gpuResourceSizeInBytes) 1273 return; 1274 1275 if (!allocation.suggestHaveBackbuffer && !m_visible) 1276 discardFramebuffer(); 1277 1278 if (!allocation.gpuResourceSizeInBytes) { 1279 releaseRenderPassTextures(); 1280 m_client->releaseContentsTextures(); 1281 GLC(m_context, m_context->flush()); 1282 } else 1283 m_client->setMemoryAllocationLimitBytes(allocation.gpuResourceSizeInBytes); 1284 } 1285 1273 1286 void LayerRendererChromium::finish() 1274 1287 { … … 1279 1292 bool LayerRendererChromium::swapBuffers(const IntRect& subBuffer) 1280 1293 { 1281 // FIXME: Remove this once gpu process supports ignoring swap buffers command while framebuffer is discarded. 1282 // Alternatively (preferably?), protect all cc code so as not to attempt a swap after a framebuffer discard. 1283 if (m_isFramebufferDiscarded) { 1284 m_client->setFullRootLayerDamage(); 1285 return false; 1286 } 1294 ASSERT(m_visible); 1295 ASSERT(!m_isFramebufferDiscarded); 1287 1296 1288 1297 TRACE_EVENT("LayerRendererChromium::swapBuffers", this, 0); … … 1387 1396 GLC(context, context->deleteFramebuffer(temporaryFBO)); 1388 1397 GLC(context, context->deleteTexture(temporaryTexture)); 1398 } 1399 1400 if (!m_visible) { 1401 TRACE_EVENT0("cc", "LayerRendererChromium::getFramebufferPixels dropping resources after readback"); 1402 discardFramebuffer(); 1403 releaseRenderPassTextures(); 1404 m_client->releaseContentsTextures(); 1405 GLC(m_context, m_context->flush()); 1389 1406 } 1390 1407 } -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r121005 r121076 35 35 #if USE(ACCELERATED_COMPOSITING) 36 36 37 #include "Extensions3DChromium.h" 37 38 #include "TextureCopier.h" 38 39 #include "TrackingTextureAllocator.h" … … 54 55 class GeometryBinding; 55 56 class GraphicsContext3D; 56 class LayerRendererGpuMemoryAllocationChangedCallbackAdapter;57 57 class LayerRendererSwapBuffersCompleteCallbackAdapter; 58 58 class ManagedTexture; … … 112 112 int matrixLocation, int alphaLocation, int quadLocation); 113 113 void copyTextureToFramebuffer(int textureId, const IntSize& bounds, const WebKit::WebTransformationMatrix& drawMatrix); 114 void setGpuMemoryAllocation(Extensions3DChromium::GpuMemoryAllocationCHROMIUM); 114 115 115 116 protected: 116 friend class LayerRendererGpuMemoryAllocationChangedCallbackAdapter;117 117 void discardFramebuffer(); 118 118 void ensureFramebuffer(); … … 259 259 bool m_isViewportChanged; 260 260 bool m_isFramebufferDiscarded; 261 bool m_visible; 261 262 TextureUploaderOption m_textureUploaderSetting; 262 263 }; -
trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp
r121005 r121076 243 243 } 244 244 245 void TextureManager::evictAndRemoveAllDeletedTextures() 246 { 247 unprotectAllTextures(); 248 reduceMemoryToLimit(0); 249 m_evictedTextures.clear(); 250 } 251 245 252 void TextureManager::evictAndDeleteAllTextures(TextureAllocator* allocator) 246 253 { -
trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h
r121005 r121076 45 45 virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0; 46 46 virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0; 47 virtual void deleteAllTextures() = 0; 47 48 48 49 protected: … … 89 90 void deleteEvictedTextures(TextureAllocator*); 90 91 92 void evictAndRemoveAllDeletedTextures(); 91 93 void evictAndDeleteAllTextures(TextureAllocator*); 92 94 -
trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp
r121005 r121076 90 90 } else 91 91 GLC(m_context.get(), m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE)); 92 m_allocatedTextureIds.add(textureId); 92 93 return textureId; 93 94 } … … 97 98 m_currentMemoryUseBytes -= TextureManager::memoryUseBytes(size, format); 98 99 GLC(m_context.get(), m_context->deleteTexture(textureId)); 100 ASSERT(m_allocatedTextureIds.contains(textureId)); 101 m_allocatedTextureIds.remove(textureId); 102 } 103 104 void TrackingTextureAllocator::deleteAllTextures() 105 { 106 for (HashSet<unsigned>::const_iterator it = m_allocatedTextureIds.begin(); it != m_allocatedTextureIds.end(); ++it) 107 GLC(m_context.get(), m_context->deleteTexture(*it)); 108 m_currentMemoryUseBytes = 0; 109 m_allocatedTextureIds.clear(); 99 110 } 100 111 -
trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h
r121005 r121076 28 28 #include "GraphicsContext3D.h" 29 29 #include "TextureManager.h" 30 #include <wtf/HashSet.h> 30 31 #include <wtf/PassRefPtr.h> 31 32 … … 41 42 virtual ~TrackingTextureAllocator(); 42 43 43 virtual unsigned createTexture(const IntSize&, GC3Denum format); 44 virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum format); 44 virtual unsigned createTexture(const IntSize&, GC3Denum format) OVERRIDE; 45 virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum format) OVERRIDE; 46 virtual void deleteAllTextures() OVERRIDE; 45 47 46 48 size_t currentMemoryUseBytes() const { return m_currentMemoryUseBytes; } … … 58 60 TextureUsageHint m_textureUsageHint; 59 61 bool m_useTextureStorageExt; 62 HashSet<unsigned> m_allocatedTextureIds; 60 63 }; 61 64 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r121069 r121076 74 74 , m_client(client) 75 75 , m_frameNumber(0) 76 , m_frameIsForDisplay(false)77 76 , m_layerRendererInitialized(false) 78 77 , m_contextLost(false) … … 82 81 , m_deviceScaleFactor(1) 83 82 , m_visible(true) 84 , m_memoryAllocationBytes(0)85 , m_memoryAllocationIsForDisplay(false)86 83 , m_pageScaleFactor(1) 87 84 , m_minPageScaleFactor(1) … … 152 149 153 150 m_contentsTextureManager = TextureManager::create(0, 0, m_proxy->layerRendererCapabilities().maxTextureSize); 154 155 // FIXME: This is the same as setContentsMemoryAllocationLimitBytes, but156 // we're in the middle of a commit here and don't want to force another.157 m_memoryAllocationBytes = TextureManager::highLimitBytes(deviceViewportSize());158 m_memoryAllocationIsForDisplay = true;159 151 160 152 m_layerRendererInitialized = true; … … 258 250 hostImpl->setBackgroundColor(m_backgroundColor); 259 251 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); 260 hostImpl->setVisible(m_visible);261 hostImpl->setSourceFrameCanBeDrawn(m_frameIsForDisplay);262 252 263 253 m_frameNumber++; … … 328 318 { 329 319 m_proxy->setNeedsCommit(); 330 }331 332 void CCLayerTreeHost::setNeedsForcedCommit()333 {334 m_proxy->setNeedsForcedCommit();335 320 } 336 321 … … 400 385 if (m_visible == visible) 401 386 return; 402 403 387 m_visible = visible; 404 405 // FIXME: Remove this stuff, it is here just for the m20 merge. 406 if (!m_visible && m_layerRendererInitialized) { 407 if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer) 408 setContentsMemoryAllocationLimitBytes(0); 409 else 410 setContentsMemoryAllocationLimitBytes(m_contentsTextureManager->preferredMemoryLimitBytes()); 411 } 412 413 setNeedsForcedCommit(); 414 } 415 416 void CCLayerTreeHost::setContentsMemoryAllocationLimitBytes(size_t bytes) 388 m_proxy->setVisible(visible); 389 } 390 391 void CCLayerTreeHost::evictAllContentTextures() 417 392 { 418 393 ASSERT(CCProxy::isMainThread()); 419 if (m_memoryAllocationBytes == bytes) 420 return; 421 422 m_memoryAllocationBytes = bytes; 423 m_memoryAllocationIsForDisplay = bytes; 424 425 // When not visible, force a commit so that we change our memory allocation 426 // and evict/delete any textures if we are being requested to. 427 if (!m_visible) 428 setNeedsForcedCommit(); 429 else 430 setNeedsCommit(); 394 ASSERT(m_contentsTextureManager.get()); 395 m_contentsTextureManager->evictAndRemoveAllDeletedTextures(); 431 396 } 432 397 … … 475 440 476 441 477 void CCLayerTreeHost::updateLayers(CCTextureUpdater& updater )442 void CCLayerTreeHost::updateLayers(CCTextureUpdater& updater, size_t contentsMemoryLimitBytes) 478 443 { 479 444 ASSERT(m_layerRendererInitialized); 480 // The visible state and memory allocation are set independently and in 481 // arbitrary order, so do not change the memory allocation used for the 482 // current commit until both values match intentions. 483 // FIXME: These two states should be combined into a single action so we 484 // need a single commit to change visible state, and this can be removed. 485 bool memoryAllocationStateMatchesVisibility = m_visible == m_memoryAllocationIsForDisplay; 486 if (memoryAllocationStateMatchesVisibility) { 487 m_contentsTextureManager->setMemoryAllocationLimitBytes(m_memoryAllocationBytes); 488 m_frameIsForDisplay = m_memoryAllocationIsForDisplay; 489 } 445 ASSERT(contentsMemoryLimitBytes); 490 446 491 447 if (!rootLayer()) … … 494 450 if (viewportSize().isEmpty()) 495 451 return; 452 453 m_contentsTextureManager->setMemoryAllocationLimitBytes(contentsMemoryLimitBytes); 496 454 497 455 updateLayers(rootLayer(), updater); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
r121069 r121076 172 172 // Returns false if we should abort this frame due to initialization failure. 173 173 bool initializeLayerRendererIfNeeded(); 174 void updateLayers(CCTextureUpdater& );174 void updateLayers(CCTextureUpdater&, size_t contentsMemoryLimitBytes); 175 175 176 176 CCLayerTreeHostClient* client() { return m_client; } … … 203 203 // virtual for testing 204 204 virtual void setNeedsCommit(); 205 void setNeedsForcedCommit();206 205 void setNeedsRedraw(); 207 206 bool commitRequested() const; … … 229 228 230 229 TextureManager* contentsTextureManager() const; 231 void setContentsMemoryAllocationLimitBytes(size_t); 230 231 // This will cause contents texture manager to evict all textures, but 232 // without deleting them. This happens after all content textures have 233 // already been deleted on impl, after getting a 0 allocation limit. 234 // Set during a commit, but before updateLayers. 235 void evictAllContentTextures(); 232 236 233 237 bool visible() const { return m_visible; } … … 282 286 283 287 int m_frameNumber; 284 bool m_frameIsForDisplay;285 288 286 289 OwnPtr<CCProxy> m_proxy; … … 301 304 bool m_visible; 302 305 303 size_t m_memoryAllocationBytes;304 bool m_memoryAllocationIsForDisplay;305 306 306 typedef HashMap<WebKit::WebGraphicsContext3D*, RefPtr<RateLimiter> > RateLimiterMap; 307 307 RateLimiterMap m_rateLimiters; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
r121069 r121076 30 30 #include "TextStream.h" 31 31 #include "TraceEvent.h" 32 #include "TrackingTextureAllocator.h" 32 33 #include "cc/CCActiveGestureAnimation.h" 33 34 #include "cc/CCDamageTracker.h" … … 121 122 , m_deviceScaleFactor(1) 122 123 , m_visible(true) 123 , m_sourceFrameCanBeDrawn(true) 124 , m_contentsTexturesWerePurgedSinceLastCommit(false) 125 , m_memoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize())) 124 126 , m_headsUpDisplay(CCHeadsUpDisplay::create()) 125 127 , m_pageScale(1) … … 156 158 // updated. 157 159 updateMaxScrollPosition(); 160 m_contentsTexturesWerePurgedSinceLastCommit = false; 158 161 } 159 162 … … 166 169 if (!m_layerRenderer) 167 170 return false; 168 if ( !m_sourceFrameCanBeDrawn)171 if (m_contentsTexturesWerePurgedSinceLastCommit) 169 172 return false; 170 173 return true; 171 174 } 172 175 173 CCGraphicsContext* CCLayerTreeHostImpl::context() 176 CCGraphicsContext* CCLayerTreeHostImpl::context() const 174 177 { 175 178 return m_context.get(); … … 468 471 } 469 472 470 void CCLayerTreeHostImpl::setContentsMemoryAllocationLimitBytes(size_t bytes) 471 { 472 m_client->postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThread(bytes); 473 void CCLayerTreeHostImpl::releaseContentsTextures() 474 { 475 contentsTextureAllocator()->deleteAllTextures(); 476 m_contentsTexturesWerePurgedSinceLastCommit = true; 477 } 478 479 void CCLayerTreeHostImpl::setMemoryAllocationLimitBytes(size_t bytes) 480 { 481 if (m_memoryAllocationLimitBytes == bytes) 482 return; 483 m_memoryAllocationLimitBytes = bytes; 484 485 ASSERT(bytes); 486 m_client->setNeedsCommitOnImplThread(); 473 487 } 474 488 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h
r121069 r121076 58 58 virtual void setNeedsCommitOnImplThread() = 0; 59 59 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) = 0; 60 virtual void postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThread(size_t) = 0;61 60 }; 62 61 … … 110 109 virtual void onSwapBuffersComplete() OVERRIDE; 111 110 virtual void setFullRootLayerDamage() OVERRIDE; 112 virtual void setContentsMemoryAllocationLimitBytes(size_t) OVERRIDE; 111 virtual void releaseContentsTextures() OVERRIDE; 112 virtual void setMemoryAllocationLimitBytes(size_t) OVERRIDE; 113 113 114 114 // Implementation 115 115 bool canDraw(); 116 CCGraphicsContext* context() ;116 CCGraphicsContext* context() const; 117 117 118 118 String layerTreeAsText() const; … … 147 147 void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumber; } 148 148 149 bool sourceFrameCanBeDrawn() const { return m_sourceFrameCanBeDrawn; }150 void setSourceFrameCanBeDrawn(bool sourceFrameCanBeDrawn) { m_sourceFrameCanBeDrawn = sourceFrameCanBeDrawn; }149 bool contentsTexturesWerePurgedSinceLastCommit() const { return m_contentsTexturesWerePurgedSinceLastCommit; } 150 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBytes; } 151 151 152 152 const IntSize& viewportSize() const { return m_viewportSize; } … … 236 236 float m_deviceScaleFactor; 237 237 bool m_visible; 238 bool m_sourceFrameCanBeDrawn; 238 bool m_contentsTexturesWerePurgedSinceLastCommit; 239 size_t m_memoryAllocationLimitBytes; 239 240 240 241 OwnPtr<CCHeadsUpDisplay> m_headsUpDisplay; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h
r121069 r121076 71 71 virtual void setSurfaceReady() = 0; 72 72 73 virtual void setVisible(bool) = 0; 74 73 75 // Attempts to initialize the layer renderer. Returns false if the context isn't usable for compositing. 74 76 virtual bool initializeLayerRenderer() = 0; … … 84 86 virtual void setNeedsAnimate() = 0; 85 87 virtual void setNeedsCommit() = 0; 86 virtual void setNeedsForcedCommit() = 0;87 88 virtual void setNeedsRedraw() = 0; 88 89 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderer.h
r121005 r121076 50 50 virtual void onSwapBuffersComplete() = 0; 51 51 virtual void setFullRootLayerDamage() = 0; 52 virtual void setContentsMemoryAllocationLimitBytes(size_t) = 0; 52 virtual void releaseContentsTextures() = 0; 53 virtual void setMemoryAllocationLimitBytes(size_t) = 0; 53 54 }; 54 55 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp
r121005 r121076 89 89 void CCScheduler::beginFrameComplete() 90 90 { 91 TRACE_EVENT ("CCScheduler::beginFrameComplete", this, 0);91 TRACE_EVENT0("cc", "CCScheduler::beginFrameComplete"); 92 92 m_stateMachine.beginFrameComplete(); 93 93 processScheduledActions(); 94 94 } 95 95 96 void CCScheduler::beginFrameAborted() 97 { 98 TRACE_EVENT0("cc", "CCScheduler::beginFrameAborted"); 99 m_stateMachine.beginFrameAborted(); 100 processScheduledActions(); 101 } 102 96 103 void CCScheduler::setMaxFramesPending(int maxFramesPending) 97 104 { … … 101 108 void CCScheduler::didSwapBuffersComplete() 102 109 { 103 TRACE_EVENT ("CCScheduler::didSwapBuffersComplete", this, 0);110 TRACE_EVENT0("cc", "CCScheduler::didSwapBuffersComplete"); 104 111 m_frameRateController->didFinishFrame(); 105 112 } … … 107 114 void CCScheduler::didLoseContext() 108 115 { 109 TRACE_EVENT ("CCScheduler::didLoseContext", this, 0);116 TRACE_EVENT0("cc", "CCScheduler::didLoseContext"); 110 117 m_frameRateController->didAbortAllPendingFrames(); 111 118 m_stateMachine.didLoseContext(); … … 115 122 void CCScheduler::didRecreateContext() 116 123 { 117 TRACE_EVENT ("CCScheduler::didRecreateContext", this, 0);124 TRACE_EVENT0("cc", "CCScheduler::didRecreateContext"); 118 125 m_stateMachine.didRecreateContext(); 119 126 processScheduledActions(); … … 126 133 m_stateMachine.beginUpdateMoreResourcesComplete(m_client->hasMoreResourceUpdates()); 127 134 } 128 TRACE_EVENT ("CCScheduler::vsyncTick", this, 0);135 TRACE_EVENT0("cc", "CCScheduler::vsyncTick"); 129 136 130 137 m_stateMachine.didEnterVSync(); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h
r121005 r121076 95 95 96 96 void beginFrameComplete(); 97 void beginFrameAborted(); 97 98 98 99 void setMaxFramesPending(int); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp
r121005 r121076 27 27 #include "cc/CCSchedulerStateMachine.h" 28 28 29 #include <stdio.h> 30 29 31 namespace WebCore { 30 32 … … 300 302 } 301 303 304 void CCSchedulerStateMachine::beginFrameAborted() 305 { 306 ASSERT(m_commitState == COMMIT_STATE_FRAME_IN_PROGRESS); 307 m_commitState = COMMIT_STATE_IDLE; 308 } 309 302 310 void CCSchedulerStateMachine::beginUpdateMoreResourcesComplete(bool morePending) 303 311 { -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h
r121005 r121076 121 121 void beginFrameComplete(); 122 122 123 // Call this only in response to receiving an ACTION_BEGIN_FRAME 124 // from nextState if the client rejects the beginFrame message. 125 void beginFrameAborted(); 126 123 127 // Call this only in response to receiving an ACTION_UPDATE_MORE_RESOURCES 124 128 // from nextState. Indicates that the specific update request completed. -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp
r121069 r121076 154 154 } 155 155 156 void CCSingleThreadProxy::setVisible(bool visible) 157 { 158 DebugScopedSetImplThread impl; 159 m_layerTreeHostImpl->setVisible(visible); 160 } 161 156 162 bool CCSingleThreadProxy::initializeLayerRenderer() 157 163 { … … 259 265 } 260 266 261 void CCSingleThreadProxy::setNeedsForcedCommit()262 {263 // This proxy doesn't block commits when not visible so use a normal commit.264 setNeedsCommit();265 }266 267 267 void CCSingleThreadProxy::setNeedsRedraw() 268 268 { … … 291 291 DebugScopedSetImplThread impl; 292 292 293 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator()); 293 if (!m_layerTreeHostImpl->contentsTexturesWerePurgedSinceLastCommit()) 294 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator()); 294 295 m_layerTreeHostImpl.clear(); 295 296 } … … 311 312 } 312 313 313 void CCSingleThreadProxy::postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThread(size_t bytes)314 {315 ASSERT(CCProxy::isImplThread());316 DebugScopedSetMainThread main;317 ASSERT(m_layerTreeHost);318 m_layerTreeHost->setContentsMemoryAllocationLimitBytes(bytes);319 }320 321 314 // Called by the legacy scheduling path (e.g. where render_widget does the scheduling) 322 315 void CCSingleThreadProxy::compositeImmediately() … … 346 339 ASSERT(CCProxy::isMainThread()); 347 340 341 348 342 if (!m_layerTreeHost->initializeLayerRendererIfNeeded()) 349 343 return false; 350 344 345 if (m_layerTreeHostImpl->contentsTexturesWerePurgedSinceLastCommit()) 346 m_layerTreeHost->evictAllContentTextures(); 347 351 348 CCTextureUpdater updater; 352 m_layerTreeHost->updateLayers(updater );349 m_layerTreeHost->updateLayers(updater, m_layerTreeHostImpl->memoryAllocationLimitBytes()); 353 350 354 351 m_layerTreeHost->willCommit(); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h
r121069 r121076 50 50 virtual bool initializeContext() OVERRIDE; 51 51 virtual void setSurfaceReady() OVERRIDE; 52 virtual void setVisible(bool) OVERRIDE; 52 53 virtual bool initializeLayerRenderer() OVERRIDE; 53 54 virtual bool recreateContext() OVERRIDE; … … 57 58 virtual void setNeedsAnimate() OVERRIDE; 58 59 virtual void setNeedsCommit() OVERRIDE; 59 virtual void setNeedsForcedCommit() OVERRIDE;60 60 virtual void setNeedsRedraw() OVERRIDE; 61 61 virtual bool commitRequested() const OVERRIDE; … … 74 74 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_layerTreeHost->scheduleComposite(); } 75 75 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE; 76 virtual void postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThread(size_t) OVERRIDE;77 76 78 77 // Called by the legacy path where RenderWidget does the scheduling. -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
r121069 r121076 81 81 , m_started(false) 82 82 , m_texturesAcquired(true) 83 , m_inCompositeAndReadback(false) 83 84 , m_mainThreadProxy(CCScopedThreadProxy::create(CCProxy::mainThread())) 84 85 , m_beginFrameCompletionEventOnImplThread(0) … … 115 116 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::forceBeginFrameOnImplThread, AllowCrossThreadAccess(&beginFrameCompletion))); 116 117 beginFrameCompletion.wait(); 118 m_inCompositeAndReadback = true; 117 119 beginFrame(); 120 m_inCompositeAndReadback = false; 118 121 119 122 // Perform a synchronous readback. … … 202 205 TRACE_EVENT0("cc", "CCThreadProxy::setSurfaceReadyOnImplThread"); 203 206 m_schedulerOnImplThread->setCanBeginFrame(true); 207 } 208 209 void CCThreadProxy::setVisible(bool visible) 210 { 211 TRACE_EVENT0("cc", "CCThreadProxy::setVisible"); 212 CCCompletionEvent completion; 213 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::setVisibleOnImplThread, AllowCrossThreadAccess(&completion), visible)); 214 completion.wait(); 215 } 216 217 void CCThreadProxy::setVisibleOnImplThread(CCCompletionEvent* completion, bool visible) 218 { 219 TRACE_EVENT0("cc", "CCThreadProxy::setVisibleOnImplThread"); 220 m_layerTreeHostImpl->setVisible(visible); 221 m_schedulerOnImplThread->setVisible(visible); 222 completion->signal(); 204 223 } 205 224 … … 301 320 } 302 321 303 void CCThreadProxy::setNeedsForcedCommit()304 {305 ASSERT(isMainThread());306 if (m_forcedCommitRequested)307 return;308 309 TRACE_EVENT("CCThreadProxy::setNeedsForcedCommit", this, 0);310 m_commitRequested = true;311 m_forcedCommitRequested = true;312 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::setNeedsForcedCommitOnImplThread));313 }314 315 322 void CCThreadProxy::didLoseContextOnImplThread() 316 323 { … … 348 355 TRACE_EVENT("CCThreadProxy::postAnimationEventsToMainThreadOnImplThread", this, 0); 349 356 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnimationEvents, events, wallClockTime)); 350 }351 352 void CCThreadProxy::postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThread(size_t bytes)353 {354 ASSERT(isImplThread());355 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setContentsMemoryAllocationLimitBytes, bytes));356 357 } 357 358 … … 457 458 m_currentTextureUpdaterOnImplThread = adoptPtr(new CCTextureUpdater); 458 459 m_pendingBeginFrameRequest->updater = m_currentTextureUpdaterOnImplThread.get(); 460 m_pendingBeginFrameRequest->contentsTexturesWereDeleted = m_layerTreeHostImpl->contentsTexturesWerePurgedSinceLastCommit(); 461 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl->memoryAllocationLimitBytes(); 459 462 460 463 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrame)); … … 499 502 m_layerTreeHost->applyScrollAndScale(*request->scrollInfo); 500 503 504 if (!m_inCompositeAndReadback && !m_layerTreeHost->visible()) { 505 m_commitRequested = false; 506 m_forcedCommitRequested = false; 507 508 TRACE_EVENT0("cc", "EarlyOut_NotVisible"); 509 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrameAbortedOnImplThread)); 510 return; 511 } 512 501 513 m_layerTreeHost->willBeginFrame(); 502 514 503 // FIXME: recreate the context if it was requested by the impl thread.504 515 m_layerTreeHost->updateAnimations(request->monotonicFrameBeginTime); 505 516 m_layerTreeHost->layout(); … … 514 525 return; 515 526 516 m_layerTreeHost->updateLayers(*request->updater); 527 if (request->contentsTexturesWereDeleted) 528 m_layerTreeHost->evictAllContentTextures(); 529 530 m_layerTreeHost->updateLayers(*request->updater, request->memoryAllocationLimitBytes); 517 531 518 532 // Once single buffered layers are committed, they cannot be modified until … … 560 574 561 575 m_schedulerOnImplThread->beginFrameComplete(); 576 } 577 578 void CCThreadProxy::beginFrameAbortedOnImplThread() 579 { 580 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread"); 581 ASSERT(isImplThread()); 582 ASSERT(m_schedulerOnImplThread); 583 ASSERT(m_schedulerOnImplThread->commitPending()); 584 585 m_schedulerOnImplThread->beginFrameAborted(); 562 586 } 563 587 … … 662 686 m_readbackRequestOnImplThread->completion.signal(); 663 687 m_readbackRequestOnImplThread = 0; 664 } 665 666 if (drawFrame) 688 } else if (drawFrame) 667 689 result.didSwap = m_layerTreeHostImpl->swapBuffers(); 668 690 … … 745 767 return; 746 768 m_layerTreeHost->setAnimationEvents(events, wallClockTime); 747 }748 749 void CCThreadProxy::setContentsMemoryAllocationLimitBytes(size_t bytes)750 {751 ASSERT(isMainThread());752 if (!m_layerTreeHost)753 return;754 m_layerTreeHost->setContentsMemoryAllocationLimitBytes(bytes);755 769 } 756 770 … … 837 851 TRACE_EVENT("CCThreadProxy::layerTreeHostClosedOnImplThread", this, 0); 838 852 ASSERT(isImplThread()); 839 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator()); 853 if (!m_layerTreeHostImpl->contentsTexturesWerePurgedSinceLastCommit()) 854 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator()); 840 855 m_inputHandlerOnImplThread.clear(); 841 856 m_layerTreeHostImpl.clear(); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h
r121069 r121076 57 57 virtual bool initializeContext() OVERRIDE; 58 58 virtual void setSurfaceReady() OVERRIDE; 59 virtual void setVisible(bool) OVERRIDE; 59 60 virtual bool initializeLayerRenderer() OVERRIDE; 60 61 virtual bool recreateContext() OVERRIDE; … … 64 65 virtual void setNeedsAnimate() OVERRIDE; 65 66 virtual void setNeedsCommit() OVERRIDE; 66 virtual void setNeedsForcedCommit() OVERRIDE;67 67 virtual void setNeedsRedraw() OVERRIDE; 68 68 virtual bool commitRequested() const OVERRIDE; … … 81 81 virtual void setNeedsCommitOnImplThread() OVERRIDE; 82 82 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE; 83 virtual void postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThread(size_t) OVERRIDE;84 83 85 84 // CCSchedulerClient implementation … … 109 108 OwnPtr<CCScrollAndScaleSet> scrollInfo; 110 109 CCTextureUpdater* updater; 110 bool contentsTexturesWereDeleted; 111 size_t memoryAllocationLimitBytes; 111 112 }; 112 113 OwnPtr<BeginFrameAndCommitState> m_pendingBeginFrameRequest; … … 117 118 void didCompleteSwapBuffers(); 118 119 void setAnimationEvents(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime); 119 void setContentsMemoryAllocationLimitBytes(size_t);120 120 void beginContextRecreation(); 121 121 void tryToRecreateContext(); … … 130 130 void forceBeginFrameOnImplThread(CCCompletionEvent*); 131 131 void beginFrameCompleteOnImplThread(CCCompletionEvent*); 132 void beginFrameAbortedOnImplThread(); 132 133 void requestReadbackOnImplThread(ReadbackRequest*); 133 134 void requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, double durationSec); … … 135 136 void initializeImplOnImplThread(CCCompletionEvent*); 136 137 void setSurfaceReadyOnImplThread(); 138 void setVisibleOnImplThread(CCCompletionEvent*, bool); 137 139 void initializeContextOnImplThread(CCGraphicsContext*); 138 140 void initializeLayerRendererOnImplThread(CCCompletionEvent*, bool* initializeSucceeded, LayerRendererCapabilities*); … … 158 160 bool m_started; 159 161 bool m_texturesAcquired; 162 bool m_inCompositeAndReadback; 160 163 161 164 OwnPtr<CCLayerTreeHostImpl> m_layerTreeHostImpl; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp
r121005 r121076 32 32 #include "Extensions3DChromium.h" 33 33 #include "GraphicsContext3D.h" 34 #include "LayerRendererChromium.h" // For GLC macro 34 35 #include "LayerTextureSubImage.h" 35 36 #include "NotImplemented.h" … … 76 77 m_provider = 0; 77 78 } 78 freePlaneData(layerTreeHostImpl()-> layerRenderer());79 freePlaneData(layerTreeHostImpl()->context()); 79 80 80 81 #if !ASSERT_DISABLED … … 126 127 127 128 willDrawInternal(layerRenderer, context); 128 freeUnusedPlaneData( layerRenderer);129 freeUnusedPlaneData(context); 129 130 130 131 if (!m_frame) … … 160 161 } 161 162 162 if (!allocatePlaneData(layerRenderer )) {163 if (!allocatePlaneData(layerRenderer, context)) { 163 164 m_provider->putCurrentFrame(m_frame); 164 165 m_frame = 0; … … 283 284 } 284 285 285 bool CCVideoLayerImpl::FramePlane::allocateData(CC Renderer* layerRenderer)286 bool CCVideoLayerImpl::FramePlane::allocateData(CCGraphicsContext* context) 286 287 { 287 288 if (textureId) 288 289 return true; 289 290 290 textureId = layerRenderer->contentsTextureAllocator()->createTexture(size, format); 291 GraphicsContext3D* context3D = context->context3D(); 292 if (!context3D) 293 return false; 294 295 GLC(context3D, textureId = context3D->createTexture()); 296 GLC(context3D, context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId)); 297 // Do basic linear filtering on resize. 298 GLC(context3D, context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); 299 GLC(context3D, context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); 300 // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE. 301 GLC(context3D, context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); 302 GLC(context3D, context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); 303 304 GLC(context3D, context3D->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE)); 305 291 306 return textureId; 292 307 } 293 308 294 void CCVideoLayerImpl::FramePlane::freeData(CC Renderer* layerRenderer)309 void CCVideoLayerImpl::FramePlane::freeData(CCGraphicsContext* context) 295 310 { 296 311 if (!textureId) 297 312 return; 298 313 299 layerRenderer->contentsTextureAllocator()->deleteTexture(textureId, size, format); 314 GraphicsContext3D* context3D = context->context3D(); 315 if (!context3D) 316 return; 317 318 GLC(context3D, context3D->deleteTexture(textureId)); 300 319 textureId = 0; 301 320 } 302 321 303 bool CCVideoLayerImpl::allocatePlaneData(CCRenderer* layerRenderer )322 bool CCVideoLayerImpl::allocatePlaneData(CCRenderer* layerRenderer, CCGraphicsContext* context) 304 323 { 305 324 int maxTextureSize = layerRenderer->capabilities().maxTextureSize; … … 313 332 314 333 if (plane.size != requiredTextureSize || plane.format != m_format) { 315 plane.freeData( layerRenderer);334 plane.freeData(context); 316 335 plane.size = requiredTextureSize; 317 336 plane.format = m_format; … … 319 338 320 339 if (!plane.textureId) { 321 if (!plane.allocateData( layerRenderer))340 if (!plane.allocateData(context)) 322 341 return false; 323 342 plane.visibleSize = computeVisibleSize(*m_frame, planeIndex); … … 352 371 } 353 372 354 void CCVideoLayerImpl::freePlaneData(CC Renderer* layerRenderer)373 void CCVideoLayerImpl::freePlaneData(CCGraphicsContext* context) 355 374 { 356 375 for (unsigned i = 0; i < WebKit::WebVideoFrame::maxPlanes; ++i) 357 m_framePlanes[i].freeData( layerRenderer);358 } 359 360 void CCVideoLayerImpl::freeUnusedPlaneData(CC Renderer* layerRenderer)376 m_framePlanes[i].freeData(context); 377 } 378 379 void CCVideoLayerImpl::freeUnusedPlaneData(CCGraphicsContext* context) 361 380 { 362 381 unsigned firstUnusedPlane = m_frame ? m_frame->planes() : 0; 363 382 for (unsigned i = firstUnusedPlane; i < WebKit::WebVideoFrame::maxPlanes; ++i) 364 m_framePlanes[i].freeData( layerRenderer);383 m_framePlanes[i].freeData(context); 365 384 } 366 385 … … 382 401 void CCVideoLayerImpl::didLoseContext() 383 402 { 384 freePlaneData(layerTreeHostImpl()-> layerRenderer());403 freePlaneData(layerTreeHostImpl()->context()); 385 404 } 386 405 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h
r121005 r121076 76 76 FramePlane() : textureId(0) { } 77 77 78 bool allocateData(CC Renderer*);79 void freeData(CC Renderer*);78 bool allocateData(CCGraphicsContext*); 79 void freeData(CCGraphicsContext*); 80 80 }; 81 81 … … 87 87 88 88 void willDrawInternal(CCRenderer*, CCGraphicsContext*); 89 bool allocatePlaneData(CCRenderer* );89 bool allocatePlaneData(CCRenderer*, CCGraphicsContext*); 90 90 bool copyPlaneData(CCRenderer*, CCGraphicsContext*); 91 void freePlaneData(CC Renderer*);92 void freeUnusedPlaneData(CC Renderer*);91 void freePlaneData(CCGraphicsContext*); 92 void freeUnusedPlaneData(CCGraphicsContext*); 93 93 94 94 // Guards the destruction of m_provider and the frame that it provides -
trunk/Source/WebKit/chromium/ChangeLog
r121070 r121076 1 2012-06-22 James Robinson <jamesr@chromium.org> 2 3 [chromium] LayerRendererChromium is not getting visibility messages in single threaded compositing mode. 4 https://bugs.webkit.org/show_bug.cgi?id=89045 5 6 Reviewed by Adrienne Walker. 7 8 Based on patch by Michal Mocny <mmocny@google.com>. 9 10 Update various test fixtures and tests to cover scheduling, visibility, and resource allocation changes. 11 12 * tests/CCLayerTreeHostImplTest.cpp: 13 * tests/CCLayerTreeHostTest.cpp: 14 (CCLayerTreeHostTestAbortFrameWhenInvisible): 15 (WTF::CCLayerTreeHostTestAbortFrameWhenInvisible::CCLayerTreeHostTestAbortFrameWhenInvisible): 16 (WTF::CCLayerTreeHostTestAbortFrameWhenInvisible::beginTest): 17 (WTF::CCLayerTreeHostTestAbortFrameWhenInvisible::afterTest): 18 (WTF): 19 (WTF::TEST_F): 20 (WTF::CCLayerTreeHostTestLayerOcclusion::beginTest): 21 (WTF::CCLayerTreeHostTestLayerOcclusionWithFilters::beginTest): 22 (WTF::CCLayerTreeHostTestManySurfaces::beginTest): 23 * tests/CCSchedulerStateMachineTest.cpp: 24 (WebCore::TEST): 25 * tests/CCTiledLayerTestCommon.h: 26 * tests/FakeWebGraphicsContext3D.h: 27 (WebKit::FakeWebGraphicsContext3D::FakeWebGraphicsContext3D): 28 (FakeWebGraphicsContext3D): 29 (WebKit::FakeWebGraphicsContext3D::createTexture): 30 * tests/LayerRendererChromiumTest.cpp: 31 (TEST_F): 32 * tests/TiledLayerChromiumTest.cpp: 33 34 1 35 2012-06-22 Sadrul Habib Chowdhury <sadrul@chromium.org> 2 36 -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
r121005 r121076 82 82 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = true; } 83 83 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE { } 84 virtual void postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThread(size_t) OVERRIDE { }85 84 86 85 PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassRefPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr) … … 1793 1792 } 1794 1793 1795 class PartialSwapContext : public FakeWebGraphicsContext3D {1794 class PartialSwapContext : public FakeWebGraphicsContext3D { 1796 1795 public: 1797 1796 WebString getString(WGC3Denum name) … … 2042 2041 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { 2043 2042 public: 2043 StrictWebGraphicsContext3D() 2044 : FakeWebGraphicsContext3D() 2045 { 2046 m_nextTextureId = 7; // Start allocating texture ids larger than any other resource IDs so we can tell if someone's mixing up their resource types. 2047 } 2048 2044 2049 virtual WebGLId createBuffer() { return 2; } 2045 2050 virtual WebGLId createFramebuffer() { return 3; } … … 2047 2052 virtual WebGLId createRenderbuffer() { return 5; } 2048 2053 virtual WebGLId createShader(WGC3Denum) { return 6; } 2049 virtual WebGLId createTexture() { return 7; }2050 2054 2051 2055 virtual void deleteBuffer(WebGLId id) … … 2079 2083 } 2080 2084 2085 virtual WebGLId createTexture() 2086 { 2087 unsigned textureId = FakeWebGraphicsContext3D::createTexture(); 2088 m_allocatedTextureIds.add(textureId); 2089 return textureId; 2090 } 2081 2091 virtual void deleteTexture(WebGLId id) 2082 2092 { 2083 if ( id != 7)2093 if (!m_allocatedTextureIds.contains(id)) 2084 2094 ADD_FAILURE() << "Trying to delete texture id " << id; 2095 m_allocatedTextureIds.remove(id); 2085 2096 } 2086 2097 … … 2117 2128 virtual void bindTexture(WGC3Denum, WebGLId id) 2118 2129 { 2119 if (id != 7 && id)2130 if (id && !m_allocatedTextureIds.contains(id)) 2120 2131 ADD_FAILURE() << "Trying to bind texture id " << id; 2121 2132 } … … 2125 2136 return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new StrictWebGraphicsContext3D()), GraphicsContext3D::RenderDirectlyToHostWindow); 2126 2137 } 2138 2139 private: 2140 HashSet<unsigned> m_allocatedTextureIds; 2127 2141 }; 2128 2142 … … 2264 2278 public: 2265 2279 TrackingWebGraphicsContext3D() 2266 : m_nextTextureId(1)2280 : FakeWebGraphicsContext3D() 2267 2281 , m_numTextures(0) 2268 2282 { } … … 2270 2284 virtual WebGLId createTexture() OVERRIDE 2271 2285 { 2272 WebGLId id = m_nextTextureId; 2273 ++m_nextTextureId; 2286 WebGLId id = FakeWebGraphicsContext3D::createTexture(); 2274 2287 2275 2288 m_textures.set(id, true); … … 2303 2316 2304 2317 private: 2305 WebGLId m_nextTextureId;2306 2318 HashMap<WebGLId, bool> m_textures; 2307 2319 unsigned m_numTextures; -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
r121069 r121076 487 487 } 488 488 489 class CCLayerTreeHostTestAbortFrameWhenInvisible : public CCLayerTreeHostTestThreadOnly { 490 public: 491 CCLayerTreeHostTestAbortFrameWhenInvisible() 492 { 493 } 494 495 virtual void beginTest() 496 { 497 // Request a commit (from the main thread), which will trigger the commit flow from the impl side. 498 m_layerTreeHost->setNeedsCommit(); 499 // Then mark ourselves as not visible before processing any more messages on the main thread. 500 m_layerTreeHost->setVisible(false); 501 // If we make it without kicking a frame, we pass! 502 endTestAfterDelay(1); 503 } 504 505 virtual void layout() OVERRIDE 506 { 507 ASSERT_FALSE(true); 508 endTest(); 509 } 510 511 virtual void afterTest() 512 { 513 } 514 515 private: 516 }; 517 518 TEST_F(CCLayerTreeHostTestAbortFrameWhenInvisible, runMultiThread) 519 { 520 runTestThreaded(); 521 } 522 489 523 490 524 // Trigger a frame with setNeedsCommit. Then, inside the resulting animate … … 997 1031 runTest(true); 998 1032 } 999 1000 class CCLayerTreeHostTestVisibilityAndAllocationControlDrawing : public CCLayerTreeHostTest {1001 public:1002 1003 CCLayerTreeHostTestVisibilityAndAllocationControlDrawing() { }1004 1005 virtual void beginTest()1006 {1007 postSetNeedsCommitToMainThread();1008 }1009 1010 virtual void didCommitAndDrawFrame()1011 {1012 int lastFrame = m_layerTreeHost->frameNumber() - 1;1013 1014 // These frames should draw.1015 switch (lastFrame) {1016 case 0:1017 // Set the tree invisible, this should not draw.1018 m_layerTreeHost->setVisible(false);1019 break;1020 case 2:1021 // Set the tree invisible and give a non-visible allocation, this1022 // should not draw.1023 m_layerTreeHost->setVisible(false);1024 m_layerTreeHost->setContentsMemoryAllocationLimitBytes(0);1025 break;1026 case 5:1027 // Give a memory allocation not for display, but while we are1028 // visible. This should not be used and we should remain1029 // ready for display and it should draw.1030 m_layerTreeHost->setContentsMemoryAllocationLimitBytes(0);1031 break;1032 case 6:1033 endTest();1034 break;1035 1036 default:1037 ASSERT_NOT_REACHED();1038 }1039 }1040 1041 virtual void didCommit()1042 {1043 int lastFrame = m_layerTreeHost->frameNumber() - 1;1044 1045 // These frames should not draw.1046 switch (lastFrame) {1047 case 1:1048 // Set the tree visible, this should draw.1049 m_layerTreeHost->setVisible(true);1050 break;1051 case 3:1052 // Set visible without giving a visible memory allocation, this1053 // shouldn't make the impl side ready for display, so it should1054 // not draw.1055 m_layerTreeHost->setVisible(true);1056 break;1057 case 4:1058 // Now give a memory allocation for display, this should draw.1059 m_layerTreeHost->setContentsMemoryAllocationLimitBytes(1);1060 break;1061 }1062 }1063 1064 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl)1065 {1066 switch (impl->sourceFrameNumber()) {1067 case 0:1068 // The host starts out visible and able to display before we do any commit.1069 EXPECT_TRUE(impl->visible());1070 EXPECT_TRUE(impl->sourceFrameCanBeDrawn());1071 break;1072 case 1:1073 // We still have a memory allocation for display.1074 EXPECT_FALSE(impl->visible());1075 EXPECT_TRUE(impl->sourceFrameCanBeDrawn());1076 break;1077 case 2:1078 EXPECT_TRUE(impl->visible());1079 EXPECT_TRUE(impl->sourceFrameCanBeDrawn());1080 break;1081 case 3:1082 EXPECT_FALSE(impl->visible());1083 EXPECT_FALSE(impl->sourceFrameCanBeDrawn());1084 break;1085 case 4:1086 EXPECT_TRUE(impl->visible());1087 EXPECT_FALSE(impl->sourceFrameCanBeDrawn());1088 break;1089 case 5:1090 EXPECT_TRUE(impl->visible());1091 EXPECT_TRUE(impl->sourceFrameCanBeDrawn());1092 break;1093 case 6:1094 EXPECT_TRUE(impl->visible());1095 EXPECT_TRUE(impl->sourceFrameCanBeDrawn());1096 break;1097 }1098 }1099 1100 virtual void afterTest()1101 {1102 }1103 };1104 1105 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestVisibilityAndAllocationControlDrawing)1106 1033 1107 1034 // Verifies that startPageScaleAnimation events propagate correctly from CCLayerTreeHost to … … 1735 1662 ASSERT_TRUE(m_layerTreeHost->initializeLayerRendererIfNeeded()); 1736 1663 CCTextureUpdater updater; 1737 m_layerTreeHost->updateLayers(updater );1664 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1738 1665 m_layerTreeHost->commitComplete(); 1739 1666 … … 1752 1679 m_layerTreeHost->setRootLayer(rootLayer); 1753 1680 m_layerTreeHost->setViewportSize(rootLayer->bounds()); 1754 m_layerTreeHost->updateLayers(updater );1681 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1755 1682 m_layerTreeHost->commitComplete(); 1756 1683 … … 1770 1697 m_layerTreeHost->setRootLayer(rootLayer); 1771 1698 m_layerTreeHost->setViewportSize(rootLayer->bounds()); 1772 m_layerTreeHost->updateLayers(updater );1699 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1773 1700 m_layerTreeHost->commitComplete(); 1774 1701 … … 1790 1717 m_layerTreeHost->setRootLayer(rootLayer); 1791 1718 m_layerTreeHost->setViewportSize(rootLayer->bounds()); 1792 m_layerTreeHost->updateLayers(updater );1719 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1793 1720 m_layerTreeHost->commitComplete(); 1794 1721 … … 1812 1739 m_layerTreeHost->setRootLayer(rootLayer); 1813 1740 m_layerTreeHost->setViewportSize(rootLayer->bounds()); 1814 m_layerTreeHost->updateLayers(updater );1741 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1815 1742 m_layerTreeHost->commitComplete(); 1816 1743 … … 1834 1761 m_layerTreeHost->setRootLayer(rootLayer); 1835 1762 m_layerTreeHost->setViewportSize(rootLayer->bounds()); 1836 m_layerTreeHost->updateLayers(updater );1763 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1837 1764 m_layerTreeHost->commitComplete(); 1838 1765 … … 1857 1784 m_layerTreeHost->setRootLayer(rootLayer); 1858 1785 m_layerTreeHost->setViewportSize(rootLayer->bounds()); 1859 m_layerTreeHost->updateLayers(updater );1786 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1860 1787 m_layerTreeHost->commitComplete(); 1861 1788 … … 1880 1807 m_layerTreeHost->setRootLayer(rootLayer); 1881 1808 m_layerTreeHost->setViewportSize(rootLayer->bounds()); 1882 m_layerTreeHost->updateLayers(updater );1809 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1883 1810 m_layerTreeHost->commitComplete(); 1884 1811 … … 1943 1870 ASSERT_TRUE(m_layerTreeHost->initializeLayerRendererIfNeeded()); 1944 1871 CCTextureUpdater updater; 1945 m_layerTreeHost->updateLayers(updater );1872 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1946 1873 m_layerTreeHost->commitComplete(); 1947 1874 … … 1970 1897 m_layerTreeHost->setRootLayer(rootLayer); 1971 1898 m_layerTreeHost->setViewportSize(rootLayer->bounds()); 1972 m_layerTreeHost->updateLayers(updater );1899 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 1973 1900 m_layerTreeHost->commitComplete(); 1974 1901 … … 2032 1959 ASSERT_TRUE(m_layerTreeHost->initializeLayerRendererIfNeeded()); 2033 1960 CCTextureUpdater updater; 2034 m_layerTreeHost->updateLayers(updater );1961 m_layerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 2035 1962 m_layerTreeHost->commitComplete(); 2036 1963 -
trunk/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp
r121005 r121076 808 808 } 809 809 810 TEST(CCSchedulerStateMachineTest, TestGoesInvisible MidCommit)810 TEST(CCSchedulerStateMachineTest, TestGoesInvisibleBeforeBeginFrameCompletes) 811 811 { 812 812 StateMachine state; … … 824 824 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 825 825 826 // Become invisible 826 // Become invisible and abort the beginFrame. 827 827 state.setVisible(false); 828 829 // Tell the scheduler the frame finished 830 state.beginFrameComplete(); 831 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCES, state.commitState()); 832 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state.nextAction()); 833 834 // Tell the scheduler the update began and finished 835 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES); 836 state.beginUpdateMoreResourcesComplete(false); 837 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState()); 838 EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); 839 840 // Commit in invisible state should leave us: 841 // - COMMIT_STATE_WAITING_FOR_FIRST_DRAW 842 // - Waiting for redraw. 843 // - No commit needed 844 state.updateState(CCSchedulerStateMachine::ACTION_COMMIT); 845 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, state.commitState()); 846 EXPECT_TRUE(state.needsRedraw()); 847 EXPECT_FALSE(state.needsCommit()); 848 849 // Expect to do nothing, both in and out of vsync. 850 state.didLeaveVSync(); 851 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 852 state.didEnterVSync(); 828 state.beginFrameAborted(); 829 830 // We should now be back in the idle state as if we didn't start a frame at all. 831 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_IDLE, state.commitState()); 853 832 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 854 833 } -
trunk/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h
r121005 r121076 151 151 class FakeTextureAllocator : public WebCore::TextureAllocator { 152 152 public: 153 virtual unsigned createTexture(const WebCore::IntSize&, GC3Denum) { return 1; } 154 virtual void deleteTexture(unsigned, const WebCore::IntSize&, GC3Denum) { } 153 virtual unsigned createTexture(const WebCore::IntSize&, GC3Denum) OVERRIDE { return 1; } 154 virtual void deleteTexture(unsigned, const WebCore::IntSize&, GC3Denum) OVERRIDE { } 155 virtual void deleteAllTextures() OVERRIDE { } 155 156 }; 156 157 -
trunk/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h
r121005 r121076 36 36 class FakeWebGraphicsContext3D : public WebGraphicsContext3D { 37 37 public: 38 FakeWebGraphicsContext3D() 39 : m_nextTextureId(1) 40 { 41 } 42 38 43 virtual bool makeContextCurrent() { return true; } 39 44 … … 247 252 virtual WebGLId createRenderbuffer() { return 1; } 248 253 virtual WebGLId createShader(WGC3Denum) { return 1; } 249 virtual WebGLId createTexture() { return 1; }254 virtual WebGLId createTexture() { return m_nextTextureId++; } 250 255 251 256 virtual void deleteBuffer(WebGLId) { } … … 268 273 269 274 protected: 275 unsigned m_nextTextureId; 270 276 Attributes m_attrs; 271 277 }; -
trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
r121005 r121076 85 85 86 86 // CCRendererClient methods. 87 virtual const IntSize& deviceViewportSize() const OVERRIDE { static IntSize fakeSize ; return fakeSize; }87 virtual const IntSize& deviceViewportSize() const OVERRIDE { static IntSize fakeSize(1, 1); return fakeSize; } 88 88 virtual const CCLayerTreeSettings& settings() const OVERRIDE { static CCLayerTreeSettings fakeSettings; return fakeSettings; } 89 89 virtual void didLoseContext() OVERRIDE { } 90 90 virtual void onSwapBuffersComplete() OVERRIDE { } 91 91 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCount++; } 92 virtual void setContentsMemoryAllocationLimitBytes(size_t bytes) OVERRIDE { m_memoryAllocationLimitBytes = bytes; } 92 virtual void releaseContentsTextures() OVERRIDE { } 93 virtual void setMemoryAllocationLimitBytes(size_t bytes) OVERRIDE { m_memoryAllocationLimitBytes = bytes; } 93 94 94 95 // Methods added for test. … … 169 170 170 171 // Test LayerRendererChromium discardFramebuffer functionality: 171 // Suggest discarding framebuffer when one exists .172 // Suggest discarding framebuffer when one exists and the renderer is not visible. 172 173 // Expected: it is discarded and damage tracker is reset. 173 TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoShouldDiscardBackbufferAndDamageRootLayer) 174 { 174 TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoShouldDiscardBackbufferAndDamageRootLayerWhileNotVisible) 175 { 176 m_layerRendererChromium.setVisible(false); 175 177 m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo); 176 178 EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount()); 177 179 EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded()); 178 180 } 181 182 // Test LayerRendererChromium discardFramebuffer functionality: 183 // Suggest discarding framebuffer when one exists and the renderer is visible. 184 // Expected: the allocation is ignored. 185 TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoDoNothingWhenVisible) 186 { 187 m_layerRendererChromium.setVisible(true); 188 m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo); 189 EXPECT_EQ(0, m_mockClient.setFullRootLayerDamageCount()); 190 EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded()); 191 } 192 179 193 180 194 // Test LayerRendererChromium discardFramebuffer functionality: … … 183 197 TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoWhenItDoesntExistShouldDoNothing) 184 198 { 199 m_layerRendererChromium.setVisible(false); 185 200 m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo); 186 201 EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount()); … … 190 205 EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount()); 191 206 EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded()); 192 }193 194 // Test LayerRendererChromium discardFramebuffer functionality:195 // Suggest discarding framebuffer, then try to swapBuffers.196 // Expected: framebuffer is discarded, swaps are ignored, and damage is reset after discard and after each swap.197 TEST_F(LayerRendererChromiumTest, SwapBuffersWhileBackbufferDiscardedShouldIgnoreSwapAndDamageRootLayer)198 {199 m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);200 EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());201 EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());202 203 swapBuffers();204 EXPECT_EQ(0, m_mockContext.frameCount());205 EXPECT_EQ(2, m_mockClient.setFullRootLayerDamageCount());206 207 swapBuffers();208 EXPECT_EQ(0, m_mockContext.frameCount());209 EXPECT_EQ(3, m_mockClient.setFullRootLayerDamageCount());210 207 } 211 208 … … 213 210 // Begin drawing a frame while a framebuffer is discarded. 214 211 // Expected: will recreate framebuffer. 215 TEST_F(LayerRendererChromiumTest, DiscardedBackbufferIsRecreatredForScopeDuration) 216 { 212 TEST_F(LayerRendererChromiumTest, DiscardedBackbufferIsRecreatedForScopeDuration) 213 { 214 m_layerRendererChromium.setVisible(false); 217 215 m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo); 218 216 EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded()); 219 217 EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount()); 220 218 219 m_layerRendererChromium.setVisible(true); 221 220 m_layerRendererChromium.beginDrawingFrame(m_mockClient.rootRenderPass()); 222 221 EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded()); … … 224 223 swapBuffers(); 225 224 EXPECT_EQ(1, m_mockContext.frameCount()); 225 } 226 227 TEST_F(LayerRendererChromiumTest, FramebufferDiscardedAfterReadbackWhenNotVisible) 228 { 229 m_layerRendererChromium.setVisible(false); 230 m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo); 231 EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded()); 232 EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount()); 233 234 char pixels[4]; 235 m_layerRendererChromium.beginDrawingFrame(m_mockClient.rootRenderPass()); 236 EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded()); 237 238 m_layerRendererChromium.getFramebufferPixels(pixels, IntRect(0, 0, 1, 1)); 239 EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded()); 240 EXPECT_EQ(2, m_mockClient.setFullRootLayerDamageCount()); 226 241 } 227 242 -
trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
r121005 r121076 825 825 ccLayerTreeHost->setRootLayer(rootLayer); 826 826 ccLayerTreeHost->setViewportSize(IntSize(300, 300)); 827 textureManager->setMaxMemoryLimitBytes(memoryLimit); 828 ccLayerTreeHost->updateLayers(updater); 827 ccLayerTreeHost->updateLayers(updater, memoryLimit); 829 828 830 829 // We'll skip the root layer. … … 838 837 rootLayer->removeAllChildren(); 839 838 840 ccLayerTreeHost->updateLayers(updater );839 ccLayerTreeHost->updateLayers(updater, memoryLimit); 841 840 EXPECT_FALSE(rootLayer->skipsDraw()); 842 841 … … 905 904 906 905 // Full update of all 6 tiles. 907 ccLayerTreeHost->updateLayers(updater );906 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 908 907 { 909 908 DebugScopedSetImplThread implThread; … … 923 922 // Full update of 3 tiles and partial update of 3 tiles. 924 923 layer->invalidateRect(IntRect(0, 0, 300, 150)); 925 ccLayerTreeHost->updateLayers(updater );924 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 926 925 { 927 926 DebugScopedSetImplThread implThread; … … 944 943 DebugScopedSetImplThread implThread; 945 944 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))); 946 ccLayerTreeHost->updateLayers(updater );945 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 947 946 updater.update(0, &allocator, &copier, &uploader, 4); 948 947 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); … … 971 970 DebugScopedSetImplThread implThread; 972 971 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))); 973 ccLayerTreeHost->updateLayers(updater );972 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 974 973 updater.update(0, &allocator, &copier, &uploader, 4); 975 974 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); … … 989 988 DebugScopedSetImplThread implThread; 990 989 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))); 991 ccLayerTreeHost->updateLayers(updater );990 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); 992 991 updater.update(0, &allocator, &copier, &uploader, 4); 993 992 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
Note: See TracChangeset
for help on using the changeset viewer.