Changeset 92900 in webkit
- Timestamp:
- Aug 11, 2011 7:07:24 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 20 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r92897 r92900 1 2011-08-11 James Robinson <jamesr@chromium.org> 2 3 [chromium] Defer managed texture creation and destruction until updateCompositorResources 4 https://bugs.webkit.org/show_bug.cgi?id=64772 5 6 Reviewed by Kenneth Russell. 7 8 This adds support for deferring GraphicsContext3D calls for texture creation and destruction for managed 9 textures and defers these calls until updateCompositorResources() for contents textures. The primary benefit of 10 this change is that it decouples managing the texture budget for the next frame (which has to happen before 11 painting layer contents) from the actual GL calls that create/destroy textures. That way, in the threaded 12 compositing world we can continue to use textures from the previous frame while software painting contents for 13 the next frame into software buffers or SkPictures. 14 15 Also renames LayerTexture to ManagedTexture to better reflect what it is. Not all ManagedTextures we create are 16 necessarily associated with layers, but they are all managed by a TextureManager. 17 18 Covered by compositing/ layout tests. 19 20 * WebCore.gypi: 21 * platform/graphics/chromium/ContentLayerChromium.h: 22 * platform/graphics/chromium/ImageLayerChromium.cpp: 23 (WebCore::ImageLayerTextureUpdater::updateTextureRect): 24 * platform/graphics/chromium/LayerRendererChromium.cpp: 25 (WebCore::LayerRendererChromium::releaseTextures): 26 (WebCore::LayerRendererChromium::drawLayers): 27 (WebCore::LayerRendererChromium::updateLayers): 28 (WebCore::LayerRendererChromium::getOffscreenLayerTexture): 29 (WebCore::LayerRendererChromium::useRenderSurface): 30 (WebCore::LayerRendererChromium::initializeSharedObjects): 31 * platform/graphics/chromium/LayerRendererChromium.h: 32 * platform/graphics/chromium/LayerTextureUpdater.h: 33 * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp: 34 (WebCore::LayerTextureUpdaterBitmap::updateTextureRect): 35 (WebCore::LayerTextureUpdaterSkPicture::updateTextureRect): 36 * platform/graphics/chromium/LayerTextureUpdaterCanvas.h: 37 * platform/graphics/chromium/LayerTilerChromium.cpp: 38 (WebCore::LayerTilerChromium::getSingleTexture): 39 (WebCore::LayerTilerChromium::createTile): 40 (WebCore::LayerTilerChromium::updateRect): 41 (WebCore::LayerTilerChromium::drawTiles): 42 * platform/graphics/chromium/LayerTilerChromium.h: 43 (WebCore::LayerTilerChromium::Tile::Tile): 44 (WebCore::LayerTilerChromium::Tile::texture): 45 * platform/graphics/chromium/ManagedTexture.cpp: Renamed from Source/WebCore/platform/graphics/chromium/LayerTexture.cpp. 46 (WebCore::ManagedTexture::ManagedTexture): 47 (WebCore::ManagedTexture::~ManagedTexture): 48 (WebCore::ManagedTexture::isValid): 49 (WebCore::ManagedTexture::reserve): 50 (WebCore::ManagedTexture::unreserve): 51 (WebCore::ManagedTexture::bindTexture): 52 (WebCore::ManagedTexture::framebufferTexture2D): 53 * platform/graphics/chromium/ManagedTexture.h: Renamed from Source/WebCore/platform/graphics/chromium/LayerTexture.h. 54 (WebCore::ManagedTexture::create): 55 (WebCore::ManagedTexture::format): 56 (WebCore::ManagedTexture::isReserved): 57 * platform/graphics/chromium/RenderSurfaceChromium.h: 58 * platform/graphics/chromium/TextureManager.cpp: 59 (WebCore::TextureManager::TextureManager): 60 (WebCore::TextureManager::deleteEvictedTextures): 61 (WebCore::TextureManager::removeTexture): 62 (WebCore::TextureManager::allocateTexture): 63 (WebCore::TextureManager::requestTexture): 64 * platform/graphics/chromium/TextureManager.h: 65 (WebCore::TextureManager::create): 66 (WebCore::TextureManager::setAssociatedContextDebugOnly): 67 (WebCore::TextureManager::associatedContextDebugOnly): 68 * platform/graphics/chromium/TiledLayerChromium.h: 69 * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: 70 (WebCore::CCHeadsUpDisplay::draw): 71 * platform/graphics/chromium/cc/CCHeadsUpDisplay.h: 72 * platform/graphics/chromium/cc/CCRenderSurface.cpp: 73 (WebCore::CCRenderSurface::prepareContentsTexture): 74 (WebCore::CCRenderSurface::drawSurface): 75 * platform/graphics/chromium/cc/CCRenderSurface.h: 76 (WebCore::CCRenderSurface::contentsTexture): 77 * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp: 78 (WebCore::CCTiledLayerImpl::bindContentsTexture): 79 1 80 2011-08-11 David Kilzer <ddkilzer@apple.com> 2 81 -
trunk/Source/WebCore/WebCore.gypi
r92890 r92900 3502 3502 'platform/graphics/chromium/LayerRendererChromium.cpp', 3503 3503 'platform/graphics/chromium/LayerRendererChromium.h', 3504 'platform/graphics/chromium/ LayerTexture.cpp',3505 'platform/graphics/chromium/ LayerTexture.h',3504 'platform/graphics/chromium/ManagedTexture.cpp', 3505 'platform/graphics/chromium/ManagedTexture.h', 3506 3506 'platform/graphics/chromium/LayerTextureSubImage.cpp', 3507 3507 'platform/graphics/chromium/LayerTextureSubImage.h', -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h
r91823 r92900 40 40 namespace WebCore { 41 41 42 class LayerTexture;43 42 class LayerTilerChromium; 44 43 class LayerTextureUpdater; -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
r90963 r92900 38 38 #include "Image.h" 39 39 #include "LayerRendererChromium.h" 40 #include " LayerTexture.h"40 #include "ManagedTexture.h" 41 41 #include "LayerTextureSubImage.h" 42 42 #include "LayerTextureUpdater.h" … … 68 68 } 69 69 70 virtual void updateTextureRect( LayerTexture* texture, const IntRect& sourceRect, const IntRect& destRect)70 virtual void updateTextureRect(ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) 71 71 { 72 texture->bindTexture( );72 texture->bindTexture(context()); 73 73 74 74 // Source rect should never go outside the image pixels, even if this -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r92895 r92900 42 42 #include "LayerChromium.h" 43 43 #include "LayerPainterChromium.h" 44 #include " LayerTexture.h"44 #include "ManagedTexture.h" 45 45 #include "LayerTextureUpdaterCanvas.h" 46 46 #include "NotImplemented.h" … … 521 521 m_contentsTextureManager->reduceMemoryToLimit(textureMemoryLowLimitBytes); 522 522 m_contentsTextureManager->unprotectAllTextures(); 523 m_contentsTextureManager->deleteEvictedTextures(m_context.get()); 523 524 // Evict all RenderSurface textures. 524 525 m_renderSurfaceTextureManager->unprotectAllTextures(); 525 526 m_renderSurfaceTextureManager->reduceMemoryToLimit(0); 527 m_renderSurfaceTextureManager->deleteEvictedTextures(m_context.get()); 526 528 } 527 529 … … 604 606 605 607 m_contentsTextureManager->unprotectAllTextures(); 606 m_contentsTextureManager->reduceMemoryToLimit(textureMemoryReclaimLimitBytes);607 608 608 609 if (textureMemoryReclaimLimitBytes > m_contentsTextureManager->currentMemoryUseBytes()) … … 610 611 else 611 612 m_renderSurfaceTextureManager->reduceMemoryToLimit(0); 613 m_renderSurfaceTextureManager->deleteEvictedTextures(m_context.get()); 612 614 613 615 if (settings().compositeOffscreen) … … 655 657 656 658 m_contentsTextureManager->reduceMemoryToLimit(textureMemoryReclaimLimitBytes); 659 m_contentsTextureManager->deleteEvictedTextures(m_context.get()); 657 660 updateCompositorResources(renderSurfaceLayerList); 658 661 } … … 983 986 } 984 987 985 LayerTexture* LayerRendererChromium::getOffscreenLayerTexture()988 ManagedTexture* LayerRendererChromium::getOffscreenLayerTexture() 986 989 { 987 990 return settings().compositeOffscreen && m_rootCCLayerImpl ? m_rootCCLayerImpl->renderSurface()->contentsTexture() : 0; … … 1023 1026 return false; 1024 1027 1025 renderSurface->contentsTexture()->framebufferTexture2D( );1028 renderSurface->contentsTexture()->framebufferTexture2D(m_context.get()); 1026 1029 1027 1030 #if !defined ( NDEBUG ) … … 1160 1163 GLC(m_context.get(), m_context->flush()); 1161 1164 1162 m_contentsTextureManager = TextureManager::create(m_context.get(), textureMemoryHighLimitBytes, m_maxTextureSize); 1163 m_renderSurfaceTextureManager = TextureManager::create(m_context.get(), textureMemoryHighLimitBytes, m_maxTextureSize); 1165 m_contentsTextureManager = TextureManager::create(textureMemoryHighLimitBytes, m_maxTextureSize); 1166 m_renderSurfaceTextureManager = TextureManager::create(textureMemoryHighLimitBytes, m_maxTextureSize); 1167 #ifndef NDEBUG 1168 m_contentsTextureManager->setAssociatedContextDebugOnly(m_context.get()); 1169 m_renderSurfaceTextureManager->setAssociatedContextDebugOnly(m_context.get()); 1170 #endif 1164 1171 return true; 1165 1172 } -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r92895 r92900 179 179 180 180 void drawRootLayer(); 181 LayerTexture* getOffscreenLayerTexture();181 ManagedTexture* getOffscreenLayerTexture(); 182 182 void copyOffscreenTextureToDisplay(); 183 183 -
trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h
r90963 r92900 37 37 class IntRect; 38 38 class IntSize; 39 class LayerTexture;39 class ManagedTexture; 40 40 41 41 class LayerTextureUpdater { … … 62 62 virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0; 63 63 virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0; 64 virtual void updateTextureRect( LayerTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;64 virtual void updateTextureRect(ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0; 65 65 66 66 protected: -
trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp
r92541 r92900 34 34 #include "GraphicsContext.h" 35 35 #include "LayerPainterChromium.h" 36 #include " LayerTexture.h"36 #include "ManagedTexture.h" 37 37 #include "PlatformColor.h" 38 38 #include "TraceEvent.h" … … 95 95 } 96 96 97 void LayerTextureUpdaterBitmap::updateTextureRect( LayerTexture* texture, const IntRect& sourceRect, const IntRect& destRect)97 void LayerTextureUpdaterBitmap::updateTextureRect(ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) 98 98 { 99 99 PlatformCanvas::AutoLocker locker(&m_canvas); 100 100 101 texture->bindTexture( );101 texture->bindTexture(context()); 102 102 m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, texture->format(), context()); 103 103 } … … 146 146 } 147 147 148 void LayerTextureUpdaterSkPicture::updateTextureRect( LayerTexture* texture, const IntRect& sourceRect, const IntRect& destRect)148 void LayerTextureUpdaterSkPicture::updateTextureRect(ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) 149 149 { 150 150 if (m_createFrameBuffer) { … … 158 158 // Bind texture. 159 159 context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); 160 texture->framebufferTexture2D( );160 texture->framebufferTexture2D(context()); 161 161 ASSERT(context()->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE); 162 162 -
trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h
r89647 r92900 77 77 virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); 78 78 virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels); 79 virtual void updateTextureRect( LayerTexture*, const IntRect& sourceRect, const IntRect& destRect);79 virtual void updateTextureRect(ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); 80 80 81 81 private: … … 95 95 virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); 96 96 virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels); 97 virtual void updateTextureRect( LayerTexture*, const IntRect& sourceRect, const IntRect& destRect);97 virtual void updateTextureRect(ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); 98 98 99 99 private: -
trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp
r92867 r92900 36 36 #include "GraphicsContext3D.h" 37 37 #include "LayerRendererChromium.h" 38 #include " LayerTexture.h"38 #include "ManagedTexture.h" 39 39 #include "LayerTextureUpdater.h" 40 40 #include "PlatformColor.h" … … 88 88 } 89 89 90 LayerTexture* LayerTilerChromium::getSingleTexture()90 ManagedTexture* LayerTilerChromium::getSingleTexture() 91 91 { 92 92 if (m_tilingData.numTiles() != 1) … … 116 116 ASSERT(tile->refCount() == 1); 117 117 } else { 118 GraphicsContext3D* context = layerRendererContext();119 118 TextureManager* manager = layerRenderer()->contentsTextureManager(); 120 tile = adoptRef(new Tile( LayerTexture::create(context,manager)));119 tile = adoptRef(new Tile(ManagedTexture::create(manager))); 121 120 } 122 121 m_tiles.add(make_pair(i, j), tile); … … 356 355 CRASH(); 357 356 358 tile->texture()->bindTexture( );357 tile->texture()->bindTexture(context); 359 358 const GC3Dint filter = m_tilingData.borderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST; 360 359 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter)); … … 541 540 ASSERT(tile->texture()->isReserved()); 542 541 543 tile->texture()->bindTexture( );542 tile->texture()->bindTexture(context); 544 543 545 544 // Don't use tileContentRect here, as that contains the full -
trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h
r92255 r92900 31 31 32 32 #include "LayerChromium.h" 33 #include " LayerTexture.h"33 #include "ManagedTexture.h" 34 34 #include "LayerTextureUpdater.h" 35 35 #include "TilingData.h" … … 86 86 87 87 // If this tiler has exactly one tile, return its texture. Otherwise, null. 88 LayerTexture* getSingleTexture();88 ManagedTexture* getSingleTexture(); 89 89 90 90 private: … … 94 94 WTF_MAKE_NONCOPYABLE(Tile); 95 95 public: 96 explicit Tile(PassOwnPtr< LayerTexture> tex) : m_tex(tex), m_i(-1), m_j(-1) { }96 explicit Tile(PassOwnPtr<ManagedTexture> tex) : m_tex(tex), m_i(-1), m_j(-1) { } 97 97 98 LayerTexture* texture() { return m_tex.get(); }98 ManagedTexture* texture() { return m_tex.get(); } 99 99 100 100 bool dirty() const { return !m_dirtyLayerRect.isEmpty(); } … … 108 108 IntRect m_dirtyLayerRect; 109 109 private: 110 OwnPtr< LayerTexture> m_tex;110 OwnPtr<ManagedTexture> m_tex; 111 111 int m_i; 112 112 int m_j; -
trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp
r92897 r92900 27 27 #if USE(ACCELERATED_COMPOSITING) 28 28 29 #include " LayerTexture.h"29 #include "ManagedTexture.h" 30 30 31 31 #include "GraphicsContext3D.h" … … 34 34 namespace WebCore { 35 35 36 LayerTexture::LayerTexture(GraphicsContext3D* context, TextureManager* manager) 37 : m_context(context) 38 , m_textureManager(manager) 36 ManagedTexture::ManagedTexture(TextureManager* manager) 37 : m_textureManager(manager) 39 38 , m_token(0) 40 39 , m_format(0) … … 43 42 } 44 43 45 LayerTexture::~LayerTexture()44 ManagedTexture::~ManagedTexture() 46 45 { 47 46 if (m_token) … … 49 48 } 50 49 51 bool LayerTexture::isValid(const IntSize& size, unsigned format)50 bool ManagedTexture::isValid(const IntSize& size, unsigned format) 52 51 { 53 52 return m_token && size == m_size && format == m_format && m_textureManager->hasTexture(m_token); 54 53 } 55 54 56 bool LayerTexture::reserve(const IntSize& size, unsigned format)55 bool ManagedTexture::reserve(const IntSize& size, unsigned format) 57 56 { 58 57 if (!m_token) 59 58 m_token = m_textureManager->getToken(); 60 59 60 bool reserved = true; 61 61 if (size == m_size && format == m_format && m_textureManager->hasTexture(m_token)) 62 62 m_textureManager->protectTexture(m_token); 63 63 else { 64 m_textureId = m_textureManager->requestTexture(m_token, size, format); 65 if (m_textureId) { 64 m_textureId = 0; 65 reserved = m_textureManager->requestTexture(m_token, size, format); 66 if (reserved) { 66 67 m_size = size; 67 68 m_format = format; … … 69 70 } 70 71 71 return m_textureId;72 return reserved; 72 73 } 73 74 74 void LayerTexture::unreserve()75 void ManagedTexture::unreserve() 75 76 { 76 77 if (!m_token) … … 80 81 } 81 82 82 void LayerTexture::bindTexture()83 void ManagedTexture::bindTexture(GraphicsContext3D* context) 83 84 { 84 85 ASSERT(m_textureManager->hasTexture(m_token)); 85 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId); 86 ASSERT(context == m_textureManager->associatedContextDebugOnly()); 87 if (!m_textureId) 88 m_textureId = m_textureManager->allocateTexture(context, m_token); 89 context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId); 86 90 } 87 91 88 void LayerTexture::framebufferTexture2D()92 void ManagedTexture::framebufferTexture2D(GraphicsContext3D* context) 89 93 { 90 m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_textureId, 0); 94 ASSERT(m_textureManager->hasTexture(m_token)); 95 ASSERT(context == m_textureManager->associatedContextDebugOnly()); 96 if (!m_textureId) 97 m_textureId = m_textureManager->allocateTexture(context, m_token); 98 context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_textureId, 0); 91 99 } 92 100 -
trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.h
r92897 r92900 23 23 */ 24 24 25 #ifndef LayerTexture_h26 #define LayerTexture_h25 #ifndef ManagedTexture_h 26 #define ManagedTexture_h 27 27 28 28 #include "IntSize.h" … … 39 39 class TextureManager; 40 40 41 class LayerTexture {42 WTF_MAKE_NONCOPYABLE( LayerTexture); WTF_MAKE_FAST_ALLOCATED;41 class ManagedTexture { 42 WTF_MAKE_NONCOPYABLE(ManagedTexture); 43 43 public: 44 static PassOwnPtr< LayerTexture> create(GraphicsContext3D* context,TextureManager* manager)44 static PassOwnPtr<ManagedTexture> create(TextureManager* manager) 45 45 { 46 return adoptPtr(new LayerTexture(context,manager));46 return adoptPtr(new ManagedTexture(manager)); 47 47 } 48 ~ LayerTexture();48 ~ManagedTexture(); 49 49 50 50 unsigned format() const { return m_format; } … … 58 58 } 59 59 60 void bindTexture( );61 void framebufferTexture2D( );60 void bindTexture(GraphicsContext3D*); 61 void framebufferTexture2D(GraphicsContext3D*); 62 62 63 63 private: 64 LayerTexture(GraphicsContext3D*,TextureManager*);64 explicit ManagedTexture(TextureManager*); 65 65 66 RefPtr<GraphicsContext3D> m_context;67 66 TextureManager* m_textureManager; 68 67 TextureToken m_token; … … 74 73 } 75 74 76 #endif 75 #endif // ManagedTexture_h 77 76 -
trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h
r92245 r92900 42 42 class LayerChromium; 43 43 class LayerRendererChromium; 44 class LayerTexture;44 class ManagedTexture; 45 45 46 46 class RenderSurfaceChromium { -
trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp
r91629 r92900 39 39 } 40 40 41 TextureManager::TextureManager(GraphicsContext3D* context, size_t memoryLimitBytes, int maxTextureSize) 42 : m_context(context) 43 , m_memoryLimitBytes(memoryLimitBytes) 41 TextureManager::TextureManager(size_t memoryLimitBytes, int maxTextureSize) 42 : m_memoryLimitBytes(memoryLimitBytes) 44 43 , m_memoryUseBytes(0) 45 44 , m_maxTextureSize(maxTextureSize) … … 133 132 } 134 133 134 void TextureManager::deleteEvictedTextures(GraphicsContext3D* context) 135 { 136 ASSERT(context == m_associatedContextDebugOnly); 137 for (size_t i = 0; i < m_evictedTextureIds.size(); ++i) 138 GLC(context, context->deleteTexture(m_evictedTextureIds[i])); 139 m_evictedTextureIds.clear(); 140 } 141 135 142 void TextureManager::removeTexture(TextureToken token, TextureInfo info) 136 143 { … … 141 148 ASSERT(m_textureLRUSet.contains(token)); 142 149 m_textureLRUSet.remove(token); 143 GLC(m_context.get(), m_context->deleteTexture(info.textureId)); 144 } 145 146 unsigned TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format) 150 m_evictedTextureIds.append(info.textureId); 151 } 152 153 unsigned TextureManager::allocateTexture(GraphicsContext3D* context, TextureToken token) 154 { 155 ASSERT(context == m_associatedContextDebugOnly); 156 TextureMap::iterator it = m_textures.find(token); 157 ASSERT(it != m_textures.end()); 158 TextureInfo* info = &it.get()->second; 159 ASSERT(info->isProtected); 160 161 unsigned textureId; 162 GLC(context, textureId = context->createTexture()); 163 GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId)); 164 // Do basic linear filtering on resize. 165 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); 166 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); 167 // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE. 168 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); 169 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); 170 GLC(context, context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, info->format, info->size.width(), info->size.height(), 0, info->format, GraphicsContext3D::UNSIGNED_BYTE)); 171 info->textureId = textureId; 172 return textureId; 173 } 174 175 bool TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format) 147 176 { 148 177 if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize) 149 return 0;178 return false; 150 179 151 180 TextureMap::iterator it = m_textures.find(token); … … 157 186 size_t memoryRequiredBytes = memoryUseBytes(size, format); 158 187 if (memoryRequiredBytes > m_memoryLimitBytes) 159 return 0;188 return false; 160 189 161 190 reduceMemoryToLimit(m_memoryLimitBytes - memoryRequiredBytes); 162 191 if (m_memoryUseBytes + memoryRequiredBytes > m_memoryLimitBytes) 163 return 0; 164 165 unsigned textureId; 166 GLC(m_context.get(), textureId = m_context->createTexture()); 167 GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId)); 168 // Do basic linear filtering on resize. 169 GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); 170 GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); 171 // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE. 172 GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); 173 GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); 174 GLC(m_context.get(), m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE)); 192 return false; 193 175 194 TextureInfo info; 176 195 info.size = size; 177 196 info.format = format; 178 info.textureId = textureId;197 info.textureId = 0; 179 198 info.isProtected = true; 180 199 addTexture(token, info); 181 return t extureId;200 return true; 182 201 } 183 202 -
trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h
r91629 r92900 41 41 WTF_MAKE_NONCOPYABLE(TextureManager); 42 42 public: 43 static PassOwnPtr<TextureManager> create( GraphicsContext3D* context,size_t memoryLimitBytes, int maxTextureSize)43 static PassOwnPtr<TextureManager> create(size_t memoryLimitBytes, int maxTextureSize) 44 44 { 45 return adoptPtr(new TextureManager( context,memoryLimitBytes, maxTextureSize));45 return adoptPtr(new TextureManager(memoryLimitBytes, maxTextureSize)); 46 46 } 47 47 … … 52 52 bool hasTexture(TextureToken); 53 53 54 unsignedrequestTexture(TextureToken, IntSize, unsigned textureFormat);54 bool requestTexture(TextureToken, IntSize, unsigned textureFormat); 55 55 56 56 void protectTexture(TextureToken); … … 59 59 bool isProtected(TextureToken); 60 60 61 unsigned allocateTexture(GraphicsContext3D*, TextureToken); 62 void deleteEvictedTextures(GraphicsContext3D*); 63 61 64 void reduceMemoryToLimit(size_t); 62 65 size_t currentMemoryUseBytes() const { return m_memoryUseBytes; } 63 66 67 #ifndef NDEBUG 68 void setAssociatedContextDebugOnly(GraphicsContext3D* context) { m_associatedContextDebugOnly = context; } 69 GraphicsContext3D* associatedContextDebugOnly() const { return m_associatedContextDebugOnly; } 70 #endif 71 64 72 private: 65 TextureManager( GraphicsContext3D*,size_t memoryLimitBytes, int maxTextureSize);73 TextureManager(size_t memoryLimitBytes, int maxTextureSize); 66 74 67 75 struct TextureInfo { … … 75 83 void removeTexture(TextureToken, TextureInfo); 76 84 77 RefPtr<GraphicsContext3D> m_context;78 79 85 typedef HashMap<TextureToken, TextureInfo> TextureMap; 80 86 TextureMap m_textures; … … 85 91 int m_maxTextureSize; 86 92 TextureToken m_nextToken; 93 94 #ifndef NDEBUG 95 GraphicsContext3D* m_associatedContextDebugOnly; 96 #endif 97 98 Vector<unsigned> m_evictedTextureIds; 87 99 }; 88 100 -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
r92255 r92900 34 34 namespace WebCore { 35 35 36 class LayerTexture;37 36 class LayerTilerChromium; 38 37 class LayerTextureUpdater; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp
r92895 r92900 35 35 #include "LayerChromium.h" 36 36 #include "LayerRendererChromium.h" 37 #include " LayerTexture.h"37 #include "ManagedTexture.h" 38 38 #include "PlatformCanvas.h" 39 39 #include "TextRun.h" … … 97 97 GraphicsContext3D* context = m_layerRenderer->context(); 98 98 if (!m_hudTexture) 99 m_hudTexture = LayerTexture::create(context,m_layerRenderer->renderSurfaceTextureManager());99 m_hudTexture = ManagedTexture::create(m_layerRenderer->renderSurfaceTextureManager()); 100 100 101 101 // Use a fullscreen texture only if we need to... … … 124 124 PlatformCanvas::AutoLocker locker(&canvas); 125 125 126 m_hudTexture->bindTexture( );126 m_hudTexture->bindTexture(context); 127 127 bool uploadedViaMap = false; 128 128 if (m_useMapSubForUploads) { … … 146 146 ASSERT(program && program->initialized()); 147 147 GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); 148 m_hudTexture->bindTexture( );148 m_hudTexture->bindTexture(context); 149 149 GLC(context, context->useProgram(program->program())); 150 150 GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0)); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.h
r92895 r92900 38 38 class GraphicsContext3D; 39 39 class LayerRendererChromium; 40 class LayerTexture;40 class ManagedTexture; 41 41 42 42 // Class that handles drawing of composited render layers using GL. … … 72 72 double m_filteredFrameTime; 73 73 74 OwnPtr< LayerTexture> m_hudTexture;74 OwnPtr<ManagedTexture> m_hudTexture; 75 75 76 76 LayerRendererChromium* m_layerRenderer; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp
r92245 r92900 33 33 #include "LayerChromium.h" 34 34 #include "LayerRendererChromium.h" 35 #include " LayerTexture.h"35 #include "ManagedTexture.h" 36 36 #include "TextStream.h" 37 37 #include "cc/CCLayerImpl.h" … … 86 86 87 87 if (!m_contentsTexture) 88 m_contentsTexture = LayerTexture::create(layerRenderer()->context(),textureManager);88 m_contentsTexture = ManagedTexture::create(textureManager); 89 89 90 90 if (m_contentsTexture->isReserved()) … … 124 124 GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE0)); 125 125 GLC(context3D, context3D->uniform1i(maskProgram->fragmentShader().samplerLocation(), 0)); 126 m_contentsTexture->bindTexture( );126 m_contentsTexture->bindTexture(context3D); 127 127 GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE1)); 128 128 GLC(context3D, context3D->uniform1i(maskProgram->fragmentShader().maskSamplerLocation(), 1)); … … 137 137 if (!useMask) { 138 138 GLC(context3D, context3D->useProgram(program->program())); 139 m_contentsTexture->bindTexture( );139 m_contentsTexture->bindTexture(context3D); 140 140 GLC(context3D, context3D->uniform1i(program->fragmentShader().samplerLocation(), 0)); 141 141 shaderMatrixLocation = program->vertexShader().matrixLocation(); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h
r92245 r92900 42 42 class CCLayerImpl; 43 43 class LayerRendererChromium; 44 class LayerTexture;44 class ManagedTexture; 45 45 46 46 class CCRenderSurface { … … 92 92 typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlphaMask> MaskProgram; 93 93 94 LayerTexture* contentsTexture() const { return m_contentsTexture.get(); }94 ManagedTexture* contentsTexture() const { return m_contentsTexture.get(); } 95 95 96 96 int owningLayerId() const; … … 105 105 bool m_skipsDraw; 106 106 107 OwnPtr< LayerTexture> m_contentsTexture;107 OwnPtr<ManagedTexture> m_contentsTexture; 108 108 float m_drawOpacity; 109 109 TransformationMatrix m_drawTransform; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp
r92245 r92900 30 30 #include "cc/CCTiledLayerImpl.h" 31 31 32 #include "LayerRendererChromium.h" 33 32 34 #include <wtf/text/WTFString.h> 33 35 34 36 namespace WebCore { 35 37 36 class LayerTexture;38 class ManagedTexture; 37 39 38 40 CCTiledLayerImpl::CCTiledLayerImpl(int id) … … 58 60 ASSERT(m_tiler); 59 61 60 LayerTexture* texture = m_tiler->getSingleTexture();62 ManagedTexture* texture = m_tiler->getSingleTexture(); 61 63 ASSERT(texture); 62 64 63 texture->bindTexture( );65 texture->bindTexture(layerRenderer()->context()); 64 66 } 65 67
Note: See TracChangeset
for help on using the changeset viewer.