Remove extra line from unit_tests.isolate
[chromium-blink-merge.git] / cc / CCRenderPassTest.cpp
blob6c7423f6b59de8212ab21a599415ef7f664bb812
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.
5 #include "config.h"
7 #include "CCRenderPass.h"
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>
15 using WebKit::WebFilterOperation;
16 using WebKit::WebFilterOperations;
17 using WebKit::WebTransformationMatrix;
19 using namespace cc;
21 namespace {
23 class CCTestRenderPass : public CCRenderPass {
24 public:
25 CCQuadList& quadList() { return m_quadList; }
26 CCSharedQuadStateList& sharedQuadStateList() { return m_sharedQuadStateList; }
29 struct CCRenderPassSize {
30 // If you add a new field to this class, make sure to add it to the copy() tests.
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;
43 TEST(CCRenderPassTest, copyShouldBeIdenticalExceptIdAndQuads)
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);
49 scoped_ptr<CCRenderPass> pass = CCRenderPass::create(id, outputRect, transformToRoot);
51 IntRect damageRect(56, 123, 19, 43);
52 bool hasTransparentBackground = true;
53 bool hasOcclusionFromOutsideTargetSurface = true;
54 WebFilterOperations filters;
55 WebFilterOperations backgroundFilters;
57 filters.append(WebFilterOperation::createGrayscaleFilter(0.2f));
58 backgroundFilters.append(WebFilterOperation::createInvertFilter(0.2f));
60 pass->setDamageRect(damageRect);
61 pass->setHasTransparentBackground(hasTransparentBackground);
62 pass->setHasOcclusionFromOutsideTargetSurface(hasOcclusionFromOutsideTargetSurface);
63 pass->setFilters(filters);
64 pass->setBackgroundFilters(backgroundFilters);
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(WebTransformationMatrix(), IntRect(), IntRect(), 1, false));
69 testPass->quadList().append(CCCheckerboardDrawQuad::create(testPass->sharedQuadStateList().last(), IntRect(), SkColor()).PassAs<CCDrawQuad>());
71 CCRenderPass::Id newId(63, 4);
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->hasOcclusionFromOutsideTargetSurface());
80 EXPECT_EQ(pass->filters(), copy->filters());
81 EXPECT_EQ(pass->backgroundFilters(), copy->backgroundFilters());
82 EXPECT_EQ(0u, copy->quadList().size());
84 EXPECT_EQ(sizeof(CCRenderPassSize), sizeof(CCRenderPass));
87 } // namespace