Changeset 122160 in webkit


Ignore:
Timestamp:
Jul 9, 2012 3:31:25 PM (12 years ago)
Author:
danakj@chromium.org
Message:

[chromium] Decouple RenderPass drawing from CCRenderSurface
https://bugs.webkit.org/show_bug.cgi?id=90573

Reviewed by Adrienne Walker.

Source/WebCore:

Removes the managed textures from CCRenderSurface and stores them in a
HashMap in LayerRendererChromium.

At the start of a frame, all textures for the frame are reserved, and
unneeded textures are deleted. After each quad is drawn, evicted textures
(ie temporary textures used for background filters) are deleted to keep
within memory limits. At the end of the frame, all surface contents
textures are kept reserved and thus not deleted.

We add a numeric identifier to CCRenderPass which can be used to
identify the pass across serialization in the future, and is used
in the interface to LayerRendererChromium. Also we add to the
CCRenderPass a contentsChangedSinceLastFrame() flag so that the
value does not need to be retrieved from the CCRenderSurface.

The pointer from CCRenderPass to CCRenderSurface remains for some
code in the CCLayerTreeHostImpl, and will be addressed in the future, but
the pointer is no longer used at all while drawing a frame inside
LayerRendererChromium.

Covered by existing tests, no intended change in behaviour.

  • platform/graphics/chromium/LayerRendererChromium.cpp:

(WebCore::LayerRendererChromium::releaseRenderPassTextures):
(WebCore::LayerRendererChromium::decideRenderPassAllocationsForFrame):
(WebCore):
(WebCore::LayerRendererChromium::haveCachedResourcesForRenderPassId):
(WebCore::LayerRendererChromium::drawQuad):
(WebCore::LayerRendererChromium::drawBackgroundFilters):
(WebCore::LayerRendererChromium::drawRenderPassQuad):
(WebCore::LayerRendererChromium::finishDrawingFrame):
(WebCore::LayerRendererChromium::useRenderPass):
(WebCore::LayerRendererChromium::initializeSharedObjects):

  • platform/graphics/chromium/LayerRendererChromium.h:

(LayerRendererChromium):

  • platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:

(WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
(WebCore::CCLayerTreeHostImpl::removePassesWithCachedTextures):

  • platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:

(CCLayerTreeHostImpl):

  • platform/graphics/chromium/cc/CCRenderPass.cpp:

(WebCore::CCRenderPass::create):
(WebCore::CCRenderPass::CCRenderPass):

  • platform/graphics/chromium/cc/CCRenderPass.h:

(CCRenderPass):
(WebCore::CCRenderPass::id):
(WebCore::CCRenderPass::setFramebufferOutputRect):

  • platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp:

(WebCore::CCRenderPassDrawQuad::create):
(WebCore::CCRenderPassDrawQuad::CCRenderPassDrawQuad):

  • platform/graphics/chromium/cc/CCRenderPassDrawQuad.h:

(CCRenderPassDrawQuad):
(WebCore::CCRenderPassDrawQuad::renderPassId):
(WebCore::CCRenderPassDrawQuad::contentsChangedSinceLastFrame):

  • platform/graphics/chromium/cc/CCRenderSurface.cpp:

(WebCore::CCRenderSurface::appendQuads):

  • platform/graphics/chromium/cc/CCRenderSurface.h:

(WebCore):
(CCRenderSurface):

  • platform/graphics/chromium/cc/CCRenderer.h:

(CCRenderer):

  • platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:

(WebCore::CCTiledLayerImpl::pushTileProperties):

  • platform/graphics/chromium/cc/CCTiledLayerImpl.h:

(CCTiledLayerImpl):

Source/WebKit/chromium:

  • tests/CCLayerTreeHostImplTest.cpp:
  • tests/LayerRendererChromiumTest.cpp:

(FakeCCRendererClient::FakeCCRendererClient):

Location:
trunk/Source
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122159 r122160  
     12012-07-09  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Decouple RenderPass drawing from CCRenderSurface
     4        https://bugs.webkit.org/show_bug.cgi?id=90573
     5
     6        Reviewed by Adrienne Walker.
     7
     8        Removes the managed textures from CCRenderSurface and stores them in a
     9        HashMap in LayerRendererChromium.
     10
     11        At the start of a frame, all textures for the frame are reserved, and
     12        unneeded textures are deleted. After each quad is drawn, evicted textures
     13        (ie temporary textures used for background filters) are deleted to keep
     14        within memory limits. At the end of the frame, all surface contents
     15        textures are kept reserved and thus not deleted.
     16
     17        We add a numeric identifier to CCRenderPass which can be used to
     18        identify the pass across serialization in the future, and is used
     19        in the interface to LayerRendererChromium. Also we add to the
     20        CCRenderPass a contentsChangedSinceLastFrame() flag so that the
     21        value does not need to be retrieved from the CCRenderSurface.
     22
     23        The pointer from CCRenderPass to CCRenderSurface remains for some
     24        code in the CCLayerTreeHostImpl, and will be addressed in the future, but
     25        the pointer is no longer used at all while drawing a frame inside
     26        LayerRendererChromium.
     27
     28        Covered by existing tests, no intended change in behaviour.
     29
     30        * platform/graphics/chromium/LayerRendererChromium.cpp:
     31        (WebCore::LayerRendererChromium::releaseRenderPassTextures):
     32        (WebCore::LayerRendererChromium::decideRenderPassAllocationsForFrame):
     33        (WebCore):
     34        (WebCore::LayerRendererChromium::haveCachedResourcesForRenderPassId):
     35        (WebCore::LayerRendererChromium::drawQuad):
     36        (WebCore::LayerRendererChromium::drawBackgroundFilters):
     37        (WebCore::LayerRendererChromium::drawRenderPassQuad):
     38        (WebCore::LayerRendererChromium::finishDrawingFrame):
     39        (WebCore::LayerRendererChromium::useRenderPass):
     40        (WebCore::LayerRendererChromium::initializeSharedObjects):
     41        * platform/graphics/chromium/LayerRendererChromium.h:
     42        (LayerRendererChromium):
     43        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
     44        (WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
     45        (WebCore::CCLayerTreeHostImpl::removePassesWithCachedTextures):
     46        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
     47        (CCLayerTreeHostImpl):
     48        * platform/graphics/chromium/cc/CCRenderPass.cpp:
     49        (WebCore::CCRenderPass::create):
     50        (WebCore::CCRenderPass::CCRenderPass):
     51        * platform/graphics/chromium/cc/CCRenderPass.h:
     52        (CCRenderPass):
     53        (WebCore::CCRenderPass::id):
     54        (WebCore::CCRenderPass::setFramebufferOutputRect):
     55        * platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp:
     56        (WebCore::CCRenderPassDrawQuad::create):
     57        (WebCore::CCRenderPassDrawQuad::CCRenderPassDrawQuad):
     58        * platform/graphics/chromium/cc/CCRenderPassDrawQuad.h:
     59        (CCRenderPassDrawQuad):
     60        (WebCore::CCRenderPassDrawQuad::renderPassId):
     61        (WebCore::CCRenderPassDrawQuad::contentsChangedSinceLastFrame):
     62        * platform/graphics/chromium/cc/CCRenderSurface.cpp:
     63        (WebCore::CCRenderSurface::appendQuads):
     64        * platform/graphics/chromium/cc/CCRenderSurface.h:
     65        (WebCore):
     66        (CCRenderSurface):
     67        * platform/graphics/chromium/cc/CCRenderer.h:
     68        (CCRenderer):
     69        * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
     70        (WebCore::CCTiledLayerImpl::pushTileProperties):
     71        * platform/graphics/chromium/cc/CCTiledLayerImpl.h:
     72        (CCTiledLayerImpl):
     73
    1742012-07-09  Adam Klein  <adamk@chromium.org>
    275
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r121870 r122160  
    275275void LayerRendererChromium::releaseRenderPassTextures()
    276276{
    277     if (m_implTextureManager)
    278         m_implTextureManager->evictAndDeleteAllTextures(m_implTextureAllocator.get());
     277    if (!m_implTextureManager)
     278        return;
     279    m_renderPassTextures.clear();
     280    m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get());
    279281}
    280282
     
    316318void LayerRendererChromium::decideRenderPassAllocationsForFrame(const CCRenderPassList& renderPassesInDrawOrder)
    317319{
    318     // FIXME: Get this memory limit from GPU Memory Manager
    319     size_t contentsMemoryUseBytes = m_contentsTextureAllocator->currentMemoryUseBytes();
    320     size_t maxLimitBytes = TextureManager::highLimitBytes(viewportSize());
    321     size_t memoryLimitBytes = maxLimitBytes - contentsMemoryUseBytes > 0u ? maxLimitBytes - contentsMemoryUseBytes : 0u;
    322 
    323     m_implTextureManager->setMaxMemoryLimitBytes(memoryLimitBytes);
     320    HashMap<int, const CCRenderPass*> passesInFrame;
     321    for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i)
     322        passesInFrame.set(renderPassesInDrawOrder[i]->id(), renderPassesInDrawOrder[i].get());
     323
     324    Vector<int> passesToDelete;
     325    HashMap<int, OwnPtr<ManagedTexture> >::const_iterator passIterator;
     326    for (passIterator = m_renderPassTextures.begin(); passIterator != m_renderPassTextures.end(); ++passIterator) {
     327        const CCRenderPass* renderPassInFrame = passesInFrame.get(passIterator->first);
     328        if (!renderPassInFrame) {
     329            passesToDelete.append(passIterator->first);
     330            continue;
     331        }
     332
     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        }
     340    }
     341
     342    // Delete RenderPass textures from the previous frame that will not be used again.
     343    for (size_t i = 0; i < passesToDelete.size(); ++i)
     344        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.
     349    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        }
     356
     357        const IntSize& requiredSize = renderPassesInDrawOrder[i]->framebufferOutputRect().size();
     358        GC3Denum requiredFormat = GraphicsContext3D::RGBA;
     359        bool reserved = texture->reserve(requiredSize, requiredFormat);
     360        ASSERT_UNUSED(reserved, reserved);
     361    }
     362}
     363
     364bool LayerRendererChromium::haveCachedResourcesForRenderPassId(int id) const
     365{
     366    ManagedTexture* texture = m_renderPassTextures.get(id);
     367    return texture && texture->textureId();
    324368}
    325369
     
    420464        break;
    421465    }
     466
     467    m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get());
    422468}
    423469
     
    489535}
    490536
    491 void LayerRendererChromium::drawBackgroundFilters(const CCRenderPassDrawQuad* quad, const WebTransformationMatrix& contentsDeviceTransform)
     537PassOwnPtr<ManagedTexture> LayerRendererChromium::drawBackgroundFilters(const CCRenderPassDrawQuad* quad, const WebTransformationMatrix& contentsDeviceTransform)
    492538{
    493539    // This method draws a background filter, which applies a filter to any pixels behind the quad and seen through its background.
     
    507553    // FIXME: When this algorithm changes, update CCLayerTreeHost::prioritizeTextures() accordingly.
    508554
    509     CCRenderSurface* drawingSurface = quad->renderPass()->targetSurface();
    510555    if (quad->backgroundFilters().isEmpty())
    511         return;
     556        return nullptr;
    512557
    513558    // FIXME: We only allow background filters on an opaque render surface because other surfaces may contain
    514559    // translucent pixels, and the contents behind those translucent pixels wouldn't have the filter applied.
    515560    if (m_currentRenderPass->hasTransparentBackground())
    516         return;
     561        return nullptr;
    517562    ASSERT(!m_currentManagedTexture);
    518563
     
    529574    OwnPtr<ManagedTexture> deviceBackgroundTexture = ManagedTexture::create(m_implTextureManager.get());
    530575    if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect))
    531         return;
     576        return nullptr;
    532577
    533578    SkBitmap filteredDeviceBackground = applyFilters(this, quad->backgroundFilters(), deviceBackgroundTexture.get());
    534579    if (!filteredDeviceBackground.getTexture())
    535         return;
     580        return nullptr;
    536581
    537582    GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.getTexture());
    538583    int filteredDeviceBackgroundTextureId = texture->getTextureHandle();
    539584
    540     if (!drawingSurface->prepareBackgroundTexture(this))
    541         return;
     585    OwnPtr<ManagedTexture> backgroundTexture = ManagedTexture::create(m_implTextureManager.get());
     586    if (!backgroundTexture->reserve(quad->quadRect().size(), GraphicsContext3D::RGBA))
     587        return nullptr;
    542588
    543589    const CCRenderPass* targetRenderPass = m_currentRenderPass;
    544     if (useManagedTexture(drawingSurface->backgroundTexture(), quad->quadRect())) {
     590    bool usingBackgroundTexture = useManagedTexture(backgroundTexture.get(), quad->quadRect());
     591
     592    if (usingBackgroundTexture) {
    545593        // Copy the readback pixels from device to the background texture for the surface.
    546594        WebTransformationMatrix deviceToFramebufferTransform;
     
    552600
    553601        copyTextureToFramebuffer(filteredDeviceBackgroundTextureId, deviceRect.size(), deviceToFramebufferTransform);
    554 
    555         useRenderPass(targetRenderPass);
    556     }
     602    }
     603
     604    useRenderPass(targetRenderPass);
     605
     606    if (!usingBackgroundTexture)
     607        return nullptr;
     608    return backgroundTexture.release();
    557609}
    558610
    559611void LayerRendererChromium::drawRenderPassQuad(const CCRenderPassDrawQuad* quad)
    560612{
    561     // The replica is always drawn first, so free after drawing the contents.
    562     bool shouldReleaseTextures = !quad->isReplica();
    563 
    564     CCRenderSurface* drawingSurface = quad->renderPass()->targetSurface();
    565 
    566613    WebTransformationMatrix renderTransform = quad->layerTransform();
    567614    // Apply a scaling factor to size the quad from 1x1 to its intended size.
     
    570617
    571618    // Can only draw surface if device matrix is invertible.
    572     if (!contentsDeviceTransform.isInvertible() || !drawingSurface->hasValidContentsTexture()) {
    573         if (shouldReleaseTextures) {
    574             drawingSurface->releaseBackgroundTexture();
    575             drawingSurface->releaseContentsTexture();
    576         }
     619    if (!contentsDeviceTransform.isInvertible())
    577620        return;
    578     }
    579 
    580     drawBackgroundFilters(quad, contentsDeviceTransform);
     621
     622    ManagedTexture* contentsTexture = m_renderPassTextures.get(quad->renderPassId());
     623    ASSERT(contentsTexture && contentsTexture->textureId());
     624
     625    OwnPtr<ManagedTexture> backgroundTexture = drawBackgroundFilters(quad, contentsDeviceTransform);
    581626
    582627    // FIXME: Cache this value so that we don't have to do it for both the surface and its replica.
    583628    // Apply filters to the contents texture.
    584     SkBitmap filterBitmap = applyFilters(this, quad->filters(), drawingSurface->contentsTexture());
    585     int contentsTextureId = drawingSurface->contentsTexture()->textureId();
     629    SkBitmap filterBitmap = applyFilters(this, quad->filters(), contentsTexture);
     630    int contentsTextureId = contentsTexture->textureId();
    586631    if (filterBitmap.getTexture()) {
    587632        GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTexture());
     
    590635
    591636    // Draw the background texture if there is one.
    592     if (drawingSurface->hasValidBackgroundTexture())
    593         copyTextureToFramebuffer(drawingSurface->backgroundTexture()->textureId(), quad->quadRect().size(), quad->layerTransform());
     637    if (backgroundTexture) {
     638        ASSERT(backgroundTexture->size() == quad->quadRect().size());
     639        copyTextureToFramebuffer(backgroundTexture->textureId(), quad->quadRect().size(), quad->layerTransform());
     640    }
    594641
    595642    bool clipped = false;
     
    674721    drawTexturedQuad(quad->layerTransform(), quad->quadRect().width(), quad->quadRect().height(), quad->opacity(), surfaceQuad,
    675722                     shaderMatrixLocation, shaderAlphaLocation, shaderQuadLocation);
    676 
    677     if (shouldReleaseTextures) {
    678         drawingSurface->releaseBackgroundTexture();
    679         drawingSurface->releaseContentsTexture();
    680     }
    681723}
    682724
     
    10801122    GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
    10811123    GLC(m_context, m_context->disable(GraphicsContext3D::BLEND));
    1082 
    1083     m_implTextureManager->unprotectAllTextures();
    1084     m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get());
    10851124}
    10861125
     
    13401379    }
    13411380
    1342     if (!renderPass->targetSurface()->prepareContentsTexture(this))
    1343         return false;
    1344 
    1345     return bindFramebufferToTexture(renderPass->targetSurface()->contentsTexture(), renderPass->framebufferOutputRect());
     1381    ManagedTexture* texture = m_renderPassTextures.get(renderPass->id());
     1382    ASSERT(texture);
     1383
     1384    return bindFramebufferToTexture(texture, renderPass->framebufferOutputRect());
    13461385}
    13471386
     
    14321471    GLC(m_context, m_context->flush());
    14331472
    1434     m_implTextureManager = TextureManager::create(TextureManager::highLimitBytes(viewportSize()),
    1435                                                   TextureManager::reclaimLimitBytes(viewportSize()),
    1436                                                   m_capabilities.maxTextureSize);
     1473    m_implTextureManager = TextureManager::create(std::numeric_limits<size_t>::max(), std::numeric_limits<size_t>::max(), m_capabilities.maxTextureSize);
    14371474    m_textureCopier = AcceleratedTextureCopier::create(m_context, m_isUsingBindUniform);
    14381475    if (m_textureUploaderSetting == ThrottledUploader)
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r121823 r122160  
    8181
    8282    virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) OVERRIDE;
     83    virtual bool haveCachedResourcesForRenderPassId(int id) const OVERRIDE;
     84
    8385    virtual void beginDrawingFrame(const CCRenderPass* defaultRenderPass) OVERRIDE;
    8486    virtual void drawRenderPass(const CCRenderPass*, const FloatRect& framebufferDamageRect) OVERRIDE;
     
    124126    bool initialize();
    125127
     128    void releaseRenderPassTextures();
     129
    126130private:
    127131    static void toGLMatrix(float*, const WebKit::WebTransformationMatrix&);
     
    130134    void drawCheckerboardQuad(const CCCheckerboardDrawQuad*);
    131135    void drawDebugBorderQuad(const CCDebugBorderDrawQuad*);
    132     void drawBackgroundFilters(const CCRenderPassDrawQuad*, const WebKit::WebTransformationMatrix& deviceTransform);
     136    PassOwnPtr<ManagedTexture> drawBackgroundFilters(const CCRenderPassDrawQuad*, const WebKit::WebTransformationMatrix& deviceTransform);
    133137    void drawRenderPassQuad(const CCRenderPassDrawQuad*);
    134138    void drawSolidColorQuad(const CCSolidColorDrawQuad*);
     
    149153
    150154    void clearRenderPass(const CCRenderPass*, const FloatRect& framebufferDamageRect);
    151 
    152     void releaseRenderPassTextures();
    153155
    154156    bool makeContextCurrent();
     
    264266    OwnPtr<TrackingTextureAllocator> m_implTextureAllocator;
    265267
     268    HashMap<int, OwnPtr<ManagedTexture> > m_renderPassTextures;
     269
    266270    WebKit::WebGraphicsContext3D* m_context;
    267271
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp

    r121583 r122160  
    8686{
    8787    ASSERT(CCProxy::isImplThread());
    88     ASSERT(m_layerId >= 0);
     88    ASSERT(m_layerId > 0);
    8989}
    9090
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp

    r121450 r122160  
    296296        CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface();
    297297
    298         OwnPtr<CCRenderPass> pass = CCRenderPass::create(renderSurface);
     298        // FIXME: Make this unique across all CCLayerTreeHostImpls.
     299        int globalRenderPassId = renderSurfaceLayer->id();
     300
     301        OwnPtr<CCRenderPass> pass = CCRenderPass::create(renderSurface, globalRenderPassId);
    299302        surfacePassMap.add(renderSurface, pass.get());
    300303        frame.renderPasses.append(pass.release());
     
    352355
    353356    m_layerRenderer->decideRenderPassAllocationsForFrame(frame.renderPasses);
    354     removePassesWithCachedTextures(frame.renderPasses, frame.skippedPasses);
     357    removePassesWithCachedTextures(frame.renderPasses, frame.skippedPasses, m_layerRenderer.get());
    355358
    356359    return drawFrame;
     
    432435}
    433436
    434 void CCLayerTreeHostImpl::removePassesWithCachedTextures(CCRenderPassList& passes, CCRenderPassList& skippedPasses)
     437void CCLayerTreeHostImpl::removePassesWithCachedTextures(CCRenderPassList& passes, CCRenderPassList& skippedPasses, const CCRenderer* renderer)
    435438{
    436439    for (int passIndex = passes.size() - 1; passIndex >= 0; --passIndex) {
     
    446449
    447450            CCRenderPassDrawQuad* renderPassQuad = static_cast<CCRenderPassDrawQuad*>(currentQuad);
    448             CCRenderSurface* targetSurface = renderPassQuad->renderPass()->targetSurface();
    449 
    450             if (targetSurface->contentsChanged() || !targetSurface->hasCachedContentsTexture())
     451            if (!renderPassQuad->contentsChangedSinceLastFrame().isEmpty())
    451452                continue;
    452 
    453             // Reserve the texture immediately. We do not need to pass in layer renderer
    454             // since the texture already exists, just needs to be reserved.
    455             if (!targetSurface->prepareContentsTexture(0))
     453            if (!renderer->haveCachedResourcesForRenderPassId(renderPassQuad->renderPassId()))
    456454                continue;
    457455
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h

    r121396 r122160  
    179179
    180180    // Removes all render passes for which we have cached textures, and which did not change their content.
    181     static void removePassesWithCachedTextures(CCRenderPassList& passes, CCRenderPassList& skippedPasses);
     181    static void removePassesWithCachedTextures(CCRenderPassList& passes, CCRenderPassList& skippedPasses, const CCRenderer*);
    182182
    183183protected:
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp

    r121583 r122160  
    3838namespace WebCore {
    3939
    40 PassOwnPtr<CCRenderPass> CCRenderPass::create(CCRenderSurface* targetSurface)
     40PassOwnPtr<CCRenderPass> CCRenderPass::create(CCRenderSurface* targetSurface, int id)
    4141{
    42     return adoptPtr(new CCRenderPass(targetSurface));
     42    return adoptPtr(new CCRenderPass(targetSurface, id));
    4343}
    4444
    45 CCRenderPass::CCRenderPass(CCRenderSurface* targetSurface)
    46     : m_targetSurface(targetSurface)
     45CCRenderPass::CCRenderPass(CCRenderSurface* targetSurface, int id)
     46    : m_id(id)
     47    , m_targetSurface(targetSurface)
    4748    , m_framebufferOutputRect(targetSurface->contentRect())
    4849    , m_hasTransparentBackground(true)
    4950{
    50     ASSERT(m_targetSurface);
     51    ASSERT(targetSurface);
     52    ASSERT(id > 0);
    5153}
    5254
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h

    r121396 r122160  
    5454    WTF_MAKE_NONCOPYABLE(CCRenderPass);
    5555public:
    56     static PassOwnPtr<CCRenderPass> create(CCRenderSurface*);
     56    static PassOwnPtr<CCRenderPass> create(CCRenderSurface*, int id);
    5757
    5858    void appendQuadsForLayer(CCLayerImpl*, CCOcclusionTrackerImpl*, bool& hadMissingTiles);
     
    6161
    6262    const CCQuadList& quadList() const { return m_quadList; }
     63
     64    int id() const { return m_id; }
    6365    CCRenderSurface* targetSurface() const { return m_targetSurface; }
     66
    6467    // This denotes the bounds in physical pixels of the output generated by this RenderPass.
    6568    const IntRect& framebufferOutputRect() const { return m_framebufferOutputRect; }
     
    6972
    7073protected:
    71     explicit CCRenderPass(CCRenderSurface*);
     74    CCRenderPass(CCRenderSurface*, int id);
    7275
     76    int m_id;
    7377    CCRenderSurface* m_targetSurface;
    7478    CCQuadList m_quadList;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp

    r119419 r122160  
    2828#include "cc/CCRenderPassDrawQuad.h"
    2929
     30#include "cc/CCRenderPass.h"
     31
    3032namespace WebCore {
    3133
    32 PassOwnPtr<CCRenderPassDrawQuad> CCRenderPassDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCRenderPass* renderPass, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId)
     34PassOwnPtr<CCRenderPassDrawQuad> CCRenderPassDrawQuad::create(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCRenderPass* renderPass, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame)
    3335{
    34     return adoptPtr(new CCRenderPassDrawQuad(sharedQuadState, quadRect, renderPass, isReplica, filters, backgroundFilters, maskTextureId));
     36    return adoptPtr(new CCRenderPassDrawQuad(sharedQuadState, quadRect, renderPass, isReplica, filters, backgroundFilters, maskTextureId, contentsChangedSinceLastFrame));
    3537}
    3638
    37 CCRenderPassDrawQuad::CCRenderPassDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCRenderPass* renderPass, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId)
     39CCRenderPassDrawQuad::CCRenderPassDrawQuad(const CCSharedQuadState* sharedQuadState, const IntRect& quadRect, const CCRenderPass* renderPass, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame)
    3840    : CCDrawQuad(sharedQuadState, CCDrawQuad::RenderPass, quadRect)
    3941    , m_renderPass(renderPass)
     42    , m_renderPassId(renderPass->id())
    4043    , m_isReplica(isReplica)
    4144    , m_filters(filters)
    4245    , m_backgroundFilters(backgroundFilters)
    4346    , m_maskTextureId(maskTextureId)
     47    , m_contentsChangedSinceLastFrame(contentsChangedSinceLastFrame)
    4448{
    4549    ASSERT(m_renderPass);
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPassDrawQuad.h

    r119419 r122160  
    3838    WTF_MAKE_NONCOPYABLE(CCRenderPassDrawQuad);
    3939public:
    40     static PassOwnPtr<CCRenderPassDrawQuad> create(const CCSharedQuadState*, const IntRect&, const CCRenderPass*, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId);
     40    static PassOwnPtr<CCRenderPassDrawQuad> create(const CCSharedQuadState*, const IntRect&, const CCRenderPass*, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame);
    4141
    4242    const CCRenderPass* renderPass() const { return m_renderPass; }
     43    int renderPassId() const { return m_renderPassId; }
    4344    bool isReplica() const { return m_isReplica; }
    4445    unsigned maskTextureId() const { return m_maskTextureId; }
     46    const IntRect& contentsChangedSinceLastFrame() const { return m_contentsChangedSinceLastFrame; }
    4547
    4648    const WebKit::WebFilterOperations& filters() const { return m_filters; }
     
    4850
    4951private:
    50     CCRenderPassDrawQuad(const CCSharedQuadState*, const IntRect&, const CCRenderPass*, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId);
     52    CCRenderPassDrawQuad(const CCSharedQuadState*, const IntRect&, const CCRenderPass*, bool isReplica, const WebKit::WebFilterOperations& filters, const WebKit::WebFilterOperations& backgroundFilters, unsigned maskTextureId, const IntRect& contentsChangedSinceLastFrame);
    5153
    5254    const CCRenderPass* m_renderPass;
     55    int m_renderPassId;
    5356    bool m_isReplica;
    5457    WebKit::WebFilterOperations m_filters;
    5558    WebKit::WebFilterOperations m_backgroundFilters;
    5659    unsigned m_maskTextureId;
     60    IntRect m_contentsChangedSinceLastFrame;
    5761};
    5862
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp

    r121583 r122160  
    3232#include "GraphicsContext3D.h"
    3333#include "LayerRendererChromium.h"
    34 #include "ManagedTexture.h"
    3534#include "TextStream.h"
    3635#include "cc/CCDamageTracker.h"
     
    8685}
    8786
    88 bool CCRenderSurface::prepareContentsTexture(LayerRendererChromium* layerRenderer)
    89 {
    90     // FIXME: This method should be separated into two: one to reserve an
    91     // existing surface, and one to create a new one. That way we will not
    92     // need to pass null layerRenderer.
    93     if (layerRenderer) {
    94         TextureManager* textureManager = layerRenderer->implTextureManager();
    95 
    96         if (!m_contentsTexture)
    97             m_contentsTexture = ManagedTexture::create(textureManager);
    98     }
    99 
    100     if (!m_contentsTexture)
    101         return false;
    102 
    103     if (m_contentsTexture->isReserved())
    104         return true;
    105 
    106     if (!m_contentsTexture->reserve(m_contentRect.size(), GraphicsContext3D::RGBA))
    107         return false;
    108 
    109     return true;
    110 }
    111 
    112 void CCRenderSurface::releaseContentsTexture()
    113 {
    114     if (!m_contentsTexture || !m_contentsTexture->isReserved())
    115         return;
    116     m_contentsTexture->unreserve();
    117 }
    118 
    119 bool CCRenderSurface::hasValidContentsTexture() const
    120 {
    121     return m_contentsTexture && m_contentsTexture->isReserved() && m_contentsTexture->isValid(m_contentRect.size(), GraphicsContext3D::RGBA);
    122 }
    123 
    124 bool CCRenderSurface::hasCachedContentsTexture() const
    125 {
    126     return m_contentsTexture && m_contentsTexture->isValid(m_contentRect.size(), GraphicsContext3D::RGBA);
    127 }
    128 
    129 bool CCRenderSurface::prepareBackgroundTexture(LayerRendererChromium* layerRenderer)
    130 {
    131     TextureManager* textureManager = layerRenderer->implTextureManager();
    132 
    133     if (!m_backgroundTexture)
    134         m_backgroundTexture = ManagedTexture::create(textureManager);
    135 
    136     if (m_backgroundTexture->isReserved())
    137         return true;
    138 
    139     if (!m_backgroundTexture->reserve(m_contentRect.size(), GraphicsContext3D::RGBA))
    140         return false;
    141 
    142     return true;
    143 }
    144 
    145 void CCRenderSurface::releaseBackgroundTexture()
    146 {
    147     if (!m_backgroundTexture || !m_backgroundTexture->isReserved())
    148         return;
    149     m_backgroundTexture->unreserve();
    150 }
    151 
    152 bool CCRenderSurface::hasValidBackgroundTexture() const
    153 {
    154     return m_backgroundTexture && m_backgroundTexture->isReserved() && m_backgroundTexture->isValid(m_contentRect.size(), GraphicsContext3D::RGBA);
    155 }
    156 
    15787String CCRenderSurface::name() const
    15888{
     
    303233
    304234    int maskTextureId = maskLayer ? maskLayer->contentsTextureId() : 0;
    305 
    306     quadList.appendSurface(CCRenderPassDrawQuad::create(sharedQuadState, contentRect(), renderPass, forReplica, filters(), backgroundFilters(), maskTextureId));
     235    IntRect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect : IntRect();
     236
     237    quadList.appendSurface(CCRenderPassDrawQuad::create(sharedQuadState, contentRect(), renderPass, forReplica, filters(), backgroundFilters(), maskTextureId, contentsChangedSinceLastFrame));
    307238}
    308239
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h

    r121458 r122160  
    3232#include "FloatRect.h"
    3333#include "IntRect.h"
    34 #include "TextureManager.h"
    3534#include <public/WebFilterOperations.h>
    3635#include <public/WebTransformationMatrix.h>
     
    4645class CCLayerImpl;
    4746class LayerRendererChromium;
    48 class ManagedTexture;
    4947class TextStream;
    5048
     
    5452    explicit CCRenderSurface(CCLayerImpl*);
    5553    virtual ~CCRenderSurface();
    56 
    57     virtual bool prepareContentsTexture(LayerRendererChromium*);
    58     void releaseContentsTexture();
    59     bool hasValidContentsTexture() const;
    60     virtual bool hasCachedContentsTexture() const;
    61 
    62     bool prepareBackgroundTexture(LayerRendererChromium*);
    63     void releaseBackgroundTexture();
    64     bool hasValidBackgroundTexture() const;
    6554
    6655    String name() const;
     
    117106    const IntRect& scissorRect() const { return m_scissorRect; }
    118107
    119     virtual bool contentsChanged() const;
     108    bool contentsChanged() const;
    120109
    121110    void setContentRect(const IntRect&);
     
    124113    void clearLayerList() { m_layerList.clear(); }
    125114    Vector<CCLayerImpl*>& layerList() { return m_layerList; }
    126 
    127     ManagedTexture* contentsTexture() const { return m_contentsTexture.get(); }
    128     ManagedTexture* backgroundTexture() const { return m_backgroundTexture.get(); }
    129115
    130116    int owningLayerId() const;
     
    155141    IntRect m_contentRect;
    156142    bool m_surfacePropertyChanged;
    157 
    158     OwnPtr<ManagedTexture> m_contentsTexture;
    159     OwnPtr<ManagedTexture> m_backgroundTexture;
    160143
    161144    float m_drawOpacity;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderer.h

    r121076 r122160  
    7373
    7474    virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) = 0;
     75    virtual bool haveCachedResourcesForRenderPassId(int) const = 0;
     76
    7577    virtual void beginDrawingFrame(const CCRenderPass* defaultRenderPass) = 0;
    7678    virtual void drawRenderPass(const CCRenderPass*, const FloatRect& rootScissorRectInCurrentPass) = 0;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp

    r121396 r122160  
    3030#include "cc/CCTiledLayerImpl.h"
    3131
     32#include "GraphicsContext3D.h"
    3233#include "SkColor.h"
    3334#include "TextStream.h"
     
    221222}
    222223
    223 void CCTiledLayerImpl::pushTileProperties(int i, int j, Platform3DObject textureId, const IntRect& opaqueRect)
     224void CCTiledLayerImpl::pushTileProperties(int i, int j, unsigned textureId, const IntRect& opaqueRect)
    224225{
    225226    DrawableTile* tile = tileAt(i, j);
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.h

    r120820 r122160  
    5151    void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; }
    5252    void setTilingData(const CCLayerTilingData& tiler);
    53     void pushTileProperties(int, int, Platform3DObject textureId, const IntRect& opaqueRect);
     53    void pushTileProperties(int, int, unsigned textureId, const IntRect& opaqueRect);
    5454
    5555    void setContentsSwizzled(bool contentsSwizzled) { m_contentsSwizzled = contentsSwizzled; }
  • trunk/Source/WebKit/chromium/ChangeLog

    r122159 r122160  
     12012-07-09  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Decouple RenderPass drawing from CCRenderSurface
     4        https://bugs.webkit.org/show_bug.cgi?id=90573
     5
     6        Reviewed by Adrienne Walker.
     7
     8        * tests/CCLayerTreeHostImplTest.cpp:
     9        * tests/LayerRendererChromiumTest.cpp:
     10        (FakeCCRendererClient::FakeCCRendererClient):
     11
    1122012-07-09  Adam Klein  <adamk@chromium.org>
    213
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp

    r121450 r122160  
    128128    void setupScrollAndContentsLayers(const IntSize& contentSize)
    129129    {
    130         OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
     130        OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
    131131        root->setScrollable(true);
    132132        root->setScrollPosition(IntPoint(0, 0));
    133133        root->setMaxScrollPosition(contentSize);
    134         OwnPtr<CCLayerImpl> contents = CCLayerImpl::create(1);
     134        OwnPtr<CCLayerImpl> contents = CCLayerImpl::create(2);
    135135        contents->setDrawsContent(true);
    136136        contents->setBounds(contentSize);
     
    187187{
    188188    {
    189         OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
    190         root->addChild(CCLayerImpl::create(1));
     189        OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
    191190        root->addChild(CCLayerImpl::create(2));
    192         root->children()[1]->addChild(CCLayerImpl::create(3));
     191        root->addChild(CCLayerImpl::create(3));
    193192        root->children()[1]->addChild(CCLayerImpl::create(4));
    194         root->children()[1]->children()[0]->addChild(CCLayerImpl::create(5));
     193        root->children()[1]->addChild(CCLayerImpl::create(5));
     194        root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6));
    195195        m_hostImpl->setRootLayer(root.release());
    196196    }
     
    215215    IntSize scrollDelta(11, -15);
    216216    {
    217         OwnPtr<CCLayerImpl> root = CCLayerImpl::create(10);
     217        OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
    218218        root->setScrollPosition(scrollPosition);
    219219        root->setScrollable(true);
     
    264264TEST_F(CCLayerTreeHostImplTest, replaceTreeWhileScrolling)
    265265{
    266     const int scrollLayerId = 0;
     266    const int scrollLayerId = 1;
    267267
    268268    setupScrollAndContentsLayers(IntSize(100, 100));
     
    626626        setDrawsContent(true);
    627627        setSkipsDraw(false);
     628        setVisibleLayerRect(IntRect(0, 0, 10, 10));
    628629
    629630        OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100, 100), CCLayerTilingData::HasBorderTexels);
     631        tiler->setBounds(contentBounds());
    630632        setTilingData(*tiler.get());
    631633    }
     
    640642    // The root layer is always drawn, so run this test on a child layer that
    641643    // will be masked out by the root layer's bounds.
    642     m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0));
     644    m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
    643645    DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
    644646    root->setMasksToBounds(true);
    645647
    646     root->addChild(DidDrawCheckLayer::create(1));
     648    root->addChild(DidDrawCheckLayer::create(2));
    647649    DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[0].get());
    648650    // Ensure visibleLayerRect for layer is empty
     
    687689    m_hostImpl->setViewportSize(bigSize);
    688690
    689     m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0));
     691    m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
    690692    DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
    691693
    692     root->addChild(DidDrawCheckLayer::create(1));
     694    root->addChild(DidDrawCheckLayer::create(2));
    693695    DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->children()[0].get());
    694696
    695     root->addChild(DidDrawCheckLayer::create(2));
     697    root->addChild(DidDrawCheckLayer::create(3));
    696698    DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children()[1].get());
    697699    // This layer covers the occludedLayer above. Make this layer large so it can occlude.
     
    719721TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers)
    720722{
    721     m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0));
     723    m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
    722724    DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
    723725
    724     root->addChild(DidDrawCheckLayer::create(1));
     726    root->addChild(DidDrawCheckLayer::create(2));
    725727    DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()[0].get());
    726728
    727     layer1->addChild(DidDrawCheckLayer::create(2));
     729    layer1->addChild(DidDrawCheckLayer::create(3));
    728730    DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children()[0].get());
    729731
     
    770772{
    771773    // When the texture is not missing, we draw as usual.
    772     m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0));
     774    m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
    773775    DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
    774     root->addChild(MissingTextureAnimatingLayer::create(1, false, false, true));
     776    root->addChild(MissingTextureAnimatingLayer::create(2, false, false, true));
    775777
    776778    CCLayerTreeHostImpl::FrameData frame;
     
    781783
    782784    // When a texture is missing and we're not animating, we draw as usual with checkerboarding.
    783     m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0));
     785    m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
    784786    root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
    785     root->addChild(MissingTextureAnimatingLayer::create(1, true, false, false));
     787    root->addChild(MissingTextureAnimatingLayer::create(2, true, false, false));
    786788
    787789    EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
     
    790792
    791793    // When a texture is missing and we're animating, we don't want to draw anything.
    792     m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0));
     794    m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
    793795    root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
    794     root->addChild(MissingTextureAnimatingLayer::create(1, true, false, true));
     796    root->addChild(MissingTextureAnimatingLayer::create(2, true, false, true));
    795797
    796798    EXPECT_FALSE(m_hostImpl->prepareToDraw(frame));
     
    799801
    800802    // When the layer skips draw and we're animating, we still draw the frame.
    801     m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0));
     803    m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
    802804    root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
    803     root->addChild(MissingTextureAnimatingLayer::create(1, false, true, true));
     805    root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true));
    804806
    805807    EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
     
    810812TEST_F(CCLayerTreeHostImplTest, scrollRootIgnored)
    811813{
    812     OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
     814    OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
    813815    root->setScrollable(false);
    814816    m_hostImpl->setRootLayer(root.release());
     
    834836    contentLayer->setContentBounds(IntSize(surfaceSize.width() * 2, surfaceSize.height() * 2));
    835837
    836     OwnPtr<CCLayerImpl> scrollLayer = CCLayerImpl::create(0);
     838    OwnPtr<CCLayerImpl> scrollLayer = CCLayerImpl::create(2);
    837839    scrollLayer->setScrollable(true);
    838840    scrollLayer->setMaxScrollPosition(surfaceSize);
     
    853855{
    854856    IntSize surfaceSize(10, 10);
    855     OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
    856     root->addChild(createScrollableLayer(1, FloatPoint(5, 5), surfaceSize));
     857    OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
     858    root->addChild(createScrollableLayer(2, FloatPoint(5, 5), surfaceSize));
    857859    m_hostImpl->setRootLayer(root.release());
    858860    m_hostImpl->setViewportSize(surfaceSize);
     
    869871{
    870872    IntSize surfaceSize(10, 10);
    871     OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
    872     root->addChild(createScrollableLayer(1, FloatPoint(5, 5), surfaceSize));
     873    OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
     874    root->addChild(createScrollableLayer(2, FloatPoint(5, 5), surfaceSize));
    873875    m_hostImpl->setRootLayer(root.release());
    874876    m_hostImpl->setViewportSize(surfaceSize);
     
    884886{
    885887    IntSize surfaceSize(10, 10);
    886     OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
    887     OwnPtr<CCLayerImpl> child = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize);
     888    OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
     889    OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize);
    888890    m_hostImpl->setViewportSize(surfaceSize);
    889891
     
    907909{
    908910    IntSize surfaceSize(10, 10);
    909     OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(0, FloatPoint(5, 5), surfaceSize);
     911    OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize);
    910912    contentLayer->setShouldScrollOnMainThread(true);
    911913    contentLayer->setScrollable(false);
    912914
    913     OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize);
     915    OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize);
    914916    scrollLayer->addChild(contentLayer.release());
    915917
     
    926928    IntSize surfaceSize(10, 10);
    927929    float pageScale = 2;
    928     OwnPtr<CCLayerImpl> root = createScrollableLayer(0, FloatPoint(5, 5), surfaceSize);
     930    OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize);
    929931    m_hostImpl->setRootLayer(root.release());
    930932    m_hostImpl->setViewportSize(surfaceSize);
     
    944946    expectedScrollDelta.scale(pageScale);
    945947    OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
    946     expectContains(*scrollInfo.get(), 0, expectedScrollDelta);
     948    expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
    947949
    948950    // The scroll range should also have been updated.
     
    957959    IntSize surfaceSize(10, 10);
    958960    float pageScale = 2;
    959     OwnPtr<CCLayerImpl> root = createScrollableLayer(0, FloatPoint(5, 5), surfaceSize);
     961    OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize);
    960962    m_hostImpl->setRootLayer(root.release());
    961963    m_hostImpl->setViewportSize(surfaceSize);
     
    977979    // The scroll delta is not scaled because the main thread did not scale.
    978980    OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
    979     expectContains(*scrollInfo.get(), 0, expectedScrollDelta);
     981    expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
    980982
    981983    // The scroll range should also have been updated.
     
    989991{
    990992    IntSize surfaceSize(10, 10);
    991     OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
     993    OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
    992994    // Also mark the root scrollable so it becomes the root scroll layer.
    993995    root->setScrollable(true);
    994     root->addChild(createScrollableLayer(1, FloatPoint(5, 5), surfaceSize));
     996    int scrollLayerId = 2;
     997    root->addChild(createScrollableLayer(scrollLayerId, FloatPoint(5, 5), surfaceSize));
    995998    m_hostImpl->setRootLayer(root.release());
    996999    m_hostImpl->setViewportSize(surfaceSize);
     
    10121015    expectedScrollDelta.scale(pageScale);
    10131016    OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
    1014     expectContains(*scrollInfo.get(), 1, expectedScrollDelta);
     1017    expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
    10151018
    10161019    // The scroll range should not have changed.
     
    10271030    // scroll.
    10281031    IntSize surfaceSize(10, 10);
    1029     OwnPtr<CCLayerImpl> root = createScrollableLayer(0, FloatPoint(5, 5), surfaceSize);
    1030 
    1031     OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize);
     1032    OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize);
     1033
     1034    OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, FloatPoint(5, 5), surfaceSize);
    10321035    grandChild->setScrollPosition(IntPoint(0, 5));
    10331036
    1034     OwnPtr<CCLayerImpl> child = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize);
     1037    OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize);
    10351038    child->setScrollPosition(IntPoint(3, 0));
    10361039    child->addChild(grandChild.release());
     
    10631066    // should be applied to one of its ancestors if possible.
    10641067    IntSize surfaceSize(10, 10);
    1065     OwnPtr<CCLayerImpl> root = createScrollableLayer(0, FloatPoint(5, 5), surfaceSize);
    1066     OwnPtr<CCLayerImpl> child = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize);
     1068    OwnPtr<CCLayerImpl> root = createScrollableLayer(1, FloatPoint(5, 5), surfaceSize);
     1069    OwnPtr<CCLayerImpl> child = createScrollableLayer(2, FloatPoint(5, 5), surfaceSize);
    10671070
    10681071    child->setScrollable(false);
     
    10891092{
    10901093    IntSize surfaceSize(10, 10);
    1091     m_hostImpl->setRootLayer(createScrollableLayer(0, FloatPoint(5, 5), surfaceSize));
     1094    m_hostImpl->setRootLayer(createScrollableLayer(1, FloatPoint(5, 5), surfaceSize));
    10921095    m_hostImpl->setViewportSize(surfaceSize);
    10931096
     
    10951098    initializeLayerRendererAndDrawFrame();
    10961099    m_hostImpl->detachLayerTree();
    1097     m_hostImpl->setRootLayer(createScrollableLayer(0, FloatPoint(5, 5), surfaceSize));
     1100    m_hostImpl->setRootLayer(createScrollableLayer(2, FloatPoint(5, 5), surfaceSize));
    10981101
    10991102    // Scrolling should still work even though we did not draw yet.
     
    11871190
    11881191    {
    1189         OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
     1192        OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
    11901193        root->setAnchorPoint(FloatPoint(0, 0));
    11911194        root->setBounds(IntSize(10, 10));
     
    11961199    CCLayerImpl* root = m_hostImpl->rootLayer();
    11971200
    1198     root->addChild(BlendStateCheckLayer::create(1));
     1201    root->addChild(BlendStateCheckLayer::create(2));
    11991202    BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->children()[0].get());
    12001203
     
    12481251    m_hostImpl->didDrawAllLayers(frame);
    12491252
    1250     layer1->addChild(BlendStateCheckLayer::create(2));
     1253    layer1->addChild(BlendStateCheckLayer::create(3));
    12511254    BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->children()[0].get());
    12521255
     
    14081411    m_hostImpl->setViewportSize(viewportSize);
    14091412
    1410     m_hostImpl->setRootLayer(BlendStateCheckLayer::create(0));
     1413    m_hostImpl->setRootLayer(BlendStateCheckLayer::create(1));
    14111414    BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl->rootLayer());
    14121415    root->setExpectation(false, true);
     
    19982001TEST_F(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayers)
    19992002{
    2000     m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(0));
     2003    m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(1));
    20012004    ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificationCheckLayer*>(m_hostImpl->rootLayer());
    20022005
     
    22012204TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
    22022205{
    2203     OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(0));
    2204     rootLayer->setBounds(IntSize(10, 10));
    2205     rootLayer->setAnchorPoint(FloatPoint(0, 0));
    2206 
    2207     OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(1);
    2208     tileLayer->setBounds(IntSize(10, 10));
    2209     tileLayer->setAnchorPoint(FloatPoint(0, 0));
    2210     tileLayer->setContentBounds(IntSize(10, 10));
    2211     tileLayer->setDrawsContent(true);
    2212     tileLayer->setSkipsDraw(false);
    2213     OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 10), CCLayerTilingData::NoBorderTexels));
    2214     tilingData->setBounds(IntSize(10, 10));
    2215     tileLayer->setTilingData(*tilingData);
    2216     tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10));
    2217     rootLayer->addChild(tileLayer.release());
    2218 
    2219     OwnPtr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(2);
    2220     textureLayer->setBounds(IntSize(10, 10));
    2221     textureLayer->setAnchorPoint(FloatPoint(0, 0));
    2222     textureLayer->setContentBounds(IntSize(10, 10));
    2223     textureLayer->setDrawsContent(true);
    2224     textureLayer->setTextureId(1);
    2225     rootLayer->addChild(textureLayer.release());
    2226 
    2227     FakeVideoFrameProvider provider;
    2228     OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(3, &provider);
    2229     videoLayer->setBounds(IntSize(10, 10));
    2230     videoLayer->setAnchorPoint(FloatPoint(0, 0));
    2231     videoLayer->setContentBounds(IntSize(10, 10));
    2232     videoLayer->setDrawsContent(true);
    2233     videoLayer->setLayerTreeHostImpl(m_hostImpl.get());
    2234     rootLayer->addChild(videoLayer.release());
    2235 
    2236     OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(4);
    2237     ioSurfaceLayer->setBounds(IntSize(10, 10));
    2238     ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0));
    2239     ioSurfaceLayer->setContentBounds(IntSize(10, 10));
    2240     ioSurfaceLayer->setDrawsContent(true);
    2241     ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10));
    2242     ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());
    2243     rootLayer->addChild(ioSurfaceLayer.release());
    2244 
    2245     // Use a context that supports IOSurfaces
    2246     m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
    2247 
    2248     m_hostImpl->setRootLayer(rootLayer.release());
    2249 
    2250     CCLayerTreeHostImpl::FrameData frame;
    2251     EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
    2252     m_hostImpl->drawLayers(frame);
    2253     m_hostImpl->didDrawAllLayers(frame);
    2254     m_hostImpl->swapBuffers();
    2255 
    2256     // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSurface,
    2257     // that will warn if any resource from the previous context gets used.
    2258     m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new StrictWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
    2259     EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
    2260     m_hostImpl->drawLayers(frame);
    2261     m_hostImpl->didDrawAllLayers(frame);
    2262     m_hostImpl->swapBuffers();
    2263 }
    2264 
    2265 // Fake WebGraphicsContext3D that tracks the number of textures in use.
    2266 class TrackingWebGraphicsContext3D : public FakeWebGraphicsContext3D {
    2267 public:
    2268     TrackingWebGraphicsContext3D()
    2269         : FakeWebGraphicsContext3D()
    2270         , m_numTextures(0)
    2271     { }
    2272 
    2273     virtual WebGLId createTexture() OVERRIDE
    2274     {
    2275         WebGLId id = FakeWebGraphicsContext3D::createTexture();
    2276 
    2277         m_textures.set(id, true);
    2278         ++m_numTextures;
    2279         return id;
    2280     }
    2281 
    2282     virtual void deleteTexture(WebGLId id) OVERRIDE
    2283     {
    2284         if (!m_textures.get(id))
    2285             return;
    2286 
    2287         m_textures.set(id, false);
    2288         --m_numTextures;
    2289     }
    2290 
    2291     virtual WebString getString(WGC3Denum name) OVERRIDE
    2292     {
    2293         if (name == WebCore::GraphicsContext3D::EXTENSIONS)
    2294             return WebString("GL_CHROMIUM_iosurface GL_ARB_texture_rectangle");
    2295 
    2296         return WebString();
    2297     }
    2298 
    2299     unsigned numTextures() const { return m_numTextures; }
    2300 
    2301 private:
    2302     HashMap<WebGLId, bool> m_textures;
    2303     unsigned m_numTextures;
    2304 };
    2305 
    2306 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures)
    2307 {
    23082206    OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1));
    23092207    rootLayer->setBounds(IntSize(10, 10));
     
    23482246    rootLayer->addChild(ioSurfaceLayer.release());
    23492247
     2248    // Use a context that supports IOSurfaces
     2249    m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
     2250
     2251    m_hostImpl->setRootLayer(rootLayer.release());
     2252
     2253    CCLayerTreeHostImpl::FrameData frame;
     2254    EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
     2255    m_hostImpl->drawLayers(frame);
     2256    m_hostImpl->didDrawAllLayers(frame);
     2257    m_hostImpl->swapBuffers();
     2258
     2259    // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSurface,
     2260    // that will warn if any resource from the previous context gets used.
     2261    m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new StrictWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
     2262    EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
     2263    m_hostImpl->drawLayers(frame);
     2264    m_hostImpl->didDrawAllLayers(frame);
     2265    m_hostImpl->swapBuffers();
     2266}
     2267
     2268// Fake WebGraphicsContext3D that tracks the number of textures in use.
     2269class TrackingWebGraphicsContext3D : public FakeWebGraphicsContext3D {
     2270public:
     2271    TrackingWebGraphicsContext3D()
     2272        : FakeWebGraphicsContext3D()
     2273        , m_numTextures(0)
     2274    { }
     2275
     2276    virtual WebGLId createTexture() OVERRIDE
     2277    {
     2278        WebGLId id = FakeWebGraphicsContext3D::createTexture();
     2279
     2280        m_textures.set(id, true);
     2281        ++m_numTextures;
     2282        return id;
     2283    }
     2284
     2285    virtual void deleteTexture(WebGLId id) OVERRIDE
     2286    {
     2287        if (!m_textures.get(id))
     2288            return;
     2289
     2290        m_textures.set(id, false);
     2291        --m_numTextures;
     2292    }
     2293
     2294    virtual WebString getString(WGC3Denum name) OVERRIDE
     2295    {
     2296        if (name == WebCore::GraphicsContext3D::EXTENSIONS)
     2297            return WebString("GL_CHROMIUM_iosurface GL_ARB_texture_rectangle");
     2298
     2299        return WebString();
     2300    }
     2301
     2302    unsigned numTextures() const { return m_numTextures; }
     2303
     2304private:
     2305    HashMap<WebGLId, bool> m_textures;
     2306    unsigned m_numTextures;
     2307};
     2308
     2309TEST_F(CCLayerTreeHostImplTest, layersFreeTextures)
     2310{
     2311    OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1));
     2312    rootLayer->setBounds(IntSize(10, 10));
     2313    rootLayer->setAnchorPoint(FloatPoint(0, 0));
     2314
     2315    OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2);
     2316    tileLayer->setBounds(IntSize(10, 10));
     2317    tileLayer->setAnchorPoint(FloatPoint(0, 0));
     2318    tileLayer->setContentBounds(IntSize(10, 10));
     2319    tileLayer->setDrawsContent(true);
     2320    tileLayer->setSkipsDraw(false);
     2321    OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 10), CCLayerTilingData::NoBorderTexels));
     2322    tilingData->setBounds(IntSize(10, 10));
     2323    tileLayer->setTilingData(*tilingData);
     2324    tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10));
     2325    rootLayer->addChild(tileLayer.release());
     2326
     2327    OwnPtr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(3);
     2328    textureLayer->setBounds(IntSize(10, 10));
     2329    textureLayer->setAnchorPoint(FloatPoint(0, 0));
     2330    textureLayer->setContentBounds(IntSize(10, 10));
     2331    textureLayer->setDrawsContent(true);
     2332    textureLayer->setTextureId(1);
     2333    rootLayer->addChild(textureLayer.release());
     2334
     2335    FakeVideoFrameProvider provider;
     2336    OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(4, &provider);
     2337    videoLayer->setBounds(IntSize(10, 10));
     2338    videoLayer->setAnchorPoint(FloatPoint(0, 0));
     2339    videoLayer->setContentBounds(IntSize(10, 10));
     2340    videoLayer->setDrawsContent(true);
     2341    videoLayer->setLayerTreeHostImpl(m_hostImpl.get());
     2342    rootLayer->addChild(videoLayer.release());
     2343
     2344    OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(5);
     2345    ioSurfaceLayer->setBounds(IntSize(10, 10));
     2346    ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0));
     2347    ioSurfaceLayer->setContentBounds(IntSize(10, 10));
     2348    ioSurfaceLayer->setDrawsContent(true);
     2349    ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10));
     2350    ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());
     2351    rootLayer->addChild(ioSurfaceLayer.release());
     2352
    23502353    // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the CCLayerTreeHostImpl takes ownership of).
    23512354    OwnPtr<CCGraphicsContext> ccContext(CCGraphicsContext::create3D(adoptPtr(new TrackingWebGraphicsContext3D)));
     
    24662469}
    24672470
     2471class LayerRendererChromiumWithReleaseTextures : public LayerRendererChromium {
     2472public:
     2473    using LayerRendererChromium::releaseRenderPassTextures;
     2474};
     2475
    24682476TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
    24692477{
     
    25492557    }
    25502558
    2551     // Change opacity again, but evict the cached surface texture
     2559    // Change opacity again, and evict the cached surface texture.
    25522560    surfaceLayerPtr->setOpacity(0.5f);
    2553     ManagedTexture* contentsTexture = surfaceLayerPtr->renderSurface()->contentsTexture();
    2554     ASSERT_TRUE(contentsTexture->isValid(contentsTexture->size(), contentsTexture->format()));
    2555     CCRenderer* renderer = myHostImpl->layerRenderer();
    2556     TextureManager* textureManager = renderer->implTextureManager();
    2557     size_t maxMemoryLimit = textureManager->maxMemoryLimitBytes();
    2558 
    2559     // This should evice all cached surfaces
    2560     textureManager->setMaxMemoryLimitBytes(0);
    2561 
    2562     // Restore original limit
    2563     textureManager->setMaxMemoryLimitBytes(maxMemoryLimit);
    2564 
    2565     // Was our surface evicted?
    2566     ASSERT_FALSE(contentsTexture->isValid(contentsTexture->size(), contentsTexture->format()));
     2561    static_cast<LayerRendererChromiumWithReleaseTextures*>(myHostImpl->layerRenderer())->releaseRenderPassTextures();
    25672562
    25682563    // Change opacity and draw
     
    25832578        CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get());
    25842579        EXPECT_FALSE(quad->renderPass()->targetSurface()->contentsChanged());
     2580
     2581        // Was our surface evicted?
     2582        EXPECT_FALSE(myHostImpl->layerRenderer()->haveCachedResourcesForRenderPassId(quad->renderPass()->id()));
    25852583
    25862584        myHostImpl->drawLayers(frame);
     
    27072705    }
    27082706
    2709     // Change opacity again, but evict the cached surface texture
     2707    // Change opacity again, and evict the cached surface texture.
    27102708    surfaceLayerPtr->setOpacity(0.5f);
    2711     ManagedTexture* contentsTexture = surfaceLayerPtr->renderSurface()->contentsTexture();
    2712     ASSERT_TRUE(contentsTexture->isValid(contentsTexture->size(), contentsTexture->format()));
    2713     CCRenderer* renderer = myHostImpl->layerRenderer();
    2714     TextureManager* textureManager = renderer->implTextureManager();
    2715     size_t maxMemoryLimit = textureManager->maxMemoryLimitBytes();
    2716 
    2717     // This should evice all cached surfaces
    2718     textureManager->setMaxMemoryLimitBytes(0);
    2719 
    2720     // Restore original limit
    2721     textureManager->setMaxMemoryLimitBytes(maxMemoryLimit);
    2722 
    2723     // Was our surface evicted?
    2724     ASSERT_FALSE(contentsTexture->isValid(contentsTexture->size(), contentsTexture->format()));
     2709    static_cast<LayerRendererChromiumWithReleaseTextures*>(myHostImpl->layerRenderer())->releaseRenderPassTextures();
    27252710
    27262711    // Change opacity and draw
     
    27412726        CCRenderPassDrawQuad* quad = static_cast<CCRenderPassDrawQuad*>(frame.renderPasses[1]->quadList()[0].get());
    27422727        EXPECT_FALSE(quad->renderPass()->targetSurface()->contentsChanged());
     2728
     2729        // Was our surface evicted?
     2730        EXPECT_FALSE(myHostImpl->layerRenderer()->haveCachedResourcesForRenderPassId(quad->renderPass()->id()));
    27432731
    27442732        myHostImpl->drawLayers(frame);
     
    28992887};
    29002888
    2901 class FakeRenderSurface : public CCRenderSurface {
    2902 private:
    2903     bool m_hasCachedTexture;
    2904     bool m_contentsChanged;
    2905 
    2906 public:
    2907     FakeRenderSurface(CCLayerImpl* layerImpl)
    2908         : CCRenderSurface(layerImpl),
    2909           m_hasCachedTexture(false)
    2910     {
    2911     }
    2912 
    2913     virtual bool hasCachedContentsTexture() const OVERRIDE
    2914     {
    2915         return m_hasCachedTexture;
    2916     }
    2917 
    2918     virtual bool prepareContentsTexture(LayerRendererChromium* lrc) OVERRIDE
    2919     {
    2920         return true;
    2921     }
    2922 
    2923     virtual bool contentsChanged() const OVERRIDE
    2924     {
    2925         return m_contentsChanged;
    2926     }
    2927 
    2928     void setHasCachedTexture(bool hasCachedTexture)
    2929     {
    2930         m_hasCachedTexture = hasCachedTexture;
    2931     }
    2932 
    2933     void setContentsChanged(bool contentsChanged)
    2934     {
    2935         m_contentsChanged = contentsChanged;
    2936     }
    2937 };
    2938 
    29392889class CCTestRenderPass: public CCRenderPass {
    29402890public:
    2941     static PassOwnPtr<CCRenderPass> create(CCRenderSurface* targetSurface)
    2942     {
    2943         return adoptPtr(new CCTestRenderPass(targetSurface));
    2944     }
     2891    static PassOwnPtr<CCRenderPass> create(CCRenderSurface* targetSurface, int id) { return adoptPtr(new CCTestRenderPass(targetSurface, id)); }
     2892
     2893    void appendQuad(PassOwnPtr<CCDrawQuad> quad) { m_quadList.append(quad); }
    29452894
    29462895protected:
    2947     CCTestRenderPass(CCRenderSurface* surface)
    2948         : CCRenderPass(surface)
    2949     {
    2950     }
    2951 
     2896    CCTestRenderPass(CCRenderSurface* targetSurface, int id) : CCRenderPass(targetSurface, id) { }
     2897};
     2898
     2899class CCTestRenderer : public LayerRendererChromium, public CCRendererClient {
    29522900public:
    2953     void appendQuad(PassOwnPtr<CCDrawQuad> quad)
    2954     {
    2955         m_quadList.append(quad);
    2956     }
     2901    static PassOwnPtr<CCTestRenderer> create(WebKit::WebGraphicsContext3D* context)
     2902    {
     2903        OwnPtr<CCTestRenderer> renderer(adoptPtr(new CCTestRenderer(context)));
     2904        if (!renderer->initialize())
     2905            return nullptr;
     2906
     2907        return renderer.release();
     2908    }
     2909
     2910    void clearCachedTextures() { m_textures.clear(); }
     2911    void setHaveCachedResourcesForRenderPassId(int id) { m_textures.add(id); }
     2912
     2913    virtual bool haveCachedResourcesForRenderPassId(int id) const OVERRIDE { return m_textures.contains(id); }
     2914
     2915    // CCRendererClient implementation.
     2916    virtual const IntSize& deviceViewportSize() const OVERRIDE { return m_viewportSize; }
     2917    virtual const CCLayerTreeSettings& settings() const OVERRIDE { return m_settings; }
     2918    virtual void didLoseContext() OVERRIDE { }
     2919    virtual void onSwapBuffersComplete() OVERRIDE { }
     2920    virtual void setFullRootLayerDamage() OVERRIDE { }
     2921    virtual void releaseContentsTextures() OVERRIDE { }
     2922    virtual void setMemoryAllocationLimitBytes(size_t) OVERRIDE { }
     2923
     2924protected:
     2925    CCTestRenderer(WebKit::WebGraphicsContext3D* context) : LayerRendererChromium(this, context, UnthrottledUploader) { }
     2926
     2927private:
     2928    CCLayerTreeSettings m_settings;
     2929    IntSize m_viewportSize;
     2930    HashSet<int> m_textures;
    29572931};
    29582932
    2959 static PassOwnPtr<CCRenderPass> createDummyRenderPass(RenderPassRemovalTestData& testData)
    2960 {
    2961     OwnPtr<CCLayerImpl> layerImpl = CCLayerImpl::create(1);
    2962     CCRenderSurface* renderSurface = new FakeRenderSurface(layerImpl.get());
    2963     OwnPtr<CCRenderPass> renderPassPtr = CCTestRenderPass::create(renderSurface);
    2964 
    2965     testData.renderSurfaceStore.append(adoptPtr(renderSurface));
     2933static PassOwnPtr<CCRenderPass> createDummyRenderPass(RenderPassRemovalTestData& testData, int id)
     2934{
     2935    OwnPtr<CCLayerImpl> layerImpl(CCLayerImpl::create(id));
     2936    OwnPtr<CCRenderSurface> renderSurface(adoptPtr(new CCRenderSurface(layerImpl.get())));
     2937    OwnPtr<CCRenderPass> renderPassPtr(CCTestRenderPass::create(renderSurface.get(), layerImpl->id()));
     2938
     2939    testData.renderSurfaceStore.append(renderSurface.release());
    29662940    testData.layerStore.append(layerImpl.release());
    29672941    return renderPassPtr.release();
    29682942}
    29692943
    2970 static void configureRenderPassTestData(const char* testScript, RenderPassRemovalTestData& testData)
    2971 {
     2944static void configureRenderPassTestData(const char* testScript, RenderPassRemovalTestData& testData, CCTestRenderer* renderer)
     2945{
     2946    renderer->clearCachedTextures();
     2947
    29722948    // One shared state for all quads - we don't need the correct details
    29732949    testData.sharedQuadState = CCSharedQuadState::create(WebTransformationMatrix(), WebTransformationMatrix(), IntRect(), IntRect(), 1.0, true);
     
    29762952
    29772953    // Pre-create root pass
    2978     OwnPtr<CCRenderPass> rootRenderPass = createDummyRenderPass(testData);
    2979     testData.renderPassId.insert(std::pair<CCRenderPass*, char>(rootRenderPass.get(), testScript[0]));
    2980     testData.renderPassCache.insert(std::pair<char, RenderPassCacheEntry>(testScript[0], RenderPassCacheEntry(rootRenderPass.release())));
    2981     while (*currentChar != '\0') {
     2954    char rootRenderPassId = testScript[0];
     2955    OwnPtr<CCRenderPass> rootRenderPass = createDummyRenderPass(testData, rootRenderPassId);
     2956    testData.renderPassId.insert(std::pair<CCRenderPass*, char>(rootRenderPass.get(), rootRenderPassId));
     2957    testData.renderPassCache.insert(std::pair<char, RenderPassCacheEntry>(rootRenderPassId, RenderPassCacheEntry(rootRenderPass.release())));
     2958    while (*currentChar) {
    29822959        char renderPassId = currentChar[0];
    29832960        currentChar++;
     
    29922969
    29932970        // Cycle through quad data and create all quads
    2994         while (*currentChar != '\n' && *currentChar != '\0') {
     2971        while (*currentChar && *currentChar != '\n') {
    29952972            if (*currentChar == 's') {
    29962973                // Solid color draw quad
     
    30022979                // RenderPass draw quad
    30032980                char newRenderPassId = *currentChar;
     2981                ASSERT_NE(rootRenderPassId, newRenderPassId);
    30042982                currentChar++;
    30052983                bool hasTexture = false;
     
    30082986                if (*currentChar == '[') {
    30092987                    currentChar++;
    3010                     while ((*currentChar != ']') && (*currentChar != '\0')) {
     2988                    while (*currentChar && *currentChar != ']') {
    30112989                        switch (*currentChar) {
    30122990                        case 'c':
     
    30263004
    30273005                if (testData.renderPassCache.find(newRenderPassId) == testData.renderPassCache.end()) {
    3028                     OwnPtr<CCRenderPass> refRenderPass = createDummyRenderPass(testData);
     3006                    if (hasTexture)
     3007                        renderer->setHaveCachedResourcesForRenderPassId(newRenderPassId);
     3008
     3009                    OwnPtr<CCRenderPass> refRenderPass = createDummyRenderPass(testData, newRenderPassId);
    30293010                    refRenderPassPtr = refRenderPass.get();
    3030                     FakeRenderSurface* refRenderSurface = static_cast<FakeRenderSurface*>(refRenderPass->targetSurface());
    3031                     refRenderSurface->setHasCachedTexture(hasTexture);
    3032                     refRenderSurface->setContentsChanged(contentsChanged);
    30333011                    testData.renderPassId.insert(std::pair<CCRenderPass*, char>(refRenderPass.get(), newRenderPassId));
    30343012                    testData.renderPassCache.insert(std::pair<char, RenderPassCacheEntry>(newRenderPassId, RenderPassCacheEntry(refRenderPass.release())));
     
    30363014                    refRenderPassPtr = testData.renderPassCache[newRenderPassId].renderPass;
    30373015
    3038                 OwnPtr<CCRenderPassDrawQuad> quad = CCRenderPassDrawQuad::create(testData.sharedQuadState.get(), IntRect(), refRenderPassPtr, isReplica, WebKit::WebFilterOperations(), WebKit::WebFilterOperations(), 1);
     3016                IntRect quadRect = IntRect(0, 0, 1, 1);
     3017                IntRect contentsChangedRect = contentsChanged ? quadRect : IntRect();
     3018                OwnPtr<CCRenderPassDrawQuad> quad = CCRenderPassDrawQuad::create(testData.sharedQuadState.get(), quadRect, refRenderPassPtr, isReplica, WebKit::WebFilterOperations(), WebKit::WebFilterOperations(), 1, contentsChangedRect);
    30393019                static_cast<CCTestRenderPass*>(renderPass.get())->appendQuad(quad.release());
    30403020            }
    30413021        }
    30423022        testData.renderPassList.insert(0, renderPass.release());
    3043         if (*currentChar != '\0')
     3023        if (*currentChar)
    30443024            currentChar++;
    30453025    }
     
    30643044                pos++;
    30653045                break;
    3066             case CCDrawQuad::RenderPass:
    3067                 {
    3068                     CCRenderPassDrawQuad* renderPassDrawQuad = static_cast<CCRenderPassDrawQuad*>(currentQuad);
    3069                     const CCRenderPass* refPass = renderPassDrawQuad->renderPass();
    3070                     char refPassId = testData.renderPassId.find(refPass)->second;
    3071                     *pos = refPassId;
    3072                     pos++;
    3073                 }
     3046            case CCDrawQuad::RenderPass: {
     3047                CCRenderPassDrawQuad* renderPassDrawQuad = static_cast<CCRenderPassDrawQuad*>(currentQuad);
     3048                const CCRenderPass* refPass = renderPassDrawQuad->renderPass();
     3049                char refPassId = testData.renderPassId.find(refPass)->second;
     3050                *pos = refPassId;
     3051                pos++;
    30743052                break;
     3053            }
    30753054            default:
    30763055                *pos = 'x';
     
    32363215}
    32373216
    3238 TEST(RenderPassRemovalTest, testRemoveRenderPasses)
    3239 {
     3217TEST_F(CCLayerTreeHostImplTest, testRemoveRenderPasses)
     3218{
     3219    OwnPtr<CCGraphicsContext> context(createContext());
     3220    WebKit::WebGraphicsContext3D* context3d = context->context3D();
     3221    ASSERT_TRUE(context3d);
     3222    OwnPtr<CCTestRenderer> renderer(CCTestRenderer::create(context3d));
     3223
    32403224    int testCaseIndex = 0;
    32413225    while (removeRenderPassesCases[testCaseIndex].name) {
    3242         DebugScopedSetImplThread implThread;
    32433226        RenderPassRemovalTestData testData;
    32443227        CCRenderPassList skippedPasses;
    3245         configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initScript, testData);
    3246         CCLayerTreeHostImpl::removePassesWithCachedTextures(testData.renderPassList, skippedPasses);
     3228        configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initScript, testData, renderer.get());
     3229        CCLayerTreeHostImpl::removePassesWithCachedTextures(testData.renderPassList, skippedPasses, renderer.get());
    32473230        verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testData);
    32483231        testCaseIndex++;
  • trunk/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp

    r121060 r122160  
    157157};
    158158
    159 int CCOcclusionTrackerTestImplThreadTypes::nextCCLayerImplId = 0;
     159int CCOcclusionTrackerTestImplThreadTypes::nextCCLayerImplId = 1;
    160160
    161161template<typename Types, bool opaqueLayers>
  • trunk/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp

    r120820 r122160  
    6161static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const WebTransformationMatrix& drawTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect, Vector<CCLayerImpl*>& surfaceLayerList)
    6262{
    63     OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(0);
     63    OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(1);
    6464    OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100, 100), CCLayerTilingData::NoBorderTexels);
    6565    tiler->setBounds(layerRect.size());
  • trunk/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp

    r119401 r122160  
    5858    DebugScopedSetImplThread setImplThread;
    5959
    60     OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(0);
     60    OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(1);
    6161    owningLayer->createRenderSurface();
    6262    ASSERT_TRUE(owningLayer->renderSurface());
     
    9696    DebugScopedSetImplThread setImplThread;
    9797
    98     OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(0);
     98    OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(1);
    9999    owningLayer->createRenderSurface();
    100100    ASSERT_TRUE(owningLayer->renderSurface());
  • trunk/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp

    r121396 r122160  
    4848    IntRect visibleLayerRect = IntRect(IntPoint(), layerSize);
    4949
    50     OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
     50    OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(1);
    5151    layer->setVisibleLayerRect(visibleLayerRect);
    5252    layer->setBounds(layerSize);
     
    6969    IntRect visibleLayerRect = IntRect(IntPoint(), layerSize);
    7070
    71     OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
     71    OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(1);
    7272    layer->setVisibleLayerRect(visibleLayerRect);
    7373    layer->setBounds(layerSize);
     
    9292    IntRect visibleLayerRect = IntRect(IntPoint(), layerSize);
    9393
    94     OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
     94    OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(1);
    9595    layer->setVisibleLayerRect(visibleLayerRect);
    9696    layer->setBounds(layerSize);
  • trunk/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp

    r120820 r122160  
    4444static PassOwnPtr<CCTiledLayerImpl> createLayer(const IntSize& tileSize, const IntSize& layerSize, CCLayerTilingData::BorderTexelOption borderTexels)
    4545{
    46     OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(0);
     46    OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(1);
    4747    OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(tileSize, borderTexels);
    4848    tiler->setBounds(layerSize);
  • trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp

    r121204 r122160  
    8080    {
    8181        m_rootLayer->createRenderSurface();
    82         m_rootRenderPass = CCRenderPass::create(m_rootLayer->renderSurface());
     82        m_rootRenderPass = CCRenderPass::create(m_rootLayer->renderSurface(), m_rootLayer->id());
    8383    }
    8484
  • trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

    r121870 r122160  
    9898    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    9999    DebugScopedSetImplThread implThread;
    100     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     100    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    101101
    102102    // The tile size is 100x100, so this invalidates and then paints two tiles.
     
    135135    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    136136    DebugScopedSetImplThread implThread;
    137     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     137    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    138138    TestCCOcclusionTracker occluded;
    139139
     
    181181    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    182182    DebugScopedSetImplThread implThread;
    183     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     183    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    184184
    185185    // The tile size is 100x100, so this invalidates and then paints two tiles.
     
    227227    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    228228    DebugScopedSetImplThread implThread;
    229     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     229    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    230230
    231231    // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the center.
     
    286286    DebugScopedSetImplThread implThread;
    287287    RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    288     OwnPtr<FakeCCTiledLayerImpl> layerImpl1(adoptPtr(new FakeCCTiledLayerImpl(0)));
     288    OwnPtr<FakeCCTiledLayerImpl> layerImpl1(adoptPtr(new FakeCCTiledLayerImpl(1)));
    289289    RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    290     OwnPtr<FakeCCTiledLayerImpl> layerImpl2(adoptPtr(new FakeCCTiledLayerImpl(0)));
     290    OwnPtr<FakeCCTiledLayerImpl> layerImpl2(adoptPtr(new FakeCCTiledLayerImpl(2)));
    291291
    292292    // For this test we have two layers. layer1 exhausts most texture memory, leaving room for 2 more tiles from
     
    369369    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    370370    DebugScopedSetImplThread implThread;
    371     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     371    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    372372    TestCCOcclusionTracker occluded;
    373373
     
    396396    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    397397    DebugScopedSetImplThread implThread;
    398     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     398    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    399399
    400400    // The tile size is 100x100, so this invalidates and then paints two tiles.
     
    423423    RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    424424    DebugScopedSetImplThread implThread;
    425     OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(0)));
    426     OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     425    OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(1)));
     426    OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(2)));
    427427
    428428    layer1->setBounds(IntSize(100, 200));
     
    461461    RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    462462    DebugScopedSetImplThread implThread;
    463     OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(0)));
    464     OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     463    OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(1)));
     464    OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(2)));
    465465
    466466    layer1->setBounds(IntSize(100, 200));
     
    504504    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    505505    DebugScopedSetImplThread implThread;
    506     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     506    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    507507
    508508    // Invalidates 9 tiles and then paints one visible tile.
     
    538538    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    539539    DebugScopedSetImplThread implThread;
    540     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     540    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    541541
    542542    // The layer's bounds are empty.
     
    579579    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    580580    DebugScopedSetImplThread implThread;
    581     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     581    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    582582
    583583    // Pretend the layer is animating.
     
    626626    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    627627    DebugScopedSetImplThread implThread;
    628     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     628    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    629629
    630630    // Invalidate the layer but make none of it visible, so nothing paints.
     
    679679        for (int i = 0; width[i]; ++i) {
    680680            RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    681             OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     681            OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    682682
    683683            // Pretend the layer is animating.
     
    748748    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    749749    DebugScopedSetImplThread implThread;
    750     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     750    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    751751
    752752    FakeTextureAllocator fakeAllocator;
     
    837837    RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
    838838    DebugScopedSetImplThread implThread;
    839     OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     839    OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    840840
    841841    // Create a layer with one tile.
     
    10021002    {
    10031003        DebugScopedSetImplThread implThread;
    1004         OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     1004        OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    10051005        updateTextures(4);
    10061006        EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
     
    10201020    {
    10211021        DebugScopedSetImplThread implThread;
    1022         OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     1022        OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    10231023        updateTextures(4);
    10241024        EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount());
     
    10371037    {
    10381038        DebugScopedSetImplThread implThread;
    1039         OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     1039        OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    10401040        ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
    10411041        updateTextures(4);
     
    10551055    {
    10561056        DebugScopedSetImplThread implThread;
    1057         OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     1057        OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    10581058        layer->pushPropertiesTo(layerImpl.get());
    10591059    }
     
    10641064    {
    10651065        DebugScopedSetImplThread implThread;
    1066         OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     1066        OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    10671067        ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
    10681068        updateTextures(4);
     
    10821082    {
    10831083        DebugScopedSetImplThread implThread;
    1084         OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
     1084        OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1)));
    10851085        ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max());
    10861086        updateTextures(4);
Note: See TracChangeset for help on using the changeset viewer.