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

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

Issue 1981823002: Remove OwnPtr::release() calls in platform/ (part 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 static const int initialWidth = 100; 202 static const int initialWidth = 100;
203 static const int initialHeight = 100; 203 static const int initialHeight = 100;
204 static const int alternateHeight = 50; 204 static const int alternateHeight = 50;
205 205
206 class DrawingBufferForTests : public DrawingBuffer { 206 class DrawingBufferForTests : public DrawingBuffer {
207 public: 207 public:
208 static PassRefPtr<DrawingBufferForTests> create(PassOwnPtr<WebGraphicsContex t3DProvider> contextProvider, const IntSize& size, PreserveDrawingBuffer preserv e) 208 static PassRefPtr<DrawingBufferForTests> create(PassOwnPtr<WebGraphicsContex t3DProvider> contextProvider, const IntSize& size, PreserveDrawingBuffer preserv e)
209 { 209 {
210 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(conte xtProvider->contextGL()); 210 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(conte xtProvider->contextGL());
211 RefPtr<DrawingBufferForTests> drawingBuffer = adoptRef(new DrawingBuffer ForTests(std::move(contextProvider), extensionsUtil.release(), preserve)); 211 RefPtr<DrawingBufferForTests> drawingBuffer = adoptRef(new DrawingBuffer ForTests(std::move(contextProvider), std::move(extensionsUtil), preserve));
212 bool multisampleExtensionSupported = false; 212 bool multisampleExtensionSupported = false;
213 if (!drawingBuffer->initialize(size, multisampleExtensionSupported)) { 213 if (!drawingBuffer->initialize(size, multisampleExtensionSupported)) {
214 drawingBuffer->beginDestruction(); 214 drawingBuffer->beginDestruction();
215 return nullptr; 215 return nullptr;
216 } 216 }
217 return drawingBuffer.release(); 217 return drawingBuffer.release();
218 } 218 }
219 219
220 DrawingBufferForTests(PassOwnPtr<WebGraphicsContext3DProvider> contextProvid er, PassOwnPtr<Extensions3DUtil> extensionsUtil, PreserveDrawingBuffer preserve) 220 DrawingBufferForTests(PassOwnPtr<WebGraphicsContext3DProvider> contextProvid er, PassOwnPtr<Extensions3DUtil> extensionsUtil, PreserveDrawingBuffer preserve)
221 : DrawingBuffer(std::move(contextProvider), std::move(extensionsUtil), f alse /* discardFramebufferSupported */, true /* wantAlphaChannel */, false /* pr emultipliedAlpha */, preserve, false /* wantDepth */, false /* wantStencil */) 221 : DrawingBuffer(std::move(contextProvider), std::move(extensionsUtil), f alse /* discardFramebufferSupported */, true /* wantAlphaChannel */, false /* pr emultipliedAlpha */, preserve, false /* wantDepth */, false /* wantStencil */)
(...skipping 30 matching lines...) Expand all
252 private: 252 private:
253 OwnPtr<gpu::gles2::GLES2Interface> m_gl; 253 OwnPtr<gpu::gles2::GLES2Interface> m_gl;
254 }; 254 };
255 255
256 class DrawingBufferTest : public Test { 256 class DrawingBufferTest : public Test {
257 protected: 257 protected:
258 void SetUp() override 258 void SetUp() override
259 { 259 {
260 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests) ; 260 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests) ;
261 m_gl = gl.get(); 261 m_gl = gl.get();
262 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web GraphicsContext3DProviderForTests(gl.release())); 262 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web GraphicsContext3DProviderForTests(std::move(gl)));
263 m_drawingBuffer = DrawingBufferForTests::create(provider.release(), IntS ize(initialWidth, initialHeight), DrawingBuffer::Preserve); 263 m_drawingBuffer = DrawingBufferForTests::create(std::move(provider), Int Size(initialWidth, initialHeight), DrawingBuffer::Preserve);
264 CHECK(m_drawingBuffer); 264 CHECK(m_drawingBuffer);
265 } 265 }
266 266
267 GLES2InterfaceForTests* m_gl; 267 GLES2InterfaceForTests* m_gl;
268 RefPtr<DrawingBufferForTests> m_drawingBuffer; 268 RefPtr<DrawingBufferForTests> m_drawingBuffer;
269 }; 269 };
270 270
271 TEST_F(DrawingBufferTest, verifyResizingProperlyAffectsMailboxes) 271 TEST_F(DrawingBufferTest, verifyResizingProperlyAffectsMailboxes)
272 { 272 {
273 WebExternalTextureMailbox mailbox; 273 WebExternalTextureMailbox mailbox;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // m_drawingBuffer waits for the sync point because the destruction is in pr ogress. 474 // m_drawingBuffer waits for the sync point because the destruction is in pr ogress.
475 EXPECT_EQ(waitSyncToken, m_gl->mostRecentlyWaitedSyncToken()); 475 EXPECT_EQ(waitSyncToken, m_gl->mostRecentlyWaitedSyncToken());
476 } 476 }
477 477
478 class DrawingBufferImageChromiumTest : public DrawingBufferTest { 478 class DrawingBufferImageChromiumTest : public DrawingBufferTest {
479 protected: 479 protected:
480 void SetUp() override 480 void SetUp() override
481 { 481 {
482 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests) ; 482 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests) ;
483 m_gl = gl.get(); 483 m_gl = gl.get();
484 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web GraphicsContext3DProviderForTests(gl.release())); 484 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web GraphicsContext3DProviderForTests(std::move(gl)));
485 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true); 485 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true);
486 m_imageId0 = m_gl->nextImageIdToBeCreated(); 486 m_imageId0 = m_gl->nextImageIdToBeCreated();
487 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId0)).Times(1); 487 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId0)).Times(1);
488 m_drawingBuffer = DrawingBufferForTests::create(provider.release(), 488 m_drawingBuffer = DrawingBufferForTests::create(std::move(provider),
489 IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve); 489 IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve);
490 CHECK(m_drawingBuffer); 490 CHECK(m_drawingBuffer);
491 testing::Mock::VerifyAndClearExpectations(m_gl); 491 testing::Mock::VerifyAndClearExpectations(m_gl);
492 } 492 }
493 493
494 void TearDown() override 494 void TearDown() override
495 { 495 {
496 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(false); 496 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(false);
497 } 497 }
498 498
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 DepthStencilTestCase(false, false, 0, "neither"), 654 DepthStencilTestCase(false, false, 0, "neither"),
655 DepthStencilTestCase(true, false, 1, "stencil only"), 655 DepthStencilTestCase(true, false, 1, "stencil only"),
656 DepthStencilTestCase(false, true, 1, "depth only"), 656 DepthStencilTestCase(false, true, 1, "depth only"),
657 DepthStencilTestCase(true, true, 1, "both"), 657 DepthStencilTestCase(true, true, 1, "both"),
658 }; 658 };
659 659
660 for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); i++) { 660 for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); i++) {
661 SCOPED_TRACE(cases[i].testCaseName); 661 SCOPED_TRACE(cases[i].testCaseName);
662 OwnPtr<DepthStencilTrackingGLES2Interface> gl = adoptPtr(new DepthStenci lTrackingGLES2Interface); 662 OwnPtr<DepthStencilTrackingGLES2Interface> gl = adoptPtr(new DepthStenci lTrackingGLES2Interface);
663 DepthStencilTrackingGLES2Interface* trackingGL = gl.get(); 663 DepthStencilTrackingGLES2Interface* trackingGL = gl.get();
664 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web GraphicsContext3DProviderForTests(gl.release())); 664 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web GraphicsContext3DProviderForTests(std::move(gl)));
665 DrawingBuffer::PreserveDrawingBuffer preserve = DrawingBuffer::Preserve; 665 DrawingBuffer::PreserveDrawingBuffer preserve = DrawingBuffer::Preserve;
666 666
667 bool premultipliedAlpha = false; 667 bool premultipliedAlpha = false;
668 bool wantAlphaChannel = true; 668 bool wantAlphaChannel = true;
669 bool wantDepthBuffer = cases[i].requestDepth; 669 bool wantDepthBuffer = cases[i].requestDepth;
670 bool wantStencilBuffer = cases[i].requestStencil; 670 bool wantStencilBuffer = cases[i].requestStencil;
671 bool wantAntialiasing = false; 671 bool wantAntialiasing = false;
672 RefPtr<DrawingBuffer> drawingBuffer = DrawingBuffer::create( 672 RefPtr<DrawingBuffer> drawingBuffer = DrawingBuffer::create(
673 provider.release(), 673 std::move(provider),
674 IntSize(10, 10), 674 IntSize(10, 10),
675 premultipliedAlpha, 675 premultipliedAlpha,
676 wantAlphaChannel, 676 wantAlphaChannel,
677 wantDepthBuffer, 677 wantDepthBuffer,
678 wantStencilBuffer, 678 wantStencilBuffer,
679 wantAntialiasing, 679 wantAntialiasing,
680 preserve); 680 preserve);
681 681
682 // When we request a depth or a stencil buffer, we will get both. 682 // When we request a depth or a stencil buffer, we will get both.
683 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe r->hasDepthBuffer()); 683 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe r->hasDepthBuffer());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 m_drawingBuffer->beginDestruction(); 732 m_drawingBuffer->beginDestruction();
733 } 733 }
734 734
735 class DrawingBufferImageChromiumFallbackTest : public DrawingBufferTest { 735 class DrawingBufferImageChromiumFallbackTest : public DrawingBufferTest {
736 protected: 736 protected:
737 void SetUp() override 737 void SetUp() override
738 { 738 {
739 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests) ; 739 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests) ;
740 gl->setAllowImageChromium(false); 740 gl->setAllowImageChromium(false);
741 m_gl = gl.get(); 741 m_gl = gl.get();
742 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web GraphicsContext3DProviderForTests(gl.release())); 742 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web GraphicsContext3DProviderForTests(std::move(gl)));
743 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true); 743 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true);
744 m_drawingBuffer = DrawingBufferForTests::create(provider.release(), 744 m_drawingBuffer = DrawingBufferForTests::create(std::move(provider),
745 IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve); 745 IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve);
746 } 746 }
747 747
748 void TearDown() override 748 void TearDown() override
749 { 749 {
750 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(false); 750 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(false);
751 } 751 }
752 }; 752 };
753 753
754 TEST_F(DrawingBufferImageChromiumFallbackTest, verifyImageChromiumFallback) 754 TEST_F(DrawingBufferImageChromiumFallbackTest, verifyImageChromiumFallback)
755 { 755 {
756 WebExternalTextureMailbox mailbox; 756 WebExternalTextureMailbox mailbox;
757 757
758 IntSize initialSize(initialWidth, initialHeight); 758 IntSize initialSize(initialWidth, initialHeight);
759 m_drawingBuffer->markContentsChanged(); 759 m_drawingBuffer->markContentsChanged();
760 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 760 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
761 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); 761 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize());
762 EXPECT_FALSE(mailbox.allowOverlay); 762 EXPECT_FALSE(mailbox.allowOverlay);
763 763
764 m_drawingBuffer->mailboxReleased(mailbox, false); 764 m_drawingBuffer->mailboxReleased(mailbox, false);
765 m_drawingBuffer->beginDestruction(); 765 m_drawingBuffer->beginDestruction();
766 } 766 }
767 767
768 } // namespace blink 768 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698