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

Side by Side Diff: cc/test/layer_test_common.h

Issue 201153021: cc: Apply occlusion before creating quads in TextureLayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: append-texture: year Created 6 years, 9 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_impl_unittest.cc ('k') | cc/test/layer_test_common.cc » ('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 #ifndef CC_TEST_LAYER_TEST_COMMON_H_ 5 #ifndef CC_TEST_LAYER_TEST_COMMON_H_
6 #define CC_TEST_LAYER_TEST_COMMON_H_ 6 #define CC_TEST_LAYER_TEST_COMMON_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "cc/test/fake_layer_tree_host.h" 10 #include "cc/test/fake_layer_tree_host.h"
11 #include "cc/test/mock_quad_culler.h"
11 #include "cc/trees/layer_tree_host_impl.h" 12 #include "cc/trees/layer_tree_host_impl.h"
12 13
13 #define EXPECT_SET_NEEDS_COMMIT(expect, code_to_test) \ 14 #define EXPECT_SET_NEEDS_COMMIT(expect, code_to_test) \
14 do { \ 15 do { \
15 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times((expect)); \ 16 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times((expect)); \
16 code_to_test; \ 17 code_to_test; \
17 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ 18 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \
18 } while (false) 19 } while (false)
19 20
20 #define EXPECT_SET_NEEDS_UPDATE(expect, code_to_test) \ 21 #define EXPECT_SET_NEEDS_UPDATE(expect, code_to_test) \
21 do { \ 22 do { \
22 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times((expect)); \ 23 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times((expect)); \
23 code_to_test; \ 24 code_to_test; \
24 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ 25 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \
25 } while (false) 26 } while (false)
26 27
27 namespace gfx { class Rect; } 28 namespace gfx { class Rect; }
28 29
29 namespace cc { 30 namespace cc {
31 class OutputSurface;
30 class QuadList; 32 class QuadList;
33 class ResourceProvider;
31 34
32 class LayerTestCommon { 35 class LayerTestCommon {
33 public: 36 public:
34 static const char* quad_string; 37 static const char* quad_string;
35 38
36 static void VerifyQuadsExactlyCoverRect(const QuadList& quads, 39 static void VerifyQuadsExactlyCoverRect(const QuadList& quads,
37 const gfx::Rect& rect); 40 const gfx::Rect& rect);
38 41
39 static void VerifyQuadsCoverRectWithOcclusion( 42 static void VerifyQuadsCoverRectWithOcclusion(
40 const QuadList& quads, 43 const QuadList& quads,
41 const gfx::Rect& rect, 44 const gfx::Rect& rect,
42 const gfx::Rect& occluded, 45 const gfx::Rect& occluded,
43 size_t* partially_occluded_count); 46 size_t* partially_occluded_count);
44 47
45 class LayerImplTest { 48 class LayerImplTest {
46 public: 49 public:
47 LayerImplTest(); 50 LayerImplTest();
48 ~LayerImplTest(); 51 ~LayerImplTest();
49 52
50 template <typename T> 53 template <typename T>
51 T* AddChildToRoot() { 54 T* AddChildToRoot() {
52 scoped_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), 2); 55 scoped_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), 2);
53 T* ptr = layer.get(); 56 T* ptr = layer.get();
54 root_layer_impl_->AddChild(layer.template PassAs<LayerImpl>()); 57 root_layer_impl_->AddChild(layer.template PassAs<LayerImpl>());
55 return ptr; 58 return ptr;
56 } 59 }
57 60
58 void CalcDrawProps(const gfx::Size& viewport_size) { 61 template <typename T, typename A>
59 LayerImplList layer_list; 62 T* AddChildToRoot(A a) {
60 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 63 scoped_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), 2, a);
61 root_layer_impl_.get(), viewport_size, &layer_list); 64 T* ptr = layer.get();
62 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 65 root_layer_impl_->AddChild(layer.template PassAs<LayerImpl>());
66 return ptr;
63 } 67 }
64 68
69 void CalcDrawProps(const gfx::Size& viewport_size);
70 void AppendQuadsWithOcclusion(LayerImpl* layer_impl,
71 const gfx::Rect& occluded);
72
73 OutputSurface* output_surface() const {
74 return host_->host_impl()->output_surface();
75 }
76 ResourceProvider* resource_provider() const {
77 return host_->host_impl()->resource_provider();
78 }
79 const QuadList& quad_list() const { return quad_culler_.quad_list(); }
80
65 private: 81 private:
66 scoped_ptr<FakeLayerTreeHost> host_; 82 scoped_ptr<FakeLayerTreeHost> host_;
67 scoped_ptr<LayerImpl> root_layer_impl_; 83 scoped_ptr<LayerImpl> root_layer_impl_;
84 MockQuadCuller quad_culler_;
68 }; 85 };
69 }; 86 };
70 87
71 } // namespace cc 88 } // namespace cc
72 89
73 #endif // CC_TEST_LAYER_TEST_COMMON_H_ 90 #endif // CC_TEST_LAYER_TEST_COMMON_H_
OLDNEW
« no previous file with comments | « cc/layers/texture_layer_impl_unittest.cc ('k') | cc/test/layer_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698