Fix for ISpy relocation.
[chromium-blink-merge.git] / cc / test / mock_quad_culler.cc
blob781647d9381bbe426526dbf3e4066f61c65ea715
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
3 // found in the LICENSE file.
5 #include "cc/test/mock_quad_culler.h"
7 #include "cc/base/math_util.h"
8 #include "cc/quads/draw_quad.h"
10 namespace cc {
12 MockQuadCuller::MockQuadCuller()
13 : active_quad_list_(&quad_list_storage_),
14 active_shared_quad_state_list_(&shared_quad_state_storage_) {}
16 MockQuadCuller::MockQuadCuller(
17 QuadList* external_quad_list,
18 SharedQuadStateList* external_shared_quad_state_list)
19 : active_quad_list_(external_quad_list),
20 active_shared_quad_state_list_(external_shared_quad_state_list) {}
22 MockQuadCuller::~MockQuadCuller() {}
24 SharedQuadState* MockQuadCuller::UseSharedQuadState(
25 scoped_ptr<SharedQuadState> shared_quad_state) {
26 SharedQuadState* raw_ptr = shared_quad_state.get();
27 active_shared_quad_state_list_->push_back(shared_quad_state.Pass());
28 return raw_ptr;
31 gfx::Rect MockQuadCuller::UnoccludedContentRect(
32 const gfx::Rect& content_rect,
33 const gfx::Transform& draw_transform) {
34 DCHECK(draw_transform.IsIdentityOrIntegerTranslation() ||
35 occluded_target_rect_.IsEmpty());
36 gfx::Rect target_rect =
37 MathUtil::MapEnclosingClippedRect(draw_transform, content_rect);
38 target_rect.Subtract(occluded_target_rect_);
39 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization);
40 if (!draw_transform.GetInverse(&inverse_draw_transform))
41 NOTREACHED();
42 gfx::Rect result = MathUtil::ProjectEnclosingClippedRect(
43 inverse_draw_transform, target_rect);
44 return result;
47 gfx::Rect MockQuadCuller::UnoccludedContributingSurfaceContentRect(
48 const gfx::Rect& content_rect,
49 const gfx::Transform& draw_transform) {
50 DCHECK(draw_transform.IsIdentityOrIntegerTranslation() ||
51 occluded_target_rect_for_contributing_surface_.IsEmpty());
52 gfx::Rect target_rect =
53 MathUtil::MapEnclosingClippedRect(draw_transform, content_rect);
54 target_rect.Subtract(occluded_target_rect_for_contributing_surface_);
55 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization);
56 if (!draw_transform.GetInverse(&inverse_draw_transform))
57 NOTREACHED();
58 gfx::Rect result = MathUtil::ProjectEnclosingClippedRect(
59 inverse_draw_transform, target_rect);
60 return result;
63 bool MockQuadCuller::MaybeAppend(scoped_ptr<DrawQuad> draw_quad) {
64 if (!draw_quad->rect.IsEmpty()) {
65 active_quad_list_->push_back(draw_quad.Pass());
66 return true;
68 return false;
71 void MockQuadCuller::Append(scoped_ptr<DrawQuad> draw_quad) {
72 DCHECK(!draw_quad->rect.IsEmpty());
73 DCHECK(!draw_quad->visible_rect.IsEmpty());
74 active_quad_list_->push_back(draw_quad.Pass());
77 } // namespace cc