Changeset 122506 in webkit
- Timestamp:
- Jul 12, 2012 2:35:34 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 deleted
- 34 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r122503 r122506 1 2012-07-12 Eric Penner <epenner@google.com> 2 3 [chromium] Use CCTexture/TextureAllocator and remove TextureManager 4 https://bugs.webkit.org/show_bug.cgi?id=91001 5 6 Reviewed by Adrienne Walker. 7 8 Use CCTexture to clean up CCPrioritizedTexture::Backing. 9 Add TextureAllocator.h and remove remainder of TextureManager.h/cpp. 10 Minor move/refactoring of link/unlink in CCPrioritizedTexture. 11 Remove double initialization of the default memory limit. 12 13 Covered by existing tests (refactoring). 14 15 * WebCore.gypi: 16 * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp: 17 * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h: 18 (WebCore): 19 * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp: 20 * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h: 21 (WebCore): 22 * platform/graphics/chromium/ImageLayerChromium.cpp: 23 * platform/graphics/chromium/LayerRendererChromium.cpp: 24 (WebCore::LayerRendererChromium::initialize): 25 * platform/graphics/chromium/ManagedTexture.cpp: Removed. 26 * platform/graphics/chromium/ManagedTexture.h: Removed. 27 * platform/graphics/chromium/RenderSurfaceChromium.h: 28 (WebCore): 29 * platform/graphics/chromium/TextureAllocator.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h. 30 (WebCore): 31 (TextureAllocator): 32 (WebCore::TextureAllocator::~TextureAllocator): 33 * platform/graphics/chromium/TextureManager.cpp: Removed. 34 * platform/graphics/chromium/TextureManager.h: Removed. 35 * platform/graphics/chromium/TiledLayerChromium.cpp: 36 * platform/graphics/chromium/TrackingTextureAllocator.cpp: 37 (WebCore::TrackingTextureAllocator::createTexture): 38 (WebCore::TrackingTextureAllocator::deleteTexture): 39 * platform/graphics/chromium/TrackingTextureAllocator.h: 40 * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: 41 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: 42 (WebCore::CCLayerTreeHost::prioritizeTextures): 43 * platform/graphics/chromium/cc/CCLayerTreeHost.h: 44 (WebCore): 45 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: 46 (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl): 47 * platform/graphics/chromium/cc/CCPrioritizedTexture.cpp: 48 (WebCore::CCPrioritizedTexture::CCPrioritizedTexture): 49 (WebCore::CCPrioritizedTexture::setDimensions): 50 (WebCore::CCPrioritizedTexture::textureId): 51 (WebCore::CCPrioritizedTexture::bindTexture): 52 (WebCore::CCPrioritizedTexture::framebufferTexture2D): 53 (WebCore::CCPrioritizedTexture::link): 54 (WebCore): 55 (WebCore::CCPrioritizedTexture::unlink): 56 * platform/graphics/chromium/cc/CCPrioritizedTexture.h: 57 (WebCore): 58 (WebCore::CCPrioritizedTexture::bytes): 59 (CCPrioritizedTexture): 60 (WebCore::CCPrioritizedTexture::haveBackingTexture): 61 (WebCore::CCPrioritizedTexture::Backing::Backing): 62 (WebCore::CCPrioritizedTexture::Backing::~Backing): 63 (WebCore::CCPrioritizedTexture::Backing::owner): 64 (Backing): 65 (WebCore::CCPrioritizedTexture::backing): 66 * platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp: 67 (WebCore::CCPrioritizedTextureManager::prioritizeTextures): 68 (WebCore::CCPrioritizedTextureManager::requestLate): 69 (WebCore::CCPrioritizedTextureManager::acquireBackingTextureIfNeeded): 70 (WebCore::CCPrioritizedTextureManager::reduceMemory): 71 (WebCore::CCPrioritizedTextureManager::clearAllMemory): 72 (WebCore::CCPrioritizedTextureManager::registerTexture): 73 (WebCore::CCPrioritizedTextureManager::returnBackingTexture): 74 (WebCore::CCPrioritizedTextureManager::createBacking): 75 (WebCore::CCPrioritizedTextureManager::destroyBacking): 76 (WebCore::CCPrioritizedTextureManager::assertInvariants): 77 * platform/graphics/chromium/cc/CCPrioritizedTextureManager.h: 78 (CCPrioritizedTextureManager): 79 (WebCore::CCPrioritizedTextureManager::defaultMemoryAllocationLimit): 80 (WebCore::CCPrioritizedTextureManager::compareBackings): 81 * platform/graphics/chromium/cc/CCPriorityCalculator.h: 82 * platform/graphics/chromium/cc/CCScopedTexture.cpp: 83 * platform/graphics/chromium/cc/CCScopedTexture.h: 84 * platform/graphics/chromium/cc/CCTexture.h: 85 (WebCore::CCTexture::CCTexture): 86 * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp: 87 (WebCore): 88 * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp: 89 1 90 2012-07-12 Ryosuke Niwa <rniwa@webkit.org> 2 91 -
trunk/Source/WebCore/WebCore.gypi
r122484 r122506 8250 8250 'platform/graphics/chromium/LayerTextureSubImage.h', 8251 8251 'platform/graphics/chromium/LayerTextureUpdater.h', 8252 'platform/graphics/chromium/ManagedTexture.cpp',8253 'platform/graphics/chromium/ManagedTexture.h',8254 8252 'platform/graphics/chromium/PlatformCanvas.cpp', 8255 8253 'platform/graphics/chromium/PlatformCanvas.h', … … 8273 8271 'platform/graphics/chromium/TextureLayerChromium.cpp', 8274 8272 'platform/graphics/chromium/TextureLayerChromium.h', 8275 'platform/graphics/chromium/TextureManager.cpp', 8276 'platform/graphics/chromium/TextureManager.h', 8273 'platform/graphics/chromium/TextureAllocator.h', 8277 8274 'platform/graphics/chromium/TextureUploader.h', 8278 8275 'platform/graphics/chromium/ThrottledTextureUploader.cpp', -
trunk/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp
r121574 r122506 34 34 #include "PlatformColor.h" 35 35 #include "PlatformContextSkia.h" 36 #include "TextureAllocator.h" 36 37 #include "cc/CCGraphicsContext.h" 37 38 #include "skia/ext/platform_canvas.h" -
trunk/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h
r121574 r122506 39 39 class LayerPainterChromium; 40 40 class CCGraphicsContext; 41 class TextureAllocator; 41 42 42 43 // This class rasterizes the contentRect into a skia bitmap canvas. It then updates -
trunk/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp
r121574 r122506 35 35 #include "SkCanvas.h" 36 36 #include "SkDevice.h" 37 #include "TextureAllocator.h" 37 38 #include "cc/CCGraphicsContext.h" 38 39 -
trunk/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h
r121574 r122506 35 35 namespace WebCore { 36 36 37 class TextureAllocator; 38 37 39 // This class records the contentRect into an SkPicture, then software rasterizes 38 40 // the SkPicture into bitmaps for each tile. This implements CCSettings::perTilePainting. -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
r122373 r122506 37 37 #include "LayerTextureSubImage.h" 38 38 #include "LayerTextureUpdater.h" 39 #include "ManagedTexture.h"40 39 #include "PlatformColor.h" 41 40 #include "cc/CCLayerTreeHost.h" -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r122383 r122506 44 44 #include "SkBitmap.h" 45 45 #include "SkColor.h" 46 #include "TextureManager.h"47 46 #include "ThrottledTextureUploader.h" 48 47 #include "TraceEvent.h" … … 210 209 if (m_capabilities.usingGpuMemoryManager) 211 210 m_context->setMemoryAllocationChangedCallbackCHROMIUM(this); 212 else213 m_client->setMemoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize()));214 211 215 212 m_capabilities.usingDiscardFramebuffer = extensions.contains("GL_CHROMIUM_discard_framebuffer"); -
trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h
r120820 r122506 41 41 class LayerChromium; 42 42 class LayerRendererChromium; 43 class ManagedTexture;44 43 45 44 class RenderSurfaceChromium { -
trunk/Source/WebCore/platform/graphics/chromium/TextureAllocator.h
r122505 r122506 1 1 /* 2 * Copyright (C) 201 0, Google Inc. All rights reserved.2 * Copyright (C) 2012, Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 23 23 */ 24 24 25 #ifndef CCPriorityCalculator_h 26 #define CCPriorityCalculator_h 25 26 #ifndef TextureAllocator_h 27 #define TextureAllocator_h 27 28 28 29 #include "GraphicsContext3D.h" 29 30 #include "IntRect.h" 30 31 #include "IntSize.h" 31 #include "TextureManager.h"32 32 33 33 namespace WebCore { 34 34 35 class CCPriorityCalculator {35 class TextureAllocator { 36 36 public: 37 static int uiPriority(bool drawsToRootSurface); 38 static int visiblePriority(bool drawsToRootSurface); 39 static int renderSurfacePriority(); 40 static int lingeringPriority(int previousPriority); 41 int priorityFromDistance(const IntRect& visibleRect, const IntRect& textureRect, bool drawsToRootSurface) const; 42 int priorityFromDistance(unsigned pixels, bool drawsToRootSurface) const; 43 int priorityFromVisibility(bool visible, bool drawsToRootSurface) const; 37 virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0; 38 virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0; 39 virtual void deleteAllTextures() = 0; 44 40 45 static inline int highestPriority() { return std::numeric_limits<int>::min(); } 46 static inline int lowestPriority() { return std::numeric_limits<int>::max(); } 47 static inline bool priorityIsLower(int a, int b) { return a > b; } 48 static inline bool priorityIsHigher(int a, int b) { return a < b; } 41 protected: 42 virtual ~TextureAllocator() { } 49 43 }; 50 44 … … 52 46 53 47 #endif 48 49 -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
r122373 r122506 31 31 32 32 #include "GraphicsContext3D.h" 33 #include "ManagedTexture.h"34 33 #include "Region.h" 35 34 #include "TextStream.h" -
trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp
r122272 r122506 76 76 return 0; 77 77 78 m_currentMemoryUseBytes += TextureManager::memoryUseBytes(size, format);78 m_currentMemoryUseBytes += CCTexture::memorySizeBytes(size, format); 79 79 80 80 unsigned textureId = 0; … … 101 101 void TrackingTextureAllocator::deleteTexture(unsigned textureId, const IntSize& size, GC3Denum format) 102 102 { 103 m_currentMemoryUseBytes -= TextureManager::memoryUseBytes(size, format);103 m_currentMemoryUseBytes -= CCTexture::memorySizeBytes(size, format); 104 104 GLC(m_context, m_context->deleteTexture(textureId)); 105 105 GLC(m_context, m_context->deleteTexture(textureId)); -
trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h
r122272 r122506 26 26 #define TrackingTextureAllocator_h 27 27 28 #include "Texture Manager.h"28 #include "TextureAllocator.h" 29 29 #include <wtf/HashSet.h> 30 30 #include <wtf/PassRefPtr.h> -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp
r122272 r122506 32 32 #include "LayerRendererChromium.h" 33 33 #include "PlatformCanvas.h" 34 #include "TextureManager.h"35 34 #include "cc/CCDebugRectHistory.h" 36 35 #include "cc/CCFrameRateCounter.h" -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r122360 r122506 28 28 29 29 #include "LayerChromium.h" 30 #include "ManagedTexture.h"31 30 #include "Region.h" 32 31 #include "TraceEvent.h" … … 530 529 RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface(); 531 530 532 size_t bytes = TextureManager::memoryUseBytes(renderSurface->contentRect().size(), GraphicsContext3D::RGBA);531 size_t bytes = CCTexture::memorySizeBytes(renderSurface->contentRect().size(), GraphicsContext3D::RGBA); 533 532 contentsTextureBytes += bytes; 534 533 … … 539 538 maxBackgroundTextureBytes = bytes; 540 539 if (!readbackBytes) 541 readbackBytes = TextureManager::memoryUseBytes(m_deviceViewportSize, GraphicsContext3D::RGBA);540 readbackBytes = CCTexture::memorySizeBytes(m_deviceViewportSize, GraphicsContext3D::RGBA); 542 541 } 543 542 size_t renderSurfacesBytes = readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
r122360 r122506 52 52 class CCLayerTreeHostImplClient; 53 53 class CCTextureUpdater; 54 class ManagedTexture;55 54 class Region; 56 55 class TextureAllocator; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
r122373 r122506 43 43 #include "cc/CCOverdrawMetrics.h" 44 44 #include "cc/CCPageScaleAnimation.h" 45 #include "cc/CCPrioritizedTextureManager.h" 45 46 #include "cc/CCRenderPassDrawQuad.h" 46 47 #include "cc/CCSettings.h" … … 123 124 , m_visible(true) 124 125 , m_contentsTexturesWerePurgedSinceLastCommit(false) 125 , m_memoryAllocationLimitBytes( TextureManager::highLimitBytes(viewportSize()))126 , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAllocationLimit()) 126 127 , m_headsUpDisplay(CCHeadsUpDisplay::create()) 127 128 , m_pageScale(1) -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp
r121574 r122506 30 30 #include "CCPriorityCalculator.h" 31 31 #include "LayerRendererChromium.h" 32 #include "TextureAllocator.h" 32 33 #include <algorithm> 33 34 … … 39 40 : m_size(size) 40 41 , m_format(format) 41 , m_ memorySizeBytes(0)42 , m_bytes(0) 42 43 , m_priority(CCPriorityCalculator::lowestPriority()) 43 44 , m_isAbovePriorityCutoff(false) 44 , m_ currentBacking(0)45 , m_backing(0) 45 46 , m_manager(0) 46 47 { … … 48 49 ASSERT(format || size.isEmpty()); 49 50 if (format) 50 m_ memorySizeBytes = TextureManager::memoryUseBytes(size, format);51 m_bytes = CCTexture::memorySizeBytes(size, format); 51 52 if (manager) 52 53 manager->registerTexture(this); … … 75 76 m_format = format; 76 77 m_size = size; 77 m_ memorySizeBytes = TextureManager::memoryUseBytes(size, format);78 ASSERT(m_manager || !m_ currentBacking);78 m_bytes = CCTexture::memorySizeBytes(size, format); 79 ASSERT(m_manager || !m_backing); 79 80 if (m_manager) 80 81 m_manager->returnBackingTexture(this); … … 98 99 unsigned CCPrioritizedTexture::textureId() 99 100 { 100 if (m_ currentBacking)101 return m_ currentBacking->textureId();101 if (m_backing) 102 return m_backing->id(); 102 103 return 0; 103 104 } … … 108 109 if (m_isAbovePriorityCutoff) 109 110 acquireBackingTexture(allocator); 110 ASSERT(m_ currentBacking);111 ASSERT(m_backing); 111 112 WebKit::WebGraphicsContext3D* context3d = context->context3D(); 112 113 if (!context3d) { … … 122 123 if (m_isAbovePriorityCutoff) 123 124 acquireBackingTexture(allocator); 124 ASSERT(m_ currentBacking);125 ASSERT(m_backing); 125 126 WebKit::WebGraphicsContext3D* context3d = context->context3D(); 126 127 if (!context3d) { … … 131 132 } 132 133 133 void CCPrioritizedTexture:: setCurrentBacking(CCPrioritizedTexture::Backing* backing)134 void CCPrioritizedTexture::link(Backing* backing) 134 135 { 135 if (m_currentBacking == backing) 136 return; 137 m_currentBacking = backing; 136 ASSERT(backing); 137 ASSERT(!backing->m_owner); 138 ASSERT(!m_backing); 139 140 m_backing = backing; 141 m_backing->m_owner = this; 138 142 } 143 144 void CCPrioritizedTexture::unlink() 145 { 146 ASSERT(m_backing); 147 ASSERT(m_backing->m_owner == this); 148 149 m_backing->m_owner = 0; 150 m_backing = 0; 151 } 152 153 139 154 140 155 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h
r121574 r122506 27 27 28 28 #include "CCPriorityCalculator.h" 29 #include "CCTexture.h" 29 30 #include "GraphicsContext3D.h" 30 31 #include "IntRect.h" 31 32 #include "IntSize.h" 32 #include "TextureManager.h"33 33 34 34 namespace WebCore { … … 37 37 class CCPriorityCalculator; 38 38 class CCGraphicsContext; 39 class TextureAllocator; 39 40 40 41 class CCPrioritizedTexture { … … 58 59 GC3Denum format() const { return m_format; } 59 60 IntSize size() const { return m_size; } 60 size_t memorySizeBytes() const { return m_memorySizeBytes; }61 size_t bytes() const { return m_bytes; } 61 62 62 63 // Set priority for the requested texture. … … 69 70 70 71 // This returns whether we still have a backing texture. This can continue 71 // to be true even after canA quireBackingTexture() becomes false. In this72 // to be true even after canAcquireBackingTexture() becomes false. In this 72 73 // case the texture can be used but shouldn't be updated since it will get 73 74 // taken away "soon". 74 bool haveBackingTexture() const { return !! currentBacking(); }75 bool haveBackingTexture() const { return !!backing(); } 75 76 76 // If canA quireBackingTexture() is true acquireBackingTexture() will acquire77 // If canAcquireBackingTexture() is true acquireBackingTexture() will acquire 77 78 // a backing texture for use. Call this whenever the texture is actually needed. 78 79 void acquireBackingTexture(TextureAllocator*); … … 82 83 // by not painting occluded textures. In this case the manager 83 84 // refuses all visible textures and requestLate() will enable 84 // canA quireBackingTexture() on a call-order basis. We might want to85 // canAcquireBackingTexture() on a call-order basis. We might want to 85 86 // just remove this in the future (carefully) and just make sure we don't 86 87 // regress OOMs situations. 87 88 bool requestLate(); 88 89 89 // These functions will a quire the texture if possible. If neither haveBackingTexture()90 // nor canA quireBackingTexture() is true, an ID of zero will be used/returned.90 // These functions will acquire the texture if possible. If neither haveBackingTexture() 91 // nor canAcquireBackingTexture() is true, an ID of zero will be used/returned. 91 92 void bindTexture(CCGraphicsContext*, TextureAllocator*); 92 93 void framebufferTexture2D(CCGraphicsContext*, TextureAllocator*); … … 96 97 friend class CCPrioritizedTextureManager; 97 98 98 class Backing {99 class Backing : public CCTexture { 99 100 WTF_MAKE_NONCOPYABLE(Backing); 100 101 public: 101 IntSize size() const { return m_size; } 102 GC3Denum format() const { return m_format; } 103 size_t memorySizeBytes() const { return m_memorySizeBytes; } 104 unsigned textureId() const { return m_textureId; } 105 CCPrioritizedTexture* currentTexture() const { return m_currentTexture; } 106 void setCurrentTexture(CCPrioritizedTexture* current) { m_currentTexture = current; } 102 Backing(unsigned id, IntSize size, GC3Denum format) 103 : CCTexture(id, size, format), m_owner(0) { } 104 ~Backing() { ASSERT(!m_owner); } 107 105 106 CCPrioritizedTexture* owner() { return m_owner; } 108 107 private: 109 friend class CCPrioritizedTextureManager; 110 111 Backing(IntSize size, GC3Denum format, unsigned textureId) 112 : m_size(size) 113 , m_format(format) 114 , m_memorySizeBytes(TextureManager::memoryUseBytes(size, format)) 115 , m_textureId(textureId) 116 , m_priority(CCPriorityCalculator::lowestPriority()) 117 , m_currentTexture(0) { } 118 ~Backing() { ASSERT(!m_currentTexture); } 119 120 IntSize m_size; 121 GC3Denum m_format; 122 size_t m_memorySizeBytes; 123 unsigned m_textureId; 124 int m_priority; 125 CCPrioritizedTexture* m_currentTexture; 108 friend class CCPrioritizedTexture; 109 CCPrioritizedTexture* m_owner; 126 110 }; 127 111 … … 132 116 void setManagerInternal(CCPrioritizedTextureManager* manager) { m_manager = manager; } 133 117 134 Backing* currentBacking() const { return m_currentBacking; } 135 void setCurrentBacking(Backing*); 118 Backing* backing() const { return m_backing; } 119 void link(Backing*); 120 void unlink(); 136 121 137 122 IntSize m_size; 138 123 GC3Denum m_format; 139 size_t m_ memorySizeBytes;124 size_t m_bytes; 140 125 141 126 size_t m_priority; 142 127 bool m_isAbovePriorityCutoff; 143 128 144 Backing* m_ currentBacking;129 Backing* m_backing; 145 130 CCPrioritizedTextureManager* m_manager; 146 131 }; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp
r121870 r122506 98 98 } 99 99 100 size_t newMemoryBytes = memoryBytes + (*it)-> memorySizeBytes();100 size_t newMemoryBytes = memoryBytes + (*it)->bytes(); 101 101 if (newMemoryBytes > m_memoryAvailableBytes) { 102 102 m_priorityCutoff = (*it)->requestPriority(); … … 115 115 (*it)->setAbovePriorityCutoff(isAbovePriorityCutoff); 116 116 if (isAbovePriorityCutoff) 117 m_memoryAboveCutoffBytes += (*it)-> memorySizeBytes();117 m_memoryAboveCutoffBytes += (*it)->bytes(); 118 118 } 119 119 ASSERT(m_memoryAboveCutoffBytes <= m_memoryAvailableBytes); … … 158 158 return false; 159 159 160 size_t newMemoryBytes = m_memoryAboveCutoffBytes + texture-> memorySizeBytes();160 size_t newMemoryBytes = m_memoryAboveCutoffBytes + texture->bytes(); 161 161 if (newMemoryBytes > m_memoryAvailableBytes) 162 162 return false; … … 164 164 m_memoryAboveCutoffBytes = newMemoryBytes; 165 165 texture->setAbovePriorityCutoff(true); 166 if (texture-> currentBacking()) {167 m_backings.remove(texture-> currentBacking());168 m_backings.add(texture-> currentBacking());166 if (texture->backing()) { 167 m_backings.remove(texture->backing()); 168 m_backings.add(texture->backing()); 169 169 } 170 170 return true; … … 174 174 { 175 175 ASSERT(texture->isAbovePriorityCutoff()); 176 if (texture-> currentBacking() || !texture->isAbovePriorityCutoff())176 if (texture->backing() || !texture->isAbovePriorityCutoff()) 177 177 return; 178 178 … … 182 182 // First try to recycle 183 183 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { 184 if ((*it)-> currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff())184 if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()) 185 185 break; 186 186 if ((*it)->size() == texture->size() && (*it)->format() == texture->format()) { … … 192 192 // Otherwise reduce memory and just allocate a new backing texures. 193 193 if (!backing) { 194 reduceMemory(m_memoryAvailableBytes - texture-> memorySizeBytes(), allocator);194 reduceMemory(m_memoryAvailableBytes - texture->bytes(), allocator); 195 195 backing = createBacking(texture->size(), texture->format(), allocator); 196 196 } 197 197 198 198 // Move the used backing texture to the end of the eviction list. 199 if (backing-> currentTexture())200 unlink(backing->currentTexture(), backing);201 link(texture,backing);199 if (backing->owner()) 200 backing->owner()->unlink(); 201 texture->link(backing); 202 202 m_backings.remove(backing); 203 203 m_backings.add(backing); … … 212 212 while (memoryUseBytes() > limitBytes && m_backings.size() > 0) { 213 213 BackingSet::iterator it = m_backings.begin(); 214 if ((*it)-> currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff())214 if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()) 215 215 break; 216 216 destroyBacking((*it), allocator); … … 230 230 size_t wastedMemory = 0; 231 231 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { 232 if ((*it)-> currentTexture())233 break; 234 wastedMemory += (*it)-> memorySizeBytes();232 if ((*it)->owner()) 233 break; 234 wastedMemory += (*it)->bytes(); 235 235 } 236 236 size_t tenPercentOfMemory = m_memoryAvailableBytes / 10; … … 245 245 while (m_backings.size() > 0) { 246 246 BackingSet::iterator it = m_backings.begin(); 247 if ((*it)-> currentTexture())248 unlink((*it)->currentTexture(), (*it));247 if ((*it)->owner()) 248 (*it)->owner()->unlink(); 249 249 destroyBacking((*it), allocator); 250 250 } … … 259 259 } 260 260 261 void CCPrioritizedTextureManager::unlink(CCPrioritizedTexture* texture, CCPrioritizedTexture::Backing* backing)262 {263 ASSERT(texture && backing);264 ASSERT(texture->currentBacking() == backing);265 ASSERT(backing->currentTexture() == texture);266 267 texture->setCurrentBacking(0);268 backing->setCurrentTexture(0);269 }270 271 void CCPrioritizedTextureManager::link(CCPrioritizedTexture* texture, CCPrioritizedTexture::Backing* backing)272 {273 ASSERT(texture && backing);274 ASSERT(!texture->currentBacking());275 ASSERT(!backing->currentTexture());276 277 texture->setCurrentBacking(backing);278 backing->setCurrentTexture(texture);279 }280 281 282 261 void CCPrioritizedTextureManager::registerTexture(CCPrioritizedTexture* texture) 283 262 { 284 263 ASSERT(texture); 285 264 ASSERT(!texture->textureManager()); 286 ASSERT(!texture-> currentBacking());265 ASSERT(!texture->backing()); 287 266 ASSERT(m_textures.find(texture) == m_textures.end()); 288 267 … … 306 285 void CCPrioritizedTextureManager::returnBackingTexture(CCPrioritizedTexture* texture) 307 286 { 308 if (texture-> currentBacking()) {287 if (texture->backing()) { 309 288 // Move the backing texture to the front for eviction/recycling and unlink it. 310 m_backings.remove(texture-> currentBacking());311 m_backings.insertBefore(m_backings.begin(), texture-> currentBacking());312 unlink(texture, texture->currentBacking());289 m_backings.remove(texture->backing()); 290 m_backings.insertBefore(m_backings.begin(), texture->backing()); 291 texture->unlink(); 313 292 } 314 293 } … … 318 297 ASSERT(allocator); 319 298 320 unsigned textureId = allocator->createTexture(size, format); 321 CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(size, format, textureId); 322 m_memoryUseBytes += backing->memorySizeBytes(); 299 CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(allocator->createTexture(size, format), size, format); 300 m_memoryUseBytes += backing->bytes(); 323 301 // Put backing texture at the front for eviction, since it isn't in use yet. 324 302 m_backings.insertBefore(m_backings.begin(), backing); … … 329 307 { 330 308 ASSERT(backing); 331 ASSERT(!backing-> currentTexture() || !backing->currentTexture()->isAbovePriorityCutoff());309 ASSERT(!backing->owner() || !backing->owner()->isAbovePriorityCutoff()); 332 310 ASSERT(m_backings.find(backing) != m_backings.end()); 333 311 334 312 if (allocator) 335 allocator->deleteTexture(backing-> textureId(), backing->size(), backing->format());336 if (backing-> currentTexture())337 unlink(backing->currentTexture(), backing);338 m_memoryUseBytes -= backing-> memorySizeBytes();313 allocator->deleteTexture(backing->id(), backing->size(), backing->format()); 314 if (backing->owner()) 315 backing->owner()->unlink(); 316 m_memoryUseBytes -= backing->bytes(); 339 317 m_backings.remove(backing); 340 318 … … 352 330 // Backings/textures must be doubly-linked and only to other backings/textures in this manager. 353 331 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { 354 if ((*it)-> currentTexture()) {355 ASSERT(m_textures.find((*it)-> currentTexture()) != m_textures.end());356 ASSERT((*it)-> currentTexture()->currentBacking() == (*it));332 if ((*it)->owner()) { 333 ASSERT(m_textures.find((*it)->owner()) != m_textures.end()); 334 ASSERT((*it)->owner()->backing() == (*it)); 357 335 } 358 336 } 359 337 for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) { 360 if ((*it)-> currentBacking()) {361 ASSERT(m_backings.find((*it)-> currentBacking()) != m_backings.end());362 ASSERT((*it)-> currentBacking()->currentTexture() == (*it));338 if ((*it)->backing()) { 339 ASSERT(m_backings.find((*it)->backing()) != m_backings.end()); 340 ASSERT((*it)->backing()->owner() == (*it)); 363 341 } 364 342 } … … 369 347 bool reachedProtected = false; 370 348 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { 371 if ((*it)-> currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff())349 if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()) 372 350 reachedProtected = true; 373 351 if (reachedProtected) 374 ASSERT((*it)-> currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff());352 ASSERT((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()); 375 353 } 376 354 } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h
r121870 r122506 28 28 #include "CCPrioritizedTexture.h" 29 29 #include "CCPriorityCalculator.h" 30 #include "CCTexture.h" 30 31 #include "GraphicsContext3D.h" 31 32 #include "IntRect.h" 32 33 #include "IntSize.h" 33 #include "TextureManager.h"34 34 35 35 namespace WebCore { … … 50 50 } 51 51 ~CCPrioritizedTextureManager(); 52 53 // FIXME (http://crbug.com/137094): This 64MB default is a straggler from the 54 // old texture manager and is just to give us a default memory allocation before 55 // we get a callback from the GPU memory manager. We should probaby either: 56 // - wait for the callback before rendering anything instead 57 // - push this into the GPU memory manager somehow. 58 static size_t defaultMemoryAllocationLimit() { return 64 * 1024 * 1024; } 52 59 53 60 // memoryUseBytes() describes the number of bytes used by existing allocated textures. … … 92 99 static inline bool compareBackings(CCPrioritizedTexture::Backing* a, CCPrioritizedTexture::Backing* b) 93 100 { 94 int priorityA = a-> currentTexture() ? a->currentTexture()->requestPriority() : CCPriorityCalculator::lowestPriority();95 int priorityB = b-> currentTexture() ? b->currentTexture()->requestPriority() : CCPriorityCalculator::lowestPriority();101 int priorityA = a->owner() ? a->owner()->requestPriority() : CCPriorityCalculator::lowestPriority(); 102 int priorityB = b->owner() ? b->owner()->requestPriority() : CCPriorityCalculator::lowestPriority(); 96 103 if (priorityA == priorityB) 97 104 return a < b; … … 102 109 103 110 void reduceMemory(size_t limit, TextureAllocator*); 104 105 void link(CCPrioritizedTexture*, CCPrioritizedTexture::Backing*);106 void unlink(CCPrioritizedTexture*, CCPrioritizedTexture::Backing*);107 111 108 112 CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, TextureAllocator*); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h
r121870 r122506 29 29 #include "IntRect.h" 30 30 #include "IntSize.h" 31 #include "TextureManager.h"32 31 33 32 namespace WebCore { -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp
r122180 r122506 25 25 26 26 #include "config.h" 27 28 27 #include "cc/CCScopedTexture.h" 29 28 30 #include "Texture Manager.h" // For TextureAllocator29 #include "TextureAllocator.h" 31 30 32 31 namespace WebCore { -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h
r122180 r122506 27 27 #define CCScopedTexture_h 28 28 29 #include "TextureAllocator.h" 29 30 #include "cc/CCTexture.h" 30 31 … … 35 36 namespace WebCore { 36 37 37 class TextureAllocator;38 38 39 39 class CCScopedTexture : protected CCTexture { -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTexture.h
r122180 r122506 36 36 public: 37 37 CCTexture() : m_id(0) { } 38 CCTexture(unsigned id, IntSize size, GC3Denum format) 39 : m_id(id) 40 , m_size(size) 41 , m_format(format) { } 38 42 39 43 unsigned id() const { return m_id; } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp
r122373 r122506 55 55 static const int debugTileBorderMissingTileColorBlue = 0; 56 56 57 class ManagedTexture;58 59 57 class DrawableTile : public CCLayerTilingData::Tile { 60 58 WTF_MAKE_NONCOPYABLE(DrawableTile); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp
r121214 r122506 36 36 #include "NotImplemented.h" 37 37 #include "TextStream.h" 38 #include "Texture Manager.h" // For TextureAllocator38 #include "TextureAllocator.h" 39 39 #include "cc/CCGraphicsContext.h" 40 40 #include "cc/CCLayerTreeHostImpl.h" -
trunk/Source/WebKit/chromium/ChangeLog
r122496 r122506 1 2012-07-12 Eric Penner <epenner@google.com> 2 3 [chromium] Use CCTexture/TextureAllocator and remove TextureManager 4 https://bugs.webkit.org/show_bug.cgi?id=91001 5 6 Reviewed by Adrienne Walker. 7 8 Deleting old texture manager tests. 9 10 * WebKit.gypi: 11 * tests/CCLayerTreeHostImplTest.cpp: 12 * tests/CCPrioritizedTextureTest.cpp: 13 (WTF::CCPrioritizedTextureTest::texturesMemorySize): 14 * tests/CCThreadedTest.cpp: 15 * tests/CCTiledLayerTestCommon.h: 16 * tests/Canvas2DLayerBridgeTest.cpp: 17 * tests/TextureManagerTest.cpp: Removed. 18 1 19 2012-07-12 Robert Sesek <rsesek@chromium.org> 2 20 -
trunk/Source/WebKit/chromium/WebKit.gypi
r122344 r122506 139 139 'tests/TextureCopierTest.cpp', 140 140 'tests/TextureLayerChromiumTest.cpp', 141 'tests/TextureManagerTest.cpp',142 141 'tests/ThrottledTextureUploaderTest.cpp', 143 142 'tests/TiledLayerChromiumTest.cpp', -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
r122373 r122506 32 32 #include "FakeWebGraphicsContext3D.h" 33 33 #include "LayerRendererChromium.h" 34 #include "ManagedTexture.h"35 34 #include "cc/CCIOSurfaceLayerImpl.h" 36 35 #include "cc/CCLayerImpl.h" -
trunk/Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp
r121870 r122506 29 29 #include "CCTiledLayerTestCommon.h" 30 30 #include "cc/CCPrioritizedTextureManager.h" 31 #include "cc/CCTexture.h" 31 32 #include <gtest/gtest.h> 32 33 … … 51 52 size_t texturesMemorySize(size_t textureCount) 52 53 { 53 return TextureManager::memoryUseBytes(m_textureSize, m_textureFormat) * textureCount;54 return CCTexture::memorySizeBytes(m_textureSize, m_textureFormat) * textureCount; 54 55 } 55 56 -
trunk/Source/WebKit/chromium/tests/CCThreadedTest.cpp
r121204 r122506 35 35 #include "GraphicsContext3DPrivate.h" 36 36 #include "LayerChromium.h" 37 #include "TextureManager.h"38 37 #include "WebCompositor.h" 39 38 #include "WebKit.h" -
trunk/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h
r122373 r122506 30 30 #include "LayerTextureUpdater.h" 31 31 #include "Region.h" 32 #include "TextureAllocator.h" 32 33 #include "TextureCopier.h" 33 34 #include "TextureUploader.h" -
trunk/Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp
r121268 r122506 31 31 #include "ImageBuffer.h" 32 32 #include "LayerChromium.h" 33 #include "TextureManager.h"34 33 #include "WebCompositor.h" 35 34 #include "WebKit.h" -
trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
r122160 r122506 31 31 #include "WebCompositor.h" 32 32 #include "cc/CCDrawQuad.h" 33 #include "cc/CCPrioritizedTextureManager.h" 33 34 #include "cc/CCSettings.h" 34 35 #include "cc/CCSingleThreadProxy.h" … … 77 78 : m_setFullRootLayerDamageCount(0) 78 79 , m_rootLayer(CCLayerImpl::create(1)) 79 , m_memoryAllocationLimitBytes( 0)80 , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAllocationLimit()) 80 81 { 81 82 m_rootLayer->createRenderSurface();
Note: See TracChangeset
for help on using the changeset viewer.