Changeset 122506 in webkit


Ignore:
Timestamp:
Jul 12, 2012 2:35:34 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Use CCTexture/TextureAllocator and remove TextureManager
https://bugs.webkit.org/show_bug.cgi?id=91001

Patch by Eric Penner <epenner@google.com> on 2012-07-12
Reviewed by Adrienne Walker.

Source/WebCore:

Use CCTexture to clean up CCPrioritizedTexture::Backing.
Add TextureAllocator.h and remove remainder of TextureManager.h/cpp.
Minor move/refactoring of link/unlink in CCPrioritizedTexture.
Remove double initialization of the default memory limit.

Covered by existing tests (refactoring).

  • WebCore.gypi:
  • platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp:
  • platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h:

(WebCore):

  • platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp:
  • platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h:

(WebCore):

  • platform/graphics/chromium/ImageLayerChromium.cpp:
  • platform/graphics/chromium/LayerRendererChromium.cpp:

(WebCore::LayerRendererChromium::initialize):

  • platform/graphics/chromium/ManagedTexture.cpp: Removed.
  • platform/graphics/chromium/ManagedTexture.h: Removed.
  • platform/graphics/chromium/RenderSurfaceChromium.h:

(WebCore):

  • platform/graphics/chromium/TextureAllocator.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h.

(WebCore):
(TextureAllocator):
(WebCore::TextureAllocator::~TextureAllocator):

  • platform/graphics/chromium/TextureManager.cpp: Removed.
  • platform/graphics/chromium/TextureManager.h: Removed.
  • platform/graphics/chromium/TiledLayerChromium.cpp:
  • platform/graphics/chromium/TrackingTextureAllocator.cpp:

(WebCore::TrackingTextureAllocator::createTexture):
(WebCore::TrackingTextureAllocator::deleteTexture):

  • platform/graphics/chromium/TrackingTextureAllocator.h:
  • platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
  • platform/graphics/chromium/cc/CCLayerTreeHost.cpp:

(WebCore::CCLayerTreeHost::prioritizeTextures):

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

(WebCore):

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

(WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):

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

(WebCore::CCPrioritizedTexture::CCPrioritizedTexture):
(WebCore::CCPrioritizedTexture::setDimensions):
(WebCore::CCPrioritizedTexture::textureId):
(WebCore::CCPrioritizedTexture::bindTexture):
(WebCore::CCPrioritizedTexture::framebufferTexture2D):
(WebCore::CCPrioritizedTexture::link):
(WebCore):
(WebCore::CCPrioritizedTexture::unlink):

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

(WebCore):
(WebCore::CCPrioritizedTexture::bytes):
(CCPrioritizedTexture):
(WebCore::CCPrioritizedTexture::haveBackingTexture):
(WebCore::CCPrioritizedTexture::Backing::Backing):
(WebCore::CCPrioritizedTexture::Backing::~Backing):
(WebCore::CCPrioritizedTexture::Backing::owner):
(Backing):
(WebCore::CCPrioritizedTexture::backing):

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

(WebCore::CCPrioritizedTextureManager::prioritizeTextures):
(WebCore::CCPrioritizedTextureManager::requestLate):
(WebCore::CCPrioritizedTextureManager::acquireBackingTextureIfNeeded):
(WebCore::CCPrioritizedTextureManager::reduceMemory):
(WebCore::CCPrioritizedTextureManager::clearAllMemory):
(WebCore::CCPrioritizedTextureManager::registerTexture):
(WebCore::CCPrioritizedTextureManager::returnBackingTexture):
(WebCore::CCPrioritizedTextureManager::createBacking):
(WebCore::CCPrioritizedTextureManager::destroyBacking):
(WebCore::CCPrioritizedTextureManager::assertInvariants):

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

(CCPrioritizedTextureManager):
(WebCore::CCPrioritizedTextureManager::defaultMemoryAllocationLimit):
(WebCore::CCPrioritizedTextureManager::compareBackings):

  • platform/graphics/chromium/cc/CCPriorityCalculator.h:
  • platform/graphics/chromium/cc/CCScopedTexture.cpp:
  • platform/graphics/chromium/cc/CCScopedTexture.h:
  • platform/graphics/chromium/cc/CCTexture.h:

(WebCore::CCTexture::CCTexture):

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

(WebCore):

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

Source/WebKit/chromium:

Deleting old texture manager tests.

  • WebKit.gypi:
  • tests/CCLayerTreeHostImplTest.cpp:
  • tests/CCPrioritizedTextureTest.cpp:

(WTF::CCPrioritizedTextureTest::texturesMemorySize):

  • tests/CCThreadedTest.cpp:
  • tests/CCTiledLayerTestCommon.h:
  • tests/Canvas2DLayerBridgeTest.cpp:
  • tests/TextureManagerTest.cpp: Removed.
Location:
trunk/Source
Files:
5 deleted
34 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122503 r122506  
     12012-07-12  Eric Penner  <epenner@google.com>
     2
     3        [chromium] Use CCTexture/TextureAllocator and remove TextureManager
     4        https://bugs.webkit.org/show_bug.cgi?id=91001
     5
     6        Reviewed by Adrienne Walker.
     7
     8        Use CCTexture to clean up CCPrioritizedTexture::Backing.
     9        Add TextureAllocator.h and remove remainder of TextureManager.h/cpp.
     10        Minor move/refactoring of link/unlink in CCPrioritizedTexture.
     11        Remove double initialization of the default memory limit.
     12
     13        Covered by existing tests (refactoring).
     14
     15        * WebCore.gypi:
     16        * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp:
     17        * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h:
     18        (WebCore):
     19        * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp:
     20        * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h:
     21        (WebCore):
     22        * platform/graphics/chromium/ImageLayerChromium.cpp:
     23        * platform/graphics/chromium/LayerRendererChromium.cpp:
     24        (WebCore::LayerRendererChromium::initialize):
     25        * platform/graphics/chromium/ManagedTexture.cpp: Removed.
     26        * platform/graphics/chromium/ManagedTexture.h: Removed.
     27        * platform/graphics/chromium/RenderSurfaceChromium.h:
     28        (WebCore):
     29        * platform/graphics/chromium/TextureAllocator.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h.
     30        (WebCore):
     31        (TextureAllocator):
     32        (WebCore::TextureAllocator::~TextureAllocator):
     33        * platform/graphics/chromium/TextureManager.cpp: Removed.
     34        * platform/graphics/chromium/TextureManager.h: Removed.
     35        * platform/graphics/chromium/TiledLayerChromium.cpp:
     36        * platform/graphics/chromium/TrackingTextureAllocator.cpp:
     37        (WebCore::TrackingTextureAllocator::createTexture):
     38        (WebCore::TrackingTextureAllocator::deleteTexture):
     39        * platform/graphics/chromium/TrackingTextureAllocator.h:
     40        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
     41        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     42        (WebCore::CCLayerTreeHost::prioritizeTextures):
     43        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     44        (WebCore):
     45        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
     46        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
     47        * platform/graphics/chromium/cc/CCPrioritizedTexture.cpp:
     48        (WebCore::CCPrioritizedTexture::CCPrioritizedTexture):
     49        (WebCore::CCPrioritizedTexture::setDimensions):
     50        (WebCore::CCPrioritizedTexture::textureId):
     51        (WebCore::CCPrioritizedTexture::bindTexture):
     52        (WebCore::CCPrioritizedTexture::framebufferTexture2D):
     53        (WebCore::CCPrioritizedTexture::link):
     54        (WebCore):
     55        (WebCore::CCPrioritizedTexture::unlink):
     56        * platform/graphics/chromium/cc/CCPrioritizedTexture.h:
     57        (WebCore):
     58        (WebCore::CCPrioritizedTexture::bytes):
     59        (CCPrioritizedTexture):
     60        (WebCore::CCPrioritizedTexture::haveBackingTexture):
     61        (WebCore::CCPrioritizedTexture::Backing::Backing):
     62        (WebCore::CCPrioritizedTexture::Backing::~Backing):
     63        (WebCore::CCPrioritizedTexture::Backing::owner):
     64        (Backing):
     65        (WebCore::CCPrioritizedTexture::backing):
     66        * platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:
     67        (WebCore::CCPrioritizedTextureManager::prioritizeTextures):
     68        (WebCore::CCPrioritizedTextureManager::requestLate):
     69        (WebCore::CCPrioritizedTextureManager::acquireBackingTextureIfNeeded):
     70        (WebCore::CCPrioritizedTextureManager::reduceMemory):
     71        (WebCore::CCPrioritizedTextureManager::clearAllMemory):
     72        (WebCore::CCPrioritizedTextureManager::registerTexture):
     73        (WebCore::CCPrioritizedTextureManager::returnBackingTexture):
     74        (WebCore::CCPrioritizedTextureManager::createBacking):
     75        (WebCore::CCPrioritizedTextureManager::destroyBacking):
     76        (WebCore::CCPrioritizedTextureManager::assertInvariants):
     77        * platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:
     78        (CCPrioritizedTextureManager):
     79        (WebCore::CCPrioritizedTextureManager::defaultMemoryAllocationLimit):
     80        (WebCore::CCPrioritizedTextureManager::compareBackings):
     81        * platform/graphics/chromium/cc/CCPriorityCalculator.h:
     82        * platform/graphics/chromium/cc/CCScopedTexture.cpp:
     83        * platform/graphics/chromium/cc/CCScopedTexture.h:
     84        * platform/graphics/chromium/cc/CCTexture.h:
     85        (WebCore::CCTexture::CCTexture):
     86        * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
     87        (WebCore):
     88        * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
     89
    1902012-07-12  Ryosuke Niwa  <rniwa@webkit.org>
    291
  • trunk/Source/WebCore/WebCore.gypi

    r122484 r122506  
    82508250            'platform/graphics/chromium/LayerTextureSubImage.h',
    82518251            'platform/graphics/chromium/LayerTextureUpdater.h',
    8252             'platform/graphics/chromium/ManagedTexture.cpp',
    8253             'platform/graphics/chromium/ManagedTexture.h',
    82548252            'platform/graphics/chromium/PlatformCanvas.cpp',
    82558253            'platform/graphics/chromium/PlatformCanvas.h',
     
    82738271            'platform/graphics/chromium/TextureLayerChromium.cpp',
    82748272            'platform/graphics/chromium/TextureLayerChromium.h',
    8275             'platform/graphics/chromium/TextureManager.cpp',
    8276             'platform/graphics/chromium/TextureManager.h',
     8273            'platform/graphics/chromium/TextureAllocator.h',
    82778274            'platform/graphics/chromium/TextureUploader.h',
    82788275            'platform/graphics/chromium/ThrottledTextureUploader.cpp',
  • trunk/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp

    r121574 r122506  
    3434#include "PlatformColor.h"
    3535#include "PlatformContextSkia.h"
     36#include "TextureAllocator.h"
    3637#include "cc/CCGraphicsContext.h"
    3738#include "skia/ext/platform_canvas.h"
  • trunk/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h

    r121574 r122506  
    3939class LayerPainterChromium;
    4040class CCGraphicsContext;
     41class TextureAllocator;
    4142
    4243// This class rasterizes the contentRect into a skia bitmap canvas. It then updates
  • trunk/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp

    r121574 r122506  
    3535#include "SkCanvas.h"
    3636#include "SkDevice.h"
     37#include "TextureAllocator.h"
    3738#include "cc/CCGraphicsContext.h"
    3839
  • trunk/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h

    r121574 r122506  
    3535namespace WebCore {
    3636
     37class TextureAllocator;
     38
    3739// This class records the contentRect into an SkPicture, then software rasterizes
    3840// the SkPicture into bitmaps for each tile. This implements CCSettings::perTilePainting.
  • trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp

    r122373 r122506  
    3737#include "LayerTextureSubImage.h"
    3838#include "LayerTextureUpdater.h"
    39 #include "ManagedTexture.h"
    4039#include "PlatformColor.h"
    4140#include "cc/CCLayerTreeHost.h"
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r122383 r122506  
    4444#include "SkBitmap.h"
    4545#include "SkColor.h"
    46 #include "TextureManager.h"
    4746#include "ThrottledTextureUploader.h"
    4847#include "TraceEvent.h"
     
    210209    if (m_capabilities.usingGpuMemoryManager)
    211210        m_context->setMemoryAllocationChangedCallbackCHROMIUM(this);
    212     else
    213         m_client->setMemoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize()));
    214211
    215212    m_capabilities.usingDiscardFramebuffer = extensions.contains("GL_CHROMIUM_discard_framebuffer");
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h

    r120820 r122506  
    4141class LayerChromium;
    4242class LayerRendererChromium;
    43 class ManagedTexture;
    4443
    4544class RenderSurfaceChromium {
  • trunk/Source/WebCore/platform/graphics/chromium/TextureAllocator.h

    r122505 r122506  
    11/*
    2  * Copyright (C) 2010, Google Inc. All rights reserved.
     2 * Copyright (C) 2012, Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2323 */
    2424
    25 #ifndef CCPriorityCalculator_h
    26 #define CCPriorityCalculator_h
     25
     26#ifndef TextureAllocator_h
     27#define TextureAllocator_h
    2728
    2829#include "GraphicsContext3D.h"
    2930#include "IntRect.h"
    3031#include "IntSize.h"
    31 #include "TextureManager.h"
    3232
    3333namespace WebCore {
    3434
    35 class CCPriorityCalculator {
     35class TextureAllocator {
    3636public:
    37     static int uiPriority(bool drawsToRootSurface);
    38     static int visiblePriority(bool drawsToRootSurface);
    39     static int renderSurfacePriority();
    40     static int lingeringPriority(int previousPriority);
    41     int priorityFromDistance(const IntRect& visibleRect, const IntRect& textureRect, bool drawsToRootSurface) const;
    42     int priorityFromDistance(unsigned pixels, bool drawsToRootSurface) const;
    43     int priorityFromVisibility(bool visible, bool drawsToRootSurface) const;
     37    virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0;
     38    virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0;
     39    virtual void deleteAllTextures() = 0;
    4440
    45     static inline int highestPriority() { return std::numeric_limits<int>::min(); }
    46     static inline int lowestPriority() { return std::numeric_limits<int>::max(); }
    47     static inline bool priorityIsLower(int a, int b) { return a > b; }
    48     static inline bool priorityIsHigher(int a, int b) { return a < b; }
     41protected:
     42    virtual ~TextureAllocator() { }
    4943};
    5044
     
    5246
    5347#endif
     48
     49
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp

    r122373 r122506  
    3131
    3232#include "GraphicsContext3D.h"
    33 #include "ManagedTexture.h"
    3433#include "Region.h"
    3534#include "TextStream.h"
  • trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp

    r122272 r122506  
    7676        return 0;
    7777
    78     m_currentMemoryUseBytes += TextureManager::memoryUseBytes(size, format);
     78    m_currentMemoryUseBytes += CCTexture::memorySizeBytes(size, format);
    7979
    8080    unsigned textureId = 0;
     
    101101void TrackingTextureAllocator::deleteTexture(unsigned textureId, const IntSize& size, GC3Denum format)
    102102{
    103     m_currentMemoryUseBytes -= TextureManager::memoryUseBytes(size, format);
     103    m_currentMemoryUseBytes -= CCTexture::memorySizeBytes(size, format);
    104104    GLC(m_context, m_context->deleteTexture(textureId));
    105105    GLC(m_context, m_context->deleteTexture(textureId));
  • trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h

    r122272 r122506  
    2626#define TrackingTextureAllocator_h
    2727
    28 #include "TextureManager.h"
     28#include "TextureAllocator.h"
    2929#include <wtf/HashSet.h>
    3030#include <wtf/PassRefPtr.h>
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp

    r122272 r122506  
    3232#include "LayerRendererChromium.h"
    3333#include "PlatformCanvas.h"
    34 #include "TextureManager.h"
    3534#include "cc/CCDebugRectHistory.h"
    3635#include "cc/CCFrameRateCounter.h"
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r122360 r122506  
    2828
    2929#include "LayerChromium.h"
    30 #include "ManagedTexture.h"
    3130#include "Region.h"
    3231#include "TraceEvent.h"
     
    530529        RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
    531530
    532         size_t bytes = TextureManager::memoryUseBytes(renderSurface->contentRect().size(), GraphicsContext3D::RGBA);
     531        size_t bytes = CCTexture::memorySizeBytes(renderSurface->contentRect().size(), GraphicsContext3D::RGBA);
    533532        contentsTextureBytes += bytes;
    534533
     
    539538            maxBackgroundTextureBytes = bytes;
    540539        if (!readbackBytes)
    541             readbackBytes = TextureManager::memoryUseBytes(m_deviceViewportSize, GraphicsContext3D::RGBA);
     540            readbackBytes = CCTexture::memorySizeBytes(m_deviceViewportSize, GraphicsContext3D::RGBA);
    542541    }
    543542    size_t renderSurfacesBytes = readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r122360 r122506  
    5252class CCLayerTreeHostImplClient;
    5353class CCTextureUpdater;
    54 class ManagedTexture;
    5554class Region;
    5655class TextureAllocator;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp

    r122373 r122506  
    4343#include "cc/CCOverdrawMetrics.h"
    4444#include "cc/CCPageScaleAnimation.h"
     45#include "cc/CCPrioritizedTextureManager.h"
    4546#include "cc/CCRenderPassDrawQuad.h"
    4647#include "cc/CCSettings.h"
     
    123124    , m_visible(true)
    124125    , m_contentsTexturesWerePurgedSinceLastCommit(false)
    125     , m_memoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize()))
     126    , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAllocationLimit())
    126127    , m_headsUpDisplay(CCHeadsUpDisplay::create())
    127128    , m_pageScale(1)
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp

    r121574 r122506  
    3030#include "CCPriorityCalculator.h"
    3131#include "LayerRendererChromium.h"
     32#include "TextureAllocator.h"
    3233#include <algorithm>
    3334
     
    3940    : m_size(size)
    4041    , m_format(format)
    41     , m_memorySizeBytes(0)
     42    , m_bytes(0)
    4243    , m_priority(CCPriorityCalculator::lowestPriority())
    4344    , m_isAbovePriorityCutoff(false)
    44     , m_currentBacking(0)
     45    , m_backing(0)
    4546    , m_manager(0)
    4647{
     
    4849    ASSERT(format || size.isEmpty());
    4950    if (format)
    50         m_memorySizeBytes = TextureManager::memoryUseBytes(size, format);
     51        m_bytes = CCTexture::memorySizeBytes(size, format);
    5152    if (manager)
    5253        manager->registerTexture(this);
     
    7576        m_format = format;
    7677        m_size = size;
    77         m_memorySizeBytes = TextureManager::memoryUseBytes(size, format);
    78         ASSERT(m_manager || !m_currentBacking);
     78        m_bytes = CCTexture::memorySizeBytes(size, format);
     79        ASSERT(m_manager || !m_backing);
    7980        if (m_manager)
    8081            m_manager->returnBackingTexture(this);
     
    9899unsigned CCPrioritizedTexture::textureId()
    99100{
    100     if (m_currentBacking)
    101         return m_currentBacking->textureId();
     101    if (m_backing)
     102        return m_backing->id();
    102103    return 0;
    103104}
     
    108109    if (m_isAbovePriorityCutoff)
    109110        acquireBackingTexture(allocator);
    110     ASSERT(m_currentBacking);
     111    ASSERT(m_backing);
    111112    WebKit::WebGraphicsContext3D* context3d = context->context3D();
    112113    if (!context3d) {
     
    122123    if (m_isAbovePriorityCutoff)
    123124        acquireBackingTexture(allocator);
    124     ASSERT(m_currentBacking);
     125    ASSERT(m_backing);
    125126    WebKit::WebGraphicsContext3D* context3d = context->context3D();
    126127    if (!context3d) {
     
    131132}
    132133
    133 void CCPrioritizedTexture::setCurrentBacking(CCPrioritizedTexture::Backing* backing)
     134void CCPrioritizedTexture::link(Backing* backing)
    134135{
    135     if (m_currentBacking == backing)
    136         return;
    137     m_currentBacking = backing;
     136    ASSERT(backing);
     137    ASSERT(!backing->m_owner);
     138    ASSERT(!m_backing);
     139
     140    m_backing = backing;
     141    m_backing->m_owner = this;
    138142}
     143
     144void CCPrioritizedTexture::unlink()
     145{
     146    ASSERT(m_backing);
     147    ASSERT(m_backing->m_owner == this);
     148
     149    m_backing->m_owner = 0;
     150    m_backing = 0;
     151}
     152
     153
    139154
    140155} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h

    r121574 r122506  
    2727
    2828#include "CCPriorityCalculator.h"
     29#include "CCTexture.h"
    2930#include "GraphicsContext3D.h"
    3031#include "IntRect.h"
    3132#include "IntSize.h"
    32 #include "TextureManager.h"
    3333
    3434namespace WebCore {
     
    3737class CCPriorityCalculator;
    3838class CCGraphicsContext;
     39class TextureAllocator;
    3940
    4041class CCPrioritizedTexture {
     
    5859    GC3Denum format() const { return m_format; }
    5960    IntSize size() const { return m_size; }
    60     size_t memorySizeBytes() const { return m_memorySizeBytes; }
     61    size_t bytes() const { return m_bytes; }
    6162
    6263    // Set priority for the requested texture.
     
    6970
    7071    // This returns whether we still have a backing texture. This can continue
    71     // to be true even after canAquireBackingTexture() becomes false. In this
     72    // to be true even after canAcquireBackingTexture() becomes false. In this
    7273    // case the texture can be used but shouldn't be updated since it will get
    7374    // taken away "soon".
    74     bool haveBackingTexture() const { return !!currentBacking(); }
     75    bool haveBackingTexture() const { return !!backing(); }
    7576
    76     // If canAquireBackingTexture() is true acquireBackingTexture() will acquire
     77    // If canAcquireBackingTexture() is true acquireBackingTexture() will acquire
    7778    // a backing texture for use. Call this whenever the texture is actually needed.
    7879    void acquireBackingTexture(TextureAllocator*);
     
    8283    //        by not painting occluded textures. In this case the manager
    8384    //        refuses all visible textures and requestLate() will enable
    84     //        canAquireBackingTexture() on a call-order basis. We might want to
     85    //        canAcquireBackingTexture() on a call-order basis. We might want to
    8586    //        just remove this in the future (carefully) and just make sure we don't
    8687    //        regress OOMs situations.
    8788    bool requestLate();
    8889
    89     // These functions will aquire the texture if possible. If neither haveBackingTexture()
    90     // nor canAquireBackingTexture() is true, an ID of zero will be used/returned.
     90    // These functions will acquire the texture if possible. If neither haveBackingTexture()
     91    // nor canAcquireBackingTexture() is true, an ID of zero will be used/returned.
    9192    void bindTexture(CCGraphicsContext*, TextureAllocator*);
    9293    void framebufferTexture2D(CCGraphicsContext*, TextureAllocator*);
     
    9697    friend class CCPrioritizedTextureManager;
    9798
    98     class Backing {
     99    class Backing : public CCTexture {
    99100        WTF_MAKE_NONCOPYABLE(Backing);
    100101    public:
    101         IntSize size() const { return m_size; }
    102         GC3Denum format() const { return m_format; }
    103         size_t memorySizeBytes() const { return m_memorySizeBytes; }
    104         unsigned textureId() const { return m_textureId; }
    105         CCPrioritizedTexture* currentTexture() const { return m_currentTexture; }
    106         void setCurrentTexture(CCPrioritizedTexture* current) { m_currentTexture = current; }
     102        Backing(unsigned id, IntSize size, GC3Denum format)
     103            : CCTexture(id, size, format), m_owner(0) { }
     104        ~Backing() { ASSERT(!m_owner); }
    107105
     106        CCPrioritizedTexture* owner() { return m_owner; }
    108107    private:
    109         friend class CCPrioritizedTextureManager;
    110 
    111         Backing(IntSize size, GC3Denum format, unsigned textureId)
    112             : m_size(size)
    113             , m_format(format)
    114             , m_memorySizeBytes(TextureManager::memoryUseBytes(size, format))
    115             , m_textureId(textureId)
    116             , m_priority(CCPriorityCalculator::lowestPriority())
    117             , m_currentTexture(0) { }
    118         ~Backing() { ASSERT(!m_currentTexture); }
    119 
    120         IntSize m_size;
    121         GC3Denum m_format;
    122         size_t m_memorySizeBytes;
    123         unsigned m_textureId;
    124         int m_priority;
    125         CCPrioritizedTexture* m_currentTexture;
     108        friend class CCPrioritizedTexture;
     109        CCPrioritizedTexture* m_owner;
    126110    };
    127111
     
    132116    void setManagerInternal(CCPrioritizedTextureManager* manager) { m_manager = manager; }
    133117
    134     Backing* currentBacking() const { return m_currentBacking; }
    135     void setCurrentBacking(Backing*);
     118    Backing* backing() const { return m_backing; }
     119    void link(Backing*);
     120    void unlink();
    136121
    137122    IntSize m_size;
    138123    GC3Denum m_format;
    139     size_t m_memorySizeBytes;
     124    size_t m_bytes;
    140125
    141126    size_t m_priority;
    142127    bool m_isAbovePriorityCutoff;
    143128
    144     Backing* m_currentBacking;
     129    Backing* m_backing;
    145130    CCPrioritizedTextureManager* m_manager;
    146131};
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp

    r121870 r122506  
    9898        }
    9999
    100         size_t newMemoryBytes = memoryBytes + (*it)->memorySizeBytes();
     100        size_t newMemoryBytes = memoryBytes + (*it)->bytes();
    101101        if (newMemoryBytes > m_memoryAvailableBytes) {
    102102            m_priorityCutoff = (*it)->requestPriority();
     
    115115        (*it)->setAbovePriorityCutoff(isAbovePriorityCutoff);
    116116        if (isAbovePriorityCutoff)
    117             m_memoryAboveCutoffBytes += (*it)->memorySizeBytes();
     117            m_memoryAboveCutoffBytes += (*it)->bytes();
    118118    }
    119119    ASSERT(m_memoryAboveCutoffBytes <= m_memoryAvailableBytes);
     
    158158        return false;
    159159
    160     size_t newMemoryBytes = m_memoryAboveCutoffBytes + texture->memorySizeBytes();
     160    size_t newMemoryBytes = m_memoryAboveCutoffBytes + texture->bytes();
    161161    if (newMemoryBytes > m_memoryAvailableBytes)
    162162        return false;
     
    164164    m_memoryAboveCutoffBytes = newMemoryBytes;
    165165    texture->setAbovePriorityCutoff(true);
    166     if (texture->currentBacking()) {
    167         m_backings.remove(texture->currentBacking());
    168         m_backings.add(texture->currentBacking());
     166    if (texture->backing()) {
     167        m_backings.remove(texture->backing());
     168        m_backings.add(texture->backing());
    169169    }
    170170    return true;
     
    174174{
    175175    ASSERT(texture->isAbovePriorityCutoff());
    176     if (texture->currentBacking() || !texture->isAbovePriorityCutoff())
     176    if (texture->backing() || !texture->isAbovePriorityCutoff())
    177177        return;
    178178
     
    182182    // First try to recycle
    183183    for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
    184         if ((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff())
     184        if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff())
    185185            break;
    186186        if ((*it)->size() == texture->size() && (*it)->format() == texture->format()) {
     
    192192    // Otherwise reduce memory and just allocate a new backing texures.
    193193    if (!backing) {
    194         reduceMemory(m_memoryAvailableBytes - texture->memorySizeBytes(), allocator);
     194        reduceMemory(m_memoryAvailableBytes - texture->bytes(), allocator);
    195195        backing = createBacking(texture->size(), texture->format(), allocator);
    196196    }
    197197
    198198    // Move the used backing texture to the end of the eviction list.
    199     if (backing->currentTexture())
    200         unlink(backing->currentTexture(), backing);
    201     link(texture, backing);
     199    if (backing->owner())
     200        backing->owner()->unlink();
     201    texture->link(backing);
    202202    m_backings.remove(backing);
    203203    m_backings.add(backing);
     
    212212    while (memoryUseBytes() > limitBytes && m_backings.size() > 0) {
    213213        BackingSet::iterator it = m_backings.begin();
    214         if ((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff())
     214        if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff())
    215215            break;
    216216        destroyBacking((*it), allocator);
     
    230230    size_t wastedMemory = 0;
    231231    for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
    232         if ((*it)->currentTexture())
    233             break;
    234         wastedMemory += (*it)->memorySizeBytes();
     232        if ((*it)->owner())
     233            break;
     234        wastedMemory += (*it)->bytes();
    235235    }
    236236    size_t tenPercentOfMemory = m_memoryAvailableBytes / 10;
     
    245245    while (m_backings.size() > 0) {
    246246        BackingSet::iterator it = m_backings.begin();
    247         if ((*it)->currentTexture())
    248             unlink((*it)->currentTexture(), (*it));
     247        if ((*it)->owner())
     248            (*it)->owner()->unlink();
    249249        destroyBacking((*it), allocator);
    250250    }
     
    259259}
    260260
    261 void CCPrioritizedTextureManager::unlink(CCPrioritizedTexture* texture, CCPrioritizedTexture::Backing* backing)
    262 {
    263     ASSERT(texture && backing);
    264     ASSERT(texture->currentBacking() == backing);
    265     ASSERT(backing->currentTexture() == texture);
    266 
    267     texture->setCurrentBacking(0);
    268     backing->setCurrentTexture(0);
    269 }
    270 
    271 void CCPrioritizedTextureManager::link(CCPrioritizedTexture* texture, CCPrioritizedTexture::Backing* backing)
    272 {
    273     ASSERT(texture && backing);
    274     ASSERT(!texture->currentBacking());
    275     ASSERT(!backing->currentTexture());
    276 
    277     texture->setCurrentBacking(backing);
    278     backing->setCurrentTexture(texture);
    279 }
    280 
    281 
    282261void CCPrioritizedTextureManager::registerTexture(CCPrioritizedTexture* texture)
    283262{
    284263    ASSERT(texture);
    285264    ASSERT(!texture->textureManager());
    286     ASSERT(!texture->currentBacking());
     265    ASSERT(!texture->backing());
    287266    ASSERT(m_textures.find(texture) == m_textures.end());
    288267
     
    306285void CCPrioritizedTextureManager::returnBackingTexture(CCPrioritizedTexture* texture)
    307286{
    308     if (texture->currentBacking()) {
     287    if (texture->backing()) {
    309288        // Move the backing texture to the front for eviction/recycling and unlink it.
    310         m_backings.remove(texture->currentBacking());
    311         m_backings.insertBefore(m_backings.begin(), texture->currentBacking());
    312         unlink(texture, texture->currentBacking());
     289        m_backings.remove(texture->backing());
     290        m_backings.insertBefore(m_backings.begin(), texture->backing());
     291        texture->unlink();
    313292    }
    314293}
     
    318297    ASSERT(allocator);
    319298
    320     unsigned textureId = allocator->createTexture(size, format);
    321     CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(size, format, textureId);
    322     m_memoryUseBytes += backing->memorySizeBytes();
     299    CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(allocator->createTexture(size, format), size, format);
     300    m_memoryUseBytes += backing->bytes();
    323301    // Put backing texture at the front for eviction, since it isn't in use yet.
    324302    m_backings.insertBefore(m_backings.begin(), backing);
     
    329307{
    330308    ASSERT(backing);
    331     ASSERT(!backing->currentTexture() || !backing->currentTexture()->isAbovePriorityCutoff());
     309    ASSERT(!backing->owner() || !backing->owner()->isAbovePriorityCutoff());
    332310    ASSERT(m_backings.find(backing) != m_backings.end());
    333311
    334312    if (allocator)
    335         allocator->deleteTexture(backing->textureId(), backing->size(), backing->format());
    336     if (backing->currentTexture())
    337         unlink(backing->currentTexture(), backing);
    338     m_memoryUseBytes -= backing->memorySizeBytes();
     313        allocator->deleteTexture(backing->id(), backing->size(), backing->format());
     314    if (backing->owner())
     315        backing->owner()->unlink();
     316    m_memoryUseBytes -= backing->bytes();
    339317    m_backings.remove(backing);
    340318
     
    352330    // Backings/textures must be doubly-linked and only to other backings/textures in this manager.
    353331    for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
    354         if ((*it)->currentTexture()) {
    355             ASSERT(m_textures.find((*it)->currentTexture()) != m_textures.end());
    356             ASSERT((*it)->currentTexture()->currentBacking() == (*it));
     332        if ((*it)->owner()) {
     333            ASSERT(m_textures.find((*it)->owner()) != m_textures.end());
     334            ASSERT((*it)->owner()->backing() == (*it));
    357335        }
    358336    }
    359337    for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) {
    360         if ((*it)->currentBacking()) {
    361             ASSERT(m_backings.find((*it)->currentBacking()) != m_backings.end());
    362             ASSERT((*it)->currentBacking()->currentTexture() == (*it));
     338        if ((*it)->backing()) {
     339            ASSERT(m_backings.find((*it)->backing()) != m_backings.end());
     340            ASSERT((*it)->backing()->owner() == (*it));
    363341        }
    364342    }
     
    369347    bool reachedProtected = false;
    370348    for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
    371         if ((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff())
     349        if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff())
    372350            reachedProtected = true;
    373351        if (reachedProtected)
    374             ASSERT((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff());
     352            ASSERT((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff());
    375353    }
    376354}
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h

    r121870 r122506  
    2828#include "CCPrioritizedTexture.h"
    2929#include "CCPriorityCalculator.h"
     30#include "CCTexture.h"
    3031#include "GraphicsContext3D.h"
    3132#include "IntRect.h"
    3233#include "IntSize.h"
    33 #include "TextureManager.h"
    3434
    3535namespace WebCore {
     
    5050    }
    5151    ~CCPrioritizedTextureManager();
     52
     53    // FIXME (http://crbug.com/137094): This 64MB default is a straggler from the
     54    // old texture manager and is just to give us a default memory allocation before
     55    // we get a callback from the GPU memory manager. We should probaby either:
     56    // - wait for the callback before rendering anything instead
     57    // - push this into the GPU memory manager somehow.
     58    static size_t defaultMemoryAllocationLimit() { return 64 * 1024 * 1024; }
    5259
    5360    // memoryUseBytes() describes the number of bytes used by existing allocated textures.
     
    9299    static inline bool compareBackings(CCPrioritizedTexture::Backing* a, CCPrioritizedTexture::Backing* b)
    93100    {
    94         int priorityA = a->currentTexture() ? a->currentTexture()->requestPriority() : CCPriorityCalculator::lowestPriority();
    95         int priorityB = b->currentTexture() ? b->currentTexture()->requestPriority() : CCPriorityCalculator::lowestPriority();
     101        int priorityA = a->owner() ? a->owner()->requestPriority() : CCPriorityCalculator::lowestPriority();
     102        int priorityB = b->owner() ? b->owner()->requestPriority() : CCPriorityCalculator::lowestPriority();
    96103        if (priorityA == priorityB)
    97104            return a < b;
     
    102109
    103110    void reduceMemory(size_t limit, TextureAllocator*);
    104 
    105     void link(CCPrioritizedTexture*, CCPrioritizedTexture::Backing*);
    106     void unlink(CCPrioritizedTexture*, CCPrioritizedTexture::Backing*);
    107111
    108112    CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, TextureAllocator*);
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h

    r121870 r122506  
    2929#include "IntRect.h"
    3030#include "IntSize.h"
    31 #include "TextureManager.h"
    3231
    3332namespace WebCore {
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp

    r122180 r122506  
    2525
    2626#include "config.h"
    27 
    2827#include "cc/CCScopedTexture.h"
    2928
    30 #include "TextureManager.h" // For TextureAllocator
     29#include "TextureAllocator.h"
    3130
    3231namespace WebCore {
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h

    r122180 r122506  
    2727#define CCScopedTexture_h
    2828
     29#include "TextureAllocator.h"
    2930#include "cc/CCTexture.h"
    3031
     
    3536namespace WebCore {
    3637
    37 class TextureAllocator;
    3838
    3939class CCScopedTexture : protected CCTexture {
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCTexture.h

    r122180 r122506  
    3636public:
    3737    CCTexture() : m_id(0) { }
     38    CCTexture(unsigned id, IntSize size, GC3Denum format)
     39        : m_id(id)
     40        , m_size(size)
     41        , m_format(format) { }
    3842
    3943    unsigned id() const { return m_id; }
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp

    r122373 r122506  
    5555static const int debugTileBorderMissingTileColorBlue = 0;
    5656
    57 class ManagedTexture;
    58 
    5957class DrawableTile : public CCLayerTilingData::Tile {
    6058    WTF_MAKE_NONCOPYABLE(DrawableTile);
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp

    r121214 r122506  
    3636#include "NotImplemented.h"
    3737#include "TextStream.h"
    38 #include "TextureManager.h" // For TextureAllocator
     38#include "TextureAllocator.h"
    3939#include "cc/CCGraphicsContext.h"
    4040#include "cc/CCLayerTreeHostImpl.h"
  • trunk/Source/WebKit/chromium/ChangeLog

    r122496 r122506  
     12012-07-12  Eric Penner  <epenner@google.com>
     2
     3        [chromium] Use CCTexture/TextureAllocator and remove TextureManager
     4        https://bugs.webkit.org/show_bug.cgi?id=91001
     5
     6        Reviewed by Adrienne Walker.
     7
     8        Deleting old texture manager tests.
     9
     10        * WebKit.gypi:
     11        * tests/CCLayerTreeHostImplTest.cpp:
     12        * tests/CCPrioritizedTextureTest.cpp:
     13        (WTF::CCPrioritizedTextureTest::texturesMemorySize):
     14        * tests/CCThreadedTest.cpp:
     15        * tests/CCTiledLayerTestCommon.h:
     16        * tests/Canvas2DLayerBridgeTest.cpp:
     17        * tests/TextureManagerTest.cpp: Removed.
     18
    1192012-07-12  Robert Sesek  <rsesek@chromium.org>
    220
  • trunk/Source/WebKit/chromium/WebKit.gypi

    r122344 r122506  
    139139            'tests/TextureCopierTest.cpp',
    140140            'tests/TextureLayerChromiumTest.cpp',
    141             'tests/TextureManagerTest.cpp',
    142141            'tests/ThrottledTextureUploaderTest.cpp',
    143142            'tests/TiledLayerChromiumTest.cpp',
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp

    r122373 r122506  
    3232#include "FakeWebGraphicsContext3D.h"
    3333#include "LayerRendererChromium.h"
    34 #include "ManagedTexture.h"
    3534#include "cc/CCIOSurfaceLayerImpl.h"
    3635#include "cc/CCLayerImpl.h"
  • trunk/Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp

    r121870 r122506  
    2929#include "CCTiledLayerTestCommon.h"
    3030#include "cc/CCPrioritizedTextureManager.h"
     31#include "cc/CCTexture.h"
    3132#include <gtest/gtest.h>
    3233
     
    5152    size_t texturesMemorySize(size_t textureCount)
    5253    {
    53         return TextureManager::memoryUseBytes(m_textureSize, m_textureFormat) * textureCount;
     54        return CCTexture::memorySizeBytes(m_textureSize, m_textureFormat) * textureCount;
    5455    }
    5556
  • trunk/Source/WebKit/chromium/tests/CCThreadedTest.cpp

    r121204 r122506  
    3535#include "GraphicsContext3DPrivate.h"
    3636#include "LayerChromium.h"
    37 #include "TextureManager.h"
    3837#include "WebCompositor.h"
    3938#include "WebKit.h"
  • trunk/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h

    r122373 r122506  
    3030#include "LayerTextureUpdater.h"
    3131#include "Region.h"
     32#include "TextureAllocator.h"
    3233#include "TextureCopier.h"
    3334#include "TextureUploader.h"
  • trunk/Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp

    r121268 r122506  
    3131#include "ImageBuffer.h"
    3232#include "LayerChromium.h"
    33 #include "TextureManager.h"
    3433#include "WebCompositor.h"
    3534#include "WebKit.h"
  • trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp

    r122160 r122506  
    3131#include "WebCompositor.h"
    3232#include "cc/CCDrawQuad.h"
     33#include "cc/CCPrioritizedTextureManager.h"
    3334#include "cc/CCSettings.h"
    3435#include "cc/CCSingleThreadProxy.h"
     
    7778        : m_setFullRootLayerDamageCount(0)
    7879        , m_rootLayer(CCLayerImpl::create(1))
    79         , m_memoryAllocationLimitBytes(0)
     80        , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAllocationLimit())
    8081    {
    8182        m_rootLayer->createRenderSurface();
Note: See TracChangeset for help on using the changeset viewer.