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

Side by Side Diff: cc/trees/occlusion_tracker_unittest.cc

Issue 93663004: [#2] Pass gfx structs by const ref (gfx::Rect, gfx::RectF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT, fix builds on non-linux platforms! Created 6 years, 11 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
« no previous file with comments | « cc/trees/occlusion_tracker.cc ('k') | cc/trees/proxy.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/trees/occlusion_tracker.h" 5 #include "cc/trees/occlusion_tracker.h"
6 6
7 #include "cc/animation/layer_animation_controller.h" 7 #include "cc/animation/layer_animation_controller.h"
8 #include "cc/base/math_util.h" 8 #include "cc/base/math_util.h"
9 #include "cc/debug/overdraw_metrics.h" 9 #include "cc/debug/overdraw_metrics.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 21 matching lines...) Expand all
32 public: 32 public:
33 TestContentLayer() : Layer(), override_opaque_contents_rect_(false) { 33 TestContentLayer() : Layer(), override_opaque_contents_rect_(false) {
34 SetIsDrawable(true); 34 SetIsDrawable(true);
35 } 35 }
36 36
37 virtual Region VisibleContentOpaqueRegion() const OVERRIDE { 37 virtual Region VisibleContentOpaqueRegion() const OVERRIDE {
38 if (override_opaque_contents_rect_) 38 if (override_opaque_contents_rect_)
39 return gfx::IntersectRects(opaque_contents_rect_, visible_content_rect()); 39 return gfx::IntersectRects(opaque_contents_rect_, visible_content_rect());
40 return Layer::VisibleContentOpaqueRegion(); 40 return Layer::VisibleContentOpaqueRegion();
41 } 41 }
42 void SetOpaqueContentsRect(gfx::Rect opaque_contents_rect) { 42 void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) {
43 override_opaque_contents_rect_ = true; 43 override_opaque_contents_rect_ = true;
44 opaque_contents_rect_ = opaque_contents_rect; 44 opaque_contents_rect_ = opaque_contents_rect;
45 } 45 }
46 46
47 private: 47 private:
48 virtual ~TestContentLayer() {} 48 virtual ~TestContentLayer() {}
49 49
50 bool override_opaque_contents_rect_; 50 bool override_opaque_contents_rect_;
51 gfx::Rect opaque_contents_rect_; 51 gfx::Rect opaque_contents_rect_;
52 }; 52 };
53 53
54 class TestContentLayerImpl : public LayerImpl { 54 class TestContentLayerImpl : public LayerImpl {
55 public: 55 public:
56 TestContentLayerImpl(LayerTreeImpl* tree_impl, int id) 56 TestContentLayerImpl(LayerTreeImpl* tree_impl, int id)
57 : LayerImpl(tree_impl, id), override_opaque_contents_rect_(false) { 57 : LayerImpl(tree_impl, id), override_opaque_contents_rect_(false) {
58 SetDrawsContent(true); 58 SetDrawsContent(true);
59 } 59 }
60 60
61 virtual Region VisibleContentOpaqueRegion() const OVERRIDE { 61 virtual Region VisibleContentOpaqueRegion() const OVERRIDE {
62 if (override_opaque_contents_rect_) 62 if (override_opaque_contents_rect_)
63 return gfx::IntersectRects(opaque_contents_rect_, visible_content_rect()); 63 return gfx::IntersectRects(opaque_contents_rect_, visible_content_rect());
64 return LayerImpl::VisibleContentOpaqueRegion(); 64 return LayerImpl::VisibleContentOpaqueRegion();
65 } 65 }
66 void SetOpaqueContentsRect(gfx::Rect opaque_contents_rect) { 66 void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) {
67 override_opaque_contents_rect_ = true; 67 override_opaque_contents_rect_ = true;
68 opaque_contents_rect_ = opaque_contents_rect; 68 opaque_contents_rect_ = opaque_contents_rect;
69 } 69 }
70 70
71 private: 71 private:
72 bool override_opaque_contents_rect_; 72 bool override_opaque_contents_rect_;
73 gfx::Rect opaque_contents_rect_; 73 gfx::Rect opaque_contents_rect_;
74 }; 74 };
75 75
76 static inline bool LayerImplDrawTransformIsUnknown(const Layer* layer) { 76 static inline bool LayerImplDrawTransformIsUnknown(const Layer* layer) {
77 return layer->draw_transform_is_animating(); 77 return layer->draw_transform_is_animating();
78 } 78 }
79 static inline bool LayerImplDrawTransformIsUnknown(const LayerImpl* layer) { 79 static inline bool LayerImplDrawTransformIsUnknown(const LayerImpl* layer) {
80 return false; 80 return false;
81 } 81 }
82 82
83 template <typename LayerType, typename RenderSurfaceType> 83 template <typename LayerType, typename RenderSurfaceType>
84 class TestOcclusionTrackerWithClip 84 class TestOcclusionTrackerWithClip
85 : public TestOcclusionTrackerBase<LayerType, RenderSurfaceType> { 85 : public TestOcclusionTrackerBase<LayerType, RenderSurfaceType> {
86 public: 86 public:
87 TestOcclusionTrackerWithClip(gfx::Rect viewport_rect, 87 TestOcclusionTrackerWithClip(const gfx::Rect& viewport_rect,
88 bool record_metrics_for_frame) 88 bool record_metrics_for_frame)
89 : TestOcclusionTrackerBase<LayerType, RenderSurfaceType>( 89 : TestOcclusionTrackerBase<LayerType, RenderSurfaceType>(
90 viewport_rect, 90 viewport_rect,
91 record_metrics_for_frame) {} 91 record_metrics_for_frame) {}
92 explicit TestOcclusionTrackerWithClip(gfx::Rect viewport_rect) 92 explicit TestOcclusionTrackerWithClip(const gfx::Rect& viewport_rect)
93 : TestOcclusionTrackerBase<LayerType, RenderSurfaceType>(viewport_rect, 93 : TestOcclusionTrackerBase<LayerType, RenderSurfaceType>(viewport_rect,
94 false) {} 94 false) {}
95 95
96 bool OccludedLayer(const LayerType* layer, 96 bool OccludedLayer(const LayerType* layer,
97 gfx::Rect content_rect) const { 97 const gfx::Rect& content_rect) const {
98 DCHECK(layer->visible_content_rect().Contains(content_rect)); 98 DCHECK(layer->visible_content_rect().Contains(content_rect));
99 return this->Occluded(layer->render_target(), 99 return this->Occluded(layer->render_target(),
100 content_rect, 100 content_rect,
101 layer->draw_transform(), 101 layer->draw_transform(),
102 LayerImplDrawTransformIsUnknown(layer)); 102 LayerImplDrawTransformIsUnknown(layer));
103 } 103 }
104 104
105 // Gives an unoccluded sub-rect of |content_rect| in the content space of the 105 // Gives an unoccluded sub-rect of |content_rect| in the content space of the
106 // layer. Simple wrapper around UnoccludedContentRect. 106 // layer. Simple wrapper around UnoccludedContentRect.
107 gfx::Rect UnoccludedLayerContentRect(const LayerType* layer, 107 gfx::Rect UnoccludedLayerContentRect(const LayerType* layer,
108 gfx::Rect content_rect) const { 108 const gfx::Rect& content_rect) const {
109 DCHECK(layer->visible_content_rect().Contains(content_rect)); 109 DCHECK(layer->visible_content_rect().Contains(content_rect));
110 return this->UnoccludedContentRect( 110 return this->UnoccludedContentRect(
111 layer->render_target(), 111 layer->render_target(),
112 content_rect, 112 content_rect,
113 layer->draw_transform(), 113 layer->draw_transform(),
114 LayerImplDrawTransformIsUnknown(layer)); 114 LayerImplDrawTransformIsUnknown(layer));
115 } 115 }
116 }; 116 };
117 117
118 struct OcclusionTrackerTestMainThreadTypes { 118 struct OcclusionTrackerTestMainThreadTypes {
(...skipping 3694 matching lines...) Expand 10 before | Expand all | Expand 10 after
3813 occlusion.occlusion_from_outside_target().ToString()); 3813 occlusion.occlusion_from_outside_target().ToString());
3814 EXPECT_EQ(gfx::Rect().ToString(), 3814 EXPECT_EQ(gfx::Rect().ToString(),
3815 occlusion.occlusion_from_inside_target().ToString()); 3815 occlusion.occlusion_from_inside_target().ToString());
3816 } 3816 }
3817 }; 3817 };
3818 3818
3819 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestEmptyEventLayerDoesNotOcclude) 3819 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestEmptyEventLayerDoesNotOcclude)
3820 3820
3821 } // namespace 3821 } // namespace
3822 } // namespace cc 3822 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/occlusion_tracker.cc ('k') | cc/trees/proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698