| OLD | NEW |
| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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), extensionsUtil.release(), preserve)); |
| 212 bool wantDepthBuffer = false; | |
| 213 bool wantStencilBuffer = false; | |
| 214 bool multisampleExtensionSupported = false; | 212 bool multisampleExtensionSupported = false; |
| 215 if (!drawingBuffer->initialize(size, wantDepthBuffer, wantStencilBuffer,
multisampleExtensionSupported)) { | 213 if (!drawingBuffer->initialize(size, multisampleExtensionSupported)) { |
| 216 drawingBuffer->beginDestruction(); | 214 drawingBuffer->beginDestruction(); |
| 217 return nullptr; | 215 return nullptr; |
| 218 } | 216 } |
| 219 return drawingBuffer.release(); | 217 return drawingBuffer.release(); |
| 220 } | 218 } |
| 221 | 219 |
| 222 DrawingBufferForTests(PassOwnPtr<WebGraphicsContext3DProvider> contextProvid
er, PassOwnPtr<Extensions3DUtil> extensionsUtil, PreserveDrawingBuffer preserve) | 220 DrawingBufferForTests(PassOwnPtr<WebGraphicsContext3DProvider> contextProvid
er, PassOwnPtr<Extensions3DUtil> extensionsUtil, PreserveDrawingBuffer preserve) |
| 223 : DrawingBuffer(std::move(contextProvider), std::move(extensionsUtil), f
alse /* discardFramebufferSupported */, true /* wantAlphaChannel */, false /* pr
emultipliedAlpha */, preserve) | 221 : DrawingBuffer(std::move(contextProvider), std::move(extensionsUtil), f
alse /* discardFramebufferSupported */, true /* wantAlphaChannel */, false /* pr
emultipliedAlpha */, preserve, false /* wantDepth */, false /* wantStencil */) |
| 224 , m_live(0) | 222 , m_live(0) |
| 225 { } | 223 { } |
| 226 | 224 |
| 227 ~DrawingBufferForTests() override | 225 ~DrawingBufferForTests() override |
| 228 { | 226 { |
| 229 if (m_live) | 227 if (m_live) |
| 230 *m_live = false; | 228 *m_live = false; |
| 231 } | 229 } |
| 232 | 230 |
| 233 bool* m_live; | 231 bool* m_live; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 273 |
| 276 IntSize initialSize(initialWidth, initialHeight); | 274 IntSize initialSize(initialWidth, initialHeight); |
| 277 IntSize alternateSize(initialWidth, alternateHeight); | 275 IntSize alternateSize(initialWidth, alternateHeight); |
| 278 | 276 |
| 279 // Produce one mailbox at size 100x100. | 277 // Produce one mailbox at size 100x100. |
| 280 m_drawingBuffer->markContentsChanged(); | 278 m_drawingBuffer->markContentsChanged(); |
| 281 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 279 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 282 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); | 280 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 283 | 281 |
| 284 // Resize to 100x50. | 282 // Resize to 100x50. |
| 285 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight), false); | 283 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight)); |
| 286 m_drawingBuffer->mailboxReleased(mailbox, false); | 284 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 287 | 285 |
| 288 // Produce a mailbox at this size. | 286 // Produce a mailbox at this size. |
| 289 m_drawingBuffer->markContentsChanged(); | 287 m_drawingBuffer->markContentsChanged(); |
| 290 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 288 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 291 EXPECT_EQ(alternateSize, m_gl->mostRecentlyProducedSize()); | 289 EXPECT_EQ(alternateSize, m_gl->mostRecentlyProducedSize()); |
| 292 | 290 |
| 293 // Reset to initial size. | 291 // Reset to initial size. |
| 294 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight), false); | 292 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight)); |
| 295 m_drawingBuffer->mailboxReleased(mailbox, false); | 293 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 296 | 294 |
| 297 // Prepare another mailbox and verify that it's the correct size. | 295 // Prepare another mailbox and verify that it's the correct size. |
| 298 m_drawingBuffer->markContentsChanged(); | 296 m_drawingBuffer->markContentsChanged(); |
| 299 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 297 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 300 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); | 298 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 301 | 299 |
| 302 // Prepare one final mailbox and verify that it's the correct size. | 300 // Prepare one final mailbox and verify that it's the correct size. |
| 303 m_drawingBuffer->mailboxReleased(mailbox, false); | 301 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 304 m_drawingBuffer->markContentsChanged(); | 302 m_drawingBuffer->markContentsChanged(); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 512 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 515 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); | 513 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 516 EXPECT_TRUE(mailbox.allowOverlay); | 514 EXPECT_TRUE(mailbox.allowOverlay); |
| 517 testing::Mock::VerifyAndClearExpectations(m_gl); | 515 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 518 | 516 |
| 519 GLuint m_imageId2 = m_gl->nextImageIdToBeCreated(); | 517 GLuint m_imageId2 = m_gl->nextImageIdToBeCreated(); |
| 520 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId2)).Times(1); | 518 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId2)).Times(1); |
| 521 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId0)).Times(1); | 519 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId0)).Times(1); |
| 522 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId0)).Times(1); | 520 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId0)).Times(1); |
| 523 // Resize to 100x50. | 521 // Resize to 100x50. |
| 524 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight), false); | 522 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight)); |
| 525 m_drawingBuffer->mailboxReleased(mailbox, false); | 523 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 526 testing::Mock::VerifyAndClearExpectations(m_gl); | 524 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 527 | 525 |
| 528 GLuint m_imageId3 = m_gl->nextImageIdToBeCreated(); | 526 GLuint m_imageId3 = m_gl->nextImageIdToBeCreated(); |
| 529 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId3)).Times(1); | 527 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId3)).Times(1); |
| 530 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId1)).Times(1); | 528 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId1)).Times(1); |
| 531 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId1)).Times(1); | 529 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId1)).Times(1); |
| 532 // Produce a mailbox at this size. | 530 // Produce a mailbox at this size. |
| 533 m_drawingBuffer->markContentsChanged(); | 531 m_drawingBuffer->markContentsChanged(); |
| 534 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 532 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 535 EXPECT_EQ(alternateSize, m_gl->mostRecentlyProducedSize()); | 533 EXPECT_EQ(alternateSize, m_gl->mostRecentlyProducedSize()); |
| 536 EXPECT_TRUE(mailbox.allowOverlay); | 534 EXPECT_TRUE(mailbox.allowOverlay); |
| 537 testing::Mock::VerifyAndClearExpectations(m_gl); | 535 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 538 | 536 |
| 539 GLuint m_imageId4 = m_gl->nextImageIdToBeCreated(); | 537 GLuint m_imageId4 = m_gl->nextImageIdToBeCreated(); |
| 540 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId4)).Times(1); | 538 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId4)).Times(1); |
| 541 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId2)).Times(1); | 539 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId2)).Times(1); |
| 542 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId2)).Times(1); | 540 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId2)).Times(1); |
| 543 // Reset to initial size. | 541 // Reset to initial size. |
| 544 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight), false); | 542 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight)); |
| 545 m_drawingBuffer->mailboxReleased(mailbox, false); | 543 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 546 testing::Mock::VerifyAndClearExpectations(m_gl); | 544 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 547 | 545 |
| 548 GLuint m_imageId5 = m_gl->nextImageIdToBeCreated(); | 546 GLuint m_imageId5 = m_gl->nextImageIdToBeCreated(); |
| 549 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId5)).Times(1); | 547 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId5)).Times(1); |
| 550 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId3)).Times(1); | 548 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId3)).Times(1); |
| 551 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId3)).Times(1); | 549 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId3)).Times(1); |
| 552 // Prepare another mailbox and verify that it's the correct size. | 550 // Prepare another mailbox and verify that it's the correct size. |
| 553 m_drawingBuffer->markContentsChanged(); | 551 m_drawingBuffer->markContentsChanged(); |
| 554 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 552 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 if (cases[i].requestDepth || cases[i].requestStencil) { | 685 if (cases[i].requestDepth || cases[i].requestStencil) { |
| 688 EXPECT_NE(0u, trackingGL->depthStencilAttachment()); | 686 EXPECT_NE(0u, trackingGL->depthStencilAttachment()); |
| 689 EXPECT_EQ(0u, trackingGL->depthAttachment()); | 687 EXPECT_EQ(0u, trackingGL->depthAttachment()); |
| 690 EXPECT_EQ(0u, trackingGL->stencilAttachment()); | 688 EXPECT_EQ(0u, trackingGL->stencilAttachment()); |
| 691 } else { | 689 } else { |
| 692 EXPECT_EQ(0u, trackingGL->depthStencilAttachment()); | 690 EXPECT_EQ(0u, trackingGL->depthStencilAttachment()); |
| 693 EXPECT_EQ(0u, trackingGL->depthAttachment()); | 691 EXPECT_EQ(0u, trackingGL->depthAttachment()); |
| 694 EXPECT_EQ(0u, trackingGL->stencilAttachment()); | 692 EXPECT_EQ(0u, trackingGL->stencilAttachment()); |
| 695 } | 693 } |
| 696 | 694 |
| 697 drawingBuffer->reset(IntSize(10, 20), false); | 695 drawingBuffer->reset(IntSize(10, 20)); |
| 698 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasDepthBuffer()); | 696 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasDepthBuffer()); |
| 699 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasStencilBuffer()); | 697 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasStencilBuffer()); |
| 700 EXPECT_EQ(cases[i].expectedRenderBuffers, trackingGL->numAllocatedRender
Buffer()); | 698 EXPECT_EQ(cases[i].expectedRenderBuffers, trackingGL->numAllocatedRender
Buffer()); |
| 701 if (cases[i].requestDepth || cases[i].requestStencil) { | 699 if (cases[i].requestDepth || cases[i].requestStencil) { |
| 702 EXPECT_NE(0u, trackingGL->depthStencilAttachment()); | 700 EXPECT_NE(0u, trackingGL->depthStencilAttachment()); |
| 703 EXPECT_EQ(0u, trackingGL->depthAttachment()); | 701 EXPECT_EQ(0u, trackingGL->depthAttachment()); |
| 704 EXPECT_EQ(0u, trackingGL->stencilAttachment()); | 702 EXPECT_EQ(0u, trackingGL->stencilAttachment()); |
| 705 } else { | 703 } else { |
| 706 EXPECT_EQ(0u, trackingGL->depthStencilAttachment()); | 704 EXPECT_EQ(0u, trackingGL->depthStencilAttachment()); |
| 707 EXPECT_EQ(0u, trackingGL->depthAttachment()); | 705 EXPECT_EQ(0u, trackingGL->depthAttachment()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 m_drawingBuffer->markContentsChanged(); | 758 m_drawingBuffer->markContentsChanged(); |
| 761 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 759 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 762 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); | 760 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 763 EXPECT_FALSE(mailbox.allowOverlay); | 761 EXPECT_FALSE(mailbox.allowOverlay); |
| 764 | 762 |
| 765 m_drawingBuffer->mailboxReleased(mailbox, false); | 763 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 766 m_drawingBuffer->beginDestruction(); | 764 m_drawingBuffer->beginDestruction(); |
| 767 } | 765 } |
| 768 | 766 |
| 769 } // namespace blink | 767 } // namespace blink |
| OLD | NEW |