Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1181)

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698