Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MOCK_OCCLUSION_TRACKER_H_ | 5 #ifndef CC_TEST_MOCK_OCCLUSION_TRACKER_H_ |
| 6 #define CC_TEST_MOCK_OCCLUSION_TRACKER_H_ | 6 #define CC_TEST_MOCK_OCCLUSION_TRACKER_H_ |
| 7 | 7 |
| 8 #include "cc/trees/occlusion_tracker.h" | 8 #include "cc/trees/occlusion_tracker.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| 11 | 11 |
| 12 template <typename LayerType> | 12 template <typename LayerType> |
| 13 class MockOcclusionTracker : public OcclusionTracker<LayerType> { | 13 class CC_EXPORT MockOcclusionTracker : public OcclusionTracker<LayerType> { |
| 14 // This class is used for testing only. It fakes just enough information to | 14 // This class is used for testing only. It fakes just enough information to |
| 15 // calculate unoccluded content rect and unoccluded contributing surface | 15 // calculate unoccluded content rect and unoccluded contributing surface |
| 16 // content rect. It calls the helper function of occlusion tracker to avoid | 16 // content rect. It calls the helper function of occlusion tracker to avoid |
| 17 // DCHECKs since testing environment won't be set up properly to pass those. | 17 // DCHECKs since testing environment won't be set up properly to pass those. |
| 18 public: | 18 public: |
| 19 MockOcclusionTracker() | 19 MockOcclusionTracker() |
| 20 : OcclusionTracker<LayerType>(gfx::Rect(0, 0, 1000, 1000)) { | 20 : OcclusionTracker<LayerType>(gfx::Rect(0, 0, 1000, 1000)) { |
| 21 typename OcclusionTracker<LayerType>::StackObject stack_obj; | 21 typename OcclusionTracker<LayerType>::StackObject stack_obj; |
| 22 OcclusionTracker<LayerType>::stack_.push_back(stack_obj); | 22 OcclusionTracker<LayerType>::stack_.push_back(stack_obj); |
| 23 OcclusionTracker<LayerType>::stack_.push_back(stack_obj); | 23 OcclusionTracker<LayerType>::stack_.push_back(stack_obj); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 35 occluded; | 35 occluded; |
| 36 } | 36 } |
| 37 | 37 |
| 38 void set_occluded_target_rect_for_contributing_surface( | 38 void set_occluded_target_rect_for_contributing_surface( |
| 39 const gfx::Rect& occluded) { | 39 const gfx::Rect& occluded) { |
| 40 OcclusionTracker< | 40 OcclusionTracker< |
| 41 LayerType>::stack_[OcclusionTracker<LayerType>::stack_.size() - 2] | 41 LayerType>::stack_[OcclusionTracker<LayerType>::stack_.size() - 2] |
| 42 .occlusion_from_inside_target = occluded; | 42 .occlusion_from_inside_target = occluded; |
| 43 } | 43 } |
| 44 | 44 |
| 45 gfx::Rect UnoccludedContentRect( | 45 virtual gfx::Rect UnoccludedContentRect( |
|
enne (OOO)
2014/05/30 21:37:43
style nit: don't inline virtuals
Also, isn't this
weiliangc
2014/05/30 21:46:07
In unittest the OcclusionTracker and LayerImpls ar
enne (OOO)
2014/05/30 22:11:10
Hmm, ok. I'm always saddened by virtual-for-testi
| |
| 46 const LayerType* render_target, | 46 const LayerType* render_target, |
| 47 const gfx::Rect& content_rect, | 47 const gfx::Rect& content_rect, |
| 48 const gfx::Transform& draw_transform) const OVERRIDE { | 48 const gfx::Transform& draw_transform) const OVERRIDE { |
| 49 return this->UnoccludedContentRectHelper( | 49 return this->UnoccludedContentRectHelper( |
|
enne (OOO)
2014/05/30 21:37:43
style nit: unnecessary this-> (here and elsewhere
weiliangc
2014/05/30 22:04:57
I think it is either this-> or OcclusionTracker<La
enne (OOO)
2014/05/30 22:05:58
Templates /o\
| |
| 50 render_target, content_rect, draw_transform); | 50 render_target, content_rect, draw_transform); |
| 51 } | 51 } |
| 52 | 52 |
| 53 gfx::Rect UnoccludedContributingSurfaceContentRect( | 53 virtual gfx::Rect UnoccludedContributingSurfaceContentRect( |
| 54 const LayerType* layer, | 54 const LayerType* layer, |
| 55 const gfx::Rect& content_rect, | 55 const gfx::Rect& content_rect, |
| 56 const gfx::Transform& draw_transform) const OVERRIDE { | 56 const gfx::Transform& draw_transform) const OVERRIDE { |
| 57 return this->UnoccludedContributingSurfaceContentRectHelper( | 57 return this->UnoccludedContributingSurfaceContentRectHelper( |
| 58 layer, content_rect, draw_transform); | 58 layer, content_rect, draw_transform); |
| 59 } | 59 } |
| 60 | |
| 61 private: | |
| 62 DISALLOW_COPY_AND_ASSIGN(MockOcclusionTracker); | |
| 60 }; | 63 }; |
| 61 | 64 |
| 62 } // namespace cc | 65 } // namespace cc |
| 63 | 66 |
| 64 #endif // CC_TEST_MOCK_OCCLUSION_TRACKER_H_ | 67 #endif // CC_TEST_MOCK_OCCLUSION_TRACKER_H_ |
| OLD | NEW |