Title: [122272] trunk/Source
Revision
122272
Author
dan...@chromium.org
Date
2012-07-10 15:48:37 -0700 (Tue, 10 Jul 2012)

Log Message

[chromium] Replace use of ManagedTexture with CCScopedTexture for impl thread and remove implTextureManager from LayerRendererChromium
https://bugs.webkit.org/show_bug.cgi?id=90841

Reviewed by Adrienne Walker.

Source/WebCore:

Remove the TextureManager from LayerRendererChromium, which was the last
instance of the class in the compositor. Instead of using ManagedTexture
objects for RenderPass textures, use instances of CCScopedTexture, which
manage the lifetime of the allocated texture ids. TextureManager will be
removed entirely once all callers of memoryUseBytes() have been removed.

No new tests. No change in behaviour.

* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::LayerRendererChromium):
(WebCore::LayerRendererChromium::releaseRenderPassTextures):
(WebCore):
(WebCore::LayerRendererChromium::renderPassTextureSize):
(WebCore::LayerRendererChromium::renderPassTextureFormat):
(WebCore::LayerRendererChromium::decideRenderPassAllocationsForFrame):
(WebCore::LayerRendererChromium::haveCachedResourcesForRenderPassId):
(WebCore::LayerRendererChromium::drawQuad):
(WebCore::applyFilters):
(WebCore::LayerRendererChromium::drawBackgroundFilters):
(WebCore::LayerRendererChromium::drawRenderPassQuad):
(WebCore::LayerRendererChromium::drawHeadsUpDisplay):
(WebCore::LayerRendererChromium::getFramebufferTexture):
(WebCore::LayerRendererChromium::isCurrentRenderPass):
(WebCore::LayerRendererChromium::useRenderPass):
(WebCore::LayerRendererChromium::useScopedTexture):
(WebCore::LayerRendererChromium::bindFramebufferToTexture):
(WebCore::LayerRendererChromium::initializeSharedObjects):
* platform/graphics/chromium/LayerRendererChromium.h:
(WebCore):
(LayerRendererChromium):
* platform/graphics/chromium/TrackingTextureAllocator.cpp:
(WebCore::TrackingTextureAllocator::TrackingTextureAllocator):
(WebCore::TrackingTextureAllocator::createTexture):
* platform/graphics/chromium/TrackingTextureAllocator.h:
(WebCore::TrackingTextureAllocator::create):
(TrackingTextureAllocator):
* platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
(WebCore::CCHeadsUpDisplay::draw):
* platform/graphics/chromium/cc/CCHeadsUpDisplay.h:
(WebCore):
(CCHeadsUpDisplay):
* platform/graphics/chromium/cc/CCRenderer.h:
(WebCore):
(CCRenderer):

Source/WebKit/chromium:

* tests/CCLayerTreeHostImplTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (122271 => 122272)


--- trunk/Source/WebCore/ChangeLog	2012-07-10 22:45:34 UTC (rev 122271)
+++ trunk/Source/WebCore/ChangeLog	2012-07-10 22:48:37 UTC (rev 122272)
@@ -1,3 +1,55 @@
+2012-07-09  Dana Jansens  <dan...@chromium.org>
+
+        [chromium] Replace use of ManagedTexture with CCScopedTexture for impl thread and remove implTextureManager from LayerRendererChromium
+        https://bugs.webkit.org/show_bug.cgi?id=90841
+
+        Reviewed by Adrienne Walker.
+
+        Remove the TextureManager from LayerRendererChromium, which was the last
+        instance of the class in the compositor. Instead of using ManagedTexture
+        objects for RenderPass textures, use instances of CCScopedTexture, which
+        manage the lifetime of the allocated texture ids. TextureManager will be
+        removed entirely once all callers of memoryUseBytes() have been removed.
+
+        No new tests. No change in behaviour.
+
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::LayerRendererChromium):
+        (WebCore::LayerRendererChromium::releaseRenderPassTextures):
+        (WebCore):
+        (WebCore::LayerRendererChromium::renderPassTextureSize):
+        (WebCore::LayerRendererChromium::renderPassTextureFormat):
+        (WebCore::LayerRendererChromium::decideRenderPassAllocationsForFrame):
+        (WebCore::LayerRendererChromium::haveCachedResourcesForRenderPassId):
+        (WebCore::LayerRendererChromium::drawQuad):
+        (WebCore::applyFilters):
+        (WebCore::LayerRendererChromium::drawBackgroundFilters):
+        (WebCore::LayerRendererChromium::drawRenderPassQuad):
+        (WebCore::LayerRendererChromium::drawHeadsUpDisplay):
+        (WebCore::LayerRendererChromium::getFramebufferTexture):
+        (WebCore::LayerRendererChromium::isCurrentRenderPass):
+        (WebCore::LayerRendererChromium::useRenderPass):
+        (WebCore::LayerRendererChromium::useScopedTexture):
+        (WebCore::LayerRendererChromium::bindFramebufferToTexture):
+        (WebCore::LayerRendererChromium::initializeSharedObjects):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (WebCore):
+        (LayerRendererChromium):
+        * platform/graphics/chromium/TrackingTextureAllocator.cpp:
+        (WebCore::TrackingTextureAllocator::TrackingTextureAllocator):
+        (WebCore::TrackingTextureAllocator::createTexture):
+        * platform/graphics/chromium/TrackingTextureAllocator.h:
+        (WebCore::TrackingTextureAllocator::create):
+        (TrackingTextureAllocator):
+        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
+        (WebCore::CCHeadsUpDisplay::draw):
+        * platform/graphics/chromium/cc/CCHeadsUpDisplay.h:
+        (WebCore):
+        (CCHeadsUpDisplay):
+        * platform/graphics/chromium/cc/CCRenderer.h:
+        (WebCore):
+        (CCRenderer):
+
 2012-07-10  Dean Jackson  <d...@apple.com>
 
         REGRESSION (r109610): Order of values in shorthand animation makes a difference

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (122271 => 122272)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2012-07-10 22:45:34 UTC (rev 122271)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2012-07-10 22:48:37 UTC (rev 122272)
@@ -38,7 +38,6 @@
 #include "FloatQuad.h"
 #include "GeometryBinding.h"
 #include "GrTexture.h"
-#include "ManagedTexture.h"
 #include "NotImplemented.h"
 #include "PlatformColor.h"
 #include "SharedGraphicsContext3D.h"
@@ -57,6 +56,7 @@
 #include "cc/CCRenderPass.h"
 #include "cc/CCRenderPassDrawQuad.h"
 #include "cc/CCRenderSurfaceFilters.h"
+#include "cc/CCScopedTexture.h"
 #include "cc/CCSettings.h"
 #include "cc/CCSingleThreadProxy.h"
 #include "cc/CCSolidColorDrawQuad.h"
@@ -157,7 +157,7 @@
                                              TextureUploaderOption textureUploaderSetting)
     : CCRenderer(client)
     , m_currentRenderPass(0)
-    , m_currentManagedTexture(0)
+    , m_currentTexture(0)
     , m_offscreenFramebufferId(0)
     , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f))
     , m_context(context)
@@ -274,10 +274,7 @@
 
 void LayerRendererChromium::releaseRenderPassTextures()
 {
-    if (!m_implTextureManager)
-        return;
     m_renderPassTextures.clear();
-    m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get());
 }
 
 void LayerRendererChromium::viewportChanged()
@@ -314,7 +311,18 @@
     GLC(m_context, m_context->enable(GraphicsContext3D::SCISSOR_TEST));
 }
 
+// static
+IntSize LayerRendererChromium::renderPassTextureSize(const CCRenderPass* pass)
+{
+    return pass->framebufferOutputRect().size();
+}
 
+// static
+GC3Denum LayerRendererChromium::renderPassTextureFormat(const CCRenderPass*)
+{
+    return GraphicsContext3D::RGBA;
+}
+
 void LayerRendererChromium::decideRenderPassAllocationsForFrame(const CCRenderPassList& renderPassesInDrawOrder)
 {
     HashMap<int, const CCRenderPass*> passesInFrame;
@@ -322,7 +330,7 @@
         passesInFrame.set(renderPassesInDrawOrder[i]->id(), renderPassesInDrawOrder[i].get());
 
     Vector<int> passesToDelete;
-    HashMap<int, OwnPtr<ManagedTexture> >::const_iterator passIterator;
+    HashMap<int, OwnPtr<CCScopedTexture> >::const_iterator passIterator;
     for (passIterator = m_renderPassTextures.begin(); passIterator != m_renderPassTextures.end(); ++passIterator) {
         const CCRenderPass* renderPassInFrame = passesInFrame.get(passIterator->first);
         if (!renderPassInFrame) {
@@ -330,43 +338,31 @@
             continue;
         }
 
-        const IntSize& requiredSize = renderPassInFrame->framebufferOutputRect().size();
-        GC3Denum requiredFormat = GraphicsContext3D::RGBA;
-        ManagedTexture* texture = passIterator->second.get();
-        if (!texture || !texture->isValid(requiredSize, requiredFormat)) {
-            passesToDelete.append(passIterator->first);
-            continue;
-        }
+        const IntSize& requiredSize = renderPassTextureSize(renderPassInFrame);
+        GC3Denum requiredFormat = renderPassTextureFormat(renderPassInFrame);
+        CCScopedTexture* texture = passIterator->second.get();
+        ASSERT(texture);
+
+        if (texture->id() && (texture->size() != requiredSize || texture->format() != requiredFormat))
+            texture->free();
     }
 
     // Delete RenderPass textures from the previous frame that will not be used again.
     for (size_t i = 0; i < passesToDelete.size(); ++i)
         m_renderPassTextures.remove(passesToDelete[i]);
-    m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get());
 
-    // All RenderPass textures should be reserved for the current frame. Every RenderPass texture
-    // is kept reserved until it is removed and deleted.
     for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) {
-        ManagedTexture* texture = m_renderPassTextures.get(renderPassesInDrawOrder[i]->id());
-        if (!texture) {
-            OwnPtr<ManagedTexture> ownTexture = ManagedTexture::create(m_implTextureManager.get());
-            texture = ownTexture.get();
-            m_renderPassTextures.set(renderPassesInDrawOrder[i]->id(), ownTexture.release());
+        if (!m_renderPassTextures.contains(renderPassesInDrawOrder[i]->id())) {
+            OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(m_implTextureAllocator.get());
+            m_renderPassTextures.set(renderPassesInDrawOrder[i]->id(), texture.release());
         }
-
-        const IntSize& requiredSize = renderPassesInDrawOrder[i]->framebufferOutputRect().size();
-        GC3Denum requiredFormat = GraphicsContext3D::RGBA;
-        // See https://bugs.webkit.org/show_bug.cgi?id=90848
-        // bool reserved = texture->reserve(requiredSize, requiredFormat);
-        // ASSERT_UNUSED(reserved, reserved);
-        texture->reserve(requiredSize, requiredFormat);
     }
 }
 
 bool LayerRendererChromium::haveCachedResourcesForRenderPassId(int id) const
 {
-    ManagedTexture* texture = m_renderPassTextures.get(id);
-    return texture && texture->textureId();
+    CCScopedTexture* texture = m_renderPassTextures.get(id);
+    return texture && texture->id();
 }
 
 void LayerRendererChromium::beginDrawingFrame(const CCRenderPass* rootRenderPass)
@@ -465,8 +461,6 @@
         drawYUVVideoQuad(quad->toYUVVideoDrawQuad());
         break;
     }
-
-    m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get());
 }
 
 void LayerRendererChromium::drawCheckerboardQuad(const CCCheckerboardDrawQuad* quad)
@@ -522,7 +516,7 @@
     GLC(context(), context()->drawElements(GraphicsContext3D::LINE_LOOP, 4, GraphicsContext3D::UNSIGNED_SHORT, 6 * sizeof(unsigned short)));
 }
 
-static inline SkBitmap applyFilters(LayerRendererChromium* layerRenderer, const WebKit::WebFilterOperations& filters, ManagedTexture* sourceTexture)
+static inline SkBitmap applyFilters(LayerRendererChromium* layerRenderer, const WebKit::WebFilterOperations& filters, CCScopedTexture* sourceTexture)
 {
     if (filters.isEmpty())
         return SkBitmap();
@@ -533,10 +527,10 @@
 
     layerRenderer->context()->flush();
 
-    return CCRenderSurfaceFilters::apply(filters, sourceTexture->textureId(), sourceTexture->size(), filterContext.get());
+    return CCRenderSurfaceFilters::apply(filters, sourceTexture->id(), sourceTexture->size(), filterContext.get());
 }
 
-PassOwnPtr<ManagedTexture> LayerRendererChromium::drawBackgroundFilters(const CCRenderPassDrawQuad* quad, const WebTransformationMatrix& contentsDeviceTransform)
+PassOwnPtr<CCScopedTexture> LayerRendererChromium::drawBackgroundFilters(const CCRenderPassDrawQuad* quad, const WebTransformationMatrix& contentsDeviceTransform)
 {
     // This method draws a background filter, which applies a filter to any pixels behind the quad and seen through its background.
     // The algorithm works as follows:
@@ -561,7 +555,7 @@
     // translucent pixels, and the contents behind those translucent pixels wouldn't have the filter applied.
     if (m_currentRenderPass->hasTransparentBackground())
         return nullptr;
-    ASSERT(!m_currentManagedTexture);
+    ASSERT(!m_currentTexture);
 
     // FIXME: Do a single readback for both the surface and replica and cache the filtered results (once filter textures are not reused).
     IntRect deviceRect = enclosingIntRect(CCMathUtil::mapClippedRect(contentsDeviceTransform, sharedGeometryQuad().boundingBox()));
@@ -573,7 +567,7 @@
 
     deviceRect.intersect(m_currentRenderPass->framebufferOutputRect());
 
-    OwnPtr<ManagedTexture> deviceBackgroundTexture = ManagedTexture::create(m_implTextureManager.get());
+    OwnPtr<CCScopedTexture> deviceBackgroundTexture = CCScopedTexture::create(m_implTextureAllocator.get());
     if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect))
         return nullptr;
 
@@ -584,12 +578,12 @@
     GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.getTexture());
     int filteredDeviceBackgroundTextureId = texture->getTextureHandle();
 
-    OwnPtr<ManagedTexture> backgroundTexture = ManagedTexture::create(m_implTextureManager.get());
-    if (!backgroundTexture->reserve(quad->quadRect().size(), GraphicsContext3D::RGBA))
+    OwnPtr<CCScopedTexture> backgroundTexture = CCScopedTexture::create(m_implTextureAllocator.get());
+    if (!backgroundTexture->allocate(quad->quadRect().size(), GraphicsContext3D::RGBA))
         return nullptr;
 
     const CCRenderPass* targetRenderPass = m_currentRenderPass;
-    bool usingBackgroundTexture = useManagedTexture(backgroundTexture.get(), quad->quadRect());
+    bool usingBackgroundTexture = useScopedTexture(backgroundTexture.get(), quad->quadRect());
 
     if (usingBackgroundTexture) {
         // Copy the readback pixels from device to the background texture for the surface.
@@ -612,8 +606,8 @@
 
 void LayerRendererChromium::drawRenderPassQuad(const CCRenderPassDrawQuad* quad)
 {
-    ManagedTexture* contentsTexture = m_renderPassTextures.get(quad->renderPassId());
-    if (!contentsTexture || !contentsTexture->textureId())
+    CCScopedTexture* contentsTexture = m_renderPassTextures.get(quad->renderPassId());
+    if (!contentsTexture || !contentsTexture->id())
         return;
 
     WebTransformationMatrix renderTransform = quad->layerTransform();
@@ -625,12 +619,12 @@
     if (!contentsDeviceTransform.isInvertible())
         return;
 
-    OwnPtr<ManagedTexture> backgroundTexture = drawBackgroundFilters(quad, contentsDeviceTransform);
+    OwnPtr<CCScopedTexture> backgroundTexture = drawBackgroundFilters(quad, contentsDeviceTransform);
 
     // FIXME: Cache this value so that we don't have to do it for both the surface and its replica.
     // Apply filters to the contents texture.
     SkBitmap filterBitmap = applyFilters(this, quad->filters(), contentsTexture);
-    int contentsTextureId = contentsTexture->textureId();
+    int contentsTextureId = contentsTexture->id();
     if (filterBitmap.getTexture()) {
         GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTexture());
         contentsTextureId = texture->getTextureHandle();
@@ -639,7 +633,7 @@
     // Draw the background texture if there is one.
     if (backgroundTexture) {
         ASSERT(backgroundTexture->size() == quad->quadRect().size());
-        copyTextureToFramebuffer(backgroundTexture->textureId(), quad->quadRect().size(), quad->layerTransform());
+        copyTextureToFramebuffer(backgroundTexture->id(), quad->quadRect().size(), quad->layerTransform());
     }
 
     bool clipped = false;
@@ -1096,8 +1090,10 @@
     GLC(context(), context()->bindTexture(Extensions3D::TEXTURE_RECTANGLE_ARB, 0));
 }
 
-void LayerRendererChromium::drawHeadsUpDisplay(ManagedTexture* hudTexture, const IntSize& hudSize)
+void LayerRendererChromium::drawHeadsUpDisplay(const CCScopedTexture* hudTexture, const IntSize& hudSize)
 {
+    ASSERT(hudTexture->id());
+
     GLC(m_context, m_context->enable(GraphicsContext3D::BLEND));
     GLC(m_context, m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
     GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
@@ -1106,9 +1102,7 @@
     const HeadsUpDisplayProgram* program = headsUpDisplayProgram();
     ASSERT(program && program->initialized());
     GLC(m_context, m_context->activeTexture(GraphicsContext3D::TEXTURE0));
-    if (!hudTexture->textureId())
-        hudTexture->allocate(m_implTextureAllocator.get());
-    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, hudTexture->textureId()));
+    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, hudTexture->id()));
     GLC(m_context, m_context->useProgram(program->program()));
     GLC(m_context, m_context->uniform1i(program->fragmentShader().samplerLocation(), 0));
 
@@ -1352,14 +1346,14 @@
     }
 }
 
-bool LayerRendererChromium::getFramebufferTexture(ManagedTexture* texture, const IntRect& deviceRect)
+bool LayerRendererChromium::getFramebufferTexture(CCScopedTexture* texture, const IntRect& deviceRect)
 {
-    if (!texture->reserve(deviceRect.size(), GraphicsContext3D::RGB))
+    ASSERT(!texture->id() || (texture->size() == deviceRect.size() && texture->format() == GraphicsContext3D::RGB));
+
+    if (!texture->id() && !texture->allocate(deviceRect.size(), GraphicsContext3D::RGB))
         return false;
 
-    if (!texture->textureId())
-        texture->allocate(m_implTextureAllocator.get());
-    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture->textureId()));
+    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture->id()));
     GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, texture->format(),
                                              deviceRect.x(), deviceRect.y(), deviceRect.width(), deviceRect.height(), 0));
     return true;
@@ -1367,13 +1361,13 @@
 
 bool LayerRendererChromium::isCurrentRenderPass(const CCRenderPass* renderPass)
 {
-    return m_currentRenderPass == renderPass && !m_currentManagedTexture;
+    return m_currentRenderPass == renderPass && !m_currentTexture;
 }
 
 bool LayerRendererChromium::useRenderPass(const CCRenderPass* renderPass)
 {
     m_currentRenderPass = renderPass;
-    m_currentManagedTexture = 0;
+    m_currentTexture = 0;
 
     if (renderPass == m_defaultRenderPass) {
         GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0));
@@ -1381,28 +1375,32 @@
         return true;
     }
 
-    ManagedTexture* texture = m_renderPassTextures.get(renderPass->id());
+    CCScopedTexture* texture = m_renderPassTextures.get(renderPass->id());
     ASSERT(texture);
 
+    if (!texture->id() && !texture->allocate(renderPassTextureSize(renderPass), renderPassTextureFormat(renderPass)))
+        return false;
+
     return bindFramebufferToTexture(texture, renderPass->framebufferOutputRect());
 }
 
-bool LayerRendererChromium::useManagedTexture(ManagedTexture* texture, const IntRect& viewportRect)
+bool LayerRendererChromium::useScopedTexture(const CCScopedTexture* texture, const IntRect& viewportRect)
 {
+    ASSERT(texture->id());
+
     m_currentRenderPass = 0;
-    m_currentManagedTexture = texture;
+    m_currentTexture = texture;
 
     return bindFramebufferToTexture(texture, viewportRect);
 }
 
-bool LayerRendererChromium::bindFramebufferToTexture(ManagedTexture* texture, const IntRect& framebufferRect)
+bool LayerRendererChromium::bindFramebufferToTexture(const CCScopedTexture* texture, const IntRect& framebufferRect)
 {
+    ASSERT(texture->id());
+
     GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_offscreenFramebufferId));
+    GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, texture->id(), 0));
 
-    if (!texture->textureId())
-        texture->allocate(m_implTextureAllocator.get());
-    GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, texture->textureId(), 0));
-
 #if !defined ( NDEBUG )
     if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
         ASSERT_NOT_REACHED();
@@ -1473,14 +1471,13 @@
 
     GLC(m_context, m_context->flush());
 
-    m_implTextureManager = TextureManager::create(std::numeric_limits<size_t>::max(), std::numeric_limits<size_t>::max(), m_capabilities.maxTextureSize);
     m_textureCopier = AcceleratedTextureCopier::create(m_context, m_isUsingBindUniform);
     if (m_textureUploaderSetting == ThrottledUploader)
         m_textureUploader = ThrottledTextureUploader::create(m_context);
     else
         m_textureUploader = UnthrottledTextureUploader::create();
-    m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context);
-    m_implTextureAllocator = TrackingTextureAllocator::create(m_context);
+    m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context, m_capabilities.maxTextureSize);
+    m_implTextureAllocator = TrackingTextureAllocator::create(m_context, m_capabilities.maxTextureSize);
     if (m_capabilities.usingTextureUsageHint)
         m_implTextureAllocator->setTextureUsageHint(TrackingTextureAllocator::FramebufferAttachment);
     if (m_capabilities.usingTextureStorageExtension) {

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h (122271 => 122272)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h	2012-07-10 22:45:34 UTC (rev 122271)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h	2012-07-10 22:48:37 UTC (rev 122272)
@@ -51,13 +51,13 @@
 class CCDrawQuad;
 class CCIOSurfaceDrawQuad;
 class CCRenderPassDrawQuad;
+class CCScopedTexture;
 class CCSolidColorDrawQuad;
 class CCStreamVideoDrawQuad;
 class CCTextureDrawQuad;
 class CCTileDrawQuad;
 class CCYUVVideoDrawQuad;
 class GeometryBinding;
-class ManagedTexture;
 class ScopedEnsureFramebufferAllocation;
 
 // Class that handles drawing of composited render layers using GL.
@@ -86,7 +86,7 @@
     virtual void drawRenderPass(const CCRenderPass*, const FloatRect& framebufferDamageRect) OVERRIDE;
     virtual void finishDrawingFrame() OVERRIDE;
 
-    virtual void drawHeadsUpDisplay(ManagedTexture*, const IntSize& hudSize) OVERRIDE;
+    virtual void drawHeadsUpDisplay(const CCScopedTexture*, const IntSize& hudSize) OVERRIDE;
 
     // waits for rendering to finish
     virtual void finish() OVERRIDE;
@@ -100,9 +100,8 @@
     const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(); }
 
     virtual void getFramebufferPixels(void *pixels, const IntRect&) OVERRIDE;
-    bool getFramebufferTexture(ManagedTexture*, const IntRect& deviceRect);
+    bool getFramebufferTexture(CCScopedTexture*, const IntRect& deviceRect);
 
-    virtual TextureManager* implTextureManager() const OVERRIDE { return m_implTextureManager.get(); }
     virtual TextureCopier* textureCopier() const OVERRIDE { return m_textureCopier.get(); }
     virtual TextureUploader* textureUploader() const OVERRIDE { return m_textureUploader.get(); }
     virtual TextureAllocator* implTextureAllocator() const OVERRIDE { return m_implTextureAllocator.get(); }
@@ -133,7 +132,7 @@
     void drawQuad(const CCDrawQuad*);
     void drawCheckerboardQuad(const CCCheckerboardDrawQuad*);
     void drawDebugBorderQuad(const CCDebugBorderDrawQuad*);
-    PassOwnPtr<ManagedTexture> drawBackgroundFilters(const CCRenderPassDrawQuad*, const WebKit::WebTransformationMatrix& deviceTransform);
+    PassOwnPtr<CCScopedTexture> drawBackgroundFilters(const CCRenderPassDrawQuad*, const WebKit::WebTransformationMatrix& deviceTransform);
     void drawRenderPassQuad(const CCRenderPassDrawQuad*);
     void drawSolidColorQuad(const CCSolidColorDrawQuad*);
     void drawStreamVideoQuad(const CCStreamVideoDrawQuad*);
@@ -144,12 +143,12 @@
 
     void setDrawFramebufferRect(const IntRect&, bool flipY);
 
-    // The current drawing target is either a RenderPass or ManagedTexture. Use these functions to switch to a new drawing target.
+    // The current drawing target is either a RenderPass or ScopedTexture. Use these functions to switch to a new drawing target.
     bool useRenderPass(const CCRenderPass*);
-    bool useManagedTexture(ManagedTexture*, const IntRect& viewportRect);
+    bool useScopedTexture(const CCScopedTexture*, const IntRect& viewportRect);
     bool isCurrentRenderPass(const CCRenderPass*);
 
-    bool bindFramebufferToTexture(ManagedTexture*, const IntRect& viewportRect);
+    bool bindFramebufferToTexture(const CCScopedTexture*, const IntRect& viewportRect);
 
     void clearRenderPass(const CCRenderPass*, const FloatRect& framebufferDamageRect);
 
@@ -170,10 +169,13 @@
     // WebGraphicsContext3D::WebGraphicsContextLostCallback implementation.
     virtual void onContextLost() OVERRIDE;
 
+    static IntSize renderPassTextureSize(const CCRenderPass*);
+    static GC3Denum renderPassTextureFormat(const CCRenderPass*);
+
     LayerRendererCapabilities m_capabilities;
 
     const CCRenderPass* m_currentRenderPass;
-    ManagedTexture* m_currentManagedTexture;
+    const CCScopedTexture* m_currentTexture;
     unsigned m_offscreenFramebufferId;
 
     OwnPtr<GeometryBinding> m_sharedGeometry;
@@ -259,13 +261,12 @@
     OwnPtr<SolidColorProgram> m_solidColorProgram;
     OwnPtr<HeadsUpDisplayProgram> m_headsUpDisplayProgram;
 
-    OwnPtr<TextureManager> m_implTextureManager;
     OwnPtr<AcceleratedTextureCopier> m_textureCopier;
     OwnPtr<TextureUploader> m_textureUploader;
     OwnPtr<TrackingTextureAllocator> m_contentsTextureAllocator;
     OwnPtr<TrackingTextureAllocator> m_implTextureAllocator;
 
-    HashMap<int, OwnPtr<ManagedTexture> > m_renderPassTextures;
+    HashMap<int, OwnPtr<CCScopedTexture> > m_renderPassTextures;
 
     WebKit::WebGraphicsContext3D* m_context;
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp (122271 => 122272)


--- trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp	2012-07-10 22:45:34 UTC (rev 122271)
+++ trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp	2012-07-10 22:48:37 UTC (rev 122272)
@@ -33,8 +33,9 @@
 
 namespace WebCore {
 
-TrackingTextureAllocator::TrackingTextureAllocator(WebKit::WebGraphicsContext3D* context)
+TrackingTextureAllocator::TrackingTextureAllocator(WebKit::WebGraphicsContext3D* context, int maxTextureSize)
     : m_context(context)
+    , m_maxTextureSize(maxTextureSize)
     , m_currentMemoryUseBytes(0)
     , m_textureUsageHint(Any)
     , m_useTextureStorageExt(false)
@@ -71,6 +72,9 @@
 
 unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum format)
 {
+    if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize)
+        return 0;
+
     m_currentMemoryUseBytes += TextureManager::memoryUseBytes(size, format);
 
     unsigned textureId = 0;

Modified: trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h (122271 => 122272)


--- trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h	2012-07-10 22:45:34 UTC (rev 122271)
+++ trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h	2012-07-10 22:48:37 UTC (rev 122272)
@@ -38,9 +38,9 @@
 class TrackingTextureAllocator : public TextureAllocator {
     WTF_MAKE_NONCOPYABLE(TrackingTextureAllocator);
 public:
-    static PassOwnPtr<TrackingTextureAllocator> create(WebKit::WebGraphicsContext3D* context)
+    static PassOwnPtr<TrackingTextureAllocator> create(WebKit::WebGraphicsContext3D* context, int maxTextureSize)
     {
-        return adoptPtr(new TrackingTextureAllocator(context));
+        return adoptPtr(new TrackingTextureAllocator(context, maxTextureSize));
     }
     virtual ~TrackingTextureAllocator();
 
@@ -56,9 +56,10 @@
     void setUseTextureStorageExt(bool useStorageExt) { m_useTextureStorageExt = useStorageExt; }
 
 protected:
-    explicit TrackingTextureAllocator(WebKit::WebGraphicsContext3D*);
+    TrackingTextureAllocator(WebKit::WebGraphicsContext3D*, int maxTextureSize);
 
     WebKit::WebGraphicsContext3D* m_context;
+    int m_maxTextureSize;
     size_t m_currentMemoryUseBytes;
     TextureUsageHint m_textureUsageHint;
     bool m_useTextureStorageExt;

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp (122271 => 122272)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp	2012-07-10 22:45:34 UTC (rev 122271)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp	2012-07-10 22:48:37 UTC (rev 122272)
@@ -75,7 +75,7 @@
         return;
     }
     if (!m_hudTexture)
-        m_hudTexture = ManagedTexture::create(layerRenderer->implTextureManager());
+        m_hudTexture = CCScopedTexture::create(layerRenderer->implTextureAllocator());
 
     const CCLayerTreeSettings& settings = layerTreeHostImpl->settings();
     // Use a fullscreen texture only if we need to...
@@ -88,7 +88,7 @@
         hudSize.setHeight(128);
     }
 
-    if (!m_hudTexture->reserve(hudSize, GraphicsContext3D::RGBA))
+    if (!m_hudTexture->id() && !m_hudTexture->allocate(hudSize, GraphicsContext3D::RGBA))
         return;
 
     // Render pixels into the texture.
@@ -104,7 +104,7 @@
     {
         PlatformCanvas::AutoLocker locker(&canvas);
 
-        m_hudTexture->bindTexture(layerTreeHostImpl->context(), layerRenderer->implTextureAllocator());
+        GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_hudTexture->id()));
         bool uploadedViaMap = false;
         if (layerRenderer->capabilities().usingMapSub) {
             uint8_t* pixelDest = static_cast<uint8_t*>(context->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, hudSize.width(), hudSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
@@ -122,8 +122,6 @@
     }
 
     layerRenderer->drawHeadsUpDisplay(m_hudTexture.get(), hudSize);
-
-    m_hudTexture->unreserve();
 }
 
 void CCHeadsUpDisplay::drawHudContents(GraphicsContext* context, CCLayerTreeHostImpl* layerTreeHostImpl, const CCLayerTreeSettings& settings, const IntSize& hudSize)

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.h (122271 => 122272)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.h	2012-07-10 22:45:34 UTC (rev 122271)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.h	2012-07-10 22:48:37 UTC (rev 122272)
@@ -27,8 +27,8 @@
 
 #if USE(ACCELERATED_COMPOSITING)
 
-#include "ManagedTexture.h"
 #include "cc/CCFontAtlas.h"
+#include "cc/CCScopedTexture.h"
 
 namespace WebCore {
 
@@ -36,6 +36,7 @@
 class CCFrameRateCounter;
 class CCLayerTreeHostImpl;
 class GraphicsContext;
+class TexureAllocator;
 
 struct CCLayerTreeSettings;
 
@@ -66,7 +67,7 @@
     bool showPlatformLayerTree(const CCLayerTreeSettings&) const;
     bool showDebugRects(const CCLayerTreeSettings&) const;
 
-    OwnPtr<ManagedTexture> m_hudTexture;
+    OwnPtr<CCScopedTexture> m_hudTexture;
     OwnPtr<CCFontAtlas> m_fontAtlas;
 };
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderer.h (122271 => 122272)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderer.h	2012-07-10 22:45:34 UTC (rev 122271)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderer.h	2012-07-10 22:48:37 UTC (rev 122272)
@@ -35,6 +35,7 @@
 
 namespace WebCore {
 
+class CCScopedTexture;
 class TextureAllocator;
 class TextureCopier;
 class TextureManager;
@@ -78,7 +79,7 @@
     virtual void drawRenderPass(const CCRenderPass*, const FloatRect& rootScissorRectInCurrentPass) = 0;
     virtual void finishDrawingFrame() = 0;
 
-    virtual void drawHeadsUpDisplay(ManagedTexture*, const IntSize& hudSize) = 0;
+    virtual void drawHeadsUpDisplay(const CCScopedTexture*, const IntSize& hudSize) = 0;
 
     // waits for rendering to finish
     virtual void finish() = 0;
@@ -89,7 +90,6 @@
 
     virtual void getFramebufferPixels(void *pixels, const IntRect&) = 0;
 
-    virtual TextureManager* implTextureManager() const = 0;
     virtual TextureCopier* textureCopier() const = 0;
     virtual TextureUploader* textureUploader() const = 0;
     virtual TextureAllocator* implTextureAllocator() const = 0;

Modified: trunk/Source/WebKit/chromium/ChangeLog (122271 => 122272)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-07-10 22:45:34 UTC (rev 122271)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-07-10 22:48:37 UTC (rev 122272)
@@ -1,3 +1,12 @@
+2012-07-09  Dana Jansens  <dan...@chromium.org>
+
+        [chromium] Replace use of ManagedTexture with CCScopedTexture for impl thread and remove implTextureManager from LayerRendererChromium
+        https://bugs.webkit.org/show_bug.cgi?id=90841
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCLayerTreeHostImplTest.cpp:
+
 2012-07-10  Xianzhu Wang  <wangxian...@chromium.org>
 
         [Chromium-Android] Use default font rendering styles in FontPlatformData::querySystemForRenderStyle()

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp (122271 => 122272)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp	2012-07-10 22:45:34 UTC (rev 122271)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp	2012-07-10 22:48:37 UTC (rev 122272)
@@ -2367,8 +2367,6 @@
 
     // Kill the layer tree.
     m_hostImpl->setRootLayer(CCLayerImpl::create(100));
-    // FIXME: Remove this when we don't use ManagedTextures in impl layers.
-    m_hostImpl->layerRenderer()->implTextureManager()->deleteEvictedTextures(m_hostImpl->layerRenderer()->implTextureAllocator());
     // There should be no textures left in use after.
     EXPECT_EQ(0u, trackingWebGraphicsContext->numTextures());
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to