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 "cc/layers/texture_layer.h" | 5 #include "cc/layers/texture_layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); | 229 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); |
230 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true)); | 230 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true)); |
231 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( | 231 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( |
232 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); | 232 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); |
233 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( | 233 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( |
234 0.5f, 0.5f, 0.5f, 0.5f)); | 234 0.5f, 0.5f, 0.5f, 0.5f)); |
235 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); | 235 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); |
236 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); | 236 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); |
237 } | 237 } |
238 | 238 |
239 TEST_F(TextureLayerTest, RateLimiter) { | |
240 FakeTextureLayerClient client; | |
241 scoped_refptr<TextureLayer> test_layer = | |
242 TextureLayer::CreateForMailbox(layer_settings_, &client); | |
243 test_layer->SetIsDrawable(true); | |
244 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | |
245 layer_tree_host_->SetRootLayer(test_layer); | |
246 | |
247 // Don't rate limit until we invalidate. | |
248 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); | |
249 test_layer->SetRateLimitContext(true); | |
250 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | |
251 | |
252 // Do rate limit after we invalidate. | |
253 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); | |
254 test_layer->SetNeedsDisplay(); | |
255 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | |
256 | |
257 // Stop rate limiter when we don't want it any more. | |
258 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); | |
259 test_layer->SetRateLimitContext(false); | |
260 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | |
261 | |
262 // Or we clear the client. | |
263 test_layer->SetRateLimitContext(true); | |
264 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); | |
265 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | |
266 test_layer->ClearClient(); | |
267 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | |
268 | |
269 // Reset to a layer with a client, that started the rate limiter. | |
270 test_layer = TextureLayer::CreateForMailbox(layer_settings_, &client); | |
271 test_layer->SetIsDrawable(true); | |
272 test_layer->SetRateLimitContext(true); | |
273 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | |
274 layer_tree_host_->SetRootLayer(test_layer); | |
275 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); | |
276 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | |
277 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); | |
278 test_layer->SetNeedsDisplay(); | |
279 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | |
280 | |
281 // Stop rate limiter when we're removed from the tree. | |
282 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); | |
283 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | |
284 layer_tree_host_->SetRootLayer(nullptr); | |
285 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | |
286 } | |
287 | |
288 class TestMailboxHolder : public TextureLayer::TextureMailboxHolder { | 239 class TestMailboxHolder : public TextureLayer::TextureMailboxHolder { |
289 public: | 240 public: |
290 using TextureLayer::TextureMailboxHolder::Create; | 241 using TextureLayer::TextureMailboxHolder::Create; |
291 | 242 |
292 protected: | 243 protected: |
293 ~TestMailboxHolder() override {} | 244 ~TestMailboxHolder() override {} |
294 }; | 245 }; |
295 | 246 |
296 class TextureLayerWithMailboxTest : public TextureLayerTest { | 247 class TextureLayerWithMailboxTest : public TextureLayerTest { |
297 protected: | 248 protected: |
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 int callback_count_; | 1456 int callback_count_; |
1506 scoped_refptr<Layer> root_; | 1457 scoped_refptr<Layer> root_; |
1507 scoped_refptr<TextureLayer> layer_; | 1458 scoped_refptr<TextureLayer> layer_; |
1508 }; | 1459 }; |
1509 | 1460 |
1510 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1461 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1511 TextureLayerWithMailboxImplThreadDeleted); | 1462 TextureLayerWithMailboxImplThreadDeleted); |
1512 | 1463 |
1513 } // namespace | 1464 } // namespace |
1514 } // namespace cc | 1465 } // namespace cc |
OLD | NEW |