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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCRenderPass.h" | 7 #include "CCRenderPass.h" |
8 | 8 |
9 #include "CCCheckerboardDrawQuad.h" | 9 #include "CCCheckerboardDrawQuad.h" |
10 #include "cc/test/geometry_test_utils.h" | 10 #include "cc/test/geometry_test_utils.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include <public/WebFilterOperations.h> | 12 #include <public/WebFilterOperations.h> |
13 #include <public/WebTransformationMatrix.h> | 13 #include <public/WebTransformationMatrix.h> |
14 | 14 |
15 using WebKit::WebFilterOperation; | 15 using WebKit::WebFilterOperation; |
16 using WebKit::WebFilterOperations; | 16 using WebKit::WebFilterOperations; |
17 using WebKit::WebTransformationMatrix; | 17 using WebKit::WebTransformationMatrix; |
18 | 18 |
19 using namespace cc; | 19 using namespace cc; |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 class CCTestRenderPass : public CCRenderPass { | 23 class TestRenderPass : public RenderPass { |
24 public: | 24 public: |
25 CCQuadList& quadList() { return m_quadList; } | 25 QuadList& quadList() { return m_quadList; } |
26 CCSharedQuadStateList& sharedQuadStateList() { return m_sharedQuadStateList;
} | 26 SharedQuadStateList& sharedQuadStateList() { return m_sharedQuadStateList; } |
27 }; | 27 }; |
28 | 28 |
29 struct CCRenderPassSize { | 29 struct RenderPassSize { |
30 // If you add a new field to this class, make sure to add it to the copy() t
ests. | 30 // If you add a new field to this class, make sure to add it to the copy() t
ests. |
31 CCRenderPass::Id m_id; | 31 RenderPass::Id m_id; |
32 CCQuadList m_quadList; | 32 QuadList m_quadList; |
33 CCSharedQuadStateList m_sharedQuadStateList; | 33 SharedQuadStateList m_sharedQuadStateList; |
34 WebKit::WebTransformationMatrix m_transformToRootTarget; | 34 WebKit::WebTransformationMatrix m_transformToRootTarget; |
35 IntRect m_outputRect; | 35 IntRect m_outputRect; |
36 FloatRect m_damageRect; | 36 FloatRect m_damageRect; |
37 bool m_hasTransparentBackground; | 37 bool m_hasTransparentBackground; |
38 bool m_hasOcclusionFromOutsideTargetSurface; | 38 bool m_hasOcclusionFromOutsideTargetSurface; |
39 WebKit::WebFilterOperations m_filters; | 39 WebKit::WebFilterOperations m_filters; |
40 WebKit::WebFilterOperations m_backgroundFilters; | 40 WebKit::WebFilterOperations m_backgroundFilters; |
41 }; | 41 }; |
42 | 42 |
43 TEST(CCRenderPassTest, copyShouldBeIdenticalExceptIdAndQuads) | 43 TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads) |
44 { | 44 { |
45 CCRenderPass::Id id(3, 2); | 45 RenderPass::Id id(3, 2); |
46 IntRect outputRect(45, 22, 120, 13); | 46 IntRect outputRect(45, 22, 120, 13); |
47 WebTransformationMatrix transformToRoot(1, 0.5, 0.5, -0.5, -1, 0); | 47 WebTransformationMatrix transformToRoot(1, 0.5, 0.5, -0.5, -1, 0); |
48 | 48 |
49 scoped_ptr<CCRenderPass> pass = CCRenderPass::create(id, outputRect, transfo
rmToRoot); | 49 scoped_ptr<RenderPass> pass = RenderPass::create(id, outputRect, transformTo
Root); |
50 | 50 |
51 IntRect damageRect(56, 123, 19, 43); | 51 IntRect damageRect(56, 123, 19, 43); |
52 bool hasTransparentBackground = true; | 52 bool hasTransparentBackground = true; |
53 bool hasOcclusionFromOutsideTargetSurface = true; | 53 bool hasOcclusionFromOutsideTargetSurface = true; |
54 WebFilterOperations filters; | 54 WebFilterOperations filters; |
55 WebFilterOperations backgroundFilters; | 55 WebFilterOperations backgroundFilters; |
56 | 56 |
57 filters.append(WebFilterOperation::createGrayscaleFilter(0.2f)); | 57 filters.append(WebFilterOperation::createGrayscaleFilter(0.2f)); |
58 backgroundFilters.append(WebFilterOperation::createInvertFilter(0.2f)); | 58 backgroundFilters.append(WebFilterOperation::createInvertFilter(0.2f)); |
59 | 59 |
60 pass->setDamageRect(damageRect); | 60 pass->setDamageRect(damageRect); |
61 pass->setHasTransparentBackground(hasTransparentBackground); | 61 pass->setHasTransparentBackground(hasTransparentBackground); |
62 pass->setHasOcclusionFromOutsideTargetSurface(hasOcclusionFromOutsideTargetS
urface); | 62 pass->setHasOcclusionFromOutsideTargetSurface(hasOcclusionFromOutsideTargetS
urface); |
63 pass->setFilters(filters); | 63 pass->setFilters(filters); |
64 pass->setBackgroundFilters(backgroundFilters); | 64 pass->setBackgroundFilters(backgroundFilters); |
65 | 65 |
66 // Stick a quad in the pass, this should not get copied. | 66 // Stick a quad in the pass, this should not get copied. |
67 CCTestRenderPass* testPass = static_cast<CCTestRenderPass*>(pass.get()); | 67 TestRenderPass* testPass = static_cast<TestRenderPass*>(pass.get()); |
68 testPass->sharedQuadStateList().append(CCSharedQuadState::create(WebTransfor
mationMatrix(), IntRect(), IntRect(), 1, false)); | 68 testPass->sharedQuadStateList().append(SharedQuadState::create(WebTransforma
tionMatrix(), IntRect(), IntRect(), 1, false)); |
69 testPass->quadList().append(CCCheckerboardDrawQuad::create(testPass->sharedQ
uadStateList().last(), IntRect(), SkColor()).PassAs<CCDrawQuad>()); | 69 testPass->quadList().append(CheckerboardDrawQuad::create(testPass->sharedQua
dStateList().last(), IntRect(), SkColor()).PassAs<DrawQuad>()); |
70 | 70 |
71 CCRenderPass::Id newId(63, 4); | 71 RenderPass::Id newId(63, 4); |
72 | 72 |
73 scoped_ptr<CCRenderPass> copy = pass->copy(newId); | 73 scoped_ptr<RenderPass> copy = pass->copy(newId); |
74 EXPECT_EQ(newId, copy->id()); | 74 EXPECT_EQ(newId, copy->id()); |
75 EXPECT_RECT_EQ(pass->outputRect(), copy->outputRect()); | 75 EXPECT_RECT_EQ(pass->outputRect(), copy->outputRect()); |
76 EXPECT_EQ(pass->transformToRootTarget(), copy->transformToRootTarget()); | 76 EXPECT_EQ(pass->transformToRootTarget(), copy->transformToRootTarget()); |
77 EXPECT_RECT_EQ(pass->damageRect(), copy->damageRect()); | 77 EXPECT_RECT_EQ(pass->damageRect(), copy->damageRect()); |
78 EXPECT_EQ(pass->hasTransparentBackground(), copy->hasTransparentBackground()
); | 78 EXPECT_EQ(pass->hasTransparentBackground(), copy->hasTransparentBackground()
); |
79 EXPECT_EQ(pass->hasOcclusionFromOutsideTargetSurface(), copy->hasOcclusionFr
omOutsideTargetSurface()); | 79 EXPECT_EQ(pass->hasOcclusionFromOutsideTargetSurface(), copy->hasOcclusionFr
omOutsideTargetSurface()); |
80 EXPECT_EQ(pass->filters(), copy->filters()); | 80 EXPECT_EQ(pass->filters(), copy->filters()); |
81 EXPECT_EQ(pass->backgroundFilters(), copy->backgroundFilters()); | 81 EXPECT_EQ(pass->backgroundFilters(), copy->backgroundFilters()); |
82 EXPECT_EQ(0u, copy->quadList().size()); | 82 EXPECT_EQ(0u, copy->quadList().size()); |
83 | 83 |
84 EXPECT_EQ(sizeof(CCRenderPassSize), sizeof(CCRenderPass)); | 84 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); |
85 } | 85 } |
86 | 86 |
87 } // namespace | 87 } // namespace |
OLD | NEW |