diff options
Diffstat (limited to 'cc/test/mock_quad_culler.cc')
-rw-r--r-- | cc/test/mock_quad_culler.cc | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/cc/test/mock_quad_culler.cc b/cc/test/mock_quad_culler.cc index ddb5913..71f1eb8 100644 --- a/cc/test/mock_quad_culler.cc +++ b/cc/test/mock_quad_culler.cc @@ -5,6 +5,7 @@ #include "cc/test/mock_quad_culler.h" #include "cc/base/math_util.h" +#include "cc/layers/layer_impl.h" #include "cc/quads/draw_quad.h" namespace cc { @@ -12,10 +13,30 @@ namespace cc { MockQuadCuller::MockQuadCuller() { render_pass_storage_ = RenderPass::Create(); active_render_pass_ = render_pass_storage_.get(); + occlusion_tracker_storage_ = make_scoped_ptr( + new MockOcclusionTracker<LayerImpl>(gfx::Rect(0, 0, 1000, 1000))); + occlusion_tracker_ = occlusion_tracker_storage_.get(); } MockQuadCuller::MockQuadCuller(RenderPass* external_render_pass) : active_render_pass_(external_render_pass) { + occlusion_tracker_storage_ = make_scoped_ptr( + new MockOcclusionTracker<LayerImpl>(gfx::Rect(0, 0, 1000, 1000))); + occlusion_tracker_ = occlusion_tracker_storage_.get(); +} + +MockQuadCuller::MockQuadCuller( + MockOcclusionTracker<LayerImpl>* occlusion_tracker) + : occlusion_tracker_(occlusion_tracker) { + render_pass_storage_ = RenderPass::Create(); + active_render_pass_ = render_pass_storage_.get(); +} + +MockQuadCuller::MockQuadCuller( + RenderPass* external_render_pass, + MockOcclusionTracker<LayerImpl>* occlusion_tracker) + : active_render_pass_(external_render_pass), + occlusion_tracker_(occlusion_tracker) { } MockQuadCuller::~MockQuadCuller() {} @@ -27,33 +48,15 @@ SharedQuadState* MockQuadCuller::CreateSharedQuadState() { gfx::Rect MockQuadCuller::UnoccludedContentRect( const gfx::Rect& content_rect, const gfx::Transform& draw_transform) { - DCHECK(draw_transform.IsIdentityOrIntegerTranslation() || - occluded_target_rect_.IsEmpty()); - gfx::Rect target_rect = - MathUtil::MapEnclosingClippedRect(draw_transform, content_rect); - target_rect.Subtract(occluded_target_rect_); - gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); - if (!draw_transform.GetInverse(&inverse_draw_transform)) - NOTREACHED(); - gfx::Rect result = MathUtil::ProjectEnclosingClippedRect( - inverse_draw_transform, target_rect); - return result; + return occlusion_tracker_->UnoccludedContentRect(content_rect, + draw_transform); } gfx::Rect MockQuadCuller::UnoccludedContributingSurfaceContentRect( const gfx::Rect& content_rect, const gfx::Transform& draw_transform) { - DCHECK(draw_transform.IsIdentityOrIntegerTranslation() || - occluded_target_rect_for_contributing_surface_.IsEmpty()); - gfx::Rect target_rect = - MathUtil::MapEnclosingClippedRect(draw_transform, content_rect); - target_rect.Subtract(occluded_target_rect_for_contributing_surface_); - gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); - if (!draw_transform.GetInverse(&inverse_draw_transform)) - NOTREACHED(); - gfx::Rect result = MathUtil::ProjectEnclosingClippedRect( - inverse_draw_transform, target_rect); - return result; + return occlusion_tracker_->UnoccludedContributingSurfaceContentRect( + content_rect, draw_transform); } void MockQuadCuller::Append(scoped_ptr<DrawQuad> draw_quad) { |