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 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/test/tiled_layer_test_common.h" | 7 #include "cc/test/tiled_layer_test_common.h" |
8 | 8 |
9 using namespace cc; | 9 using namespace cc; |
10 | 10 |
11 namespace WebKitTests { | 11 namespace WebKitTests { |
12 | 12 |
13 FakeLayerTextureUpdater::Texture::Texture(FakeLayerTextureUpdater* layer, scoped
_ptr<CCPrioritizedTexture> texture) | 13 FakeLayerTextureUpdater::Texture::Texture(FakeLayerTextureUpdater* layer, scoped
_ptr<PrioritizedTexture> texture) |
14 : LayerTextureUpdater::Texture(texture.Pass()) | 14 : LayerTextureUpdater::Texture(texture.Pass()) |
15 , m_layer(layer) | 15 , m_layer(layer) |
16 { | 16 { |
17 } | 17 } |
18 | 18 |
19 FakeLayerTextureUpdater::Texture::~Texture() | 19 FakeLayerTextureUpdater::Texture::~Texture() |
20 { | 20 { |
21 } | 21 } |
22 | 22 |
23 void FakeLayerTextureUpdater::Texture::update(CCTextureUpdateQueue& queue, const
IntRect&, const IntSize&, bool partialUpdate, CCRenderingStats&) | 23 void FakeLayerTextureUpdater::Texture::update(TextureUpdateQueue& queue, const I
ntRect&, const IntSize&, bool partialUpdate, RenderingStats&) |
24 { | 24 { |
25 TextureUploader::Parameters upload = { texture(), NULL, NULL, { IntRect(), I
ntRect(), IntSize() } }; | 25 TextureUploader::Parameters upload = { texture(), NULL, NULL, { IntRect(), I
ntRect(), IntSize() } }; |
26 if (partialUpdate) | 26 if (partialUpdate) |
27 queue.appendPartialUpload(upload); | 27 queue.appendPartialUpload(upload); |
28 else | 28 else |
29 queue.appendFullUpload(upload); | 29 queue.appendFullUpload(upload); |
30 | 30 |
31 m_layer->update(); | 31 m_layer->update(); |
32 } | 32 } |
33 | 33 |
34 FakeLayerTextureUpdater::FakeLayerTextureUpdater() | 34 FakeLayerTextureUpdater::FakeLayerTextureUpdater() |
35 : m_prepareCount(0) | 35 : m_prepareCount(0) |
36 , m_updateCount(0) | 36 , m_updateCount(0) |
37 { | 37 { |
38 } | 38 } |
39 | 39 |
40 FakeLayerTextureUpdater::~FakeLayerTextureUpdater() | 40 FakeLayerTextureUpdater::~FakeLayerTextureUpdater() |
41 { | 41 { |
42 } | 42 } |
43 | 43 |
44 void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const
IntSize&, float, float, IntRect& resultingOpaqueRect, CCRenderingStats&) | 44 void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const
IntSize&, float, float, IntRect& resultingOpaqueRect, RenderingStats&) |
45 { | 45 { |
46 m_prepareCount++; | 46 m_prepareCount++; |
47 m_lastUpdateRect = contentRect; | 47 m_lastUpdateRect = contentRect; |
48 if (!m_rectToInvalidate.isEmpty()) { | 48 if (!m_rectToInvalidate.isEmpty()) { |
49 m_layer->invalidateContentRect(m_rectToInvalidate); | 49 m_layer->invalidateContentRect(m_rectToInvalidate); |
50 m_rectToInvalidate = IntRect(); | 50 m_rectToInvalidate = IntRect(); |
51 m_layer = NULL; | 51 m_layer = NULL; |
52 } | 52 } |
53 resultingOpaqueRect = m_opaquePaintRect; | 53 resultingOpaqueRect = m_opaquePaintRect; |
54 } | 54 } |
55 | 55 |
56 void FakeLayerTextureUpdater::setRectToInvalidate(const IntRect& rect, FakeTiled
LayerChromium* layer) | 56 void FakeLayerTextureUpdater::setRectToInvalidate(const IntRect& rect, FakeTiled
Layer* layer) |
57 { | 57 { |
58 m_rectToInvalidate = rect; | 58 m_rectToInvalidate = rect; |
59 m_layer = layer; | 59 m_layer = layer; |
60 } | 60 } |
61 | 61 |
62 scoped_ptr<LayerTextureUpdater::Texture> FakeLayerTextureUpdater::createTexture(
CCPrioritizedTextureManager* manager) | 62 scoped_ptr<LayerTextureUpdater::Texture> FakeLayerTextureUpdater::createTexture(
PrioritizedTextureManager* manager) |
63 { | 63 { |
64 return scoped_ptr<LayerTextureUpdater::Texture>(new Texture(this, CCPrioriti
zedTexture::create(manager))); | 64 return scoped_ptr<LayerTextureUpdater::Texture>(new Texture(this, Prioritize
dTexture::create(manager))); |
65 } | 65 } |
66 | 66 |
67 LayerTextureUpdater::SampledTexelFormat FakeLayerTextureUpdater::sampledTexelFor
mat(GC3Denum) | 67 LayerTextureUpdater::SampledTexelFormat FakeLayerTextureUpdater::sampledTexelFor
mat(GC3Denum) |
68 { | 68 { |
69 return SampledTexelFormatRGBA; | 69 return SampledTexelFormatRGBA; |
70 } | 70 } |
71 | 71 |
72 FakeCCTiledLayerImpl::FakeCCTiledLayerImpl(int id) | 72 FakeTiledLayerImpl::FakeTiledLayerImpl(int id) |
73 : CCTiledLayerImpl(id) | 73 : TiledLayerImpl(id) |
74 { | 74 { |
75 } | 75 } |
76 | 76 |
77 FakeCCTiledLayerImpl::~FakeCCTiledLayerImpl() | 77 FakeTiledLayerImpl::~FakeTiledLayerImpl() |
78 { | 78 { |
79 } | 79 } |
80 | 80 |
81 FakeTiledLayerChromium::FakeTiledLayerChromium(CCPrioritizedTextureManager* text
ureManager) | 81 FakeTiledLayer::FakeTiledLayer(PrioritizedTextureManager* textureManager) |
82 : TiledLayerChromium() | 82 : TiledLayer() |
83 , m_fakeTextureUpdater(make_scoped_refptr(new FakeLayerTextureUpdater)) | 83 , m_fakeTextureUpdater(make_scoped_refptr(new FakeLayerTextureUpdater)) |
84 , m_textureManager(textureManager) | 84 , m_textureManager(textureManager) |
85 { | 85 { |
86 setTileSize(tileSize()); | 86 setTileSize(tileSize()); |
87 setTextureFormat(GraphicsContext3D::RGBA); | 87 setTextureFormat(GraphicsContext3D::RGBA); |
88 setBorderTexelOption(CCLayerTilingData::NoBorderTexels); | 88 setBorderTexelOption(LayerTilingData::NoBorderTexels); |
89 setIsDrawable(true); // So that we don't get false positives if any of these
tests expect to return false from drawsContent() for other reasons. | 89 setIsDrawable(true); // So that we don't get false positives if any of these
tests expect to return false from drawsContent() for other reasons. |
90 } | 90 } |
91 | 91 |
92 FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds(CCPrioritizedText
ureManager* textureManager) | 92 FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds(PrioritizedTextur
eManager* textureManager) |
93 : FakeTiledLayerChromium(textureManager) | 93 : FakeTiledLayer(textureManager) |
94 { | 94 { |
95 } | 95 } |
96 | 96 |
97 FakeTiledLayerWithScaledBounds::~FakeTiledLayerWithScaledBounds() | 97 FakeTiledLayerWithScaledBounds::~FakeTiledLayerWithScaledBounds() |
98 { | 98 { |
99 } | 99 } |
100 | 100 |
101 FakeTiledLayerChromium::~FakeTiledLayerChromium() | 101 FakeTiledLayer::~FakeTiledLayer() |
102 { | 102 { |
103 } | 103 } |
104 | 104 |
105 void FakeTiledLayerChromium::setNeedsDisplayRect(const FloatRect& rect) | 105 void FakeTiledLayer::setNeedsDisplayRect(const FloatRect& rect) |
106 { | 106 { |
107 m_lastNeedsDisplayRect = rect; | 107 m_lastNeedsDisplayRect = rect; |
108 TiledLayerChromium::setNeedsDisplayRect(rect); | 108 TiledLayer::setNeedsDisplayRect(rect); |
109 } | 109 } |
110 | 110 |
111 void FakeTiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& ca
lculator) | 111 void FakeTiledLayer::setTexturePriorities(const PriorityCalculator& calculator) |
112 { | 112 { |
113 // Ensure there is always a target render surface available. If none has bee
n | 113 // Ensure there is always a target render surface available. If none has bee
n |
114 // set (the layer is an orphan for the test), then just set a surface on its
elf. | 114 // set (the layer is an orphan for the test), then just set a surface on its
elf. |
115 bool missingTargetRenderSurface = !renderTarget(); | 115 bool missingTargetRenderSurface = !renderTarget(); |
116 | 116 |
117 if (missingTargetRenderSurface) | 117 if (missingTargetRenderSurface) |
118 createRenderSurface(); | 118 createRenderSurface(); |
119 | 119 |
120 TiledLayerChromium::setTexturePriorities(calculator); | 120 TiledLayer::setTexturePriorities(calculator); |
121 | 121 |
122 if (missingTargetRenderSurface) { | 122 if (missingTargetRenderSurface) { |
123 clearRenderSurface(); | 123 clearRenderSurface(); |
124 setRenderTarget(0); | 124 setRenderTarget(0); |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 cc::CCPrioritizedTextureManager* FakeTiledLayerChromium::textureManager() const | 128 cc::PrioritizedTextureManager* FakeTiledLayer::textureManager() const |
129 { | 129 { |
130 return m_textureManager; | 130 return m_textureManager; |
131 } | 131 } |
132 | 132 |
133 cc::LayerTextureUpdater* FakeTiledLayerChromium::textureUpdater() const | 133 cc::LayerTextureUpdater* FakeTiledLayer::textureUpdater() const |
134 { | 134 { |
135 return m_fakeTextureUpdater.get(); | 135 return m_fakeTextureUpdater.get(); |
136 } | 136 } |
137 | 137 |
138 cc::IntSize FakeTiledLayerWithScaledBounds::contentBounds() const | 138 cc::IntSize FakeTiledLayerWithScaledBounds::contentBounds() const |
139 { | 139 { |
140 return m_forcedContentBounds; | 140 return m_forcedContentBounds; |
141 } | 141 } |
142 | 142 |
143 size_t FakeTextureUploader::numBlockingUploads() | 143 size_t FakeTextureUploader::numBlockingUploads() |
144 { | 144 { |
145 return 0; | 145 return 0; |
146 } | 146 } |
147 | 147 |
148 void FakeTextureUploader::markPendingUploadsAsNonBlocking() | 148 void FakeTextureUploader::markPendingUploadsAsNonBlocking() |
149 { | 149 { |
150 } | 150 } |
151 | 151 |
152 void FakeTextureUploader::uploadTexture(cc::CCResourceProvider* resourceProvider
, Parameters upload) | 152 void FakeTextureUploader::uploadTexture(cc::ResourceProvider* resourceProvider,
Parameters upload) |
153 { | 153 { |
154 upload.texture->acquireBackingTexture(resourceProvider); | 154 upload.texture->acquireBackingTexture(resourceProvider); |
155 } | 155 } |
156 | 156 |
157 double FakeTextureUploader::estimatedTexturesPerSecond() | 157 double FakeTextureUploader::estimatedTexturesPerSecond() |
158 { | 158 { |
159 return std::numeric_limits<double>::max(); | 159 return std::numeric_limits<double>::max(); |
160 } | 160 } |
161 | 161 |
162 } // namespace | 162 } // namespace |
OLD | NEW |