| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CCTiledLayerTestCommon_h | 5 #ifndef CCTiledLayerTestCommon_h |
| 6 #define CCTiledLayerTestCommon_h | 6 #define CCTiledLayerTestCommon_h |
| 7 | 7 |
| 8 #include "CCGraphicsContext.h" | 8 #include "CCGraphicsContext.h" |
| 9 #include "CCPrioritizedTexture.h" | 9 #include "CCPrioritizedTexture.h" |
| 10 #include "CCResourceProvider.h" | 10 #include "CCResourceProvider.h" |
| 11 #include "CCTextureUpdateQueue.h" | 11 #include "CCTextureUpdateQueue.h" |
| 12 #include "CCTiledLayerImpl.h" | 12 #include "CCTiledLayerImpl.h" |
| 13 #include "IntRect.h" | 13 #include "IntRect.h" |
| 14 #include "IntSize.h" | 14 #include "IntSize.h" |
| 15 #include "LayerTextureUpdater.h" | 15 #include "LayerTextureUpdater.h" |
| 16 #include "Region.h" | 16 #include "Region.h" |
| 17 #include "TextureCopier.h" | 17 #include "TextureCopier.h" |
| 18 #include "TextureUploader.h" | 18 #include "TextureUploader.h" |
| 19 #include "TiledLayerChromium.h" | 19 #include "TiledLayerChromium.h" |
| 20 | 20 |
| 21 namespace WebKitTests { | 21 namespace WebKitTests { |
| 22 | 22 |
| 23 class FakeTiledLayerChromium; | 23 class FakeTiledLayerChromium; |
| 24 | 24 |
| 25 class FakeLayerTextureUpdater : public WebCore::LayerTextureUpdater { | 25 class FakeLayerTextureUpdater : public cc::LayerTextureUpdater { |
| 26 public: | 26 public: |
| 27 class Texture : public WebCore::LayerTextureUpdater::Texture { | 27 class Texture : public cc::LayerTextureUpdater::Texture { |
| 28 public: | 28 public: |
| 29 Texture(FakeLayerTextureUpdater*, PassOwnPtr<WebCore::CCPrioritizedTextu
re>); | 29 Texture(FakeLayerTextureUpdater*, PassOwnPtr<cc::CCPrioritizedTexture>); |
| 30 virtual ~Texture(); | 30 virtual ~Texture(); |
| 31 | 31 |
| 32 virtual void updateRect(WebCore::CCResourceProvider* , const WebCore::In
tRect&, const WebCore::IntSize&) OVERRIDE; | 32 virtual void updateRect(cc::CCResourceProvider* , const cc::IntRect&, co
nst cc::IntSize&) OVERRIDE; |
| 33 virtual void prepareRect(const WebCore::IntRect&, WebCore::CCRenderingSt
ats&) OVERRIDE; | 33 virtual void prepareRect(const cc::IntRect&, cc::CCRenderingStats&) OVER
RIDE; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 FakeLayerTextureUpdater* m_layer; | 36 FakeLayerTextureUpdater* m_layer; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 FakeLayerTextureUpdater(); | 39 FakeLayerTextureUpdater(); |
| 40 virtual ~FakeLayerTextureUpdater(); | 40 virtual ~FakeLayerTextureUpdater(); |
| 41 | 41 |
| 42 virtual PassOwnPtr<WebCore::LayerTextureUpdater::Texture> createTexture(WebC
ore::CCPrioritizedTextureManager*) OVERRIDE; | 42 virtual PassOwnPtr<cc::LayerTextureUpdater::Texture> createTexture(cc::CCPri
oritizedTextureManager*) OVERRIDE; |
| 43 virtual SampledTexelFormat sampledTexelFormat(GC3Denum) OVERRIDE; | 43 virtual SampledTexelFormat sampledTexelFormat(GC3Denum) OVERRIDE; |
| 44 | 44 |
| 45 virtual void prepareToUpdate(const WebCore::IntRect& contentRect, const WebC
ore::IntSize&, float, float, WebCore::IntRect& resultingOpaqueRect, WebCore::CCR
enderingStats&) OVERRIDE; | 45 virtual void prepareToUpdate(const cc::IntRect& contentRect, const cc::IntSi
ze&, float, float, cc::IntRect& resultingOpaqueRect, cc::CCRenderingStats&) OVER
RIDE; |
| 46 // Sets the rect to invalidate during the next call to prepareToUpdate(). Af
ter the next | 46 // Sets the rect to invalidate during the next call to prepareToUpdate(). Af
ter the next |
| 47 // call to prepareToUpdate() the rect is reset. | 47 // call to prepareToUpdate() the rect is reset. |
| 48 void setRectToInvalidate(const WebCore::IntRect&, FakeTiledLayerChromium*); | 48 void setRectToInvalidate(const cc::IntRect&, FakeTiledLayerChromium*); |
| 49 // Last rect passed to prepareToUpdate(). | 49 // Last rect passed to prepareToUpdate(). |
| 50 const WebCore::IntRect& lastUpdateRect() const { return m_lastUpdateRect; } | 50 const cc::IntRect& lastUpdateRect() const { return m_lastUpdateRect; } |
| 51 | 51 |
| 52 // Number of times prepareToUpdate has been invoked. | 52 // Number of times prepareToUpdate has been invoked. |
| 53 int prepareCount() const { return m_prepareCount; } | 53 int prepareCount() const { return m_prepareCount; } |
| 54 void clearPrepareCount() { m_prepareCount = 0; } | 54 void clearPrepareCount() { m_prepareCount = 0; } |
| 55 | 55 |
| 56 // Number of times updateRect has been invoked. | 56 // Number of times updateRect has been invoked. |
| 57 int updateCount() const { return m_updateCount; } | 57 int updateCount() const { return m_updateCount; } |
| 58 void clearUpdateCount() { m_updateCount = 0; } | 58 void clearUpdateCount() { m_updateCount = 0; } |
| 59 void updateRect() { m_updateCount++; } | 59 void updateRect() { m_updateCount++; } |
| 60 | 60 |
| 61 // Number of times prepareRect() has been invoked on a texture. | 61 // Number of times prepareRect() has been invoked on a texture. |
| 62 int prepareRectCount() const { return m_prepareRectCount; } | 62 int prepareRectCount() const { return m_prepareRectCount; } |
| 63 void clearPrepareRectCount() { m_prepareRectCount = 0; } | 63 void clearPrepareRectCount() { m_prepareRectCount = 0; } |
| 64 void prepareRect() { m_prepareRectCount++; } | 64 void prepareRect() { m_prepareRectCount++; } |
| 65 | 65 |
| 66 void setOpaquePaintRect(const WebCore::IntRect& opaquePaintRect) { m_opaqueP
aintRect = opaquePaintRect; } | 66 void setOpaquePaintRect(const cc::IntRect& opaquePaintRect) { m_opaquePaintR
ect = opaquePaintRect; } |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 int m_prepareCount; | 69 int m_prepareCount; |
| 70 int m_updateCount; | 70 int m_updateCount; |
| 71 int m_prepareRectCount; | 71 int m_prepareRectCount; |
| 72 WebCore::IntRect m_rectToInvalidate; | 72 cc::IntRect m_rectToInvalidate; |
| 73 WebCore::IntRect m_lastUpdateRect; | 73 cc::IntRect m_lastUpdateRect; |
| 74 WebCore::IntRect m_opaquePaintRect; | 74 cc::IntRect m_opaquePaintRect; |
| 75 RefPtr<FakeTiledLayerChromium> m_layer; | 75 RefPtr<FakeTiledLayerChromium> m_layer; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 class FakeCCTiledLayerImpl : public WebCore::CCTiledLayerImpl { | 78 class FakeCCTiledLayerImpl : public cc::CCTiledLayerImpl { |
| 79 public: | 79 public: |
| 80 explicit FakeCCTiledLayerImpl(int id); | 80 explicit FakeCCTiledLayerImpl(int id); |
| 81 virtual ~FakeCCTiledLayerImpl(); | 81 virtual ~FakeCCTiledLayerImpl(); |
| 82 | 82 |
| 83 using WebCore::CCTiledLayerImpl::hasTileAt; | 83 using cc::CCTiledLayerImpl::hasTileAt; |
| 84 using WebCore::CCTiledLayerImpl::hasTextureIdForTileAt; | 84 using cc::CCTiledLayerImpl::hasTextureIdForTileAt; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 class FakeTiledLayerChromium : public WebCore::TiledLayerChromium { | 87 class FakeTiledLayerChromium : public cc::TiledLayerChromium { |
| 88 public: | 88 public: |
| 89 explicit FakeTiledLayerChromium(WebCore::CCPrioritizedTextureManager*); | 89 explicit FakeTiledLayerChromium(cc::CCPrioritizedTextureManager*); |
| 90 virtual ~FakeTiledLayerChromium(); | 90 virtual ~FakeTiledLayerChromium(); |
| 91 | 91 |
| 92 static WebCore::IntSize tileSize() { return WebCore::IntSize(100, 100); } | 92 static cc::IntSize tileSize() { return cc::IntSize(100, 100); } |
| 93 | 93 |
| 94 using WebCore::TiledLayerChromium::invalidateContentRect; | 94 using cc::TiledLayerChromium::invalidateContentRect; |
| 95 using WebCore::TiledLayerChromium::needsIdlePaint; | 95 using cc::TiledLayerChromium::needsIdlePaint; |
| 96 using WebCore::TiledLayerChromium::skipsDraw; | 96 using cc::TiledLayerChromium::skipsDraw; |
| 97 using WebCore::TiledLayerChromium::numPaintedTiles; | 97 using cc::TiledLayerChromium::numPaintedTiles; |
| 98 using WebCore::TiledLayerChromium::idlePaintRect; | 98 using cc::TiledLayerChromium::idlePaintRect; |
| 99 | 99 |
| 100 virtual void setNeedsDisplayRect(const WebCore::FloatRect&) OVERRIDE; | 100 virtual void setNeedsDisplayRect(const cc::FloatRect&) OVERRIDE; |
| 101 const WebCore::FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsD
isplayRect; } | 101 const cc::FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDispla
yRect; } |
| 102 | 102 |
| 103 virtual void setTexturePriorities(const WebCore::CCPriorityCalculator&) OVER
RIDE; | 103 virtual void setTexturePriorities(const cc::CCPriorityCalculator&) OVERRIDE; |
| 104 | 104 |
| 105 virtual WebCore::CCPrioritizedTextureManager* textureManager() const OVERRID
E; | 105 virtual cc::CCPrioritizedTextureManager* textureManager() const OVERRIDE; |
| 106 FakeLayerTextureUpdater* fakeLayerTextureUpdater() { return m_fakeTextureUpd
ater.get(); } | 106 FakeLayerTextureUpdater* fakeLayerTextureUpdater() { return m_fakeTextureUpd
ater.get(); } |
| 107 WebCore::FloatRect updateRect() { return m_updateRect; } | 107 cc::FloatRect updateRect() { return m_updateRect; } |
| 108 | 108 |
| 109 protected: | 109 protected: |
| 110 virtual WebCore::LayerTextureUpdater* textureUpdater() const OVERRIDE; | 110 virtual cc::LayerTextureUpdater* textureUpdater() const OVERRIDE; |
| 111 virtual void createTextureUpdaterIfNeeded() OVERRIDE { } | 111 virtual void createTextureUpdaterIfNeeded() OVERRIDE { } |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 RefPtr<FakeLayerTextureUpdater> m_fakeTextureUpdater; | 114 RefPtr<FakeLayerTextureUpdater> m_fakeTextureUpdater; |
| 115 WebCore::CCPrioritizedTextureManager* m_textureManager; | 115 cc::CCPrioritizedTextureManager* m_textureManager; |
| 116 WebCore::FloatRect m_lastNeedsDisplayRect; | 116 cc::FloatRect m_lastNeedsDisplayRect; |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 class FakeTiledLayerWithScaledBounds : public FakeTiledLayerChromium { | 119 class FakeTiledLayerWithScaledBounds : public FakeTiledLayerChromium { |
| 120 public: | 120 public: |
| 121 explicit FakeTiledLayerWithScaledBounds(WebCore::CCPrioritizedTextureManager
*); | 121 explicit FakeTiledLayerWithScaledBounds(cc::CCPrioritizedTextureManager*); |
| 122 | 122 |
| 123 void setContentBounds(const WebCore::IntSize& contentBounds) { m_forcedConte
ntBounds = contentBounds; } | 123 void setContentBounds(const cc::IntSize& contentBounds) { m_forcedContentBou
nds = contentBounds; } |
| 124 virtual WebCore::IntSize contentBounds() const OVERRIDE; | 124 virtual cc::IntSize contentBounds() const OVERRIDE; |
| 125 | 125 |
| 126 protected: | 126 protected: |
| 127 WebCore::IntSize m_forcedContentBounds; | 127 cc::IntSize m_forcedContentBounds; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 class FakeTextureCopier : public WebCore::TextureCopier { | 130 class FakeTextureCopier : public cc::TextureCopier { |
| 131 public: | 131 public: |
| 132 virtual void copyTexture(Parameters) OVERRIDE { } | 132 virtual void copyTexture(Parameters) OVERRIDE { } |
| 133 virtual void flush() OVERRIDE { } | 133 virtual void flush() OVERRIDE { } |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 class FakeTextureUploader : public WebCore::TextureUploader { | 136 class FakeTextureUploader : public cc::TextureUploader { |
| 137 public: | 137 public: |
| 138 virtual bool isBusy() OVERRIDE; | 138 virtual bool isBusy() OVERRIDE; |
| 139 virtual void beginUploads() OVERRIDE { } | 139 virtual void beginUploads() OVERRIDE { } |
| 140 virtual void endUploads() OVERRIDE { } | 140 virtual void endUploads() OVERRIDE { } |
| 141 virtual void uploadTexture(WebCore::CCResourceProvider*, Parameters upload)
OVERRIDE; | 141 virtual void uploadTexture(cc::CCResourceProvider*, Parameters upload) OVERR
IDE; |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 } | 144 } |
| 145 #endif // CCTiledLayerTestCommon_h | 145 #endif // CCTiledLayerTestCommon_h |
| OLD | NEW |