Changeset 106700 in webkit
- Timestamp:
- Feb 3, 2012 3:18:56 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106699 r106700 1 2012-02-03 James Robinson <jamesr@chromium.org> 2 3 [chromium] Defer makeContextCurrent in compositor until first frame 4 https://bugs.webkit.org/show_bug.cgi?id=77269 5 6 Reviewed by Kenneth Russell. 7 8 There are situations where we need to instantiate a compositor, but can't call makeContextCurrent() until some 9 initialization work completes on another thread that we cannot block for. This defers the first 10 makeContextCurrent() call until we need to produce the first frame at which point we know the call can succeed, 11 assuming that the scheduler does the right thing. 12 13 This is accomplished by splitting up proxy initialization into two pieces: 14 *) initializeContext() which attempts to instantiate a GraphicsContext3D. This can fail if we can't make a 15 context at all, in which case we abort completely and return NULL from CCLayerTreeHost::create(). 16 17 *) initializeLayerRenderer() which uses the previously-created context to instantiate our compositor objects and 18 grab our renderer capabilities. This can fail if the context is not usable for compositing, which we report 19 to the client as a lost context event. 20 21 Internally this introduces a new state to the CCLayerTreeHostImpl where it has a context but does not yet have a 22 LayerRendererChromium, which has fairly minimal impact. One other change is that we don't instantiate the 23 TextureManagers until we have the renderer capabilities, but this isn't necessary until we want to start 24 painting so it doesn't have any impact outside of some overly intrustive unit tests. 25 26 * platform/graphics/chromium/ContentLayerChromium.cpp: 27 (WebCore::ContentLayerChromium::paintContentsIfDirty): 28 (WebCore::ContentLayerChromium::createTextureUpdater): 29 * platform/graphics/chromium/ContentLayerChromium.h: 30 (ContentLayerChromium): 31 * platform/graphics/chromium/ImageLayerChromium.cpp: 32 (WebCore::ImageLayerChromium::paintContentsIfDirty): 33 * platform/graphics/chromium/ImageLayerChromium.h: 34 (ImageLayerChromium): 35 * platform/graphics/chromium/TiledLayerChromium.cpp: 36 * platform/graphics/chromium/TiledLayerChromium.h: 37 (WebCore::TiledLayerChromium::setSampledTexelFormat): 38 (TiledLayerChromium): 39 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: 40 (WebCore::CCLayerTreeHost::CCLayerTreeHost): 41 (WebCore::CCLayerTreeHost::initialize): 42 (WebCore::CCLayerTreeHost::initializeLayerRenderer): 43 (WebCore): 44 (WebCore::CCLayerTreeHost::beginCommitOnImplThread): 45 (WebCore::CCLayerTreeHost::compositeAndReadback): 46 (WebCore::CCLayerTreeHost::finishAllRendering): 47 (WebCore::CCLayerTreeHost::setViewportSize): 48 (WebCore::CCLayerTreeHost::setVisible): 49 (WebCore::CCLayerTreeHost::updateLayers): 50 * platform/graphics/chromium/cc/CCLayerTreeHost.h: 51 (CCLayerTreeHost): 52 (): 53 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: 54 (WebCore::CCLayerTreeHostImpl::isContextLost): 55 * platform/graphics/chromium/cc/CCProxy.h: 56 (CCProxy): 57 * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: 58 (WebCore::CCSingleThreadProxy::CCSingleThreadProxy): 59 (WebCore::CCSingleThreadProxy::compositeAndReadback): 60 (WebCore::CCSingleThreadProxy::initializeContext): 61 (WebCore::CCSingleThreadProxy::initializeLayerRenderer): 62 (WebCore::CCSingleThreadProxy::layerRendererCapabilities): 63 * platform/graphics/chromium/cc/CCSingleThreadProxy.h: 64 (CCSingleThreadProxy): 65 * platform/graphics/chromium/cc/CCThreadProxy.cpp: 66 (WebCore::CCThreadProxy::CCThreadProxy): 67 (WebCore::CCThreadProxy::compositeAndReadback): 68 (WebCore::CCThreadProxy::initializeContext): 69 (WebCore): 70 (WebCore::CCThreadProxy::initializeLayerRenderer): 71 (WebCore::CCThreadProxy::layerRendererCapabilities): 72 (WebCore::CCThreadProxy::initializeImplOnImplThread): 73 (WebCore::CCThreadProxy::initializeContextOnImplThread): 74 (WebCore::CCThreadProxy::initializeLayerRendererOnImplThread): 75 * platform/graphics/chromium/cc/CCThreadProxy.h: 76 (CCThreadProxy): 77 1 78 2012-02-03 James Robinson <jamesr@chromium.org> 2 79 -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
r106383 r106700 97 97 { 98 98 updateTileSizeAndTilingOption(); 99 createTextureUpdaterIfNeeded(); 99 100 100 101 IntRect layerRect; … … 123 124 } 124 125 125 void ContentLayerChromium::createTextureUpdater (const CCLayerTreeHost* host)126 void ContentLayerChromium::createTextureUpdaterIfNeeded() 126 127 { 128 if (m_textureUpdater) 129 return; 127 130 #if USE(SKIA) 128 if ( host->settings().acceleratePainting)131 if (layerTreeHost()->settings().acceleratePainting) 129 132 m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate)); 130 else if ( host->settings().perTilePainting)131 m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), host->layerRendererCapabilities().usingMapSub);133 else if (layerTreeHost()->settings().perTilePainting) 134 m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), layerTreeHost()->layerRendererCapabilities().usingMapSub); 132 135 else 133 136 #endif // USE(SKIA) 134 m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), host->layerRendererCapabilities().usingMapSub);137 m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), layerTreeHost()->layerRendererCapabilities().usingMapSub); 135 138 m_textureUpdater->setOpaque(opaque()); 139 140 GC3Denum textureFormat = layerTreeHost()->layerRendererCapabilities().bestTextureFormat; 141 setTextureFormat(textureFormat); 142 setSampledTexelFormat(textureUpdater()->sampledTexelFormat(textureFormat)); 136 143 } 137 144 -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h
r106383 r106700 70 70 71 71 private: 72 virtual void createTextureUpdater(const CCLayerTreeHost*);73 72 virtual LayerTextureUpdater* textureUpdater() const { return m_textureUpdater.get(); } 73 virtual void createTextureUpdaterIfNeeded(); 74 74 75 75 ContentLayerDelegate* m_delegate; -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
r106383 r106700 161 161 void ImageLayerChromium::paintContentsIfDirty(const Region& /* occludedScreenSpace */) 162 162 { 163 createTextureUpdaterIfNeeded(); 163 164 if (m_needsDisplay) { 164 165 m_textureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame()); … … 171 172 } 172 173 174 void ImageLayerChromium::createTextureUpdaterIfNeeded() 175 { 176 if (m_textureUpdater) 177 return; 178 179 m_textureUpdater = ImageLayerTextureUpdater::create(layerTreeHost()->layerRendererCapabilities().usingMapSub); 180 GC3Denum textureFormat = layerTreeHost()->layerRendererCapabilities().bestTextureFormat; 181 setTextureFormat(textureFormat); 182 setSampledTexelFormat(textureUpdater()->sampledTexelFormat(textureFormat)); 183 } 184 173 185 LayerTextureUpdater* ImageLayerChromium::textureUpdater() const 174 186 { … … 188 200 } 189 201 190 void ImageLayerChromium::createTextureUpdater(const CCLayerTreeHost* host)191 {192 // Avoid creating a new texture updater which would not have a valid copy of the current image.193 if (!m_textureUpdater)194 m_textureUpdater = ImageLayerTextureUpdater::create(host->layerRendererCapabilities().usingMapSub);195 }196 197 202 bool ImageLayerChromium::needsContentsScale() const 198 203 { -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h
r106383 r106700 63 63 ImageLayerChromium(); 64 64 65 virtual void createTextureUpdater(const CCLayerTreeHost*);66 65 void setTilingOption(TilingOption); 67 66 68 67 virtual LayerTextureUpdater* textureUpdater() const; 68 virtual void createTextureUpdaterIfNeeded(); 69 69 virtual IntSize contentBounds() const; 70 70 -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
r106383 r106700 175 175 } 176 176 177 void TiledLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)178 {179 if (host == layerTreeHost())180 return;181 182 LayerChromium::setLayerTreeHost(host);183 184 if (!host)185 return;186 187 createTextureUpdater(host);188 setTextureFormat(host->layerRendererCapabilities().bestTextureFormat);189 m_sampledTexelFormat = textureUpdater()->sampledTexelFormat(m_textureFormat);190 }191 192 177 void TiledLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTextureUpdater& updater) 193 178 { … … 371 356 tile->m_updateRect = IntRect(); 372 357 } 358 359 createTextureUpdaterIfNeeded(); 373 360 374 361 // Create tiles as needed, expanding a dirty rect to contain all … … 474 461 m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom); 475 462 463 createTextureUpdaterIfNeeded(); 476 464 for (int j = top; j <= bottom; ++j) { 477 465 for (int i = left; i <= right; ++i) { -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
r106383 r106700 78 78 void setTextureFormat(GC3Denum textureFormat) { m_textureFormat = textureFormat; } 79 79 void setBorderTexelOption(CCLayerTilingData::BorderTexelOption); 80 void setSampledTexelFormat(LayerTextureUpdater::SampledTexelFormat sampledTexelFormat) { m_sampledTexelFormat = sampledTexelFormat; } 80 81 81 virtual void createTextureUpdater(const CCLayerTreeHost*) = 0;82 82 virtual LayerTextureUpdater* textureUpdater() const = 0; 83 virtual void createTextureUpdaterIfNeeded() = 0; 83 84 84 85 // Set invalidations to be potentially repainted during update(). … … 102 103 private: 103 104 virtual PassRefPtr<CCLayerImpl> createCCLayerImpl(); 104 105 virtual void setLayerTreeHost(CCLayerTreeHost*);106 105 107 106 void createTilerIfNeeded(); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r106383 r106700 64 64 , m_client(client) 65 65 , m_frameNumber(0) 66 , m_layerRendererInitialized(false) 66 67 , m_settings(settings) 67 68 , m_visible(true) … … 89 90 m_proxy->start(); 90 91 91 if (!m_proxy->initialize LayerRenderer())92 if (!m_proxy->initializeContext()) 92 93 return false; 93 94 94 95 m_compositorIdentifier = m_proxy->compositorIdentifier(); 95 96 // Update m_settings based on capabilities that we got back from the renderer.97 m_settings.acceleratePainting = m_proxy->layerRendererCapabilities().usingAcceleratedPainting;98 99 // Update m_settings based on partial update capability.100 m_settings.partialTextureUpdates = m_settings.partialTextureUpdates && m_proxy->partialTextureUpdateCapability();101 102 m_contentsTextureManager = TextureManager::create(TextureManager::highLimitBytes(viewportSize()),103 TextureManager::reclaimLimitBytes(viewportSize()),104 m_proxy->layerRendererCapabilities().maxTextureSize);105 96 return true; 106 97 } … … 117 108 } 118 109 110 void CCLayerTreeHost::initializeLayerRenderer() 111 { 112 TRACE_EVENT("CCLayerTreeHost::initializeLayerRenderer", this, 0); 113 if (!m_proxy->initializeLayerRenderer()) { 114 // Uh oh, better tell the client that we can't do anything with this context. 115 m_client->didRecreateGraphicsContext(false); 116 return; 117 } 118 119 // Update m_settings based on capabilities that we got back from the renderer. 120 m_settings.acceleratePainting = m_proxy->layerRendererCapabilities().usingAcceleratedPainting; 121 122 // Update m_settings based on partial update capability. 123 m_settings.partialTextureUpdates = m_settings.partialTextureUpdates && m_proxy->partialTextureUpdateCapability(); 124 125 m_contentsTextureManager = TextureManager::create(TextureManager::highLimitBytes(viewportSize()), 126 TextureManager::reclaimLimitBytes(viewportSize()), 127 m_proxy->layerRendererCapabilities().maxTextureSize); 128 129 m_layerRendererInitialized = true; 130 } 131 132 119 133 void CCLayerTreeHost::deleteContentsTexturesOnImplThread(TextureAllocator* allocator) 120 134 { … … 141 155 TRACE_EVENT("CCLayerTreeHost::commitTo", this, 0); 142 156 143 contentsTextureManager()->reduceMemoryToLimit(TextureManager::reclaimLimitBytes(viewportSize()));144 contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextureAllocator());157 m_contentsTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBytes(viewportSize())); 158 m_contentsTextureManager->deleteEvictedTextures(hostImpl->contentsTextureAllocator()); 145 159 } 146 160 … … 199 213 bool CCLayerTreeHost::compositeAndReadback(void *pixels, const IntRect& rect) 200 214 { 215 if (!m_layerRendererInitialized) { 216 initializeLayerRenderer(); 217 if (!m_layerRendererInitialized) 218 return false; 219 } 201 220 m_triggerIdlePaints = false; 202 221 bool ret = m_proxy->compositeAndReadback(pixels, rect); … … 207 226 void CCLayerTreeHost::finishAllRendering() 208 227 { 228 if (!m_layerRendererInitialized) 229 return; 209 230 m_proxy->finishAllRendering(); 210 231 } … … 255 276 return; 256 277 257 contentsTextureManager()->setMaxMemoryLimitBytes(TextureManager::highLimitBytes(viewportSize)); 258 contentsTextureManager()->setPreferredMemoryLimitBytes(TextureManager::reclaimLimitBytes(viewportSize)); 278 if (m_contentsTextureManager) { 279 m_contentsTextureManager->setMaxMemoryLimitBytes(TextureManager::highLimitBytes(viewportSize)); 280 m_contentsTextureManager->setPreferredMemoryLimitBytes(TextureManager::reclaimLimitBytes(viewportSize)); 281 } 259 282 m_viewportSize = viewportSize; 260 283 setNeedsCommit(); … … 286 309 287 310 m_visible = visible; 311 312 if (!m_layerRendererInitialized) 313 return; 314 288 315 if (!visible) { 289 316 m_contentsTextureManager->reduceMemoryToLimit(TextureManager::lowLimitBytes(viewportSize())); … … 347 374 void CCLayerTreeHost::updateLayers() 348 375 { 376 if (!m_layerRendererInitialized) { 377 initializeLayerRenderer(); 378 // If we couldn't initialize, then bail since we're returning to software mode. 379 if (!m_layerRendererInitialized) 380 return; 381 } 382 349 383 if (!rootLayer()) 350 384 return; … … 389 423 size_t preferredLimitBytes = TextureManager::reclaimLimitBytes(m_viewportSize); 390 424 size_t maxLimitBytes = TextureManager::highLimitBytes(m_viewportSize); 391 contentsTextureManager()->reduceMemoryToLimit(preferredLimitBytes);392 if ( contentsTextureManager()->currentMemoryUseBytes() >= preferredLimitBytes)425 m_contentsTextureManager->reduceMemoryToLimit(preferredLimitBytes); 426 if (m_contentsTextureManager->currentMemoryUseBytes() >= preferredLimitBytes) 393 427 return; 394 428 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
r106601 r106700 155 155 const LayerRendererCapabilities& layerRendererCapabilities() const; 156 156 157 // Test -only hook157 // Test only hook 158 158 void loseCompositorContext(int numTimes); 159 159 … … 202 202 typedef Vector<OwnPtr<ManagedTexture> > TextureList; 203 203 204 void initializeLayerRenderer(); 205 204 206 enum PaintType { PaintVisible, PaintIdle }; 205 207 static void paintContentsIfDirty(LayerChromium*, PaintType, const Region& occludedScreenSpace); … … 221 223 222 224 OwnPtr<CCProxy> m_proxy; 225 bool m_layerRendererInitialized; 223 226 224 227 RefPtr<LayerChromium> m_rootLayer; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
r106607 r106700 286 286 bool CCLayerTreeHostImpl::isContextLost() 287 287 { 288 ASSERT(m_layerRenderer); 289 return m_layerRenderer->isContextLost(); 288 return m_layerRenderer && m_layerRenderer->isContextLost(); 290 289 } 291 290 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h
r106601 r106700 62 62 virtual bool isStarted() const = 0; 63 63 64 // Attempts to initialize a context to use for rendering. Returns false if the context could not be created. 65 // The context will not be used and no frames may be produced until initializeLayerRenderer() is called. 66 virtual bool initializeContext() = 0; 67 68 // Attempts to initialize the layer renderer. Returns false if the context isn't usable for compositing. 64 69 virtual bool initializeLayerRenderer() = 0; 65 70 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp
r100984 r106700 46 46 : m_layerTreeHost(layerTreeHost) 47 47 , m_compositorIdentifier(-1) 48 , m_layerRendererInitialized(false) 48 49 , m_numFailedRecreateAttempts(0) 49 50 , m_graphicsContextLost(false) … … 70 71 bool CCSingleThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) 71 72 { 72 ASSERT(CCProxy::isMainThread()); 73 74 if (!recreateContextIfNeeded()) 75 return false; 73 TRACE_EVENT("CCSingleThreadProxy::compositeAndReadback", this, 0); 74 ASSERT(CCProxy::isMainThread()); 75 76 if (!recreateContextIfNeeded()) { 77 TRACE_EVENT("compositeAndReadback_EarlyOut_ContextLost", this, 0); 78 return false; 79 } 76 80 77 81 commitIfNeeded(); … … 110 114 } 111 115 112 bool CCSingleThreadProxy::initialize LayerRenderer()116 bool CCSingleThreadProxy::initializeContext() 113 117 { 114 118 ASSERT(CCProxy::isMainThread()); … … 117 121 return false; 118 122 ASSERT(context->hasOneRef()); 119 120 { 121 DebugScopedSetImplThread impl; 122 bool ok = m_layerTreeHostImpl->initializeLayerRenderer(context); 123 if (ok) 123 m_contextBeforeInitialization = context; 124 return true; 125 } 126 127 bool CCSingleThreadProxy::initializeLayerRenderer() 128 { 129 ASSERT(CCProxy::isMainThread()); 130 ASSERT(m_contextBeforeInitialization); 131 { 132 DebugScopedSetImplThread impl; 133 bool ok = m_layerTreeHostImpl->initializeLayerRenderer(m_contextBeforeInitialization.release()); 134 if (ok) { 135 m_layerRendererInitialized = true; 124 136 m_layerRendererCapabilitiesForMainThread = m_layerTreeHostImpl->layerRendererCapabilities(); 137 } 125 138 return ok; 126 139 } … … 129 142 const LayerRendererCapabilities& CCSingleThreadProxy::layerRendererCapabilities() const 130 143 { 144 ASSERT(m_layerRendererInitialized); 131 145 // Note: this gets called during the commit by the "impl" thread 132 146 return m_layerRendererCapabilitiesForMainThread; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h
r105583 r106700 45 45 virtual void finishAllRendering(); 46 46 virtual bool isStarted() const; 47 virtual bool initializeContext(); 47 48 virtual bool initializeLayerRenderer(); 48 49 virtual int compositorIdentifier() const { return m_compositorIdentifier; } … … 76 77 int m_compositorIdentifier; 77 78 79 // Holds on to the context between initializeContext() and initializeLayerRenderer() calls. Shouldn't 80 // be used for anything else. 81 RefPtr<GraphicsContext3D> m_contextBeforeInitialization; 82 78 83 // Used on the CCThread, but checked on main thread during initialization/shutdown. 79 84 OwnPtr<CCLayerTreeHostImpl> m_layerTreeHostImpl; 85 bool m_layerRendererInitialized; 80 86 LayerRendererCapabilities m_layerRendererCapabilitiesForMainThread; 81 87 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
r105961 r106700 60 60 , m_layerTreeHost(layerTreeHost) 61 61 , m_compositorIdentifier(-1) 62 , m_layerRendererInitialized(false) 62 63 , m_started(false) 63 64 , m_lastExecutedBeginFrameAndCommitSequenceNumber(-1) … … 85 86 ASSERT(isMainThread()); 86 87 ASSERT(m_layerTreeHost); 88 89 if (!m_layerRendererInitialized) { 90 TRACE_EVENT("compositeAndReadback_EarlyOut_LR_Uninitialized", this, 0); 91 return false; 92 } 87 93 88 94 // If a commit is pending, perform the commit first. … … 147 153 } 148 154 149 bool CCThreadProxy::initialize LayerRenderer()150 { 151 TRACE_EVENT("CCThreadProxy::initialize LayerRenderer", this, 0);155 bool CCThreadProxy::initializeContext() 156 { 157 TRACE_EVENT("CCThreadProxy::initializeContext", this, 0); 152 158 RefPtr<GraphicsContext3D> context = m_layerTreeHost->createLayerTreeHostContext3D(); 153 159 if (!context) … … 159 165 ASSERT(contextPtr->hasOneRef()); 160 166 167 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::initializeContextOnImplThread, 168 AllowCrossThreadAccess(contextPtr))); 169 return true; 170 } 171 172 bool CCThreadProxy::initializeLayerRenderer() 173 { 174 TRACE_EVENT("CCThreadProxy::initializeLayerRenderer", this, 0); 161 175 // Make a blocking call to initializeLayerRendererOnImplThread. The results of that call 162 176 // are pushed into the initializeSucceeded and capabilities local variables. … … 165 179 LayerRendererCapabilities capabilities; 166 180 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::initializeLayerRendererOnImplThread, 167 AllowCrossThreadAccess( contextPtr), AllowCrossThreadAccess(&completion),168 AllowCrossThreadAccess(&initializeSucceeded), AllowCrossThreadAccess(&capabilities),169 AllowCrossThreadAccess(& m_compositorIdentifier)));181 AllowCrossThreadAccess(&completion), 182 AllowCrossThreadAccess(&initializeSucceeded), 183 AllowCrossThreadAccess(&capabilities))); 170 184 completion.wait(); 171 185 172 if (initializeSucceeded) 186 if (initializeSucceeded) { 187 m_layerRendererInitialized = true; 173 188 m_layerRendererCapabilitiesMainThreadCopy = capabilities; 189 } 174 190 return initializeSucceeded; 175 191 } … … 183 199 const LayerRendererCapabilities& CCThreadProxy::layerRendererCapabilities() const 184 200 { 201 ASSERT(m_layerRendererInitialized); 185 202 return m_layerRendererCapabilitiesMainThreadCopy; 186 203 } … … 538 555 m_schedulerOnImplThread = CCScheduler::create(this, frameRateController.release()); 539 556 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); 557 558 m_inputHandlerOnImplThread = CCInputHandler::create(m_layerTreeHostImpl.get()); 559 m_compositorIdentifier = m_inputHandlerOnImplThread->identifier(); 560 540 561 completion->signal(); 541 562 } 542 563 543 void CCThreadProxy::initializeLayerRendererOnImplThread(GraphicsContext3D* contextPtr, CCCompletionEvent* completion, bool* initializeSucceeded, LayerRendererCapabilities* capabilities, int* compositorIdentifier) 564 void CCThreadProxy::initializeContextOnImplThread(GraphicsContext3D* context) 565 { 566 TRACE_EVENT("CCThreadProxy::initializeContextOnImplThread", this, 0); 567 ASSERT(isImplThread()); 568 m_contextBeforeInitializationOnImplThread = adoptRef(context); 569 } 570 571 void CCThreadProxy::initializeLayerRendererOnImplThread(CCCompletionEvent* completion, bool* initializeSucceeded, LayerRendererCapabilities* capabilities) 544 572 { 545 573 TRACE_EVENT("CCThreadProxy::initializeLayerRendererOnImplThread", this, 0); 546 574 ASSERT(isImplThread()); 547 RefPtr<GraphicsContext3D> context(adoptRef(contextPtr));548 *initializeSucceeded = m_layerTreeHostImpl->initializeLayerRenderer( context);575 ASSERT(m_contextBeforeInitializationOnImplThread); 576 *initializeSucceeded = m_layerTreeHostImpl->initializeLayerRenderer(m_contextBeforeInitializationOnImplThread.release()); 549 577 if (*initializeSucceeded) { 550 578 *capabilities = m_layerTreeHostImpl->layerRendererCapabilities(); 551 579 if (capabilities->usingSwapCompleteCallback) 552 580 m_schedulerOnImplThread->setMaxFramesPending(2); 553 554 m_inputHandlerOnImplThread = CCInputHandler::create(m_layerTreeHostImpl.get());555 *compositorIdentifier = m_inputHandlerOnImplThread->identifier();556 581 } 557 582 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h
r105583 r106700 53 53 virtual void finishAllRendering(); 54 54 virtual bool isStarted() const; 55 virtual bool initializeContext(); 55 56 virtual bool initializeLayerRenderer(); 56 57 virtual int compositorIdentifier() const; … … 99 100 void finishAllRenderingOnImplThread(CCCompletionEvent*); 100 101 void initializeImplOnImplThread(CCCompletionEvent*); 101 void initializeLayerRendererOnImplThread(GraphicsContext3D*, CCCompletionEvent*, bool* initializeSucceeded, LayerRendererCapabilities*, int* compositorIdentifier); 102 void initializeContextOnImplThread(GraphicsContext3D*); 103 void initializeLayerRendererOnImplThread(CCCompletionEvent*, bool* initializeSucceeded, LayerRendererCapabilities*); 102 104 void setVisibleOnImplThread(CCCompletionEvent*, bool visible); 103 105 void layerTreeHostClosedOnImplThread(CCCompletionEvent*); … … 108 110 CCLayerTreeHost* m_layerTreeHost; 109 111 int m_compositorIdentifier; 112 bool m_layerRendererInitialized; 110 113 LayerRendererCapabilities m_layerRendererCapabilitiesMainThreadCopy; 111 114 bool m_started; … … 121 124 122 125 RefPtr<CCScopedThreadProxy> m_mainThreadProxy; 126 127 // Holds on to the GraphicsContext3D we might use for compositing in between initializeContext() 128 // and initializeLayerRenderer() calls. 129 RefPtr<GraphicsContext3D> m_contextBeforeInitializationOnImplThread; 123 130 124 131 // Set when the main thread is waiing on a readback. -
trunk/Source/WebKit/chromium/ChangeLog
r106678 r106700 1 2012-02-03 James Robinson <jamesr@chromium.org> 2 3 [chromium] Defer makeContextCurrent in compositor until first frame 4 https://bugs.webkit.org/show_bug.cgi?id=77269 5 6 Reviewed by Kenneth Russell. 7 8 * tests/CCLayerTreeHostTest.cpp: 9 (WTF::CCLayerTreeHostTestSetViewportSize::beginTest): 10 * tests/TiledLayerChromiumTest.cpp: 11 (WTF::TEST): 12 1 13 2012-02-03 Beth Dakin <bdakin@apple.com> 2 14 -
trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
r106371 r106700 124 124 WebKit::WebViewImpl* webViewImpl = chrome ? static_cast<WebKit::WebViewImpl*>(chrome->client()->webView()) : 0; 125 125 126 if (threadUsage == ForUseOnThisThread && !webContext->makeContextCurrent())127 return 0;128 129 126 OwnPtr<GraphicsContext3DPrivate> priv = GraphicsContext3DPrivate::create(webViewImpl, webContext, attrs); 130 127 if (!priv) -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
r106383 r106700 1103 1103 IntSize viewportSize(10, 10); 1104 1104 layerTreeHost()->setViewportSize(viewportSize); 1105 1106 layerTreeHost()->updateLayers(); 1107 1105 1108 EXPECT_EQ(viewportSize, layerTreeHost()->viewportSize()); 1106 1109 EXPECT_EQ(TextureManager::highLimitBytes(viewportSize), layerTreeHost()->contentsTextureManager()->maxMemoryLimitBytes()); -
trunk/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
r103293 r106700 102 102 103 103 104 TEST(FakeGraphicsContext3DTest, ContextForThisThreadShould MakeCurrent)104 TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldNotMakeCurrent) 105 105 { 106 106 GraphicsContext3D::Attributes attrs; … … 108 108 EXPECT_TRUE(context); 109 109 ContextThatCountsMakeCurrents& mockContext = *static_cast<ContextThatCountsMakeCurrents*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); 110 EXPECT_EQ( 1, mockContext.makeCurrentCount());110 EXPECT_EQ(0, mockContext.makeCurrentCount()); 111 111 } 112 112 … … 120 120 } 121 121 122 class ContextWithMakeCurrentThatFails : public FakeWebGraphicsContext3D {123 public:124 ContextWithMakeCurrentThatFails() { }125 virtual bool makeContextCurrent() { return false; }126 };127 128 TEST(FakeGraphicsContext3DTest, ContextForThisThreadFailsWhenMakeCurrentFails)129 {130 GraphicsContext3D::Attributes attrs;131 RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextWithMakeCurrentThatFails()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread);132 EXPECT_FALSE(context);133 } -
trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
r106383 r106700 163 163 } 164 164 165 virtual void createTextureUpdaterIfNeeded() { } 166 165 167 RefPtr<FakeLayerTextureUpdater> m_fakeTextureUpdater; 166 168 TextureManager* m_textureManager; … … 429 431 IntRect contentRect(IntPoint::zero(), contentBounds); 430 432 431 RefPtr<FakeTiledLayerChromium> rootLayer = adoptRef(new FakeTiledLayerChromium(ccLayerTreeHost->contentsTextureManager())); 432 RefPtr<FakeTiledLayerChromium> childLayer = adoptRef(new FakeTiledLayerChromium(ccLayerTreeHost->contentsTextureManager())); 433 // We have enough memory for only one of the two layers. 434 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. 435 OwnPtr<TextureManager> textureManager = TextureManager::create(memoryLimit, memoryLimit, memoryLimit); 436 437 RefPtr<FakeTiledLayerChromium> rootLayer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 438 RefPtr<FakeTiledLayerChromium> childLayer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 433 439 rootLayer->addChild(childLayer); 434 440 … … 440 446 childLayer->invalidateRect(contentRect); 441 447 442 // We have enough memory for only one of the two layers.443 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel.444 445 448 FakeTextureAllocator textureAllocator; 446 449 CCTextureUpdater updater(&textureAllocator); … … 448 451 ccLayerTreeHost->setRootLayer(rootLayer); 449 452 ccLayerTreeHost->setViewportSize(IntSize(300, 300)); 450 ccLayerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(memoryLimit);453 textureManager->setMaxMemoryLimitBytes(memoryLimit); 451 454 ccLayerTreeHost->updateLayers(); 452 455 ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater); … … 461 464 rootLayer->removeAllChildren(); 462 465 463 // Need to set the max limit again as it gets overwritten by updateLayers().464 ccLayerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(memoryLimit);465 466 ccLayerTreeHost->updateLayers(); 466 467 EXPECT_FALSE(rootLayer->skipsDraw());
Note: See TracChangeset
for help on using the changeset viewer.