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