| 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 <public/WebFilterOperations.h> |
| 8 |
| 7 #include "cc/checkerboard_draw_quad.h" | 9 #include "cc/checkerboard_draw_quad.h" |
| 10 #include "cc/math_util.h" |
| 8 #include "cc/test/geometry_test_utils.h" | 11 #include "cc/test/geometry_test_utils.h" |
| 9 #include "cc/test/render_pass_test_common.h" | 12 #include "cc/test/render_pass_test_common.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 14 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 12 #include <public/WebFilterOperations.h> | 15 #include "ui/gfx/transform.h" |
| 13 #include <public/WebTransformationMatrix.h> | |
| 14 | 16 |
| 15 using WebKit::WebFilterOperation; | 17 using WebKit::WebFilterOperation; |
| 16 using WebKit::WebFilterOperations; | 18 using WebKit::WebFilterOperations; |
| 17 using WebKit::WebTransformationMatrix; | |
| 18 using WebKitTests::TestRenderPass; | 19 using WebKitTests::TestRenderPass; |
| 19 | 20 |
| 20 namespace cc { | 21 namespace cc { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 struct RenderPassSize { | 24 struct RenderPassSize { |
| 24 // If you add a new field to this class, make sure to add it to the copy() t
ests. | 25 // If you add a new field to this class, make sure to add it to the copy() t
ests. |
| 25 RenderPass::Id m_id; | 26 RenderPass::Id m_id; |
| 26 QuadList m_quadList; | 27 QuadList m_quadList; |
| 27 SharedQuadStateList m_sharedQuadStateList; | 28 SharedQuadStateList m_sharedQuadStateList; |
| 28 WebKit::WebTransformationMatrix m_transformToRootTarget; | 29 gfx::Transform m_transformToRootTarget; |
| 29 gfx::Rect m_outputRect; | 30 gfx::Rect m_outputRect; |
| 30 gfx::RectF m_damageRect; | 31 gfx::RectF m_damageRect; |
| 31 bool m_hasTransparentBackground; | 32 bool m_hasTransparentBackground; |
| 32 bool m_hasOcclusionFromOutsideTargetSurface; | 33 bool m_hasOcclusionFromOutsideTargetSurface; |
| 33 WebKit::WebFilterOperations m_filters; | 34 WebKit::WebFilterOperations m_filters; |
| 34 WebKit::WebFilterOperations m_backgroundFilters; | 35 WebKit::WebFilterOperations m_backgroundFilters; |
| 35 SkImageFilter* m_filter; | 36 SkImageFilter* m_filter; |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads) | 39 TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads) |
| 39 { | 40 { |
| 40 RenderPass::Id id(3, 2); | 41 RenderPass::Id id(3, 2); |
| 41 gfx::Rect outputRect(45, 22, 120, 13); | 42 gfx::Rect outputRect(45, 22, 120, 13); |
| 42 WebTransformationMatrix transformToRoot(1, 0.5, 0.5, -0.5, -1, 0); | 43 gfx::Transform transformToRoot = MathUtil::createGfxTransform(1, 0.5, 0.5, -
0.5, -1, 0); |
| 43 gfx::Rect damageRect(56, 123, 19, 43); | 44 gfx::Rect damageRect(56, 123, 19, 43); |
| 44 bool hasTransparentBackground = true; | 45 bool hasTransparentBackground = true; |
| 45 bool hasOcclusionFromOutsideTargetSurface = true; | 46 bool hasOcclusionFromOutsideTargetSurface = true; |
| 46 WebFilterOperations filters; | 47 WebFilterOperations filters; |
| 47 WebFilterOperations backgroundFilters; | 48 WebFilterOperations backgroundFilters; |
| 48 | 49 |
| 49 filters.append(WebFilterOperation::createGrayscaleFilter(0.2f)); | 50 filters.append(WebFilterOperation::createGrayscaleFilter(0.2f)); |
| 50 backgroundFilters.append(WebFilterOperation::createInvertFilter(0.2f)); | 51 backgroundFilters.append(WebFilterOperation::createInvertFilter(0.2f)); |
| 51 SkAutoTUnref<SkBlurImageFilter> filter(new SkBlurImageFilter(SK_Scalar1, SK_
Scalar1)); | 52 SkAutoTUnref<SkBlurImageFilter> filter(new SkBlurImageFilter(SK_Scalar1, SK_
Scalar1)); |
| 52 | 53 |
| 53 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 54 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
| 54 pass->SetAll(id, | 55 pass->SetAll(id, |
| 55 outputRect, | 56 outputRect, |
| 56 damageRect, | 57 damageRect, |
| 57 transformToRoot, | 58 transformToRoot, |
| 58 hasTransparentBackground, | 59 hasTransparentBackground, |
| 59 hasOcclusionFromOutsideTargetSurface, | 60 hasOcclusionFromOutsideTargetSurface, |
| 60 filters, | 61 filters, |
| 61 filter, | 62 filter, |
| 62 backgroundFilters); | 63 backgroundFilters); |
| 63 | 64 |
| 64 // Stick a quad in the pass, this should not get copied. | 65 // Stick a quad in the pass, this should not get copied. |
| 65 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); | 66 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); |
| 66 sharedState->SetAll(WebTransformationMatrix(), gfx::Rect(), gfx::Rect(), gfx
::Rect(), false, 1); | 67 sharedState->SetAll(gfx::Transform(), gfx::Rect(), gfx::Rect(), gfx::Rect(),
false, 1); |
| 67 pass->AppendSharedQuadState(sharedState.Pass()); | 68 pass->AppendSharedQuadState(sharedState.Pass()); |
| 68 | 69 |
| 69 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = CheckerboardDrawQuad::Cr
eate(); | 70 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = CheckerboardDrawQuad::Cr
eate(); |
| 70 checkerboardQuad->SetNew(pass->shared_quad_state_list.last(), gfx::Rect(), S
kColor()); | 71 checkerboardQuad->SetNew(pass->shared_quad_state_list.last(), gfx::Rect(), S
kColor()); |
| 71 pass->quad_list.append(checkerboardQuad.PassAs<DrawQuad>()); | 72 pass->quad_list.append(checkerboardQuad.PassAs<DrawQuad>()); |
| 72 | 73 |
| 73 RenderPass::Id newId(63, 4); | 74 RenderPass::Id newId(63, 4); |
| 74 | 75 |
| 75 scoped_ptr<RenderPass> copy = pass->Copy(newId); | 76 scoped_ptr<RenderPass> copy = pass->Copy(newId); |
| 76 EXPECT_EQ(newId, copy->id); | 77 EXPECT_EQ(newId, copy->id); |
| 77 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect); | 78 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect); |
| 78 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); | 79 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); |
| 79 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect); | 80 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect); |
| 80 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background
); | 81 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background
); |
| 81 EXPECT_EQ(pass->has_occlusion_from_outside_target_surface, copy->has_occlusi
on_from_outside_target_surface); | 82 EXPECT_EQ(pass->has_occlusion_from_outside_target_surface, copy->has_occlusi
on_from_outside_target_surface); |
| 82 EXPECT_EQ(pass->filters, copy->filters); | 83 EXPECT_EQ(pass->filters, copy->filters); |
| 83 EXPECT_EQ(pass->filter, copy->filter); | 84 EXPECT_EQ(pass->filter, copy->filter); |
| 84 EXPECT_EQ(pass->background_filters, copy->background_filters); | 85 EXPECT_EQ(pass->background_filters, copy->background_filters); |
| 85 EXPECT_EQ(0u, copy->quad_list.size()); | 86 EXPECT_EQ(0u, copy->quad_list.size()); |
| 86 | 87 |
| 87 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); | 88 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); |
| 88 } | 89 } |
| 89 | 90 |
| 90 } // namespace | 91 } // namespace |
| 91 } // namespace cc | 92 } // namespace cc |
| OLD | NEW |