Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: cc/layers/texture_layer_unittest.cc

Issue 53153006: Simplify rate limiting since it's main thread shared context only (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/texture_layer.cc ('k') | cc/scheduler/rate_limiter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class MockLayerTreeHost : public LayerTreeHost { 44 class MockLayerTreeHost : public LayerTreeHost {
45 public: 45 public:
46 explicit MockLayerTreeHost(LayerTreeHostClient* client) 46 explicit MockLayerTreeHost(LayerTreeHostClient* client)
47 : LayerTreeHost(client, NULL, LayerTreeSettings()) { 47 : LayerTreeHost(client, NULL, LayerTreeSettings()) {
48 Initialize(NULL); 48 Initialize(NULL);
49 } 49 }
50 50
51 MOCK_METHOD0(AcquireLayerTextures, void()); 51 MOCK_METHOD0(AcquireLayerTextures, void());
52 MOCK_METHOD0(SetNeedsCommit, void()); 52 MOCK_METHOD0(SetNeedsCommit, void());
53 MOCK_METHOD0(SetNeedsUpdateLayers, void()); 53 MOCK_METHOD0(SetNeedsUpdateLayers, void());
54 MOCK_METHOD1(StartRateLimiter, void(WebKit::WebGraphicsContext3D* context)); 54 MOCK_METHOD0(StartRateLimiter, void());
55 MOCK_METHOD1(StopRateLimiter, void(WebKit::WebGraphicsContext3D* context)); 55 MOCK_METHOD0(StopRateLimiter, void());
56 }; 56 };
57 57
58 class TextureLayerTest : public testing::Test { 58 class TextureLayerTest : public testing::Test {
59 public: 59 public:
60 TextureLayerTest() 60 TextureLayerTest()
61 : fake_client_( 61 : fake_client_(
62 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)), 62 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)),
63 host_impl_(&proxy_) {} 63 host_impl_(&proxy_) {}
64 64
65 protected: 65 protected:
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 271
272 TEST_F(TextureLayerTest, RateLimiter) { 272 TEST_F(TextureLayerTest, RateLimiter) {
273 FakeTextureLayerClient client; 273 FakeTextureLayerClient client;
274 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox( 274 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(
275 &client); 275 &client);
276 test_layer->SetIsDrawable(true); 276 test_layer->SetIsDrawable(true);
277 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 277 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
278 layer_tree_host_->SetRootLayer(test_layer); 278 layer_tree_host_->SetRootLayer(test_layer);
279 279
280 // Don't rate limit until we invalidate. 280 // Don't rate limit until we invalidate.
281 EXPECT_CALL(*layer_tree_host_, StartRateLimiter(_)).Times(0); 281 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0);
282 test_layer->SetRateLimitContext(true); 282 test_layer->SetRateLimitContext(true);
283 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 283 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
284 284
285 // Do rate limit after we invalidate. 285 // Do rate limit after we invalidate.
286 EXPECT_CALL(*layer_tree_host_, StartRateLimiter(client.Context3d())); 286 EXPECT_CALL(*layer_tree_host_, StartRateLimiter());
287 test_layer->SetNeedsDisplay(); 287 test_layer->SetNeedsDisplay();
288 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 288 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
289 289
290 // Stop rate limiter when we don't want it any more. 290 // Stop rate limiter when we don't want it any more.
291 EXPECT_CALL(*layer_tree_host_, StopRateLimiter(client.Context3d())); 291 EXPECT_CALL(*layer_tree_host_, StopRateLimiter());
292 test_layer->SetRateLimitContext(false); 292 test_layer->SetRateLimitContext(false);
293 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 293 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
294 294
295 // Or we clear the client. 295 // Or we clear the client.
296 test_layer->SetRateLimitContext(true); 296 test_layer->SetRateLimitContext(true);
297 EXPECT_CALL(*layer_tree_host_, StopRateLimiter(client.Context3d())); 297 EXPECT_CALL(*layer_tree_host_, StopRateLimiter());
298 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 298 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
299 test_layer->ClearClient(); 299 test_layer->ClearClient();
300 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 300 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
301 301
302 // Reset to a layer with a client, that started the rate limiter. 302 // Reset to a layer with a client, that started the rate limiter.
303 test_layer = TextureLayer::CreateForMailbox( 303 test_layer = TextureLayer::CreateForMailbox(
304 &client); 304 &client);
305 test_layer->SetIsDrawable(true); 305 test_layer->SetIsDrawable(true);
306 test_layer->SetRateLimitContext(true); 306 test_layer->SetRateLimitContext(true);
307 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 307 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
308 layer_tree_host_->SetRootLayer(test_layer); 308 layer_tree_host_->SetRootLayer(test_layer);
309 EXPECT_CALL(*layer_tree_host_, StartRateLimiter(_)).Times(0); 309 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0);
310 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 310 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
311 EXPECT_CALL(*layer_tree_host_, StartRateLimiter(client.Context3d())); 311 EXPECT_CALL(*layer_tree_host_, StartRateLimiter());
312 test_layer->SetNeedsDisplay(); 312 test_layer->SetNeedsDisplay();
313 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 313 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
314 314
315 // Stop rate limiter when we're removed from the tree. 315 // Stop rate limiter when we're removed from the tree.
316 EXPECT_CALL(*layer_tree_host_, StopRateLimiter(client.Context3d())); 316 EXPECT_CALL(*layer_tree_host_, StopRateLimiter());
317 layer_tree_host_->SetRootLayer(NULL); 317 layer_tree_host_->SetRootLayer(NULL);
318 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 318 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
319 } 319 }
320 320
321 class MockMailboxCallback { 321 class MockMailboxCallback {
322 public: 322 public:
323 MOCK_METHOD3(Release, void(const std::string& mailbox, 323 MOCK_METHOD3(Release, void(const std::string& mailbox,
324 unsigned sync_point, 324 unsigned sync_point,
325 bool lost_resource)); 325 bool lost_resource));
326 MOCK_METHOD3(Release2, void(base::SharedMemory* shared_memory, 326 MOCK_METHOD3(Release2, void(base::SharedMemory* shared_memory,
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 int callback_count_; 2182 int callback_count_;
2183 scoped_refptr<Layer> root_; 2183 scoped_refptr<Layer> root_;
2184 scoped_refptr<TextureLayer> layer_; 2184 scoped_refptr<TextureLayer> layer_;
2185 }; 2185 };
2186 2186
2187 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 2187 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
2188 TextureLayerWithMailboxImplThreadDeleted); 2188 TextureLayerWithMailboxImplThreadDeleted);
2189 2189
2190 } // namespace 2190 } // namespace
2191 } // namespace cc 2191 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer.cc ('k') | cc/scheduler/rate_limiter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698