Exemplo n.º 1
0
TEST_F(DrawingBufferTest, verifyDrawingBufferStaysAliveIfResourcesAreLost)
{
    bool live = true;
    m_drawingBuffer->m_live = &live;
    WebExternalTextureMailbox mailbox1;
    WebExternalTextureMailbox mailbox2;
    WebExternalTextureMailbox mailbox3;

    m_drawingBuffer->markContentsChanged();
    EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox1, 0));
    m_drawingBuffer->markContentsChanged();
    EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox2, 0));
    m_drawingBuffer->markContentsChanged();
    EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox3, 0));

    m_drawingBuffer->markContentsChanged();
    m_drawingBuffer->mailboxReleased(mailbox1, true);
    EXPECT_EQ(live, true);

    m_drawingBuffer->beginDestruction();
    EXPECT_EQ(live, true);

    m_drawingBuffer->markContentsChanged();
    m_drawingBuffer->mailboxReleased(mailbox2, false);
    EXPECT_EQ(live, true);

    DrawingBufferForTests* weakPtr = m_drawingBuffer.get();
    m_drawingBuffer.clear();
    EXPECT_EQ(live, true);

    weakPtr->markContentsChanged();
    weakPtr->mailboxReleased(mailbox3, true);
    EXPECT_EQ(live, false);
}
Exemplo n.º 2
0
TEST_F(DrawingBufferTest, verifyDestructionCompleteAfterAllMailboxesReleased) {
  bool live = true;
  m_drawingBuffer->m_live = &live;

  cc::TextureMailbox textureMailbox1;
  std::unique_ptr<cc::SingleReleaseCallback> releaseCallback1;
  cc::TextureMailbox textureMailbox2;
  std::unique_ptr<cc::SingleReleaseCallback> releaseCallback2;
  cc::TextureMailbox textureMailbox3;
  std::unique_ptr<cc::SingleReleaseCallback> releaseCallback3;

  IntSize initialSize(InitialWidth, InitialHeight);

  // Produce mailboxes.
  m_drawingBuffer->markContentsChanged();
  m_drawingBuffer->clearFramebuffers(GL_STENCIL_BUFFER_BIT);
  VerifyStateWasRestored();
  EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox1,
                                                     &releaseCallback1));
  m_drawingBuffer->markContentsChanged();
  m_drawingBuffer->clearFramebuffers(GL_DEPTH_BUFFER_BIT);
  VerifyStateWasRestored();
  EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox2,
                                                     &releaseCallback2));
  m_drawingBuffer->markContentsChanged();
  m_drawingBuffer->clearFramebuffers(GL_COLOR_BUFFER_BIT);
  VerifyStateWasRestored();
  EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox3,
                                                     &releaseCallback3));

  m_drawingBuffer->markContentsChanged();
  releaseCallback1->Run(gpu::SyncToken(), false /* lostResource */);

  m_drawingBuffer->beginDestruction();
  ASSERT_EQ(live, true);

  DrawingBufferForTests* rawPointer = m_drawingBuffer.get();
  m_drawingBuffer.clear();
  ASSERT_EQ(live, true);

  rawPointer->markContentsChanged();
  releaseCallback2->Run(gpu::SyncToken(), false /* lostResource */);
  ASSERT_EQ(live, true);

  rawPointer->markContentsChanged();
  releaseCallback3->Run(gpu::SyncToken(), false /* lostResource */);
  ASSERT_EQ(live, false);
}
Exemplo n.º 3
0
TEST_F(DrawingBufferTest, verifyDrawingBufferStaysAliveIfResourcesAreLost) {
  bool live = true;
  m_drawingBuffer->m_live = &live;

  cc::TextureMailbox textureMailbox1;
  std::unique_ptr<cc::SingleReleaseCallback> releaseCallback1;
  cc::TextureMailbox textureMailbox2;
  std::unique_ptr<cc::SingleReleaseCallback> releaseCallback2;
  cc::TextureMailbox textureMailbox3;
  std::unique_ptr<cc::SingleReleaseCallback> releaseCallback3;

  m_drawingBuffer->markContentsChanged();
  EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox1,
                                                     &releaseCallback1));
  VerifyStateWasRestored();
  m_drawingBuffer->markContentsChanged();
  EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox2,
                                                     &releaseCallback2));
  VerifyStateWasRestored();
  m_drawingBuffer->markContentsChanged();
  EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox3,
                                                     &releaseCallback3));
  VerifyStateWasRestored();

  m_drawingBuffer->markContentsChanged();
  releaseCallback1->Run(gpu::SyncToken(), true /* lostResource */);
  EXPECT_EQ(live, true);

  m_drawingBuffer->beginDestruction();
  EXPECT_EQ(live, true);

  m_drawingBuffer->markContentsChanged();
  releaseCallback2->Run(gpu::SyncToken(), false /* lostResource */);
  EXPECT_EQ(live, true);

  DrawingBufferForTests* rawPtr = m_drawingBuffer.get();
  m_drawingBuffer.clear();
  EXPECT_EQ(live, true);

  rawPtr->markContentsChanged();
  releaseCallback3->Run(gpu::SyncToken(), true /* lostResource */);
  EXPECT_EQ(live, false);
}
Exemplo n.º 4
0
TEST_F(DrawingBufferTest, verifyDestructionCompleteAfterAllMailboxesReleased)
{
    bool live = true;
    m_drawingBuffer->m_live = &live;

    WebExternalTextureMailbox mailbox1;
    WebExternalTextureMailbox mailbox2;
    WebExternalTextureMailbox mailbox3;

    IntSize initialSize(initialWidth, initialHeight);

    // Produce mailboxes.
    m_drawingBuffer->markContentsChanged();
    EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox1, 0));
    m_drawingBuffer->markContentsChanged();
    EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox2, 0));
    m_drawingBuffer->markContentsChanged();
    EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox3, 0));

    m_drawingBuffer->markContentsChanged();
    m_drawingBuffer->mailboxReleased(mailbox1, false);

    m_drawingBuffer->beginDestruction();
    EXPECT_EQ(live, true);

    DrawingBufferForTests* weakPointer = m_drawingBuffer.get();
    m_drawingBuffer.clear();
    EXPECT_EQ(live, true);

    weakPointer->markContentsChanged();
    weakPointer->mailboxReleased(mailbox2, false);
    EXPECT_EQ(live, true);

    weakPointer->markContentsChanged();
    weakPointer->mailboxReleased(mailbox3, false);
    EXPECT_EQ(live, false);
}