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