Changeset 112550 in webkit


Ignore:
Timestamp:
Mar 29, 2012 11:18:47 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Split off tiled layer constructs for unit tests into a common header
https://bugs.webkit.org/show_bug.cgi?id=82425

Patch by Dana Jansens <danakj@chromium.org> on 2012-03-29
Reviewed by Adrienne Walker.

  • WebKit.gypi:
  • tests/CCTiledLayerTestCommon.cpp: Added.

(WebKitTests):
(WebKitTests::FakeLayerTextureUpdater::Texture::Texture):
(WebKitTests::FakeLayerTextureUpdater::Texture::~Texture):
(WebKitTests::FakeLayerTextureUpdater::Texture::updateRect):
(WebKitTests::FakeLayerTextureUpdater::Texture::prepareRect):
(WebKitTests::FakeLayerTextureUpdater::FakeLayerTextureUpdater):
(WebKitTests::FakeLayerTextureUpdater::~FakeLayerTextureUpdater):
(WebKitTests::FakeLayerTextureUpdater::prepareToUpdate):
(WebKitTests::FakeLayerTextureUpdater::setRectToInvalidate):
(WebKitTests::FakeLayerTextureUpdater::createTexture):
(WebKitTests::FakeCCTiledLayerImpl::FakeCCTiledLayerImpl):
(WebKitTests::FakeCCTiledLayerImpl::~FakeCCTiledLayerImpl):
(WebKitTests::FakeTiledLayerChromium::FakeTiledLayerChromium):
(WebKitTests::FakeTiledLayerChromium::~FakeTiledLayerChromium):
(WebKitTests::FakeTiledLayerChromium::setNeedsDisplayRect):
(WebKitTests::FakeTiledLayerChromium::paintContentsIfDirty):
(WebKitTests::FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds):
(WebKitTests::FakeCCTextureUpdater::FakeCCTextureUpdater):

  • tests/CCTiledLayerTestCommon.h: Added.

(WebKitTests):
(FakeLayerTextureUpdater):
(Texture):
(WebKitTests::FakeLayerTextureUpdater::sampledTexelFormat):
(WebKitTests::FakeLayerTextureUpdater::lastUpdateRect):
(WebKitTests::FakeLayerTextureUpdater::prepareCount):
(WebKitTests::FakeLayerTextureUpdater::clearPrepareCount):
(WebKitTests::FakeLayerTextureUpdater::updateCount):
(WebKitTests::FakeLayerTextureUpdater::clearUpdateCount):
(WebKitTests::FakeLayerTextureUpdater::updateRect):
(WebKitTests::FakeLayerTextureUpdater::prepareRectCount):
(WebKitTests::FakeLayerTextureUpdater::clearPrepareRectCount):
(WebKitTests::FakeLayerTextureUpdater::prepareRect):
(WebKitTests::FakeLayerTextureUpdater::setOpaquePaintRect):
(FakeCCTiledLayerImpl):
(FakeTiledLayerChromium):
(WebKitTests::FakeTiledLayerChromium::tileSize):
(WebKitTests::FakeTiledLayerChromium::lastNeedsDisplayRect):
(WebKitTests::FakeTiledLayerChromium::textureManager):
(WebKitTests::FakeTiledLayerChromium::fakeLayerTextureUpdater):
(WebKitTests::FakeTiledLayerChromium::updateRect):
(WebKitTests::FakeTiledLayerChromium::textureUpdater):
(WebKitTests::FakeTiledLayerChromium::createTextureUpdaterIfNeeded):
(FakeTiledLayerWithScaledBounds):
(WebKitTests::FakeTiledLayerWithScaledBounds::setContentBounds):
(WebKitTests::FakeTiledLayerWithScaledBounds::contentBounds):
(FakeTextureAllocator):
(WebKitTests::FakeTextureAllocator::createTexture):
(WebKitTests::FakeTextureAllocator::deleteTexture):
(FakeTextureCopier):
(WebKitTests::FakeTextureCopier::copyTexture):
(FakeCCTextureUpdater):
(WebKitTests::FakeCCTextureUpdater::textureAllocator):

  • tests/TextureManagerTest.cpp:
  • tests/TiledLayerChromiumTest.cpp:
Location:
trunk/Source/WebKit/chromium
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r112548 r112550  
     12012-03-29  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Split off tiled layer constructs for unit tests into a common header
     4        https://bugs.webkit.org/show_bug.cgi?id=82425
     5
     6        Reviewed by Adrienne Walker.
     7
     8        * WebKit.gypi:
     9        * tests/CCTiledLayerTestCommon.cpp: Added.
     10        (WebKitTests):
     11        (WebKitTests::FakeLayerTextureUpdater::Texture::Texture):
     12        (WebKitTests::FakeLayerTextureUpdater::Texture::~Texture):
     13        (WebKitTests::FakeLayerTextureUpdater::Texture::updateRect):
     14        (WebKitTests::FakeLayerTextureUpdater::Texture::prepareRect):
     15        (WebKitTests::FakeLayerTextureUpdater::FakeLayerTextureUpdater):
     16        (WebKitTests::FakeLayerTextureUpdater::~FakeLayerTextureUpdater):
     17        (WebKitTests::FakeLayerTextureUpdater::prepareToUpdate):
     18        (WebKitTests::FakeLayerTextureUpdater::setRectToInvalidate):
     19        (WebKitTests::FakeLayerTextureUpdater::createTexture):
     20        (WebKitTests::FakeCCTiledLayerImpl::FakeCCTiledLayerImpl):
     21        (WebKitTests::FakeCCTiledLayerImpl::~FakeCCTiledLayerImpl):
     22        (WebKitTests::FakeTiledLayerChromium::FakeTiledLayerChromium):
     23        (WebKitTests::FakeTiledLayerChromium::~FakeTiledLayerChromium):
     24        (WebKitTests::FakeTiledLayerChromium::setNeedsDisplayRect):
     25        (WebKitTests::FakeTiledLayerChromium::paintContentsIfDirty):
     26        (WebKitTests::FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds):
     27        (WebKitTests::FakeCCTextureUpdater::FakeCCTextureUpdater):
     28        * tests/CCTiledLayerTestCommon.h: Added.
     29        (WebKitTests):
     30        (FakeLayerTextureUpdater):
     31        (Texture):
     32        (WebKitTests::FakeLayerTextureUpdater::sampledTexelFormat):
     33        (WebKitTests::FakeLayerTextureUpdater::lastUpdateRect):
     34        (WebKitTests::FakeLayerTextureUpdater::prepareCount):
     35        (WebKitTests::FakeLayerTextureUpdater::clearPrepareCount):
     36        (WebKitTests::FakeLayerTextureUpdater::updateCount):
     37        (WebKitTests::FakeLayerTextureUpdater::clearUpdateCount):
     38        (WebKitTests::FakeLayerTextureUpdater::updateRect):
     39        (WebKitTests::FakeLayerTextureUpdater::prepareRectCount):
     40        (WebKitTests::FakeLayerTextureUpdater::clearPrepareRectCount):
     41        (WebKitTests::FakeLayerTextureUpdater::prepareRect):
     42        (WebKitTests::FakeLayerTextureUpdater::setOpaquePaintRect):
     43        (FakeCCTiledLayerImpl):
     44        (FakeTiledLayerChromium):
     45        (WebKitTests::FakeTiledLayerChromium::tileSize):
     46        (WebKitTests::FakeTiledLayerChromium::lastNeedsDisplayRect):
     47        (WebKitTests::FakeTiledLayerChromium::textureManager):
     48        (WebKitTests::FakeTiledLayerChromium::fakeLayerTextureUpdater):
     49        (WebKitTests::FakeTiledLayerChromium::updateRect):
     50        (WebKitTests::FakeTiledLayerChromium::textureUpdater):
     51        (WebKitTests::FakeTiledLayerChromium::createTextureUpdaterIfNeeded):
     52        (FakeTiledLayerWithScaledBounds):
     53        (WebKitTests::FakeTiledLayerWithScaledBounds::setContentBounds):
     54        (WebKitTests::FakeTiledLayerWithScaledBounds::contentBounds):
     55        (FakeTextureAllocator):
     56        (WebKitTests::FakeTextureAllocator::createTexture):
     57        (WebKitTests::FakeTextureAllocator::deleteTexture):
     58        (FakeTextureCopier):
     59        (WebKitTests::FakeTextureCopier::copyTexture):
     60        (FakeCCTextureUpdater):
     61        (WebKitTests::FakeCCTextureUpdater::textureAllocator):
     62        * tests/TextureManagerTest.cpp:
     63        * tests/TiledLayerChromiumTest.cpp:
     64
    1652012-03-29  Dana Jansens  <danakj@chromium.org>
    266
  • trunk/Source/WebKit/chromium/WebKit.gypi

    r112548 r112550  
    8888            'tests/CCSolidColorLayerImplTest.cpp',
    8989            'tests/CCTiledLayerImplTest.cpp',
     90            'tests/CCTiledLayerTestCommon.h',
     91            'tests/CCTiledLayerTestCommon.cpp',
    9092            'tests/CCThreadTaskTest.cpp',
    9193            'tests/CCTimerTest.cpp',
  • trunk/Source/WebKit/chromium/tests/TextureManagerTest.cpp

    r107014 r112550  
    2525#include "config.h"
    2626
     27#include "CCTiledLayerTestCommon.h"
    2728#include "ManagedTexture.h"
    2829#include "TextureManager.h"
     
    3132
    3233using namespace WebCore;
     34using namespace WebKitTests;
    3335using namespace WTF;
    3436
    3537namespace {
    36 
    37 class FakeTextureAllocator : public TextureAllocator {
    38 public:
    39     virtual ~FakeTextureAllocator() { }
    40     virtual unsigned createTexture(const IntSize&, GC3Denum) { return 1; }
    41     virtual void deleteTexture(unsigned, const IntSize&, GC3Denum) { }
    42 };
    4338
    4439class TextureManagerTest : public testing::Test {
  • trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

    r112481 r112550  
    2929#include "CCAnimationTestCommon.h"
    3030#include "CCLayerTreeTestCommon.h"
     31#include "CCTiledLayerTestCommon.h"
    3132#include "FakeCCLayerTreeHostClient.h"
    32 #include "LayerTextureUpdater.h"
    33 #include "Region.h"
    34 #include "TextureCopier.h"
    35 #include "TextureManager.h"
    3633#include "WebCompositor.h"
    3734#include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread
    38 #include "cc/CCTextureUpdater.h"
    39 #include "cc/CCTiledLayerImpl.h"
    4035#include <gtest/gtest.h>
    4136
     
    6964private:
    7065    IntRect m_scissorRectInScreen;
    71 };
    72 
    73 class FakeTextureAllocator : public TextureAllocator {
    74 public:
    75     virtual unsigned createTexture(const IntSize&, GC3Denum) { return 1; }
    76     virtual void deleteTexture(unsigned, const IntSize&, GC3Denum) { }
    77 };
    78 
    79 class FakeTextureCopier : public TextureCopier {
    80 public:
    81     virtual void copyTexture(GraphicsContext3D*, unsigned, unsigned, const IntSize&) { }
    82 };
    83 
    84 class FakeTiledLayerChromium;
    85 
    86 class FakeLayerTextureUpdater : public LayerTextureUpdater {
    87 public:
    88     class Texture : public LayerTextureUpdater::Texture {
    89     public:
    90         Texture(FakeLayerTextureUpdater* layer, PassOwnPtr<ManagedTexture> texture)
    91             : LayerTextureUpdater::Texture(texture)
    92             , m_layer(layer)
    93         {
    94         }
    95         virtual ~Texture() { }
    96 
    97         virtual void updateRect(GraphicsContext3D*, TextureAllocator* allocator, const IntRect&, const IntRect&)
    98         {
    99             if (allocator)
    100                 texture()->allocate(allocator);
    101             m_layer->updateRect();
    102         }
    103         virtual void prepareRect(const IntRect&) { m_layer->prepareRect(); }
    104 
    105     private:
    106         FakeLayerTextureUpdater* m_layer;
    107     };
    108 
    109     FakeLayerTextureUpdater()
    110         : m_prepareCount(0)
    111         , m_updateCount(0)
    112         , m_prepareRectCount(0)
    113     {
    114     }
    115     virtual ~FakeLayerTextureUpdater() { }
    116 
    117     // Sets the rect to invalidate during the next call to prepareToUpdate(). After the next
    118     // call to prepareToUpdate() the rect is reset.
    119     void setRectToInvalidate(const IntRect&, FakeTiledLayerChromium*);
    120 
    121     // Number of times prepareToUpdate has been invoked.
    122     int prepareCount() const { return m_prepareCount; }
    123     void clearPrepareCount() { m_prepareCount = 0; }
    124 
    125     // Number of times updateRect has been invoked.
    126     int updateCount() const { return m_updateCount; }
    127     void clearUpdateCount() { m_updateCount = 0; }
    128     void updateRect() { m_updateCount++; }
    129 
    130     // Number of times prepareRect() has been invoked on a texture.
    131     int prepareRectCount() const { return m_prepareRectCount; }
    132     void clearPrepareRectCount() { m_prepareRectCount = 0; }
    133     void prepareRect() { m_prepareRectCount++; }
    134 
    135     void setOpaquePaintRect(const IntRect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; }
    136 
    137     // Last rect passed to prepareToUpdate().
    138     const IntRect& lastUpdateRect()  const { return m_lastUpdateRect; }
    139 
    140     virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) { return adoptPtr(new Texture(this, ManagedTexture::create(manager))); }
    141     virtual SampledTexelFormat sampledTexelFormat(GC3Denum) { return SampledTexelFormatRGBA; }
    142     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect);
    143 
    144 private:
    145     int m_prepareCount;
    146     int m_updateCount;
    147     int m_prepareRectCount;
    148     IntRect m_rectToInvalidate;
    149     IntRect m_lastUpdateRect;
    150     IntRect m_opaquePaintRect;
    151     RefPtr<FakeTiledLayerChromium> m_layer;
    152 };
    153 
    154 class FakeCCTiledLayerImpl : public CCTiledLayerImpl {
    155 public:
    156     explicit FakeCCTiledLayerImpl(int id)
    157         : CCTiledLayerImpl(id) { }
    158     virtual ~FakeCCTiledLayerImpl() { }
    159 
    160     using CCTiledLayerImpl::hasTileAt;
    161     using CCTiledLayerImpl::hasTextureIdForTileAt;
    162 };
    163 
    164 class FakeTiledLayerChromium : public TiledLayerChromium {
    165 public:
    166     explicit FakeTiledLayerChromium(TextureManager* textureManager)
    167         : TiledLayerChromium()
    168         , m_fakeTextureUpdater(adoptRef(new FakeLayerTextureUpdater))
    169         , m_textureManager(textureManager)
    170     {
    171         setTileSize(tileSize());
    172         setTextureFormat(GraphicsContext3D::RGBA);
    173         setBorderTexelOption(CCLayerTilingData::NoBorderTexels);
    174         setIsDrawable(true); // So that we don't get false positives if any of these tests expect to return false from drawsContent() for other reasons.
    175     }
    176     virtual ~FakeTiledLayerChromium() { }
    177 
    178     static IntSize tileSize() { return IntSize(100, 100); }
    179 
    180     using TiledLayerChromium::invalidateRect;
    181     using TiledLayerChromium::prepareToUpdate;
    182     using TiledLayerChromium::prepareToUpdateIdle;
    183     using TiledLayerChromium::needsIdlePaint;
    184     using TiledLayerChromium::skipsDraw;
    185     using TiledLayerChromium::numPaintedTiles;
    186     using TiledLayerChromium::idlePaintRect;
    187 
    188     virtual void setNeedsDisplayRect(const FloatRect& rect)
    189     {
    190         m_lastNeedsDisplayRect = rect;
    191         TiledLayerChromium::setNeedsDisplayRect(rect);
    192     }
    193 
    194     const FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRect; }
    195 
    196     FakeLayerTextureUpdater* fakeLayerTextureUpdater() { return m_fakeTextureUpdater.get(); }
    197 
    198     virtual TextureManager* textureManager() const { return m_textureManager; }
    199 
    200     virtual void paintContentsIfDirty(const CCOcclusionTracker* occlusion)
    201     {
    202         prepareToUpdate(visibleLayerRect(), occlusion);
    203     }
    204 
    205 private:
    206     virtual LayerTextureUpdater* textureUpdater() const
    207     {
    208         return m_fakeTextureUpdater.get();
    209     }
    210 
    211     virtual void createTextureUpdaterIfNeeded() { }
    212 
    213     RefPtr<FakeLayerTextureUpdater> m_fakeTextureUpdater;
    214     TextureManager* m_textureManager;
    215     FloatRect m_lastNeedsDisplayRect;
    216 };
    217 
    218 class FakeTiledLayerWithScaledBounds : public FakeTiledLayerChromium {
    219 public:
    220     explicit FakeTiledLayerWithScaledBounds(TextureManager* textureManager)
    221         : FakeTiledLayerChromium(textureManager)
    222     {
    223     }
    224 
    225     void setContentBounds(const IntSize& contentBounds) { m_forcedContentBounds = contentBounds; }
    226     virtual IntSize contentBounds() const { return m_forcedContentBounds; }
    227 
    228     FloatRect updateRect() { return m_updateRect; }
    229 
    230 protected:
    231     IntSize m_forcedContentBounds;
    232 };
    233 
    234 void FakeLayerTextureUpdater::setRectToInvalidate(const IntRect& rect, FakeTiledLayerChromium* layer)
    235 {
    236     m_rectToInvalidate = rect;
    237     m_layer = layer;
    238 }
    239 
    240 void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect)
    241 {
    242     m_prepareCount++;
    243     m_lastUpdateRect = contentRect;
    244     if (!m_rectToInvalidate.isEmpty()) {
    245         m_layer->invalidateRect(m_rectToInvalidate);
    246         m_rectToInvalidate = IntRect();
    247         m_layer = 0;
    248     }
    249     *resultingOpaqueRect = m_opaquePaintRect;
    250 }
    251 
    252 class FakeCCTextureUpdater : public CCTextureUpdater {
    253 public:
    254     explicit FakeCCTextureUpdater()
    255         : CCTextureUpdater(&m_textureAllocator, &m_textureCopier)
    256     {
    257     }
    258 
    259     FakeTextureAllocator& textureAllocator()
    260     {
    261         return m_textureAllocator;
    262     }
    263 
    264 protected:
    265     FakeTextureAllocator m_textureAllocator;
    266     FakeTextureCopier m_textureCopier;
    26766};
    26867
Note: See TracChangeset for help on using the changeset viewer.