int main(int argc,char **argv) { float* A = new float[100 * 100]; float* B = new float[100 * 100]; float* C = new float[100 * 100]; float* D = new float[100 * 100]; for (int i = 0; i < 100 * 100; i++) { A[i] = (float)rand() / RAND_MAX; B[i] = (float)rand() / RAND_MAX; } sMatrixMult (A, 100, 100, B, 100, 100, C); pMatrixMult (A, 100, 100, B, 100, 100, D); if (matrixEquil(C, D, 100, 100) == 0) { printf("YAY, your parallel results are verified\n"); alternateSize(8); alternateThreads(16); }else { printf("OH NO, your parallel results are not verified\n"); } delete[] A; delete[] B; delete[] C; delete[] D; }
TEST_F(DrawingBufferTest, verifyResizingProperlyAffectsMailboxes) { VerifyStateWasRestored(); cc::TextureMailbox textureMailbox; std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; IntSize initialSize(InitialWidth, InitialHeight); IntSize alternateSize(InitialWidth, AlternateHeight); // Produce one mailbox at size 100x100. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox, &releaseCallback)); VerifyStateWasRestored(); EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); // Resize to 100x50. m_drawingBuffer->resize(alternateSize); VerifyStateWasRestored(); releaseCallback->Run(gpu::SyncToken(), false /* lostResource */); VerifyStateWasRestored(); // Produce a mailbox at this size. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox, &releaseCallback)); EXPECT_EQ(alternateSize, m_gl->mostRecentlyProducedSize()); VerifyStateWasRestored(); // Reset to initial size. m_drawingBuffer->resize(initialSize); VerifyStateWasRestored(); SetAndSaveRestoreState(true); releaseCallback->Run(gpu::SyncToken(), false /* lostResource */); VerifyStateWasRestored(); // Prepare another mailbox and verify that it's the correct size. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox, &releaseCallback)); EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); VerifyStateWasRestored(); // Prepare one final mailbox and verify that it's the correct size. releaseCallback->Run(gpu::SyncToken(), false /* lostResource */); m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox, &releaseCallback)); VerifyStateWasRestored(); EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); releaseCallback->Run(gpu::SyncToken(), false /* lostResource */); m_drawingBuffer->beginDestruction(); }
TEST_F(DrawingBufferTest, verifyResizingProperlyAffectsMailboxes) { WebExternalTextureMailbox mailbox; IntSize initialSize(initialWidth, initialHeight); IntSize alternateSize(initialWidth, alternateHeight); // Produce one mailbox at size 100x100. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); // Resize to 100x50. m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight)); m_drawingBuffer->mailboxReleased(mailbox, false); // Produce a mailbox at this size. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); EXPECT_EQ(alternateSize, webContext()->mostRecentlyProducedSize()); // Reset to initial size. m_drawingBuffer->reset(IntSize(initialWidth, initialHeight)); m_drawingBuffer->mailboxReleased(mailbox, false); // Prepare another mailbox and verify that it's the correct size. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); // Prepare one final mailbox and verify that it's the correct size. m_drawingBuffer->mailboxReleased(mailbox, false); m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); m_drawingBuffer->mailboxReleased(mailbox, false); m_drawingBuffer->beginDestruction(); }
TEST_F(DrawingBufferImageChromiumTest, verifyResizingReallocatesImages) { cc::TextureMailbox textureMailbox; std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; IntSize initialSize(InitialWidth, InitialHeight); IntSize alternateSize(InitialWidth, AlternateHeight); GLuint m_imageId1 = m_gl->nextImageIdToBeCreated(); EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId1)).Times(1); // Produce one mailbox at size 100x100. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox, &releaseCallback)); EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); EXPECT_TRUE(textureMailbox.is_overlay_candidate()); testing::Mock::VerifyAndClearExpectations(m_gl); VerifyStateWasRestored(); GLuint m_imageId2 = m_gl->nextImageIdToBeCreated(); EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId2)).Times(1); EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId0)).Times(1); EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId0)).Times(1); EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId1)).Times(1); EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId1)).Times(1); // Resize to 100x50. m_drawingBuffer->resize(alternateSize); VerifyStateWasRestored(); releaseCallback->Run(gpu::SyncToken(), false /* lostResource */); VerifyStateWasRestored(); testing::Mock::VerifyAndClearExpectations(m_gl); GLuint m_imageId3 = m_gl->nextImageIdToBeCreated(); EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId3)).Times(1); // Produce a mailbox at this size. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox, &releaseCallback)); EXPECT_EQ(alternateSize, m_gl->mostRecentlyProducedSize()); EXPECT_TRUE(textureMailbox.is_overlay_candidate()); testing::Mock::VerifyAndClearExpectations(m_gl); GLuint m_imageId4 = m_gl->nextImageIdToBeCreated(); EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId4)).Times(1); EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId2)).Times(1); EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId2)).Times(1); EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId3)).Times(1); EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId3)).Times(1); // Reset to initial size. m_drawingBuffer->resize(initialSize); VerifyStateWasRestored(); releaseCallback->Run(gpu::SyncToken(), false /* lostResource */); VerifyStateWasRestored(); testing::Mock::VerifyAndClearExpectations(m_gl); GLuint m_imageId5 = m_gl->nextImageIdToBeCreated(); EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId5)).Times(1); // Prepare another mailbox and verify that it's the correct size. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox, &releaseCallback)); EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); EXPECT_TRUE(textureMailbox.is_overlay_candidate()); testing::Mock::VerifyAndClearExpectations(m_gl); // Prepare one final mailbox and verify that it's the correct size. releaseCallback->Run(gpu::SyncToken(), false /* lostResource */); m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->PrepareTextureMailbox(&textureMailbox, &releaseCallback)); EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); EXPECT_TRUE(textureMailbox.is_overlay_candidate()); releaseCallback->Run(gpu::SyncToken(), false /* lostResource */); EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId5)).Times(1); EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId5)).Times(1); EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId4)).Times(1); EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId4)).Times(1); m_drawingBuffer->beginDestruction(); testing::Mock::VerifyAndClearExpectations(m_gl); }
TEST_F(DrawingBufferImageChromiumTest, verifyResizingReallocatesImages) { WebExternalTextureMailbox mailbox; IntSize initialSize(initialWidth, initialHeight); IntSize alternateSize(initialWidth, alternateHeight); WGC3Duint m_imageId1 = webContext()->nextImageIdToBeCreated(); EXPECT_CALL(*webContext(), bindTexImage2DMock(m_imageId1)).Times(1); // Produce one mailbox at size 100x100. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); EXPECT_TRUE(mailbox.allowOverlay); testing::Mock::VerifyAndClearExpectations(webContext()); WGC3Duint m_imageId2 = webContext()->nextImageIdToBeCreated(); EXPECT_CALL(*webContext(), bindTexImage2DMock(m_imageId2)).Times(1); EXPECT_CALL(*webContext(), destroyImageMock(m_imageId0)).Times(1); EXPECT_CALL(*webContext(), releaseTexImage2DMock(m_imageId0)).Times(1); // Resize to 100x50. m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight)); m_drawingBuffer->mailboxReleased(mailbox, false); testing::Mock::VerifyAndClearExpectations(webContext()); WGC3Duint m_imageId3 = webContext()->nextImageIdToBeCreated(); EXPECT_CALL(*webContext(), bindTexImage2DMock(m_imageId3)).Times(1); EXPECT_CALL(*webContext(), destroyImageMock(m_imageId1)).Times(1); EXPECT_CALL(*webContext(), releaseTexImage2DMock(m_imageId1)).Times(1); // Produce a mailbox at this size. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); EXPECT_EQ(alternateSize, webContext()->mostRecentlyProducedSize()); EXPECT_TRUE(mailbox.allowOverlay); testing::Mock::VerifyAndClearExpectations(webContext()); WGC3Duint m_imageId4 = webContext()->nextImageIdToBeCreated(); EXPECT_CALL(*webContext(), bindTexImage2DMock(m_imageId4)).Times(1); EXPECT_CALL(*webContext(), destroyImageMock(m_imageId2)).Times(1); EXPECT_CALL(*webContext(), releaseTexImage2DMock(m_imageId2)).Times(1); // Reset to initial size. m_drawingBuffer->reset(IntSize(initialWidth, initialHeight)); m_drawingBuffer->mailboxReleased(mailbox, false); testing::Mock::VerifyAndClearExpectations(webContext()); WGC3Duint m_imageId5 = webContext()->nextImageIdToBeCreated(); EXPECT_CALL(*webContext(), bindTexImage2DMock(m_imageId5)).Times(1); EXPECT_CALL(*webContext(), destroyImageMock(m_imageId3)).Times(1); EXPECT_CALL(*webContext(), releaseTexImage2DMock(m_imageId3)).Times(1); // Prepare another mailbox and verify that it's the correct size. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); EXPECT_TRUE(mailbox.allowOverlay); testing::Mock::VerifyAndClearExpectations(webContext()); // Prepare one final mailbox and verify that it's the correct size. m_drawingBuffer->mailboxReleased(mailbox, false); m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); EXPECT_TRUE(mailbox.allowOverlay); m_drawingBuffer->mailboxReleased(mailbox, false); EXPECT_CALL(*webContext(), destroyImageMock(m_imageId5)).Times(1); EXPECT_CALL(*webContext(), releaseTexImage2DMock(m_imageId5)).Times(1); EXPECT_CALL(*webContext(), destroyImageMock(m_imageId4)).Times(1); EXPECT_CALL(*webContext(), releaseTexImage2DMock(m_imageId4)).Times(1); m_drawingBuffer->beginDestruction(); testing::Mock::VerifyAndClearExpectations(webContext()); }