| 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 // Temporary forwarding header |
| 6 #define CCTiledLayerTestCommon_h | 6 #include "cc/test/tiled_layer_test_common.h" |
| 7 | |
| 8 #include "CCGraphicsContext.h" | |
| 9 #include "CCPrioritizedTexture.h" | |
| 10 #include "CCResourceProvider.h" | |
| 11 #include "CCTextureUpdateQueue.h" | |
| 12 #include "CCTiledLayerImpl.h" | |
| 13 #include "IntRect.h" | |
| 14 #include "IntSize.h" | |
| 15 #include "LayerTextureUpdater.h" | |
| 16 #include "Region.h" | |
| 17 #include "TextureCopier.h" | |
| 18 #include "TextureUploader.h" | |
| 19 #include "TiledLayerChromium.h" | |
| 20 | |
| 21 namespace WebKitTests { | |
| 22 | |
| 23 class FakeTiledLayerChromium; | |
| 24 | |
| 25 class FakeLayerTextureUpdater : public cc::LayerTextureUpdater { | |
| 26 public: | |
| 27 class Texture : public cc::LayerTextureUpdater::Texture { | |
| 28 public: | |
| 29 Texture(FakeLayerTextureUpdater*, scoped_ptr<cc::CCPrioritizedTexture>); | |
| 30 virtual ~Texture(); | |
| 31 | |
| 32 virtual void updateRect(cc::CCResourceProvider* , const cc::IntRect&, co
nst cc::IntSize&) OVERRIDE; | |
| 33 virtual void prepareRect(const cc::IntRect&, cc::CCRenderingStats&) OVER
RIDE; | |
| 34 | |
| 35 private: | |
| 36 FakeLayerTextureUpdater* m_layer; | |
| 37 }; | |
| 38 | |
| 39 FakeLayerTextureUpdater(); | |
| 40 virtual ~FakeLayerTextureUpdater(); | |
| 41 | |
| 42 virtual PassOwnPtr<cc::LayerTextureUpdater::Texture> createTexture(cc::CCPri
oritizedTextureManager*) OVERRIDE; | |
| 43 virtual SampledTexelFormat sampledTexelFormat(GC3Denum) OVERRIDE; | |
| 44 | |
| 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 | |
| 47 // call to prepareToUpdate() the rect is reset. | |
| 48 void setRectToInvalidate(const cc::IntRect&, FakeTiledLayerChromium*); | |
| 49 // Last rect passed to prepareToUpdate(). | |
| 50 const cc::IntRect& lastUpdateRect() const { return m_lastUpdateRect; } | |
| 51 | |
| 52 // Number of times prepareToUpdate has been invoked. | |
| 53 int prepareCount() const { return m_prepareCount; } | |
| 54 void clearPrepareCount() { m_prepareCount = 0; } | |
| 55 | |
| 56 // Number of times updateRect has been invoked. | |
| 57 int updateCount() const { return m_updateCount; } | |
| 58 void clearUpdateCount() { m_updateCount = 0; } | |
| 59 void updateRect() { m_updateCount++; } | |
| 60 | |
| 61 // Number of times prepareRect() has been invoked on a texture. | |
| 62 int prepareRectCount() const { return m_prepareRectCount; } | |
| 63 void clearPrepareRectCount() { m_prepareRectCount = 0; } | |
| 64 void prepareRect() { m_prepareRectCount++; } | |
| 65 | |
| 66 void setOpaquePaintRect(const cc::IntRect& opaquePaintRect) { m_opaquePaintR
ect = opaquePaintRect; } | |
| 67 | |
| 68 private: | |
| 69 int m_prepareCount; | |
| 70 int m_updateCount; | |
| 71 int m_prepareRectCount; | |
| 72 cc::IntRect m_rectToInvalidate; | |
| 73 cc::IntRect m_lastUpdateRect; | |
| 74 cc::IntRect m_opaquePaintRect; | |
| 75 scoped_refptr<FakeTiledLayerChromium> m_layer; | |
| 76 }; | |
| 77 | |
| 78 class FakeCCTiledLayerImpl : public cc::CCTiledLayerImpl { | |
| 79 public: | |
| 80 explicit FakeCCTiledLayerImpl(int id); | |
| 81 virtual ~FakeCCTiledLayerImpl(); | |
| 82 | |
| 83 using cc::CCTiledLayerImpl::hasTileAt; | |
| 84 using cc::CCTiledLayerImpl::hasResourceIdForTileAt; | |
| 85 }; | |
| 86 | |
| 87 class FakeTiledLayerChromium : public cc::TiledLayerChromium { | |
| 88 public: | |
| 89 explicit FakeTiledLayerChromium(cc::CCPrioritizedTextureManager*); | |
| 90 | |
| 91 static cc::IntSize tileSize() { return cc::IntSize(100, 100); } | |
| 92 | |
| 93 using cc::TiledLayerChromium::invalidateContentRect; | |
| 94 using cc::TiledLayerChromium::needsIdlePaint; | |
| 95 using cc::TiledLayerChromium::skipsDraw; | |
| 96 using cc::TiledLayerChromium::numPaintedTiles; | |
| 97 using cc::TiledLayerChromium::idlePaintRect; | |
| 98 | |
| 99 virtual void setNeedsDisplayRect(const cc::FloatRect&) OVERRIDE; | |
| 100 const cc::FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDispla
yRect; } | |
| 101 | |
| 102 virtual void setTexturePriorities(const cc::CCPriorityCalculator&) OVERRIDE; | |
| 103 | |
| 104 virtual cc::CCPrioritizedTextureManager* textureManager() const OVERRIDE; | |
| 105 FakeLayerTextureUpdater* fakeLayerTextureUpdater() { return m_fakeTextureUpd
ater.get(); } | |
| 106 cc::FloatRect updateRect() { return m_updateRect; } | |
| 107 | |
| 108 protected: | |
| 109 virtual cc::LayerTextureUpdater* textureUpdater() const OVERRIDE; | |
| 110 virtual void createTextureUpdaterIfNeeded() OVERRIDE { } | |
| 111 virtual ~FakeTiledLayerChromium(); | |
| 112 | |
| 113 private: | |
| 114 RefPtr<FakeLayerTextureUpdater> m_fakeTextureUpdater; | |
| 115 cc::CCPrioritizedTextureManager* m_textureManager; | |
| 116 cc::FloatRect m_lastNeedsDisplayRect; | |
| 117 }; | |
| 118 | |
| 119 class FakeTiledLayerWithScaledBounds : public FakeTiledLayerChromium { | |
| 120 public: | |
| 121 explicit FakeTiledLayerWithScaledBounds(cc::CCPrioritizedTextureManager*); | |
| 122 | |
| 123 void setContentBounds(const cc::IntSize& contentBounds) { m_forcedContentBou
nds = contentBounds; } | |
| 124 virtual cc::IntSize contentBounds() const OVERRIDE; | |
| 125 | |
| 126 protected: | |
| 127 virtual ~FakeTiledLayerWithScaledBounds(); | |
| 128 cc::IntSize m_forcedContentBounds; | |
| 129 }; | |
| 130 | |
| 131 | |
| 132 class FakeTextureUploader : public cc::TextureUploader { | |
| 133 public: | |
| 134 virtual size_t numBlockingUploads() OVERRIDE; | |
| 135 virtual void markPendingUploadsAsNonBlocking() OVERRIDE; | |
| 136 virtual double estimatedTexturesPerSecond() OVERRIDE; | |
| 137 virtual void uploadTexture(cc::CCResourceProvider*, Parameters) OVERRIDE; | |
| 138 }; | |
| 139 | |
| 140 } | |
| 141 #endif // CCTiledLayerTestCommon_h | |
| OLD | NEW |