OLD | NEW |
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/render_pass.h" | 5 #include "cc/render_pass.h" |
6 | 6 |
7 #include "cc/checkerboard_draw_quad.h" | 7 #include "cc/checkerboard_draw_quad.h" |
8 #include "cc/test/geometry_test_utils.h" | 8 #include "cc/test/geometry_test_utils.h" |
9 #include "cc/test/render_pass_test_common.h" | 9 #include "cc/test/render_pass_test_common.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 WebKit::WebFilterOperations m_filters; | 33 WebKit::WebFilterOperations m_filters; |
34 WebKit::WebFilterOperations m_backgroundFilters; | 34 WebKit::WebFilterOperations m_backgroundFilters; |
35 SkImageFilter* m_filter; | 35 SkImageFilter* m_filter; |
36 }; | 36 }; |
37 | 37 |
38 TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads) | 38 TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads) |
39 { | 39 { |
40 RenderPass::Id id(3, 2); | 40 RenderPass::Id id(3, 2); |
41 gfx::Rect outputRect(45, 22, 120, 13); | 41 gfx::Rect outputRect(45, 22, 120, 13); |
42 WebTransformationMatrix transformToRoot(1, 0.5, 0.5, -0.5, -1, 0); | 42 WebTransformationMatrix transformToRoot(1, 0.5, 0.5, -0.5, -1, 0); |
43 | |
44 scoped_ptr<TestRenderPass> pass = TestRenderPass::create(id, outputRect, tra
nsformToRoot); | |
45 | |
46 gfx::Rect damageRect(56, 123, 19, 43); | 43 gfx::Rect damageRect(56, 123, 19, 43); |
47 bool hasTransparentBackground = true; | 44 bool hasTransparentBackground = true; |
48 bool hasOcclusionFromOutsideTargetSurface = true; | 45 bool hasOcclusionFromOutsideTargetSurface = true; |
49 WebFilterOperations filters; | 46 WebFilterOperations filters; |
50 WebFilterOperations backgroundFilters; | 47 WebFilterOperations backgroundFilters; |
51 | 48 |
52 filters.append(WebFilterOperation::createGrayscaleFilter(0.2f)); | 49 filters.append(WebFilterOperation::createGrayscaleFilter(0.2f)); |
53 backgroundFilters.append(WebFilterOperation::createInvertFilter(0.2f)); | 50 backgroundFilters.append(WebFilterOperation::createInvertFilter(0.2f)); |
54 SkAutoTUnref<SkBlurImageFilter> filter(new SkBlurImageFilter(SK_Scalar1, SK_
Scalar1)); | 51 SkAutoTUnref<SkBlurImageFilter> filter(new SkBlurImageFilter(SK_Scalar1, SK_
Scalar1)); |
55 | 52 |
56 pass->setDamageRect(damageRect); | 53 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
57 pass->setHasTransparentBackground(hasTransparentBackground); | 54 pass->SetAll(id, |
58 pass->setHasOcclusionFromOutsideTargetSurface(hasOcclusionFromOutsideTargetS
urface); | 55 outputRect, |
59 pass->setFilters(filters); | 56 damageRect, |
60 pass->setBackgroundFilters(backgroundFilters); | 57 transformToRoot, |
61 pass->setFilter(filter); | 58 hasTransparentBackground, |
| 59 hasOcclusionFromOutsideTargetSurface, |
| 60 filters, |
| 61 filter, |
| 62 backgroundFilters); |
62 | 63 |
63 // Stick a quad in the pass, this should not get copied. | 64 // Stick a quad in the pass, this should not get copied. |
64 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); | 65 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); |
65 sharedState->SetAll(WebTransformationMatrix(), gfx::Rect(), gfx::Rect(), 1); | 66 sharedState->SetAll(WebTransformationMatrix(), gfx::Rect(), gfx::Rect(), 1); |
66 pass->sharedQuadStateList().append(sharedState.Pass()); | 67 pass->AppendSharedQuadState(sharedState.Pass()); |
67 | 68 |
68 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = CheckerboardDrawQuad::Cr
eate(); | 69 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = CheckerboardDrawQuad::Cr
eate(); |
69 checkerboardQuad->SetNew(pass->sharedQuadStateList().last(), gfx::Rect(), Sk
Color()); | 70 checkerboardQuad->SetNew(pass->shared_quad_state_list.last(), gfx::Rect(), S
kColor()); |
70 pass->quadList().append(checkerboardQuad.PassAs<DrawQuad>()); | 71 pass->quad_list.append(checkerboardQuad.PassAs<DrawQuad>()); |
71 | 72 |
72 RenderPass::Id newId(63, 4); | 73 RenderPass::Id newId(63, 4); |
73 | 74 |
74 scoped_ptr<RenderPass> copy = pass->copy(newId); | 75 scoped_ptr<RenderPass> copy = pass->Copy(newId); |
75 EXPECT_EQ(newId, copy->id()); | 76 EXPECT_EQ(newId, copy->id); |
76 EXPECT_RECT_EQ(pass->outputRect(), copy->outputRect()); | 77 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect); |
77 EXPECT_EQ(pass->transformToRootTarget(), copy->transformToRootTarget()); | 78 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); |
78 EXPECT_RECT_EQ(pass->damageRect(), copy->damageRect()); | 79 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect); |
79 EXPECT_EQ(pass->hasTransparentBackground(), copy->hasTransparentBackground()
); | 80 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background
); |
80 EXPECT_EQ(pass->hasOcclusionFromOutsideTargetSurface(), copy->hasOcclusionFr
omOutsideTargetSurface()); | 81 EXPECT_EQ(pass->has_occlusion_from_outside_target_surface, copy->has_occlusi
on_from_outside_target_surface); |
81 EXPECT_EQ(pass->filters(), copy->filters()); | 82 EXPECT_EQ(pass->filters, copy->filters); |
82 EXPECT_EQ(pass->backgroundFilters(), copy->backgroundFilters()); | 83 EXPECT_EQ(pass->filter, copy->filter); |
83 EXPECT_EQ(pass->filter(), copy->filter()); | 84 EXPECT_EQ(pass->background_filters, copy->background_filters); |
84 EXPECT_EQ(0u, copy->quadList().size()); | 85 EXPECT_EQ(0u, copy->quad_list.size()); |
85 | 86 |
86 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); | 87 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); |
87 } | 88 } |
88 | 89 |
89 } // namespace | 90 } // namespace |
90 } // namespace cc | 91 } // namespace cc |
OLD | NEW |