Changeset 95100 in webkit
- Timestamp:
- Sep 14, 2011 11:02:27 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r95099 r95100 1 2011-09-14 James Robinson <jamesr@chromium.org> 2 3 [chromium] Move contents texture manager from LayerRendererChromium to CCLayerTreeHost 4 https://bugs.webkit.org/show_bug.cgi?id=67440 5 6 Reviewed by Kenneth Russell. 7 8 This moves the contents TextureManager over to the CCLayerTreeHost, where it belongs, and adds in a commit path 9 to make sure that textures are deleted even if the page is not visible. This move also removed the need for 10 LayerRendererChromium's CCLayerTreeHost pointer, so I removed that as well. That meant moving the 11 layerTreeAsText() logic over to the CCLayerImpl side, which is where it really belonged anyway. 12 13 Covered by existing compositing/ tests and 14 platform/chromium/compositor/lost-compositor-context-with-rendersurface.html 15 16 * platform/graphics/chromium/LayerRendererChromium.cpp: 17 (WebCore::LayerRendererChromium::releaseRenderSurfaceTextures): 18 (WebCore::LayerRendererChromium::drawLayers): 19 (WebCore::LayerRendererChromium::initializeSharedObjects): 20 (WebCore::LayerRendererChromium::cleanupSharedObjects): 21 * platform/graphics/chromium/LayerRendererChromium.h: 22 (WebCore::LayerRendererChromium::setContentsTextureMemoryUseBytes): 23 * platform/graphics/chromium/TextureManager.cpp: 24 (WebCore::TextureManager::highLimitBytes): 25 (WebCore::TextureManager::reclaimLimitBytes): 26 (WebCore::TextureManager::lowLimitBytes): 27 * platform/graphics/chromium/TextureManager.h: 28 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: 29 (WebCore::CCLayerTreeHost::initialize): 30 (WebCore::CCLayerTreeHost::~CCLayerTreeHost): 31 (WebCore::CCLayerTreeHost::deleteContentsTextures): 32 (WebCore::CCLayerTreeHost::commitTo): 33 (WebCore::CCLayerTreeHost::setVisible): 34 (WebCore::CCLayerTreeHost::contentsTextureManager): 35 * platform/graphics/chromium/cc/CCLayerTreeHost.h: 36 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: 37 (WebCore::CCLayerTreeHostImpl::setVisible): 38 * platform/graphics/chromium/cc/CCProxy.h: 39 * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: 40 (WebCore::CCSingleThreadProxy::setNeedsCommit): 41 (WebCore::CCSingleThreadProxy::stop): 42 * platform/graphics/chromium/cc/CCSingleThreadProxy.h: 43 * platform/graphics/chromium/cc/CCThreadProxy.cpp: 44 (WebCore::CCThreadProxy::setNeedsCommit): 45 (WebCore::CCThreadProxy::setNeedsCommitOnCCThread): 46 (WebCore::CCThreadProxy::layerTreeHostClosedOnCCThread): 47 * platform/graphics/chromium/cc/CCThreadProxy.h: 48 1 49 2011-09-14 David Hyatt <hyatt@apple.com> 2 50 -
trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.h
r95014 r95100 53 53 explicit CanvasLayerChromium(GraphicsLayerChromium* owner); 54 54 55 virtual const char* layerTypeAsString() const { return "CanvasLayer"; }56 57 55 bool m_hasAlpha; 58 56 bool m_premultipliedAlpha; -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h
r95014 r95100 55 55 explicit ContentLayerChromium(GraphicsLayerChromium* owner); 56 56 57 virtual const char* layerTypeAsString() const { return "ContentLayer"; }58 59 57 virtual void cleanupResources(); 60 58 virtual bool drawsContent() const; -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h
r95014 r95100 58 58 void setContents(Image* image); 59 59 60 protected:61 virtual const char* layerTypeAsString() const { return "ImageLayer"; }62 63 60 private: 64 61 ImageLayerChromium(GraphicsLayerChromium* owner); -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
r95014 r95100 377 377 } 378 378 379 String LayerChromium::layerTreeAsText() const380 {381 TextStream ts;382 dumpLayer(ts, 0);383 return ts.release();384 }385 386 static void writeIndent(TextStream& ts, int indent)387 {388 for (int i = 0; i != indent; ++i)389 ts << " ";390 }391 392 void LayerChromium::dumpLayer(TextStream& ts, int indent) const393 {394 writeIndent(ts, indent);395 ts << layerTypeAsString() << "(" << m_name << ")\n";396 dumpLayerProperties(ts, indent+2);397 if (m_replicaLayer) {398 writeIndent(ts, indent+2);399 ts << "Replica:\n";400 m_replicaLayer->dumpLayer(ts, indent+3);401 }402 if (m_maskLayer) {403 writeIndent(ts, indent+2);404 ts << "Mask:\n";405 m_maskLayer->dumpLayer(ts, indent+3);406 }407 for (size_t i = 0; i < m_children.size(); ++i)408 m_children[i]->dumpLayer(ts, indent+1);409 }410 411 void LayerChromium::dumpLayerProperties(TextStream& ts, int indent) const412 {413 writeIndent(ts, indent);414 ts << "id: " << id() << " drawsContent: " << drawsContent() << " bounds " << m_bounds.width() << "x" << m_bounds.height() << " usesLayerScissor: " << usesLayerScissor()415 << " scissorRect: (" << m_scissorRect.x() << ", " << m_scissorRect.y() << ", " << m_scissorRect.width() << ", " << m_scissorRect.height() << ")"416 << " visibleLayerRect: (" << m_visibleLayerRect.x() << ", " << m_visibleLayerRect.y() << ", " << m_visibleLayerRect.width() << ", " << m_visibleLayerRect.height() << ")"417 << "\n";418 419 }420 421 379 PassRefPtr<CCLayerImpl> LayerChromium::createCCLayerImpl() 422 380 { -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h
r95014 r95100 173 173 174 174 void drawDebugBorder(); 175 String layerTreeAsText() const;176 175 177 176 void setBorderWidth(float); … … 220 219 221 220 static void toGLMatrix(float*, const TransformationMatrix&); 222 223 void dumpLayer(TextStream&, int indent) const;224 225 virtual const char* layerTypeAsString() const { return "LayerChromium"; }226 virtual void dumpLayerProperties(TextStream&, int indent) const;227 221 228 222 FloatRect m_dirtyRect; -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r95014 r95100 71 71 namespace WebCore { 72 72 73 // FIXME: Make this limit adjustable and give it a useful value.74 75 // Absolute maximum limit for texture allocations for this instance.76 static size_t textureMemoryHighLimitBytes = 128 * 1024 * 1024;77 // Preferred texture size limit. Can be exceeded if needed.78 static size_t textureMemoryReclaimLimitBytes = 64 * 1024 * 1024;79 // The maximum texture memory usage when asked to release textures.80 static size_t textureMemoryLowLimitBytes = 3 * 1024 * 1024;81 82 size_t LayerRendererChromium::textureMemoryReclaimLimit()83 {84 return textureMemoryReclaimLimitBytes;85 }86 87 73 namespace { 88 74 … … 144 130 } // anonymous namespace 145 131 146 PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(CCLayerTreeHost * owner, CCLayerTreeHostImpl* ownerImpl, PassRefPtr<GraphicsContext3D> context)132 PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(CCLayerTreeHostImpl* owner, PassRefPtr<GraphicsContext3D> context) 147 133 { 148 134 #if USE(SKIA) … … 150 136 return 0; 151 137 #endif 152 RefPtr<LayerRendererChromium> layerRenderer(adoptRef(new LayerRendererChromium(owner, ownerImpl,context)));138 RefPtr<LayerRendererChromium> layerRenderer(adoptRef(new LayerRendererChromium(owner, context))); 153 139 if (!layerRenderer->initialize()) 154 140 return 0; … … 157 143 } 158 144 159 LayerRendererChromium::LayerRendererChromium(CCLayerTreeHost* owner, 160 CCLayerTreeHostImpl* ownerImpl, 145 LayerRendererChromium::LayerRendererChromium(CCLayerTreeHostImpl* owner, 161 146 PassRefPtr<GraphicsContext3D> context) 162 147 : m_owner(owner) 163 , m_ownerImpl(ownerImpl)164 148 , m_currentRenderSurface(0) 165 149 , m_offscreenFramebufferId(0) … … 211 195 void LayerRendererChromium::close() 212 196 { 213 if (rootLayer Impl())214 clearRenderSurfacesOnCCLayerImplRecursive(rootLayer Impl());197 if (rootLayer()) 198 clearRenderSurfacesOnCCLayerImplRecursive(rootLayer()); 215 199 } 216 200 … … 227 211 } 228 212 229 void LayerRendererChromium::releaseTextures() 230 { 231 // Reduces texture memory usage to textureMemoryLowLimitBytes by deleting non root layer 232 // textures. 233 m_owner->nonCompositedContentHost()->protectVisibleTileTextures(); 234 m_contentsTextureManager->reduceMemoryToLimit(textureMemoryLowLimitBytes); 235 m_contentsTextureManager->unprotectAllTextures(); 236 m_contentsTextureManager->deleteEvictedTextures(m_context.get()); 237 // Evict all RenderSurface textures. 238 m_renderSurfaceTextureManager->unprotectAllTextures(); 239 m_renderSurfaceTextureManager->reduceMemoryToLimit(0); 240 m_renderSurfaceTextureManager->deleteEvictedTextures(m_context.get()); 213 void LayerRendererChromium::releaseRenderSurfaceTextures() 214 { 215 m_renderSurfaceTextureManager->evictAndDeleteAllTextures(m_context.get()); 241 216 } 242 217 … … 258 233 m_headsUpDisplay->onFrameBegin(currentTime()); 259 234 260 if (!rootLayer Impl())235 if (!rootLayer()) 261 236 return; 262 237 // FIXME: No need to walk the tree here. This could be passed via draw. 263 rootLayer Impl()->setLayerRendererRecursive(this);264 265 m_renderSurfaceTextureManager->setMemoryLimitBytes( textureMemoryHighLimitBytes - m_contentsTextureManager->currentMemoryUseBytes());238 rootLayer()->setLayerRendererRecursive(this); 239 240 m_renderSurfaceTextureManager->setMemoryLimitBytes(TextureManager::highLimitBytes() - m_contentsTextureMemoryUseBytes); 266 241 drawLayersInternal(); 267 242 268 m_contentsTextureManager->unprotectAllTextures(); 269 270 if (textureMemoryReclaimLimitBytes > m_contentsTextureManager->currentMemoryUseBytes()) 271 m_renderSurfaceTextureManager->reduceMemoryToLimit(textureMemoryReclaimLimitBytes - m_contentsTextureManager->currentMemoryUseBytes()); 243 if (TextureManager::reclaimLimitBytes() > m_contentsTextureMemoryUseBytes) 244 m_renderSurfaceTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBytes() - m_contentsTextureMemoryUseBytes); 272 245 else 273 246 m_renderSurfaceTextureManager->reduceMemoryToLimit(0); … … 284 257 285 258 TRACE_EVENT("LayerRendererChromium::drawLayers", this, 0); 286 CCLayerImpl* rootDrawLayer = rootLayer Impl();259 CCLayerImpl* rootDrawLayer = rootLayer(); 287 260 makeContextCurrent(); 288 261 … … 448 421 ManagedTexture* LayerRendererChromium::getOffscreenLayerTexture() 449 422 { 450 return settings().compositeOffscreen && rootLayer Impl() ? rootLayerImpl()->renderSurface()->contentsTexture() : 0;423 return settings().compositeOffscreen && rootLayer() ? rootLayer()->renderSurface()->contentsTexture() : 0; 451 424 } 452 425 … … 604 577 GLC(m_context.get(), m_context->flush()); 605 578 606 m_contentsTextureManager = TextureManager::create(textureMemoryHighLimitBytes, m_capabilities.maxTextureSize); 607 m_renderSurfaceTextureManager = TextureManager::create(textureMemoryHighLimitBytes, m_capabilities.maxTextureSize); 608 #ifndef NDEBUG 609 m_contentsTextureManager->setAssociatedContextDebugOnly(m_context.get()); 610 m_renderSurfaceTextureManager->setAssociatedContextDebugOnly(m_context.get()); 611 #endif 579 m_renderSurfaceTextureManager = TextureManager::create(TextureManager::highLimitBytes(), m_capabilities.maxTextureSize); 612 580 return true; 613 581 } … … 818 786 GLC(m_context.get(), m_context->deleteFramebuffer(m_offscreenFramebufferId)); 819 787 820 // Clear tilers before the texture manager, as they have references to textures. 821 m_contentsTextureManager->unprotectAllTextures(); 822 m_contentsTextureManager->reduceMemoryToLimit(0); 823 m_contentsTextureManager->deleteEvictedTextures(m_context.get()); 824 m_contentsTextureManager.clear(); 825 m_renderSurfaceTextureManager->unprotectAllTextures(); 826 m_renderSurfaceTextureManager->reduceMemoryToLimit(0); 827 m_renderSurfaceTextureManager->deleteEvictedTextures(m_context.get()); 828 m_renderSurfaceTextureManager.clear(); 788 ASSERT(!m_contentsTextureMemoryUseBytes); 789 releaseRenderSurfaceTextures(); 829 790 } 830 791 … … 833 794 TextStream ts; 834 795 if (rootLayer()) { 835 ts << rootLayer()-> platformLayer()->layerTreeAsText();796 ts << rootLayer()->layerTreeAsText(); 836 797 ts << "RenderSurfaces:\n"; 837 dumpRenderSurfaces(ts, 1, rootLayer() ->platformLayer());798 dumpRenderSurfaces(ts, 1, rootLayer()); 838 799 } 839 800 return ts.release(); 840 801 } 841 802 842 void LayerRendererChromium::dumpRenderSurfaces(TextStream& ts, int indent, const LayerChromium* layer) const803 void LayerRendererChromium::dumpRenderSurfaces(TextStream& ts, int indent, const CCLayerImpl* layer) const 843 804 { 844 805 if (layer->renderSurface()) -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r95014 r95100 75 75 class LayerRendererChromium : public RefCounted<LayerRendererChromium> { 76 76 public: 77 static PassRefPtr<LayerRendererChromium> create(CCLayerTreeHost *, CCLayerTreeHostImpl*, PassRefPtr<GraphicsContext3D>);77 static PassRefPtr<LayerRendererChromium> create(CCLayerTreeHostImpl*, PassRefPtr<GraphicsContext3D>); 78 78 79 79 // Must be called in order to allow the LayerRendererChromium to destruct … … 85 85 const LayerRendererCapabilities& capabilities() const { return m_capabilities; } 86 86 87 CCLayerTreeHost* owner() { return m_owner; } 88 const CCLayerTreeHost* owner() const { return m_owner; } 89 90 GraphicsLayer* rootLayer() { return m_owner->rootLayer(); } 91 const GraphicsLayer* rootLayer() const { return m_owner->rootLayer(); } 92 93 CCLayerImpl* rootLayerImpl() { return m_ownerImpl->rootLayer(); } 94 const CCLayerImpl* rootLayerImpl() const { return m_ownerImpl->rootLayer(); } 87 CCLayerImpl* rootLayer() { return m_owner->rootLayer(); } 88 const CCLayerImpl* rootLayer() const { return m_owner->rootLayer(); } 95 89 96 90 GraphicsContext3D* context(); 97 91 bool contextSupportsMapSub() const { return m_capabilities.usingMapSub; } 98 92 99 const IntSize& viewportSize() { return m_owner Impl->viewportSize(); }93 const IntSize& viewportSize() { return m_owner->viewportSize(); } 100 94 int viewportWidth() { return viewportSize().width(); } 101 95 int viewportHeight() { return viewportSize().height(); } … … 140 134 void getFramebufferPixels(void *pixels, const IntRect& rect); 141 135 142 TextureManager* contentsTextureManager() const { return m_contentsTextureManager.get(); }143 136 TextureManager* renderSurfaceTextureManager() const { return m_renderSurfaceTextureManager.get(); } 144 137 … … 151 144 bool isContextLost(); 152 145 153 void release Textures();146 void releaseRenderSurfaceTextures(); 154 147 155 148 GC3Denum bestTextureFormat(); … … 157 150 typedef Vector<RefPtr<CCLayerImpl> > CCLayerList; 158 151 159 // FIXME: Remove this when the contents texture manager has moved to CCLayerTreeHost. 160 static size_t textureMemoryReclaimLimit(); 152 void setContentsTextureMemoryUseBytes(size_t contentsTextureMemoryUseBytes) { m_contentsTextureMemoryUseBytes = contentsTextureMemoryUseBytes; } 161 153 162 154 private: 163 LayerRendererChromium(CCLayerTreeHost *, CCLayerTreeHostImpl*, PassRefPtr<GraphicsContext3D>);155 LayerRendererChromium(CCLayerTreeHostImpl*, PassRefPtr<GraphicsContext3D>); 164 156 bool initialize(); 165 157 … … 180 172 static bool compareLayerZ(const RefPtr<CCLayerImpl>&, const RefPtr<CCLayerImpl>&); 181 173 182 void dumpRenderSurfaces(TextStream&, int indent, const LayerChromium*) const;174 void dumpRenderSurfaces(TextStream&, int indent, const CCLayerImpl*) const; 183 175 184 176 bool initializeSharedObjects(); … … 187 179 void clearRenderSurfacesOnCCLayerImplRecursive(CCLayerImpl*); 188 180 189 // FIXME: Remove CCLayerTreeHost field 190 CCLayerTreeHost* m_owner; 191 192 CCLayerTreeHostImpl* m_ownerImpl; 181 CCLayerTreeHostImpl* m_owner; 193 182 194 183 LayerRendererCapabilities m_capabilities; … … 221 210 OwnPtr<CCVideoLayerImpl::YUVProgram> m_videoLayerYUVProgram; 222 211 223 OwnPtr<TextureManager> m_contentsTextureManager;212 size_t m_contentsTextureMemoryUseBytes; 224 213 OwnPtr<TextureManager> m_renderSurfaceTextureManager; 225 214 -
trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp
r95014 r95100 84 84 { 85 85 ASSERT(m_textureManager->hasTexture(m_token)); 86 ASSERT(context == m_textureManager->associatedContextDebugOnly());87 86 if (!m_textureId) 88 87 m_textureId = m_textureManager->allocateTexture(context, m_token); … … 93 92 { 94 93 ASSERT(m_textureManager->hasTexture(m_token)); 95 ASSERT(context == m_textureManager->associatedContextDebugOnly());96 94 if (!m_textureId) 97 95 m_textureId = m_textureManager->allocateTexture(context, m_token); -
trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h
r95014 r95100 47 47 virtual void pushPropertiesTo(CCLayerImpl*); 48 48 49 protected:50 virtual const char* layerTypeAsString() const { return "PluginLayer"; }51 52 49 private: 53 50 explicit PluginLayerChromium(GraphicsLayerChromium* owner); -
trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp
r95014 r95100 60 60 } 61 61 62 String RenderSurfaceChromium::name() const63 {64 return String::format("RenderSurface(id=%d,owner=%s)", m_owningLayer->id(), m_owningLayer->name().utf8().data());65 }66 67 static void writeIndent(TextStream& ts, int indent)68 {69 for (int i = 0; i != indent; ++i)70 ts << " ";71 }72 73 void RenderSurfaceChromium::dumpSurface(TextStream& ts, int indent) const74 {75 writeIndent(ts, indent);76 ts << name() << "\n";77 78 writeIndent(ts, indent+1);79 ts << "contentRect: (" << m_contentRect.x() << ", " << m_contentRect.y() << ", " << m_contentRect.width() << ", " << m_contentRect.height()80 << " scissorRect: (" << m_scissorRect.x() << ", " << m_scissorRect.y() << ", " << m_scissorRect.width() << ", " << m_scissorRect.height() << ")"81 << "\n";82 }83 84 62 } 85 63 #endif // USE(ACCELERATED_COMPOSITING) -
trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h
r95014 r95100 55 55 void draw(const IntRect& targetSurfaceRect); 56 56 57 String name() const;58 void dumpSurface(TextStream&, int indent) const;59 60 57 // Returns the rect that encloses the RenderSurface including any reflection. 61 58 FloatRect drawableContentRect() const; -
trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp
r95014 r95100 45 45 } 46 46 47 size_t TextureManager::highLimitBytes() 48 { 49 return 128 * 1024 * 1024; 50 } 51 52 size_t TextureManager::reclaimLimitBytes() 53 { 54 return 64 * 1024 * 1024; 55 } 56 57 size_t TextureManager::lowLimitBytes() 58 { 59 return 3 * 1024 * 1024; 60 } 61 47 62 TextureManager::TextureManager(size_t memoryLimitBytes, int maxTextureSize) 48 63 : m_memoryLimitBytes(memoryLimitBytes) … … 140 155 void TextureManager::deleteEvictedTextures(GraphicsContext3D* context) 141 156 { 142 ASSERT(context == m_associatedContextDebugOnly); 143 for (size_t i = 0; i < m_evictedTextureIds.size(); ++i) { 144 if (m_evictedTextureIds[i]) 145 GLC(context, context->deleteTexture(m_evictedTextureIds[i])); 146 } 147 m_evictedTextureIds.clear(); 157 if (context) { 158 for (size_t i = 0; i < m_evictedTextures.size(); ++i) { 159 if (m_evictedTextures[i].textureId) { 160 #ifndef NDEBUG 161 ASSERT(m_evictedTextures[i].allocatingContext == context); 162 #endif 163 GLC(context, context->deleteTexture(m_evictedTextures[i].textureId)); 164 } 165 } 166 } 167 m_evictedTextures.clear(); 168 } 169 170 void TextureManager::evictAndDeleteAllTextures(GraphicsContext3D* context) 171 { 172 unprotectAllTextures(); 173 reduceMemoryToLimit(0); 174 deleteEvictedTextures(context); 148 175 } 149 176 … … 156 183 ASSERT(m_textureLRUSet.contains(token)); 157 184 m_textureLRUSet.remove(token); 158 m_evictedTextureIds.append(info.textureId); 185 EvictionEntry entry; 186 entry.textureId = info.textureId; 187 #ifndef NDEBUG 188 entry.allocatingContext = info.allocatingContext; 189 #endif 190 m_evictedTextures.append(entry); 159 191 } 160 192 161 193 unsigned TextureManager::allocateTexture(GraphicsContext3D* context, TextureToken token) 162 194 { 163 ASSERT(context == m_associatedContextDebugOnly);164 195 TextureMap::iterator it = m_textures.find(token); 165 196 ASSERT(it != m_textures.end()); … … 178 209 GLC(context, context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, info->format, info->size.width(), info->size.height(), 0, info->format, GraphicsContext3D::UNSIGNED_BYTE)); 179 210 info->textureId = textureId; 211 #ifndef NDEBUG 212 info->allocatingContext = context; 213 #endif 180 214 return textureId; 181 215 } … … 205 239 info.textureId = 0; 206 240 info.isProtected = true; 241 #ifndef NDEBUG 242 info.allocatingContext = 0; 243 #endif 207 244 addTexture(token, info); 208 245 return true; -
trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h
r95014 r95100 46 46 } 47 47 48 // Absolute maximum limit for texture allocations for this instance. 49 static size_t highLimitBytes(); 50 // Preferred texture size limit. Can be exceeded if needed. 51 static size_t reclaimLimitBytes(); 52 // The maximum texture memory usage when asked to release textures. 53 static size_t lowLimitBytes(); 54 48 55 void setMemoryLimitBytes(size_t); 49 56 … … 62 69 void deleteEvictedTextures(GraphicsContext3D*); 63 70 71 void evictAndDeleteAllTextures(GraphicsContext3D*); 72 64 73 void reduceMemoryToLimit(size_t); 65 74 size_t currentMemoryUseBytes() const { return m_memoryUseBytes; } 66 67 #ifndef NDEBUG68 void setAssociatedContextDebugOnly(GraphicsContext3D* context) { m_associatedContextDebugOnly = context; }69 GraphicsContext3D* associatedContextDebugOnly() const { return m_associatedContextDebugOnly; }70 #endif71 75 72 76 private: … … 78 82 unsigned textureId; 79 83 bool isProtected; 84 #ifndef NDEBUG 85 GraphicsContext3D* allocatingContext; 86 #endif 80 87 }; 81 88 … … 92 99 TextureToken m_nextToken; 93 100 101 struct EvictionEntry { 102 unsigned textureId; 94 103 #ifndef NDEBUG 95 GraphicsContext3D* m_associatedContextDebugOnly;104 GraphicsContext3D* allocatingContext; 96 105 #endif 106 }; 97 107 98 Vector< unsigned> m_evictedTextureIds;108 Vector<EvictionEntry> m_evictedTextures; 99 109 }; 100 110 -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
r95014 r95100 266 266 } 267 267 268 static void writeIndent(TextStream& ts, int indent)269 {270 for (int i = 0; i != indent; ++i)271 ts << " ";272 }273 274 void TiledLayerChromium::dumpLayerProperties(TextStream& ts, int indent) const275 {276 LayerChromium::dumpLayerProperties(ts, indent);277 writeIndent(ts, indent);278 ts << "skipsDraw: " << (!m_tiler || m_skipsDraw) << "\n";279 }280 281 268 TextureManager* TiledLayerChromium::textureManager() const 282 269 { -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
r95014 r95100 75 75 virtual PassRefPtr<CCLayerImpl> createCCLayerImpl(); 76 76 77 virtual void dumpLayerProperties(TextStream&, int indent) const;78 79 77 virtual void setLayerTreeHost(CCLayerTreeHost*); 80 78 -
trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h
r95014 r95100 64 64 protected: 65 65 virtual void cleanupResources(); 66 virtual const char* layerTypeAsString() const { return "VideoLayer"; }67 66 68 67 private: -
trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h
r95014 r95100 58 58 GraphicsContext3D* context() { return m_context; } 59 59 60 protected:61 virtual const char* layerTypeAsString() const { return "WebGLLayer"; }62 63 60 private: 64 61 explicit WebGLLayerChromium(GraphicsLayerChromium* owner); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.h
r95014 r95100 53 53 explicit CCCanvasLayerImpl(int); 54 54 55 virtual const char* layerTypeAsString() const { return "CanvasLayer"; } 56 55 57 unsigned m_textureId; 56 58 bool m_hasAlpha; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp
r95014 r95100 228 228 } 229 229 230 } 230 String CCLayerImpl::layerTreeAsText() const 231 { 232 TextStream ts; 233 dumpLayer(ts, 0); 234 return ts.release(); 235 } 236 237 void CCLayerImpl::dumpLayer(TextStream& ts, int indent) const 238 { 239 writeIndent(ts, indent); 240 ts << layerTypeAsString() << "(" << m_name << ")\n"; 241 dumpLayerProperties(ts, indent+2); 242 if (m_replicaLayer) { 243 writeIndent(ts, indent+2); 244 ts << "Replica:\n"; 245 m_replicaLayer->dumpLayer(ts, indent+3); 246 } 247 if (m_maskLayer) { 248 writeIndent(ts, indent+2); 249 ts << "Mask:\n"; 250 m_maskLayer->dumpLayer(ts, indent+3); 251 } 252 for (size_t i = 0; i < m_children.size(); ++i) 253 m_children[i]->dumpLayer(ts, indent+1); 254 } 255 256 } 257 231 258 232 259 #endif // USE(ACCELERATED_COMPOSITING) -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h
r95014 r95100 166 166 void setDrawableContentRect(const IntRect& rect) { m_drawableContentRect = rect; } 167 167 168 virtual void dumpLayerProperties(TextStream&, int indent) const;168 String layerTreeAsText() const; 169 169 170 170 protected: 171 171 explicit CCLayerImpl(int); 172 172 173 virtual void dumpLayerProperties(TextStream&, int indent) const; 173 174 static void writeIndent(TextStream&, int indent); 174 175 … … 177 178 friend class TreeSynchronizer; 178 179 void clearChildList(); // Warning: This does not preserve tree structure invariants and so is only exposed to the tree synchronizer. 180 181 virtual const char* layerTypeAsString() const { return "LayerChromium"; } 182 183 void dumpLayer(TextStream&, int indent) const; 179 184 180 185 // Properties internal to CCLayerImpl -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r95014 r95100 70 70 m_proxy->start(); 71 71 72 if (!m_proxy->initializeLayerRenderer( this))72 if (!m_proxy->initializeLayerRenderer()) 73 73 return false; 74 74 … … 87 87 m_proxy->setNeedsCommitAndRedraw(); 88 88 89 m_contentsTextureManager = TextureManager::create(TextureManager::highLimitBytes(), m_proxy->layerRendererCapabilities().maxTextureSize); 89 90 return true; 90 91 } … … 92 93 CCLayerTreeHost::~CCLayerTreeHost() 93 94 { 95 ASSERT(CCProxy::isMainThread()); 94 96 TRACE_EVENT("CCLayerTreeHost::~CCLayerTreeHost", this, 0); 95 97 m_proxy->stop(); 96 98 m_proxy.clear(); 99 m_updateList.clear(); 100 ASSERT(!m_contentsTextureManager || !m_contentsTextureManager->currentMemoryUseBytes()); 101 m_contentsTextureManager.clear(); 102 } 103 104 void CCLayerTreeHost::deleteContentsTextures(GraphicsContext3D* context) 105 { 106 ASSERT(CCProxy::isImplThread()); 107 if (m_contentsTextureManager) 108 m_contentsTextureManager->evictAndDeleteAllTextures(context); 97 109 } 98 110 … … 110 122 hostImpl->setSourceFrameNumber(frameNumber()); 111 123 112 contentsTextureManager()->reduceMemoryToLimit( hostImpl->layerRenderer()->textureMemoryReclaimLimit());124 contentsTextureManager()->reduceMemoryToLimit(TextureManager::reclaimLimitBytes()); 113 125 contentsTextureManager()->deleteEvictedTextures(hostImpl->context()); 114 126 … … 119 131 hostImpl->setZoomAnimatorScale(m_zoomAnimatorScale); 120 132 hostImpl->setViewport(viewportSize()); 133 134 hostImpl->layerRenderer()->setContentsTextureMemoryUseBytes(m_contentsTextureManager->currentMemoryUseBytes()); 135 m_contentsTextureManager->unprotectAllTextures(); 121 136 122 137 // Synchronize trees, if one exists at all... … … 146 161 void CCLayerTreeHost::didRecreateGraphicsContext(bool success) 147 162 { 163 m_contentsTextureManager->evictAndDeleteAllTextures(0); 164 148 165 if (rootLayer()) 149 166 rootLayer()->platformLayer()->cleanupResourcesRecursive(); … … 260 277 { 261 278 m_visible = visible; 262 m_proxy->setNeedsCommitAndRedraw(); 279 if (visible) 280 m_proxy->setNeedsCommitAndRedraw(); 281 else { 282 m_nonCompositedContentHost->protectVisibleTileTextures(); 283 m_contentsTextureManager->reduceMemoryToLimit(TextureManager::lowLimitBytes()); 284 m_contentsTextureManager->unprotectAllTextures(); 285 m_proxy->setNeedsCommit(); 286 } 263 287 } 264 288 … … 270 294 TextureManager* CCLayerTreeHost::contentsTextureManager() const 271 295 { 272 return m_ proxy->contentsTextureManager();296 return m_contentsTextureManager.get(); 273 297 } 274 298 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
r95014 r95100 158 158 void updateLayers(); 159 159 160 void deleteContentsTextures(GraphicsContext3D*); 161 160 162 protected: 161 163 CCLayerTreeHost(CCLayerTreeHostClient*, const CCSettings&); … … 185 187 OwnPtr<GraphicsLayer> m_rootLayer; 186 188 OwnPtr<NonCompositedContentHost> m_nonCompositedContentHost; 189 OwnPtr<TextureManager> m_contentsTextureManager; 187 190 188 191 LayerList m_updateList; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
r95014 r95100 75 75 TRACE_EVENT("CCLayerTreeHostImpl::drawLayers", this, 0); 76 76 ASSERT(m_layerRenderer); 77 if (m_layerRenderer-> owner()->rootLayer())77 if (m_layerRenderer->rootLayer()) 78 78 m_layerRenderer->drawLayers(); 79 79 … … 117 117 { 118 118 if (m_layerRenderer && !visible) 119 m_layerRenderer->release Textures();119 m_layerRenderer->releaseRenderSurfaceTextures(); 120 120 } 121 121 122 bool CCLayerTreeHostImpl::initializeLayerRenderer( CCLayerTreeHost* implHack,PassRefPtr<GraphicsContext3D> context)122 bool CCLayerTreeHostImpl::initializeLayerRenderer(PassRefPtr<GraphicsContext3D> context) 123 123 { 124 // If m_layerRenderer exists, then we are recovering from a lost context125 bool recreatingRenderer = m_layerRenderer;126 127 // First time layerRenderer creation128 124 RefPtr<LayerRendererChromium> layerRenderer; 129 if (!recreatingRenderer) 130 layerRenderer = LayerRendererChromium::create(implHack, this, context); 131 else 132 layerRenderer = LayerRendererChromium::create(m_layerRenderer->owner(), this, context); 133 125 layerRenderer = LayerRendererChromium::create(this, context); 134 126 135 127 // If creation failed, and we had asked for accelerated painting, disable accelerated painting … … 138 130 m_settings.acceleratePainting = false; 139 131 140 if (!recreatingRenderer) 141 layerRenderer = LayerRendererChromium::create(implHack, this, context); 142 else 143 layerRenderer = LayerRendererChromium::create(m_layerRenderer->owner(), this, context); 132 layerRenderer = LayerRendererChromium::create(this, context); 133 } 134 135 // If we had a previous layer renderer, then its context must have been lost along with all of its resources. 136 // Let the old layer renderer known its resources are gone. 137 if (m_layerRenderer) { 138 m_layerRenderer->setContentsTextureMemoryUseBytes(0); 139 m_layerRenderer->close(); 144 140 } 145 141 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h
r95014 r95100 57 57 int frameNumber() const { return m_frameNumber; } 58 58 59 bool initializeLayerRenderer( CCLayerTreeHost* ownerHack,PassRefPtr<GraphicsContext3D>);59 bool initializeLayerRenderer(PassRefPtr<GraphicsContext3D>); 60 60 bool isContextLost(); 61 61 LayerRendererChromium* layerRenderer() { return m_layerRenderer.get(); } … … 78 78 void setZoomAnimatorScale(double); 79 79 80 const CCSettings& settings() const { return m_settings; } 80 81 protected: 81 82 explicit CCLayerTreeHostImpl(const CCSettings&); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h
r95014 r95100 52 52 explicit CCPluginLayerImpl(int); 53 53 54 virtual const char* layerTypeAsString() const { return "PluginLayer"; } 55 54 56 unsigned m_textureId; 55 57 }; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h
r95014 r95100 59 59 virtual bool isStarted() const = 0; 60 60 61 virtual bool initializeLayerRenderer( CCLayerTreeHost* ownerHack) = 0;61 virtual bool initializeLayerRenderer() = 0; 62 62 63 63 virtual const LayerRendererCapabilities& layerRendererCapabilities() const = 0; 64 64 65 virtual void setNeedsCommit() = 0; 65 66 virtual void setNeedsCommitAndRedraw() = 0; 66 67 virtual void setNeedsRedraw() = 0; … … 81 82 virtual GraphicsContext3D* context() = 0; 82 83 83 // Temporary hack while LayerChromiums hold references to LayerRendererChromiums84 virtual TextureManager* contentsTextureManager() = 0;85 86 84 protected: 87 85 CCProxy() { } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp
r95014 r95100 122 122 } 123 123 124 bool CCSingleThreadProxy::initializeLayerRenderer(CCLayerTreeHost* ownerHack) 125 { 124 bool CCSingleThreadProxy::initializeLayerRenderer() 125 { 126 ASSERT(isMainThread()); 126 127 RefPtr<GraphicsContext3D> context = m_layerTreeHost->createLayerTreeHostContext3D(); 127 128 if (!context) … … 131 132 { 132 133 ScopedSetImplThread impl; 133 return m_layerTreeHostImpl->initializeLayerRenderer( ownerHack,context);134 return m_layerTreeHostImpl->initializeLayerRenderer(context); 134 135 } 135 136 } … … 145 146 m_graphicsContextLost = true; 146 147 m_timesRecreateShouldFail = numTimes - 1; 148 } 149 150 void CCSingleThreadProxy::setNeedsCommit() 151 { 152 ASSERT(isMainThread()); 153 // Commit immediately 154 { 155 ScopedSetImplThread impl; 156 m_layerTreeHostImpl->beginCommit(); 157 m_layerTreeHost->commitTo(m_layerTreeHostImpl.get()); 158 m_layerTreeHostImpl->commitComplete(); 159 } 147 160 } 148 161 … … 171 184 { 172 185 ScopedSetImplThread impl; 186 m_layerTreeHost->deleteContentsTextures(m_layerTreeHostImpl->context()); 173 187 m_layerTreeHostImpl.clear(); 174 188 } 175 189 m_layerTreeHost = 0; 176 }177 178 TextureManager* CCSingleThreadProxy::contentsTextureManager()179 {180 return m_layerTreeHostImpl->layerRenderer()->contentsTextureManager();181 190 } 182 191 … … 198 207 bool CCSingleThreadProxy::recreateContextIfNeeded() 199 208 { 209 ASSERT(isMainThread()); 200 210 if (!m_graphicsContextLost) 201 211 return true; … … 208 218 if (context) { 209 219 ASSERT(context->hasOneRef()); 210 if (m_layerTreeHostImpl->initializeLayerRenderer( 0,context)) {220 if (m_layerTreeHostImpl->initializeLayerRenderer(context)) { 211 221 m_layerTreeHost->didRecreateGraphicsContext(true); 212 222 m_graphicsContextLost = false; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h
r95014 r95100 45 45 virtual void finishAllRendering(); 46 46 virtual bool isStarted() const; 47 virtual bool initializeLayerRenderer( CCLayerTreeHost* ownerHack);47 virtual bool initializeLayerRenderer(); 48 48 virtual const LayerRendererCapabilities& layerRendererCapabilities() const; 49 49 virtual void loseCompositorContext(int numTimes); 50 virtual void setNeedsCommit(); 50 51 virtual void setNeedsCommitAndRedraw(); 51 52 virtual void setNeedsRedraw(); 52 53 virtual void start(); 53 54 virtual void stop(); 54 55 // Temporary hack while LayerChromiums hold references to LayerRendererChromiums56 virtual TextureManager* contentsTextureManager();57 55 58 56 // Special case functions. -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
r95014 r95100 99 99 } 100 100 101 bool CCThreadProxy::initializeLayerRenderer( CCLayerTreeHost* ownerHack)101 bool CCThreadProxy::initializeLayerRenderer() 102 102 { 103 103 RefPtr<GraphicsContext3D> context = m_layerTreeHost->createLayerTreeHostContext3D(); … … 116 116 LayerRendererCapabilities capabilities; 117 117 ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::initializeLayerRendererOnCCThread, 118 AllowCrossThreadAccess(ownerHack), AllowCrossThreadAccess(contextPtr), 119 AllowCrossThreadAccess(&completion), AllowCrossThreadAccess(&initializeSucceeded), AllowCrossThreadAccess(&capabilities))); 118 AllowCrossThreadAccess(contextPtr), AllowCrossThreadAccess(&completion), AllowCrossThreadAccess(&initializeSucceeded), AllowCrossThreadAccess(&capabilities))); 120 119 completion.wait(); 121 120 … … 135 134 } 136 135 136 void CCThreadProxy::setNeedsCommit() 137 { 138 ASSERT(isMainThread()); 139 if (m_commitPending) 140 return; 141 142 TRACE_EVENT("CCThreadProxy::setNeedsCommit", this, 0); 143 m_commitPending = true; 144 ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::setNeedsCommitOnCCThread)); 145 } 146 137 147 void CCThreadProxy::setNeedsCommitAndRedraw() 138 148 { … … 171 181 ASSERT(!m_layerTreeHostImpl); // verify that the impl deleted. 172 182 m_layerTreeHost = 0; 173 }174 175 TextureManager* CCThreadProxy::contentsTextureManager()176 {177 ASSERT_NOT_REACHED();178 return 0;179 183 } 180 184 … … 230 234 } 231 235 236 void CCThreadProxy::setNeedsCommitOnCCThread() 237 { 238 TRACE_EVENT("CCThreadProxy::setNeedsCommitOnCCThread", this, 0); 239 ASSERT(isImplThread()); 240 ASSERT(m_layerTreeHostImpl); 241 // FIXME: Not yet implemented, see https://bugs.webkit.org/show_bug.cgi?id=67417 242 ASSERT_NOT_REACHED(); 243 } 244 232 245 void CCThreadProxy::setNeedsCommitAndRedrawOnCCThread() 233 246 { … … 252 265 } 253 266 254 void CCThreadProxy::initializeLayerRendererOnCCThread( CCLayerTreeHost* ownerHack,GraphicsContext3D* contextPtr, CCCompletionEvent* completion, bool* initializeSucceeded, LayerRendererCapabilities* capabilities)267 void CCThreadProxy::initializeLayerRendererOnCCThread(GraphicsContext3D* contextPtr, CCCompletionEvent* completion, bool* initializeSucceeded, LayerRendererCapabilities* capabilities) 255 268 { 256 269 TRACE_EVENT("CCThreadProxy::initializeLayerRendererOnCCThread", this, 0); 257 270 ASSERT(isImplThread()); 258 271 RefPtr<GraphicsContext3D> context(adoptRef(contextPtr)); 259 *initializeSucceeded = m_layerTreeHostImpl->initializeLayerRenderer( ownerHack,context);272 *initializeSucceeded = m_layerTreeHostImpl->initializeLayerRenderer(context); 260 273 if (*initializeSucceeded) 261 274 *capabilities = m_layerTreeHostImpl->layerRendererCapabilities(); … … 267 280 TRACE_EVENT("CCThreadProxy::layerTreeHostClosedOnCCThread", this, 0); 268 281 ASSERT(isImplThread()); 282 m_layerTreeHost->deleteContentsTextures(m_layerTreeHostImpl->context()); 269 283 m_layerTreeHostImpl.clear(); 270 284 completion->signal(); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h
r95014 r95100 46 46 virtual void finishAllRendering(); 47 47 virtual bool isStarted() const; 48 virtual bool initializeLayerRenderer( CCLayerTreeHost* ownerHack);48 virtual bool initializeLayerRenderer(); 49 49 virtual const LayerRendererCapabilities& layerRendererCapabilities() const; 50 50 virtual void loseCompositorContext(int numTimes); 51 virtual void setNeedsCommit(); 51 52 virtual void setNeedsCommitAndRedraw(); 52 53 virtual void setNeedsRedraw(); 53 54 virtual void start(); 54 55 virtual void stop(); 55 56 // Temporary hack while LayerChromiums hold references to LayerRendererChromiums57 virtual TextureManager* contentsTextureManager();58 56 59 57 private: … … 68 66 void drawLayersOnCCThread(); 69 67 void initializeImplOnCCThread(CCCompletionEvent*); 70 void initializeLayerRendererOnCCThread(CCLayerTreeHost*, GraphicsContext3D*, CCCompletionEvent*, bool* initializeSucceeded, LayerRendererCapabilities*); 68 void initializeLayerRendererOnCCThread(GraphicsContext3D*, CCCompletionEvent*, bool* initializeSucceeded, LayerRendererCapabilities*); 69 void setNeedsCommitOnCCThread(); 71 70 void setNeedsCommitAndRedrawOnCCThread(); 72 71 void setNeedsRedrawOnCCThread(); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp
r95014 r95100 76 76 void CCTiledLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const 77 77 { 78 CCLayerImpl::dumpLayerProperties(ts, indent); 78 79 writeIndent(ts, indent); 79 CCLayerImpl::dumpLayerProperties(ts, indent);80 ts << "skipsDraw: " << (!m_tiler || m_skipsDraw) << "\n"; 80 81 } 81 82 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.h
r95014 r95100 68 68 explicit CCTiledLayerImpl(int id); 69 69 70 virtual const char* layerTypeAsString() const { return "ContentLayer"; } 71 70 72 // Draw all tiles that intersect with the content rect. 71 73 void draw(LayerRendererChromium*, const IntRect& contentRect, const TransformationMatrix&, float opacity); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h
r95014 r95100 59 59 explicit CCVideoLayerImpl(int); 60 60 61 virtual const char* layerTypeAsString() const { return "VideoLayer"; } 62 61 63 struct Texture { 62 64 Platform3DObject id;
Note: See TracChangeset
for help on using the changeset viewer.