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

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

Issue 13910011: Add optimization to TextureLayer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved define to layer_test_common.h Created 7 years, 8 months 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/test/layer_test_common.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 <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "cc/base/thread.h" 10 #include "cc/base/thread.h"
11 #include "cc/layers/texture_layer_client.h" 11 #include "cc/layers/texture_layer_client.h"
12 #include "cc/layers/texture_layer_impl.h" 12 #include "cc/layers/texture_layer_impl.h"
13 #include "cc/test/fake_impl_proxy.h" 13 #include "cc/test/fake_impl_proxy.h"
14 #include "cc/test/fake_layer_tree_host_client.h" 14 #include "cc/test/fake_layer_tree_host_client.h"
15 #include "cc/test/fake_layer_tree_host_impl.h" 15 #include "cc/test/fake_layer_tree_host_impl.h"
16 #include "cc/test/layer_test_common.h"
16 #include "cc/test/layer_tree_test.h" 17 #include "cc/test/layer_tree_test.h"
17 #include "cc/trees/layer_tree_host.h" 18 #include "cc/trees/layer_tree_host.h"
18 #include "cc/trees/layer_tree_impl.h" 19 #include "cc/trees/layer_tree_impl.h"
19 #include "cc/trees/single_thread_proxy.h" 20 #include "cc/trees/single_thread_proxy.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 using ::testing::Mock; 24 using ::testing::Mock;
24 using ::testing::_; 25 using ::testing::_;
25 using ::testing::AtLeast; 26 using ::testing::AtLeast;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 175 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
175 test_layer->SetTextureId(1); 176 test_layer->SetTextureId(1);
176 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 177 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
177 178
178 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AtLeast(1)); 179 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AtLeast(1));
179 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 180 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
180 test_layer->RemoveFromParent(); 181 test_layer->RemoveFromParent();
181 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 182 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
182 } 183 }
183 184
185 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) {
186 scoped_refptr<TextureLayer> test_layer = TextureLayer::Create(NULL);
187 test_layer->SetLayerTreeHost(layer_tree_host_.get());
188
189 // Test properties that should call SetNeedsCommit. All properties need to
190 // be set to new values in order for SetNeedsCommit to be called.
191 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false));
192 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV(
193 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f)));
194 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity(
195 0.5f, 0.5f, 0.5f, 0.5f));
196 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false));
197 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTextureId(1));
198
199 // Calling SetTextureId can call AcquireLayerTextures.
200 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AnyNumber());
201 }
202
184 class MockMailboxCallback { 203 class MockMailboxCallback {
185 public: 204 public:
186 MOCK_METHOD3(Release, void(const std::string& mailbox, 205 MOCK_METHOD3(Release, void(const std::string& mailbox,
187 unsigned sync_point, 206 unsigned sync_point,
188 bool lost_resource)); 207 bool lost_resource));
189 }; 208 };
190 209
191 struct CommonMailboxObjects { 210 struct CommonMailboxObjects {
192 CommonMailboxObjects() 211 CommonMailboxObjects()
193 : mailbox_name1_(64, '1'), 212 : mailbox_name1_(64, '1'),
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 620
602 // Used on either thread, protected by lock_. 621 // Used on either thread, protected by lock_.
603 base::Lock lock_; 622 base::Lock lock_;
604 unsigned expected_used_textures_on_commit_; 623 unsigned expected_used_textures_on_commit_;
605 }; 624 };
606 625
607 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerClientTest); 626 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerClientTest);
608 627
609 } // namespace 628 } // namespace
610 } // namespace cc 629 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer.cc ('k') | cc/test/layer_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698