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