diff options
author | skaslev@chromium.org <skaslev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 01:32:28 +0000 |
---|---|---|
committer | skaslev@chromium.org <skaslev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 01:32:28 +0000 |
commit | b32b0a49291f1ad51fc1bb190293c5836aa6c4e9 (patch) | |
tree | 9d9263665f46b719eebbb6f314f89ac39d3699ec /cc | |
parent | 5411d8200526d098042844fbea9871ed17c7f1d7 (diff) | |
download | chromium_src-b32b0a49291f1ad51fc1bb190293c5836aa6c4e9.zip chromium_src-b32b0a49291f1ad51fc1bb190293c5836aa6c4e9.tar.gz chromium_src-b32b0a49291f1ad51fc1bb190293c5836aa6c4e9.tar.bz2 |
Fixes a bug when the framebuffer is cleared with invalid scissor rect.
BUG=170305
Review URL: https://chromiumcodereview.appspot.com/12036091
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/direct_renderer.cc | 5 | ||||
-rw-r--r-- | cc/gl_renderer_unittest.cc | 58 | ||||
-rw-r--r-- | cc/test/render_pass_test_utils.cc | 15 | ||||
-rw-r--r-- | cc/test/render_pass_test_utils.h | 5 |
4 files changed, 82 insertions, 1 deletions
diff --git a/cc/direct_renderer.cc b/cc/direct_renderer.cc index 31f48e5..f9fb233 100644 --- a/cc/direct_renderer.cc +++ b/cc/direct_renderer.cc @@ -240,8 +240,11 @@ void DirectRenderer::drawRenderPass(DrawingFrame& frame, const RenderPass* rende setScissorTestRect(moveScissorToWindowSpace(frame, renderPassScissor)); } - if (frame.currentRenderPass != frame.rootRenderPass || m_client->shouldClearRootRenderPass()) + if (frame.currentRenderPass != frame.rootRenderPass || m_client->shouldClearRootRenderPass()) { + if (!usingScissorAsOptimization) + ensureScissorTestDisabled(); clearFramebuffer(frame); + } const QuadList& quadList = renderPass->quad_list; for (QuadList::constBackToFrontIterator it = quadList.backToFrontBegin(); it != quadList.backToFrontEnd(); ++it) { diff --git a/cc/gl_renderer_unittest.cc b/cc/gl_renderer_unittest.cc index 89603b1..e9665ab 100644 --- a/cc/gl_renderer_unittest.cc +++ b/cc/gl_renderer_unittest.cc @@ -636,5 +636,63 @@ TEST(GLRendererTest2, shouldClearRootRenderPass) Mock::VerifyAndClearExpectations(&mockContext); } +class ScissorTestOnClearCheckingContext : public FakeWebGraphicsContext3D { +public: + ScissorTestOnClearCheckingContext() : m_scissorEnabled(false) { } + + virtual void clear(WGC3Dbitfield) + { + EXPECT_FALSE(m_scissorEnabled); + } + + virtual void enable(WGC3Denum cap) + { + if (cap == GL_SCISSOR_TEST) + m_scissorEnabled = true; + } + + virtual void disable(WGC3Denum cap) + { + if (cap == GL_SCISSOR_TEST) + m_scissorEnabled = false; + } + +private: + bool m_scissorEnabled; +}; + +TEST(GLRendererTest2, scissorTestWhenClearing) { + FakeRendererClient mockClient; + scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ScissorTestOnClearCheckingContext))); + scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); + FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get()); + EXPECT_TRUE(renderer.initialize()); + EXPECT_FALSE(renderer.capabilities().usingPartialSwap); + + gfx::Rect viewportRect(mockClient.deviceViewportSize()); + ScopedPtrVector<RenderPass>& renderPasses = mockClient.renderPassesInDrawOrder(); + renderPasses.clear(); + + gfx::Rect grandChildRect(25, 25); + RenderPass::Id grandChildPassId(3, 0); + TestRenderPass* grandChildPass = addRenderPass(renderPasses, grandChildPassId, grandChildRect, gfx::Transform()); + addClippedQuad(grandChildPass, grandChildRect, SK_ColorYELLOW); + + gfx::Rect childRect(50, 50); + RenderPass::Id childPassId(2, 0); + TestRenderPass* childPass = addRenderPass(renderPasses, childPassId, childRect, gfx::Transform()); + addQuad(childPass, childRect, SK_ColorBLUE); + + RenderPass::Id rootPassId(1, 0); + TestRenderPass* rootPass = addRenderPass(renderPasses, rootPassId, viewportRect, gfx::Transform()); + addQuad(rootPass, viewportRect, SK_ColorGREEN); + + addRenderPassQuad(rootPass, childPass); + addRenderPassQuad(childPass, grandChildPass); + + renderer.decideRenderPassAllocationsForFrame(mockClient.renderPassesInDrawOrder()); + renderer.drawFrame(mockClient.renderPassesInDrawOrder()); +} + } // namespace } // namespace cc diff --git a/cc/test/render_pass_test_utils.cc b/cc/test/render_pass_test_utils.cc index b9f1217..bda83dd 100644 --- a/cc/test/render_pass_test_utils.cc +++ b/cc/test/render_pass_test_utils.cc @@ -41,6 +41,21 @@ SolidColorDrawQuad* addQuad(TestRenderPass* pass, return quadPtr; } +SolidColorDrawQuad* addClippedQuad(TestRenderPass* pass, + const gfx::Rect& rect, + SkColor color) { + MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_list); + AppendQuadsData data(pass->id); + SharedQuadState* sharedState = + quadSink.useSharedQuadState(SharedQuadState::Create()); + sharedState->SetAll(gfx::Transform(), rect, rect, true, 1); + scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); + quad->SetNew(sharedState, rect, color); + SolidColorDrawQuad* quadPtr = quad.get(); + quadSink.append(quad.PassAs<DrawQuad>(), data); + return quadPtr; +} + void addRenderPassQuad(TestRenderPass* toPass, TestRenderPass* contributingPass) { MockQuadCuller quadSink(toPass->quad_list, toPass->shared_quad_state_list); diff --git a/cc/test/render_pass_test_utils.h b/cc/test/render_pass_test_utils.h index b4d8dba..d9c2c91 100644 --- a/cc/test/render_pass_test_utils.h +++ b/cc/test/render_pass_test_utils.h @@ -32,6 +32,11 @@ SolidColorDrawQuad* addQuad(TestRenderPass* pass, const gfx::Rect& rect, SkColor color); +// Adds a solid quad to a given render pass and sets is_clipped=true. +SolidColorDrawQuad* addClippedQuad(TestRenderPass* pass, + const gfx::Rect& rect, + SkColor color); + // Adds a render pass quad to an existing render pass. void addRenderPassQuad(TestRenderPass* toPass, TestRenderPass* contributingPass); |