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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp

Issue 1852533002: Remove alpha/depth/stencil/antialias from WGC3D::Attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@premul
Patch Set: Created 4 years, 8 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 static const int initialWidth = 100; 230 static const int initialWidth = 100;
231 static const int initialHeight = 100; 231 static const int initialHeight = 100;
232 static const int alternateHeight = 50; 232 static const int alternateHeight = 50;
233 233
234 class DrawingBufferForTests : public DrawingBuffer { 234 class DrawingBufferForTests : public DrawingBuffer {
235 public: 235 public:
236 static PassRefPtr<DrawingBufferForTests> create(PassOwnPtr<WebGraphicsContex t3DProvider> contextProvider, const IntSize& size, PreserveDrawingBuffer preserv e) 236 static PassRefPtr<DrawingBufferForTests> create(PassOwnPtr<WebGraphicsContex t3DProvider> contextProvider, const IntSize& size, PreserveDrawingBuffer preserv e)
237 { 237 {
238 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(conte xtProvider->contextGL()); 238 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(conte xtProvider->contextGL());
239 RefPtr<DrawingBufferForTests> drawingBuffer = adoptRef(new DrawingBuffer ForTests(contextProvider, extensionsUtil.release(), preserve)); 239 RefPtr<DrawingBufferForTests> drawingBuffer = adoptRef(new DrawingBuffer ForTests(contextProvider, extensionsUtil.release(), preserve));
240 if (!drawingBuffer->initialize(size)) { 240 bool wantAlphaChannel = false;
241 bool wantDepthBuffer = false;
242 bool wantStencilBuffer = false;
243 bool multisampleExtensionSupported = false;
244 if (!drawingBuffer->initialize(size, wantAlphaChannel, wantDepthBuffer, wantStencilBuffer, multisampleExtensionSupported)) {
241 drawingBuffer->beginDestruction(); 245 drawingBuffer->beginDestruction();
242 return PassRefPtr<DrawingBufferForTests>(); 246 return PassRefPtr<DrawingBufferForTests>();
243 } 247 }
244 return drawingBuffer.release(); 248 return drawingBuffer.release();
245 } 249 }
246 250
247 DrawingBufferForTests(PassOwnPtr<WebGraphicsContext3DProvider> contextProvid er, PassOwnPtr<Extensions3DUtil> extensionsUtil, PreserveDrawingBuffer preserve) 251 DrawingBufferForTests(PassOwnPtr<WebGraphicsContext3DProvider> contextProvid er, PassOwnPtr<Extensions3DUtil> extensionsUtil, PreserveDrawingBuffer preserve)
248 : DrawingBuffer(contextProvider, extensionsUtil, false /* multisampleExt ensionSupported */, false /* discardFramebufferSupported */, false /* premultipl iedAlpha */, preserve, WebGraphicsContext3D::Attributes()) 252 : DrawingBuffer(contextProvider, extensionsUtil, false /* discardFramebu fferSupported */, false /* premultipliedAlpha */, preserve)
249 , m_live(0) 253 , m_live(0)
250 { } 254 { }
251 255
252 ~DrawingBufferForTests() override 256 ~DrawingBufferForTests() override
253 { 257 {
254 if (m_live) 258 if (m_live)
255 *m_live = false; 259 *m_live = false;
256 } 260 }
257 261
258 bool* m_live; 262 bool* m_live;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 309
306 IntSize initialSize(initialWidth, initialHeight); 310 IntSize initialSize(initialWidth, initialHeight);
307 IntSize alternateSize(initialWidth, alternateHeight); 311 IntSize alternateSize(initialWidth, alternateHeight);
308 312
309 // Produce one mailbox at size 100x100. 313 // Produce one mailbox at size 100x100.
310 m_drawingBuffer->markContentsChanged(); 314 m_drawingBuffer->markContentsChanged();
311 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 315 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
312 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); 316 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize());
313 317
314 // Resize to 100x50. 318 // Resize to 100x50.
315 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight)); 319 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight), false, false) ;
316 m_drawingBuffer->mailboxReleased(mailbox, false); 320 m_drawingBuffer->mailboxReleased(mailbox, false);
317 321
318 // Produce a mailbox at this size. 322 // Produce a mailbox at this size.
319 m_drawingBuffer->markContentsChanged(); 323 m_drawingBuffer->markContentsChanged();
320 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 324 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
321 EXPECT_EQ(alternateSize, webContext()->mostRecentlyProducedSize()); 325 EXPECT_EQ(alternateSize, webContext()->mostRecentlyProducedSize());
322 326
323 // Reset to initial size. 327 // Reset to initial size.
324 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight)); 328 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight), false, false);
325 m_drawingBuffer->mailboxReleased(mailbox, false); 329 m_drawingBuffer->mailboxReleased(mailbox, false);
326 330
327 // Prepare another mailbox and verify that it's the correct size. 331 // Prepare another mailbox and verify that it's the correct size.
328 m_drawingBuffer->markContentsChanged(); 332 m_drawingBuffer->markContentsChanged();
329 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 333 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
330 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); 334 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize());
331 335
332 // Prepare one final mailbox and verify that it's the correct size. 336 // Prepare one final mailbox and verify that it's the correct size.
333 m_drawingBuffer->mailboxReleased(mailbox, false); 337 m_drawingBuffer->mailboxReleased(mailbox, false);
334 m_drawingBuffer->markContentsChanged(); 338 m_drawingBuffer->markContentsChanged();
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 549 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
546 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); 550 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize());
547 EXPECT_TRUE(mailbox.allowOverlay); 551 EXPECT_TRUE(mailbox.allowOverlay);
548 testing::Mock::VerifyAndClearExpectations(webContext()); 552 testing::Mock::VerifyAndClearExpectations(webContext());
549 553
550 GLuint m_imageId2 = webContext()->nextImageIdToBeCreated(); 554 GLuint m_imageId2 = webContext()->nextImageIdToBeCreated();
551 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId2)).Times(1); 555 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId2)).Times(1);
552 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId0)).Times(1); 556 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId0)).Times(1);
553 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId0)).Times(1); 557 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId0)).Times(1);
554 // Resize to 100x50. 558 // Resize to 100x50.
555 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight)); 559 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight), false, false) ;
556 m_drawingBuffer->mailboxReleased(mailbox, false); 560 m_drawingBuffer->mailboxReleased(mailbox, false);
557 testing::Mock::VerifyAndClearExpectations(webContext()); 561 testing::Mock::VerifyAndClearExpectations(webContext());
558 562
559 GLuint m_imageId3 = webContext()->nextImageIdToBeCreated(); 563 GLuint m_imageId3 = webContext()->nextImageIdToBeCreated();
560 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId3)).Times(1); 564 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId3)).Times(1);
561 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId1)).Times(1); 565 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId1)).Times(1);
562 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId1)).Times(1); 566 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId1)).Times(1);
563 // Produce a mailbox at this size. 567 // Produce a mailbox at this size.
564 m_drawingBuffer->markContentsChanged(); 568 m_drawingBuffer->markContentsChanged();
565 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 569 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
566 EXPECT_EQ(alternateSize, webContext()->mostRecentlyProducedSize()); 570 EXPECT_EQ(alternateSize, webContext()->mostRecentlyProducedSize());
567 EXPECT_TRUE(mailbox.allowOverlay); 571 EXPECT_TRUE(mailbox.allowOverlay);
568 testing::Mock::VerifyAndClearExpectations(webContext()); 572 testing::Mock::VerifyAndClearExpectations(webContext());
569 573
570 GLuint m_imageId4 = webContext()->nextImageIdToBeCreated(); 574 GLuint m_imageId4 = webContext()->nextImageIdToBeCreated();
571 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId4)).Times(1); 575 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId4)).Times(1);
572 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId2)).Times(1); 576 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId2)).Times(1);
573 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId2)).Times(1); 577 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId2)).Times(1);
574 // Reset to initial size. 578 // Reset to initial size.
575 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight)); 579 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight), false, false);
576 m_drawingBuffer->mailboxReleased(mailbox, false); 580 m_drawingBuffer->mailboxReleased(mailbox, false);
577 testing::Mock::VerifyAndClearExpectations(webContext()); 581 testing::Mock::VerifyAndClearExpectations(webContext());
578 582
579 GLuint m_imageId5 = webContext()->nextImageIdToBeCreated(); 583 GLuint m_imageId5 = webContext()->nextImageIdToBeCreated();
580 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId5)).Times(1); 584 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId5)).Times(1);
581 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId3)).Times(1); 585 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId3)).Times(1);
582 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId3)).Times(1); 586 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId3)).Times(1);
583 // Prepare another mailbox and verify that it's the correct size. 587 // Prepare another mailbox and verify that it's the correct size.
584 m_drawingBuffer->markContentsChanged(); 588 m_drawingBuffer->markContentsChanged();
585 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 589 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 718
715 for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); i++) { 719 for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); i++) {
716 SCOPED_TRACE(cases[i].testCaseName); 720 SCOPED_TRACE(cases[i].testCaseName);
717 OwnPtr<DepthStencilTrackingGLES2Interface> gl = adoptPtr(new DepthStenci lTrackingGLES2Interface); 721 OwnPtr<DepthStencilTrackingGLES2Interface> gl = adoptPtr(new DepthStenci lTrackingGLES2Interface);
718 DepthStencilTrackingGLES2Interface* trackingGL = gl.get(); 722 DepthStencilTrackingGLES2Interface* trackingGL = gl.get();
719 OwnPtr<DepthStencilTrackingContext> context = adoptPtr(new DepthStencilT rackingContext(trackingGL)); 723 OwnPtr<DepthStencilTrackingContext> context = adoptPtr(new DepthStencilT rackingContext(trackingGL));
720 DepthStencilTrackingContext* trackingContext = context.get(); 724 DepthStencilTrackingContext* trackingContext = context.get();
721 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web GraphicsContext3DProviderForTests(context.release(), gl.release())); 725 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web GraphicsContext3DProviderForTests(context.release(), gl.release()));
722 DrawingBuffer::PreserveDrawingBuffer preserve = DrawingBuffer::Preserve; 726 DrawingBuffer::PreserveDrawingBuffer preserve = DrawingBuffer::Preserve;
723 727
724 WebGraphicsContext3D::Attributes requestedAttributes; 728 bool premultipliedAlpha = false;
725 requestedAttributes.stencil = cases[i].requestStencil; 729 bool wantAlphaChannel = false;
726 requestedAttributes.depth = cases[i].requestDepth; 730 bool wantDepthBuffer = cases[i].requestDepth;
727 RefPtr<DrawingBuffer> drawingBuffer = DrawingBuffer::create(provider.rel ease(), IntSize(10, 10), false /* premultipliedAlpha */, preserve, requestedAttr ibutes); 731 bool wantStencilBuffer = cases[i].requestStencil;
732 bool wantAntialiasing = false;
733 RefPtr<DrawingBuffer> drawingBuffer = DrawingBuffer::create(
734 provider.release(),
735 IntSize(10, 10),
736 premultipliedAlpha,
737 wantAlphaChannel,
738 wantDepthBuffer,
739 wantStencilBuffer,
740 wantAntialiasing,
741 preserve);
728 742
729 EXPECT_EQ(cases[i].requestDepth, drawingBuffer->getActualAttributes().de pth); 743 EXPECT_EQ(cases[i].requestDepth, drawingBuffer->hasDepthBuffer());
730 EXPECT_EQ(cases[i].requestStencil, drawingBuffer->getActualAttributes(). stencil); 744 EXPECT_EQ(cases[i].requestStencil, drawingBuffer->hasStencilBuffer());
731 EXPECT_EQ(cases[i].expectedRenderBuffers, trackingContext->numAllocatedR enderBuffer()); 745 EXPECT_EQ(cases[i].expectedRenderBuffers, trackingContext->numAllocatedR enderBuffer());
732 if (cases[i].requestDepth || cases[i].requestStencil) { 746 if (cases[i].requestDepth || cases[i].requestStencil) {
733 EXPECT_NE(0u, trackingContext->depthStencilAttachment()); 747 EXPECT_NE(0u, trackingContext->depthStencilAttachment());
734 EXPECT_EQ(0u, trackingContext->depthAttachment()); 748 EXPECT_EQ(0u, trackingContext->depthAttachment());
735 EXPECT_EQ(0u, trackingContext->stencilAttachment()); 749 EXPECT_EQ(0u, trackingContext->stencilAttachment());
736 } else { 750 } else {
737 EXPECT_EQ(0u, trackingContext->depthStencilAttachment()); 751 EXPECT_EQ(0u, trackingContext->depthStencilAttachment());
738 EXPECT_EQ(0u, trackingContext->depthAttachment()); 752 EXPECT_EQ(0u, trackingContext->depthAttachment());
739 EXPECT_EQ(0u, trackingContext->stencilAttachment()); 753 EXPECT_EQ(0u, trackingContext->stencilAttachment());
740 } 754 }
741 755
742 drawingBuffer->reset(IntSize(10, 20)); 756 drawingBuffer->reset(IntSize(10, 20), false, false);
743 EXPECT_EQ(cases[i].requestDepth, drawingBuffer->getActualAttributes().de pth); 757 EXPECT_EQ(cases[i].requestDepth, drawingBuffer->hasDepthBuffer());
744 EXPECT_EQ(cases[i].requestStencil, drawingBuffer->getActualAttributes(). stencil); 758 EXPECT_EQ(cases[i].requestStencil, drawingBuffer->hasStencilBuffer());
745 EXPECT_EQ(cases[i].expectedRenderBuffers, trackingContext->numAllocatedR enderBuffer()); 759 EXPECT_EQ(cases[i].expectedRenderBuffers, trackingContext->numAllocatedR enderBuffer());
746 if (cases[i].requestDepth || cases[i].requestStencil) { 760 if (cases[i].requestDepth || cases[i].requestStencil) {
747 EXPECT_NE(0u, trackingContext->depthStencilAttachment()); 761 EXPECT_NE(0u, trackingContext->depthStencilAttachment());
748 EXPECT_EQ(0u, trackingContext->depthAttachment()); 762 EXPECT_EQ(0u, trackingContext->depthAttachment());
749 EXPECT_EQ(0u, trackingContext->stencilAttachment()); 763 EXPECT_EQ(0u, trackingContext->stencilAttachment());
750 } else { 764 } else {
751 EXPECT_EQ(0u, trackingContext->depthStencilAttachment()); 765 EXPECT_EQ(0u, trackingContext->depthStencilAttachment());
752 EXPECT_EQ(0u, trackingContext->depthAttachment()); 766 EXPECT_EQ(0u, trackingContext->depthAttachment());
753 EXPECT_EQ(0u, trackingContext->stencilAttachment()); 767 EXPECT_EQ(0u, trackingContext->stencilAttachment());
754 } 768 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 m_drawingBuffer->markContentsChanged(); 821 m_drawingBuffer->markContentsChanged();
808 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 822 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
809 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); 823 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize());
810 EXPECT_FALSE(mailbox.allowOverlay); 824 EXPECT_FALSE(mailbox.allowOverlay);
811 825
812 m_drawingBuffer->mailboxReleased(mailbox, false); 826 m_drawingBuffer->mailboxReleased(mailbox, false);
813 m_drawingBuffer->beginDestruction(); 827 m_drawingBuffer->beginDestruction();
814 } 828 }
815 829
816 } // namespace blink 830 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698