| 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 "cc/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 2757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2768 }; | 2768 }; |
| 2769 | 2769 |
| 2770 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid
er* provider) | 2770 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid
er* provider) |
| 2771 { | 2771 { |
| 2772 ResourceProvider::ResourceId resourceId = provider->createResource(gfx::Size
(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); | 2772 ResourceProvider::ResourceId resourceId = provider->createResource(gfx::Size
(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); |
| 2773 | 2773 |
| 2774 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 2774 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
| 2775 pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1,
1), gfx::Transform()); | 2775 pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1,
1), gfx::Transform()); |
| 2776 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); | 2776 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); |
| 2777 sharedState->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0,
1, 1), gfx::Rect(0, 0, 1, 1), false, 1); | 2777 sharedState->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0,
1, 1), gfx::Rect(0, 0, 1, 1), false, 1); |
| 2778 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 2778 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 2779 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
| 2779 quad->SetNew(sharedState.get(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)
, resourceId, false, gfx::RectF(0, 0, 1, 1), false); | 2780 quad->SetNew(sharedState.get(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)
, resourceId, false, gfx::RectF(0, 0, 1, 1), vertex_opacity, false); |
| 2780 | 2781 |
| 2781 pass->AppendSharedQuadState(sharedState.Pass()); | 2782 pass->AppendSharedQuadState(sharedState.Pass()); |
| 2782 pass->AppendQuad(quad.PassAs<DrawQuad>()); | 2783 pass->AppendQuad(quad.PassAs<DrawQuad>()); |
| 2783 | 2784 |
| 2784 return pass.PassAs<RenderPass>(); | 2785 return pass.PassAs<RenderPass>(); |
| 2785 } | 2786 } |
| 2786 | 2787 |
| 2787 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostOutputSurface) | 2788 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostOutputSurface) |
| 2788 { | 2789 { |
| 2789 int layerId = 1; | 2790 int layerId = 1; |
| (...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4266 isReplica = true; | 4267 isReplica = true; |
| 4267 | 4268 |
| 4268 scoped_ptr<TestRenderPass> renderPass = testData.renderPassCache.take(re
nderPassId); | 4269 scoped_ptr<TestRenderPass> renderPass = testData.renderPassCache.take(re
nderPassId); |
| 4269 | 4270 |
| 4270 // Cycle through quad data and create all quads | 4271 // Cycle through quad data and create all quads |
| 4271 while (*currentChar && *currentChar != '\n') { | 4272 while (*currentChar && *currentChar != '\n') { |
| 4272 if (*currentChar == 's') { | 4273 if (*currentChar == 's') { |
| 4273 // Solid color draw quad | 4274 // Solid color draw quad |
| 4274 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create
(); | 4275 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create
(); |
| 4275 quad->SetNew(testData.sharedQuadState.get(), gfx::Rect(0, 0, 10,
10), SK_ColorWHITE); | 4276 quad->SetNew(testData.sharedQuadState.get(), gfx::Rect(0, 0, 10,
10), SK_ColorWHITE); |
| 4276 | 4277 |
| 4277 renderPass->AppendQuad(quad.PassAs<DrawQuad>()); | 4278 renderPass->AppendQuad(quad.PassAs<DrawQuad>()); |
| 4278 currentChar++; | 4279 currentChar++; |
| 4279 } else if ((*currentChar >= 'A') && (*currentChar <= 'Z')) { | 4280 } else if ((*currentChar >= 'A') && (*currentChar <= 'Z')) { |
| 4280 // RenderPass draw quad | 4281 // RenderPass draw quad |
| 4281 int layerId = *currentChar; | 4282 int layerId = *currentChar; |
| 4282 currentChar++; | 4283 currentChar++; |
| 4283 ASSERT_TRUE(currentChar); | 4284 ASSERT_TRUE(currentChar); |
| 4284 int index = *currentChar; | 4285 int index = *currentChar; |
| 4285 currentChar++; | 4286 currentChar++; |
| 4286 RenderPass::Id newRenderPassId = RenderPass::Id(layerId, index); | 4287 RenderPass::Id newRenderPassId = RenderPass::Id(layerId, index); |
| 4287 ASSERT_NE(rootRenderPassId, newRenderPassId); | 4288 ASSERT_NE(rootRenderPassId, newRenderPassId); |
| 4288 bool hasTexture = false; | 4289 bool hasTexture = false; |
| 4289 bool contentsChanged = true; | 4290 bool contentsChanged = true; |
| 4290 | 4291 |
| 4291 if (*currentChar == '[') { | 4292 if (*currentChar == '[') { |
| 4292 currentChar++; | 4293 currentChar++; |
| 4293 while (*currentChar && *currentChar != ']') { | 4294 while (*currentChar && *currentChar != ']') { |
| 4294 switch (*currentChar) { | 4295 switch (*currentChar) { |
| 4295 case 'c': | 4296 case 'c': |
| 4296 contentsChanged = false; | 4297 contentsChanged = false; |
| 4297 break; | 4298 break; |
| 4298 case 't': | 4299 case 't': |
| 4299 hasTexture = true; | 4300 hasTexture = true; |
| 4300 break; | 4301 break; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4350 *pos = RenderPassDrawQuad::MaterialCast(currentQuad)->render_pas
s_id.layer_id; | 4351 *pos = RenderPassDrawQuad::MaterialCast(currentQuad)->render_pas
s_id.layer_id; |
| 4351 pos++; | 4352 pos++; |
| 4352 *pos = RenderPassDrawQuad::MaterialCast(currentQuad)->render_pas
s_id.index; | 4353 *pos = RenderPassDrawQuad::MaterialCast(currentQuad)->render_pas
s_id.index; |
| 4353 pos++; | 4354 pos++; |
| 4354 break; | 4355 break; |
| 4355 default: | 4356 default: |
| 4356 *pos = 'x'; | 4357 *pos = 'x'; |
| 4357 pos++; | 4358 pos++; |
| 4358 break; | 4359 break; |
| 4359 } | 4360 } |
| 4360 | 4361 |
| 4361 quadListIterator++; | 4362 quadListIterator++; |
| 4362 } | 4363 } |
| 4363 *pos = '\n'; | 4364 *pos = '\n'; |
| 4364 pos++; | 4365 pos++; |
| 4365 } | 4366 } |
| 4366 *pos = '\0'; | 4367 *pos = '\0'; |
| 4367 } | 4368 } |
| 4368 | 4369 |
| 4369 // Each RenderPassList is represented by a string which describes the configurat
ion. | 4370 // Each RenderPassList is represented by a string which describes the configurat
ion. |
| 4370 // The syntax of the string is as follows: | 4371 // The syntax of the string is as follows: |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4452 "A0ssssB0sss\n" | 4453 "A0ssssB0sss\n" |
| 4453 "B0C0\n" | 4454 "B0C0\n" |
| 4454 "C0D0\n" | 4455 "C0D0\n" |
| 4455 "D0E0\n" | 4456 "D0E0\n" |
| 4456 "E0F0\n" | 4457 "E0F0\n" |
| 4457 "F0G0\n" | 4458 "F0G0\n" |
| 4458 "G0H0\n" | 4459 "G0H0\n" |
| 4459 "H0sssI0sss\n" | 4460 "H0sssI0sss\n" |
| 4460 "I0J0\n" | 4461 "I0J0\n" |
| 4461 "J0ssss\n", | 4462 "J0ssss\n", |
| 4462 | 4463 |
| 4463 "R0sssssA0ssss\n" | 4464 "R0sssssA0ssss\n" |
| 4464 }, { | 4465 }, { |
| 4465 "Wide recursion, remove all", | 4466 "Wide recursion, remove all", |
| 4466 "R0A0[ct]B0[ct]C0[ct]D0[ct]E0[ct]F0[ct]G0[ct]H0[ct]I0[ct]J0[ct]\n" | 4467 "R0A0[ct]B0[ct]C0[ct]D0[ct]E0[ct]F0[ct]G0[ct]H0[ct]I0[ct]J0[ct]\n" |
| 4467 "A0s\n" | 4468 "A0s\n" |
| 4468 "B0s\n" | 4469 "B0s\n" |
| 4469 "C0ssss\n" | 4470 "C0ssss\n" |
| 4470 "D0ssss\n" | 4471 "D0ssss\n" |
| 4471 "E0s\n" | 4472 "E0s\n" |
| 4472 "F0\n" | 4473 "F0\n" |
| 4473 "G0s\n" | 4474 "G0s\n" |
| 4474 "H0s\n" | 4475 "H0s\n" |
| 4475 "I0s\n" | 4476 "I0s\n" |
| 4476 "J0ssss\n", | 4477 "J0ssss\n", |
| 4477 | 4478 |
| 4478 "R0A0B0C0D0E0F0G0H0I0J0\n" | 4479 "R0A0B0C0D0E0F0G0H0I0J0\n" |
| 4479 }, { | 4480 }, { |
| 4480 "Remove passes regardless of cache state", | 4481 "Remove passes regardless of cache state", |
| 4481 "R0ssssA0[ct]sss\n" | 4482 "R0ssssA0[ct]sss\n" |
| 4482 "A0sssB0C0s\n" | 4483 "A0sssB0C0s\n" |
| 4483 "B0sssD0[c]ssE0[t]F0\n" | 4484 "B0sssD0[c]ssE0[t]F0\n" |
| 4484 "E0ssssss\n" | 4485 "E0ssssss\n" |
| 4485 "C0G0\n" | 4486 "C0G0\n" |
| 4486 "D0sssssss\n" | 4487 "D0sssssss\n" |
| 4487 "F0sssssss\n" | 4488 "F0sssssss\n" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4688 // scrolling model, in both x- and y-directions. | 4689 // scrolling model, in both x- and y-directions. |
| 4689 void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
ScaleFactor) | 4690 void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
ScaleFactor) |
| 4690 { | 4691 { |
| 4691 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 4692 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
| 4692 | 4693 |
| 4693 gfx::Size layoutSurfaceSize(10, 20); | 4694 gfx::Size layoutSurfaceSize(10, 20); |
| 4694 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), | 4695 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), |
| 4695 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); | 4696 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); |
| 4696 float pageScale = 2; | 4697 float pageScale = 2; |
| 4697 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); | 4698 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); |
| 4698 // For this test we want to scrolls to move both the document and the | 4699 // For this test we want to scrolls to move both the document and the |
| 4699 // pinchZoomViewport so we can see some scroll component on the implTransfor
m. | 4700 // pinchZoomViewport so we can see some scroll component on the implTransfor
m. |
| 4700 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); | 4701 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); |
| 4701 m_hostImpl->setRootLayer(root.Pass()); | 4702 m_hostImpl->setRootLayer(root.Pass()); |
| 4702 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4703 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
| 4703 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4704 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
| 4704 initializeRendererAndDrawFrame(); | 4705 initializeRendererAndDrawFrame(); |
| 4705 | 4706 |
| 4706 // Set new page scale on impl thread by pinching. | 4707 // Set new page scale on impl thread by pinching. |
| 4707 m_hostImpl->pinchGestureBegin(); | 4708 m_hostImpl->pinchGestureBegin(); |
| 4708 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4709 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4807 // cause both document-scroll and zoomViewport panning. | 4808 // cause both document-scroll and zoomViewport panning. |
| 4808 void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa
t deviceScaleFactor) | 4809 void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa
t deviceScaleFactor) |
| 4809 { | 4810 { |
| 4810 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 4811 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
| 4811 | 4812 |
| 4812 gfx::Size layoutSurfaceSize(10, 20); | 4813 gfx::Size layoutSurfaceSize(10, 20); |
| 4813 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), | 4814 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), |
| 4814 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); | 4815 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); |
| 4815 float pageScale = 2; | 4816 float pageScale = 2; |
| 4816 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); | 4817 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); |
| 4817 // For this test we want to scrolls to move both the document and the | 4818 // For this test we want to scrolls to move both the document and the |
| 4818 // pinchZoomViewport so we can see some scroll component on the implTransfor
m. | 4819 // pinchZoomViewport so we can see some scroll component on the implTransfor
m. |
| 4819 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); | 4820 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); |
| 4820 m_hostImpl->setRootLayer(root.Pass()); | 4821 m_hostImpl->setRootLayer(root.Pass()); |
| 4821 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4822 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
| 4822 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4823 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
| 4823 initializeRendererAndDrawFrame(); | 4824 initializeRendererAndDrawFrame(); |
| 4824 | 4825 |
| 4825 // Set new page scale on impl thread by pinching. | 4826 // Set new page scale on impl thread by pinching. |
| 4826 m_hostImpl->pinchGestureBegin(); | 4827 m_hostImpl->pinchGestureBegin(); |
| 4827 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4828 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4927 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); | 4928 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
| 4928 drawFrameAndTestDamage(noDamage); | 4929 drawFrameAndTestDamage(noDamage); |
| 4929 } | 4930 } |
| 4930 | 4931 |
| 4931 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4932 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
| 4932 LayerTreeHostImplTest, | 4933 LayerTreeHostImplTest, |
| 4933 ::testing::Values(false, true)); | 4934 ::testing::Values(false, true)); |
| 4934 | 4935 |
| 4935 } // namespace | 4936 } // namespace |
| 4936 } // namespace cc | 4937 } // namespace cc |
| OLD | NEW |