OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "CCRenderSurface.h" | 7 #include "CCRenderSurface.h" |
8 | 8 |
9 #include "CCLayerImpl.h" | 9 #include "CCLayerImpl.h" |
| 10 #include "CCRenderPassSink.h" |
10 #include "CCSharedQuadState.h" | 11 #include "CCSharedQuadState.h" |
11 #include "CCSingleThreadProxy.h" | 12 #include "CCSingleThreadProxy.h" |
12 #include "MockCCQuadCuller.h" | 13 #include "MockCCQuadCuller.h" |
13 #include <gmock/gmock.h> | 14 #include <gmock/gmock.h> |
14 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
15 #include <public/WebTransformationMatrix.h> | 16 #include <public/WebTransformationMatrix.h> |
16 | 17 |
17 using namespace WebCore; | 18 using namespace WebCore; |
18 using WebKit::WebTransformationMatrix; | 19 using WebKit::WebTransformationMatrix; |
19 | 20 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 ASSERT_EQ(1u, sharedStateList.size()); | 107 ASSERT_EQ(1u, sharedStateList.size()); |
107 CCSharedQuadState* sharedQuadState = sharedStateList[0].get(); | 108 CCSharedQuadState* sharedQuadState = sharedStateList[0].get(); |
108 | 109 |
109 EXPECT_EQ(30, sharedQuadState->quadTransform.m41()); | 110 EXPECT_EQ(30, sharedQuadState->quadTransform.m41()); |
110 EXPECT_EQ(40, sharedQuadState->quadTransform.m42()); | 111 EXPECT_EQ(40, sharedQuadState->quadTransform.m42()); |
111 EXPECT_EQ(contentRect, IntRect(sharedQuadState->visibleContentRect)); | 112 EXPECT_EQ(contentRect, IntRect(sharedQuadState->visibleContentRect)); |
112 EXPECT_EQ(1, sharedQuadState->opacity); | 113 EXPECT_EQ(1, sharedQuadState->opacity); |
113 EXPECT_FALSE(sharedQuadState->opaque); | 114 EXPECT_FALSE(sharedQuadState->opaque); |
114 } | 115 } |
115 | 116 |
| 117 class TestCCRenderPassSink : public CCRenderPassSink { |
| 118 public: |
| 119 virtual void appendRenderPass(PassOwnPtr<CCRenderPass> renderPass) OVERRIDE
{ m_renderPasses.append(renderPass); } |
| 120 |
| 121 const Vector<OwnPtr<CCRenderPass> >& renderPasses() const { return m_renderP
asses; } |
| 122 |
| 123 private: |
| 124 Vector<OwnPtr<CCRenderPass> > m_renderPasses; |
| 125 |
| 126 }; |
| 127 |
| 128 TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass) |
| 129 { |
| 130 // This will fake that we are on the correct thread for testing purposes. |
| 131 DebugScopedSetImplThread setImplThread; |
| 132 |
| 133 OwnPtr<CCLayerImpl> rootLayer = CCLayerImpl::create(1); |
| 134 |
| 135 OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(2); |
| 136 owningLayer->createRenderSurface(); |
| 137 ASSERT_TRUE(owningLayer->renderSurface()); |
| 138 owningLayer->setRenderTarget(owningLayer.get()); |
| 139 CCRenderSurface* renderSurface = owningLayer->renderSurface(); |
| 140 |
| 141 rootLayer->addChild(owningLayer.release()); |
| 142 |
| 143 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50)); |
| 144 WebTransformationMatrix origin; |
| 145 origin.translate(30, 40); |
| 146 |
| 147 renderSurface->setScreenSpaceTransform(origin); |
| 148 renderSurface->setContentRect(contentRect); |
| 149 |
| 150 TestCCRenderPassSink passSink; |
| 151 |
| 152 renderSurface->appendRenderPasses(passSink); |
| 153 |
| 154 ASSERT_EQ(1u, passSink.renderPasses().size()); |
| 155 CCRenderPass* pass = passSink.renderPasses()[0].get(); |
| 156 |
| 157 EXPECT_EQ(2, pass->id()); |
| 158 EXPECT_EQ(contentRect, pass->outputRect()); |
| 159 EXPECT_EQ(origin, pass->transformToRootTarget()); |
| 160 } |
| 161 |
116 } // namespace | 162 } // namespace |
OLD | NEW |