Changeset 122272 in webkit


Ignore:
Timestamp:
Jul 10, 2012 3:48:37 PM (12 years ago)
Author:
danakj@chromium.org
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:
Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122271 r122272  
     12012-07-09  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Replace use of ManagedTexture with CCScopedTexture for impl thread and remove implTextureManager from LayerRendererChromium
     4        https://bugs.webkit.org/show_bug.cgi?id=90841
     5
     6        Reviewed by Adrienne Walker.
     7
     8        Remove the TextureManager from LayerRendererChromium, which was the last
     9        instance of the class in the compositor. Instead of using ManagedTexture
     10        objects for RenderPass textures, use instances of CCScopedTexture, which
     11        manage the lifetime of the allocated texture ids. TextureManager will be
     12        removed entirely once all callers of memoryUseBytes() have been removed.
     13
     14        No new tests. No change in behaviour.
     15
     16        * platform/graphics/chromium/LayerRendererChromium.cpp:
     17        (WebCore::LayerRendererChromium::LayerRendererChromium):
     18        (WebCore::LayerRendererChromium::releaseRenderPassTextures):
     19        (WebCore):
     20        (WebCore::LayerRendererChromium::renderPassTextureSize):
     21        (WebCore::LayerRendererChromium::renderPassTextureFormat):
     22        (WebCore::LayerRendererChromium::decideRenderPassAllocationsForFrame):
     23        (WebCore::LayerRendererChromium::haveCachedResourcesForRenderPassId):
     24        (WebCore::LayerRendererChromium::drawQuad):
     25        (WebCore::applyFilters):
     26        (WebCore::LayerRendererChromium::drawBackgroundFilters):
     27        (WebCore::LayerRendererChromium::drawRenderPassQuad):
     28        (WebCore::LayerRendererChromium::drawHeadsUpDisplay):
     29        (WebCore::LayerRendererChromium::getFramebufferTexture):
     30        (WebCore::LayerRendererChromium::isCurrentRenderPass):
     31        (WebCore::LayerRendererChromium::useRenderPass):
     32        (WebCore::LayerRendererChromium::useScopedTexture):
     33        (WebCore::LayerRendererChromium::bindFramebufferToTexture):
     34        (WebCore::LayerRendererChromium::initializeSharedObjects):
     35        * platform/graphics/chromium/LayerRendererChromium.h:
     36        (WebCore):
     37        (LayerRendererChromium):
     38        * platform/graphics/chromium/TrackingTextureAllocator.cpp:
     39        (WebCore::TrackingTextureAllocator::TrackingTextureAllocator):
     40        (WebCore::TrackingTextureAllocator::createTexture):
     41        * platform/graphics/chromium/TrackingTextureAllocator.h:
     42        (WebCore::TrackingTextureAllocator::create):
     43        (TrackingTextureAllocator):
     44        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
     45        (WebCore::CCHeadsUpDisplay::draw):
     46        * platform/graphics/chromium/cc/CCHeadsUpDisplay.h:
     47        (WebCore):
     48        (CCHeadsUpDisplay):
     49        * platform/graphics/chromium/cc/CCRenderer.h:
     50        (WebCore):
     51        (CCRenderer):
     52
    1532012-07-10  Dean Jackson  <dino@apple.com>
    254
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r122252 r122272  
    3939#include "GeometryBinding.h"
    4040#include "GrTexture.h"
    41 #include "ManagedTexture.h"
    4241#include "NotImplemented.h"
    4342#include "PlatformColor.h"
     
    5857#include "cc/CCRenderPassDrawQuad.h"
    5958#include "cc/CCRenderSurfaceFilters.h"
     59#include "cc/CCScopedTexture.h"
    6060#include "cc/CCSettings.h"
    6161#include "cc/CCSingleThreadProxy.h"
     
    158158    : CCRenderer(client)
    159159    , m_currentRenderPass(0)
    160     , m_currentManagedTexture(0)
     160    , m_currentTexture(0)
    161161    , m_offscreenFramebufferId(0)
    162162    , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f))
     
    275275void LayerRendererChromium::releaseRenderPassTextures()
    276276{
    277     if (!m_implTextureManager)
    278         return;
    279277    m_renderPassTextures.clear();
    280     m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get());
    281278}
    282279
     
    315312}
    316313
     314// static
     315IntSize LayerRendererChromium::renderPassTextureSize(const CCRenderPass* pass)
     316{
     317    return pass->framebufferOutputRect().size();
     318}
     319
     320// static
     321GC3Denum LayerRendererChromium::renderPassTextureFormat(const CCRenderPass*)
     322{
     323    return GraphicsContext3D::RGBA;
     324}
    317325
    318326void LayerRendererChromium::decideRenderPassAllocationsForFrame(const CCRenderPassList& renderPassesInDrawOrder)
     
    323331
    324332    Vector<int> passesToDelete;
    325     HashMap<int, OwnPtr<ManagedTexture> >::const_iterator passIterator;
     333    HashMap<int, OwnPtr<CCScopedTexture> >::const_iterator passIterator;
    326334    for (passIterator = m_renderPassTextures.begin(); passIterator != m_renderPassTextures.end(); ++passIterator) {
    327335        const CCRenderPass* renderPassInFrame = passesInFrame.get(passIterator->first);
     
    331339        }
    332340
    333         const IntSize& requiredSize = renderPassInFrame->framebufferOutputRect().size();
    334         GC3Denum requiredFormat = GraphicsContext3D::RGBA;
    335         ManagedTexture* texture = passIterator->second.get();
    336         if (!texture || !texture->isValid(requiredSize, requiredFormat)) {
    337             passesToDelete.append(passIterator->first);
    338             continue;
    339         }
     341        const IntSize& requiredSize = renderPassTextureSize(renderPassInFrame);
     342        GC3Denum requiredFormat = renderPassTextureFormat(renderPassInFrame);
     343        CCScopedTexture* texture = passIterator->second.get();
     344        ASSERT(texture);
     345
     346        if (texture->id() && (texture->size() != requiredSize || texture->format() != requiredFormat))
     347            texture->free();
    340348    }
    341349
     
    343351    for (size_t i = 0; i < passesToDelete.size(); ++i)
    344352        m_renderPassTextures.remove(passesToDelete[i]);
    345     m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get());
    346 
    347     // All RenderPass textures should be reserved for the current frame. Every RenderPass texture
    348     // is kept reserved until it is removed and deleted.
     353
    349354    for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) {
    350         ManagedTexture* texture = m_renderPassTextures.get(renderPassesInDrawOrder[i]->id());
    351         if (!texture) {
    352             OwnPtr<ManagedTexture> ownTexture = ManagedTexture::create(m_implTextureManager.get());
    353             texture = ownTexture.get();
    354             m_renderPassTextures.set(renderPassesInDrawOrder[i]->id(), ownTexture.release());
     355        if (!m_renderPassTextures.contains(renderPassesInDrawOrder[i]->id())) {
     356            OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(m_implTextureAllocator.get());
     357            m_renderPassTextures.set(renderPassesInDrawOrder[i]->id(), texture.release());
    355358        }
    356 
    357         const IntSize& requiredSize = renderPassesInDrawOrder[i]->framebufferOutputRect().size();
    358         GC3Denum requiredFormat = GraphicsContext3D::RGBA;
    359         // See https://bugs.webkit.org/show_bug.cgi?id=90848
    360         // bool reserved = texture->reserve(requiredSize, requiredFormat);
    361         // ASSERT_UNUSED(reserved, reserved);
    362         texture->reserve(requiredSize, requiredFormat);
    363359    }
    364360}
     
    366362bool LayerRendererChromium::haveCachedResourcesForRenderPassId(int id) const
    367363{
    368     ManagedTexture* texture = m_renderPassTextures.get(id);
    369     return texture && texture->textureId();
     364    CCScopedTexture* texture = m_renderPassTextures.get(id);
     365    return texture && texture->id();
    370366}
    371367
     
    466462        break;
    467463    }
    468 
    469     m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get());
    470464}
    471465
     
    523517}
    524518
    525 static inline SkBitmap applyFilters(LayerRendererChromium* layerRenderer, const WebKit::WebFilterOperations& filters, ManagedTexture* sourceTexture)
     519static inline SkBitmap applyFilters(LayerRendererChromium* layerRenderer, const WebKit::WebFilterOperations& filters, CCScopedTexture* sourceTexture)
    526520{
    527521    if (filters.isEmpty())
     
    534528    layerRenderer->context()->flush();
    535529
    536     return CCRenderSurfaceFilters::apply(filters, sourceTexture->textureId(), sourceTexture->size(), filterContext.get());
    537 }
    538 
    539 PassOwnPtr<ManagedTexture> LayerRendererChromium::drawBackgroundFilters(const CCRenderPassDrawQuad* quad, const WebTransformationMatrix& contentsDeviceTransform)
     530    return CCRenderSurfaceFilters::apply(filters, sourceTexture->id(), sourceTexture->size(), filterContext.get());
     531}
     532
     533PassOwnPtr<CCScopedTexture> LayerRendererChromium::drawBackgroundFilters(const CCRenderPassDrawQuad* quad, const WebTransformationMatrix& contentsDeviceTransform)
    540534{
    541535    // This method draws a background filter, which applies a filter to any pixels behind the quad and seen through its background.
     
    562556    if (m_currentRenderPass->hasTransparentBackground())
    563557        return nullptr;
    564     ASSERT(!m_currentManagedTexture);
     558    ASSERT(!m_currentTexture);
    565559
    566560    // FIXME: Do a single readback for both the surface and replica and cache the filtered results (once filter textures are not reused).
     
    574568    deviceRect.intersect(m_currentRenderPass->framebufferOutputRect());
    575569
    576     OwnPtr<ManagedTexture> deviceBackgroundTexture = ManagedTexture::create(m_implTextureManager.get());
     570    OwnPtr<CCScopedTexture> deviceBackgroundTexture = CCScopedTexture::create(m_implTextureAllocator.get());
    577571    if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect))
    578572        return nullptr;
     
    585579    int filteredDeviceBackgroundTextureId = texture->getTextureHandle();
    586580
    587     OwnPtr<ManagedTexture> backgroundTexture = ManagedTexture::create(m_implTextureManager.get());
    588     if (!backgroundTexture->reserve(quad->quadRect().size(), GraphicsContext3D::RGBA))
     581    OwnPtr<CCScopedTexture> backgroundTexture = CCScopedTexture::create(m_implTextureAllocator.get());
     582    if (!backgroundTexture->allocate(quad->quadRect().size(), GraphicsContext3D::RGBA))
    589583        return nullptr;
    590584
    591585    const CCRenderPass* targetRenderPass = m_currentRenderPass;
    592     bool usingBackgroundTexture = useManagedTexture(backgroundTexture.get(), quad->quadRect());
     586    bool usingBackgroundTexture = useScopedTexture(backgroundTexture.get(), quad->quadRect());
    593587
    594588    if (usingBackgroundTexture) {
     
    613607void LayerRendererChromium::drawRenderPassQuad(const CCRenderPassDrawQuad* quad)
    614608{
    615     ManagedTexture* contentsTexture = m_renderPassTextures.get(quad->renderPassId());
    616     if (!contentsTexture || !contentsTexture->textureId())
     609    CCScopedTexture* contentsTexture = m_renderPassTextures.get(quad->renderPassId());
     610    if (!contentsTexture || !contentsTexture->id())
    617611        return;
    618612
     
    626620        return;
    627621
    628     OwnPtr<ManagedTexture> backgroundTexture = drawBackgroundFilters(quad, contentsDeviceTransform);
     622    OwnPtr<CCScopedTexture> backgroundTexture = drawBackgroundFilters(quad, contentsDeviceTransform);
    629623
    630624    // FIXME: Cache this value so that we don't have to do it for both the surface and its replica.
    631625    // Apply filters to the contents texture.
    632626    SkBitmap filterBitmap = applyFilters(this, quad->filters(), contentsTexture);
    633     int contentsTextureId = contentsTexture->textureId();
     627    int contentsTextureId = contentsTexture->id();
    634628    if (filterBitmap.getTexture()) {
    635629        GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTexture());
     
    640634    if (backgroundTexture) {
    641635        ASSERT(backgroundTexture->size() == quad->quadRect().size());
    642         copyTextureToFramebuffer(backgroundTexture->textureId(), quad->quadRect().size(), quad->layerTransform());
     636        copyTextureToFramebuffer(backgroundTexture->id(), quad->quadRect().size(), quad->layerTransform());
    643637    }
    644638
     
    10971091}
    10981092
    1099 void LayerRendererChromium::drawHeadsUpDisplay(ManagedTexture* hudTexture, const IntSize& hudSize)
    1100 {
     1093void LayerRendererChromium::drawHeadsUpDisplay(const CCScopedTexture* hudTexture, const IntSize& hudSize)
     1094{
     1095    ASSERT(hudTexture->id());
     1096
    11011097    GLC(m_context, m_context->enable(GraphicsContext3D::BLEND));
    11021098    GLC(m_context, m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
     
    11071103    ASSERT(program && program->initialized());
    11081104    GLC(m_context, m_context->activeTexture(GraphicsContext3D::TEXTURE0));
    1109     if (!hudTexture->textureId())
    1110         hudTexture->allocate(m_implTextureAllocator.get());
    1111     GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, hudTexture->textureId()));
     1105    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, hudTexture->id()));
    11121106    GLC(m_context, m_context->useProgram(program->program()));
    11131107    GLC(m_context, m_context->uniform1i(program->fragmentShader().samplerLocation(), 0));
     
    13531347}
    13541348
    1355 bool LayerRendererChromium::getFramebufferTexture(ManagedTexture* texture, const IntRect& deviceRect)
    1356 {
    1357     if (!texture->reserve(deviceRect.size(), GraphicsContext3D::RGB))
     1349bool LayerRendererChromium::getFramebufferTexture(CCScopedTexture* texture, const IntRect& deviceRect)
     1350{
     1351    ASSERT(!texture->id() || (texture->size() == deviceRect.size() && texture->format() == GraphicsContext3D::RGB));
     1352
     1353    if (!texture->id() && !texture->allocate(deviceRect.size(), GraphicsContext3D::RGB))
    13581354        return false;
    13591355
    1360     if (!texture->textureId())
    1361         texture->allocate(m_implTextureAllocator.get());
    1362     GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture->textureId()));
     1356    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture->id()));
    13631357    GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, texture->format(),
    13641358                                             deviceRect.x(), deviceRect.y(), deviceRect.width(), deviceRect.height(), 0));
     
    13681362bool LayerRendererChromium::isCurrentRenderPass(const CCRenderPass* renderPass)
    13691363{
    1370     return m_currentRenderPass == renderPass && !m_currentManagedTexture;
     1364    return m_currentRenderPass == renderPass && !m_currentTexture;
    13711365}
    13721366
     
    13741368{
    13751369    m_currentRenderPass = renderPass;
    1376     m_currentManagedTexture = 0;
     1370    m_currentTexture = 0;
    13771371
    13781372    if (renderPass == m_defaultRenderPass) {
     
    13821376    }
    13831377
    1384     ManagedTexture* texture = m_renderPassTextures.get(renderPass->id());
     1378    CCScopedTexture* texture = m_renderPassTextures.get(renderPass->id());
    13851379    ASSERT(texture);
    13861380
     1381    if (!texture->id() && !texture->allocate(renderPassTextureSize(renderPass), renderPassTextureFormat(renderPass)))
     1382        return false;
     1383
    13871384    return bindFramebufferToTexture(texture, renderPass->framebufferOutputRect());
    13881385}
    13891386
    1390 bool LayerRendererChromium::useManagedTexture(ManagedTexture* texture, const IntRect& viewportRect)
    1391 {
     1387bool LayerRendererChromium::useScopedTexture(const CCScopedTexture* texture, const IntRect& viewportRect)
     1388{
     1389    ASSERT(texture->id());
     1390
    13921391    m_currentRenderPass = 0;
    1393     m_currentManagedTexture = texture;
     1392    m_currentTexture = texture;
    13941393
    13951394    return bindFramebufferToTexture(texture, viewportRect);
    13961395}
    13971396
    1398 bool LayerRendererChromium::bindFramebufferToTexture(ManagedTexture* texture, const IntRect& framebufferRect)
    1399 {
     1397bool LayerRendererChromium::bindFramebufferToTexture(const CCScopedTexture* texture, const IntRect& framebufferRect)
     1398{
     1399    ASSERT(texture->id());
     1400
    14001401    GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_offscreenFramebufferId));
    1401 
    1402     if (!texture->textureId())
    1403         texture->allocate(m_implTextureAllocator.get());
    1404     GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, texture->textureId(), 0));
     1402    GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, texture->id(), 0));
    14051403
    14061404#if !defined ( NDEBUG )
     
    14741472    GLC(m_context, m_context->flush());
    14751473
    1476     m_implTextureManager = TextureManager::create(std::numeric_limits<size_t>::max(), std::numeric_limits<size_t>::max(), m_capabilities.maxTextureSize);
    14771474    m_textureCopier = AcceleratedTextureCopier::create(m_context, m_isUsingBindUniform);
    14781475    if (m_textureUploaderSetting == ThrottledUploader)
     
    14801477    else
    14811478        m_textureUploader = UnthrottledTextureUploader::create();
    1482     m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context);
    1483     m_implTextureAllocator = TrackingTextureAllocator::create(m_context);
     1479    m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context, m_capabilities.maxTextureSize);
     1480    m_implTextureAllocator = TrackingTextureAllocator::create(m_context, m_capabilities.maxTextureSize);
    14841481    if (m_capabilities.usingTextureUsageHint)
    14851482        m_implTextureAllocator->setTextureUsageHint(TrackingTextureAllocator::FramebufferAttachment);
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r122160 r122272  
    5252class CCIOSurfaceDrawQuad;
    5353class CCRenderPassDrawQuad;
     54class CCScopedTexture;
    5455class CCSolidColorDrawQuad;
    5556class CCStreamVideoDrawQuad;
     
    5859class CCYUVVideoDrawQuad;
    5960class GeometryBinding;
    60 class ManagedTexture;
    6161class ScopedEnsureFramebufferAllocation;
    6262
     
    8787    virtual void finishDrawingFrame() OVERRIDE;
    8888
    89     virtual void drawHeadsUpDisplay(ManagedTexture*, const IntSize& hudSize) OVERRIDE;
     89    virtual void drawHeadsUpDisplay(const CCScopedTexture*, const IntSize& hudSize) OVERRIDE;
    9090
    9191    // waits for rendering to finish
     
    101101
    102102    virtual void getFramebufferPixels(void *pixels, const IntRect&) OVERRIDE;
    103     bool getFramebufferTexture(ManagedTexture*, const IntRect& deviceRect);
    104 
    105     virtual TextureManager* implTextureManager() const OVERRIDE { return m_implTextureManager.get(); }
     103    bool getFramebufferTexture(CCScopedTexture*, const IntRect& deviceRect);
     104
    106105    virtual TextureCopier* textureCopier() const OVERRIDE { return m_textureCopier.get(); }
    107106    virtual TextureUploader* textureUploader() const OVERRIDE { return m_textureUploader.get(); }
     
    134133    void drawCheckerboardQuad(const CCCheckerboardDrawQuad*);
    135134    void drawDebugBorderQuad(const CCDebugBorderDrawQuad*);
    136     PassOwnPtr<ManagedTexture> drawBackgroundFilters(const CCRenderPassDrawQuad*, const WebKit::WebTransformationMatrix& deviceTransform);
     135    PassOwnPtr<CCScopedTexture> drawBackgroundFilters(const CCRenderPassDrawQuad*, const WebKit::WebTransformationMatrix& deviceTransform);
    137136    void drawRenderPassQuad(const CCRenderPassDrawQuad*);
    138137    void drawSolidColorQuad(const CCSolidColorDrawQuad*);
     
    145144    void setDrawFramebufferRect(const IntRect&, bool flipY);
    146145
    147     // The current drawing target is either a RenderPass or ManagedTexture. Use these functions to switch to a new drawing target.
     146    // The current drawing target is either a RenderPass or ScopedTexture. Use these functions to switch to a new drawing target.
    148147    bool useRenderPass(const CCRenderPass*);
    149     bool useManagedTexture(ManagedTexture*, const IntRect& viewportRect);
     148    bool useScopedTexture(const CCScopedTexture*, const IntRect& viewportRect);
    150149    bool isCurrentRenderPass(const CCRenderPass*);
    151150
    152     bool bindFramebufferToTexture(ManagedTexture*, const IntRect& viewportRect);
     151    bool bindFramebufferToTexture(const CCScopedTexture*, const IntRect& viewportRect);
    153152
    154153    void clearRenderPass(const CCRenderPass*, const FloatRect& framebufferDamageRect);
     
    171170    virtual void onContextLost() OVERRIDE;
    172171
     172    static IntSize renderPassTextureSize(const CCRenderPass*);
     173    static GC3Denum renderPassTextureFormat(const CCRenderPass*);
     174
    173175    LayerRendererCapabilities m_capabilities;
    174176
    175177    const CCRenderPass* m_currentRenderPass;
    176     ManagedTexture* m_currentManagedTexture;
     178    const CCScopedTexture* m_currentTexture;
    177179    unsigned m_offscreenFramebufferId;
    178180
     
    260262    OwnPtr<HeadsUpDisplayProgram> m_headsUpDisplayProgram;
    261263
    262     OwnPtr<TextureManager> m_implTextureManager;
    263264    OwnPtr<AcceleratedTextureCopier> m_textureCopier;
    264265    OwnPtr<TextureUploader> m_textureUploader;
     
    266267    OwnPtr<TrackingTextureAllocator> m_implTextureAllocator;
    267268
    268     HashMap<int, OwnPtr<ManagedTexture> > m_renderPassTextures;
     269    HashMap<int, OwnPtr<CCScopedTexture> > m_renderPassTextures;
    269270
    270271    WebKit::WebGraphicsContext3D* m_context;
  • trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp

    r121204 r122272  
    3434namespace WebCore {
    3535
    36 TrackingTextureAllocator::TrackingTextureAllocator(WebKit::WebGraphicsContext3D* context)
     36TrackingTextureAllocator::TrackingTextureAllocator(WebKit::WebGraphicsContext3D* context, int maxTextureSize)
    3737    : m_context(context)
     38    , m_maxTextureSize(maxTextureSize)
    3839    , m_currentMemoryUseBytes(0)
    3940    , m_textureUsageHint(Any)
     
    7273unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum format)
    7374{
     75    if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize)
     76        return 0;
     77
    7478    m_currentMemoryUseBytes += TextureManager::memoryUseBytes(size, format);
    7579
  • trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h

    r121204 r122272  
    3939    WTF_MAKE_NONCOPYABLE(TrackingTextureAllocator);
    4040public:
    41     static PassOwnPtr<TrackingTextureAllocator> create(WebKit::WebGraphicsContext3D* context)
     41    static PassOwnPtr<TrackingTextureAllocator> create(WebKit::WebGraphicsContext3D* context, int maxTextureSize)
    4242    {
    43         return adoptPtr(new TrackingTextureAllocator(context));
     43        return adoptPtr(new TrackingTextureAllocator(context, maxTextureSize));
    4444    }
    4545    virtual ~TrackingTextureAllocator();
     
    5757
    5858protected:
    59     explicit TrackingTextureAllocator(WebKit::WebGraphicsContext3D*);
     59    TrackingTextureAllocator(WebKit::WebGraphicsContext3D*, int maxTextureSize);
    6060
    6161    WebKit::WebGraphicsContext3D* m_context;
     62    int m_maxTextureSize;
    6263    size_t m_currentMemoryUseBytes;
    6364    TextureUsageHint m_textureUsageHint;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp

    r121361 r122272  
    7676    }
    7777    if (!m_hudTexture)
    78         m_hudTexture = ManagedTexture::create(layerRenderer->implTextureManager());
     78        m_hudTexture = CCScopedTexture::create(layerRenderer->implTextureAllocator());
    7979
    8080    const CCLayerTreeSettings& settings = layerTreeHostImpl->settings();
     
    8989    }
    9090
    91     if (!m_hudTexture->reserve(hudSize, GraphicsContext3D::RGBA))
     91    if (!m_hudTexture->id() && !m_hudTexture->allocate(hudSize, GraphicsContext3D::RGBA))
    9292        return;
    9393
     
    105105        PlatformCanvas::AutoLocker locker(&canvas);
    106106
    107         m_hudTexture->bindTexture(layerTreeHostImpl->context(), layerRenderer->implTextureAllocator());
     107        GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_hudTexture->id()));
    108108        bool uploadedViaMap = false;
    109109        if (layerRenderer->capabilities().usingMapSub) {
     
    123123
    124124    layerRenderer->drawHeadsUpDisplay(m_hudTexture.get(), hudSize);
    125 
    126     m_hudTexture->unreserve();
    127125}
    128126
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.h

    r120820 r122272  
    2828#if USE(ACCELERATED_COMPOSITING)
    2929
    30 #include "ManagedTexture.h"
    3130#include "cc/CCFontAtlas.h"
     31#include "cc/CCScopedTexture.h"
    3232
    3333namespace WebCore {
     
    3737class CCLayerTreeHostImpl;
    3838class GraphicsContext;
     39class TexureAllocator;
    3940
    4041struct CCLayerTreeSettings;
     
    6768    bool showDebugRects(const CCLayerTreeSettings&) const;
    6869
    69     OwnPtr<ManagedTexture> m_hudTexture;
     70    OwnPtr<CCScopedTexture> m_hudTexture;
    7071    OwnPtr<CCFontAtlas> m_fontAtlas;
    7172};
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderer.h

    r122160 r122272  
    3636namespace WebCore {
    3737
     38class CCScopedTexture;
    3839class TextureAllocator;
    3940class TextureCopier;
     
    7980    virtual void finishDrawingFrame() = 0;
    8081
    81     virtual void drawHeadsUpDisplay(ManagedTexture*, const IntSize& hudSize) = 0;
     82    virtual void drawHeadsUpDisplay(const CCScopedTexture*, const IntSize& hudSize) = 0;
    8283
    8384    // waits for rendering to finish
     
    9091    virtual void getFramebufferPixels(void *pixels, const IntRect&) = 0;
    9192
    92     virtual TextureManager* implTextureManager() const = 0;
    9393    virtual TextureCopier* textureCopier() const = 0;
    9494    virtual TextureUploader* textureUploader() const = 0;
  • trunk/Source/WebKit/chromium/ChangeLog

    r122255 r122272  
     12012-07-09  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Replace use of ManagedTexture with CCScopedTexture for impl thread and remove implTextureManager from LayerRendererChromium
     4        https://bugs.webkit.org/show_bug.cgi?id=90841
     5
     6        Reviewed by Adrienne Walker.
     7
     8        * tests/CCLayerTreeHostImplTest.cpp:
     9
    1102012-07-10  Xianzhu Wang  <wangxianzhu@chromium.org>
    211
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp

    r122252 r122272  
    23682368    // Kill the layer tree.
    23692369    m_hostImpl->setRootLayer(CCLayerImpl::create(100));
    2370     // FIXME: Remove this when we don't use ManagedTextures in impl layers.
    2371     m_hostImpl->layerRenderer()->implTextureManager()->deleteEvictedTextures(m_hostImpl->layerRenderer()->implTextureAllocator());
    23722370    // There should be no textures left in use after.
    23732371    EXPECT_EQ(0u, trackingWebGraphicsContext->numTextures());
Note: See TracChangeset for help on using the changeset viewer.