| Index: gpu/command_buffer/tests/gl_gpu_fence_unittest.cc
|
| diff --git a/gpu/command_buffer/tests/gl_gpu_fence_unittest.cc b/gpu/command_buffer/tests/gl_gpu_fence_unittest.cc
|
| index 1a93547e6a7ccba44899bf67f93444d60601a778..edfc0ea8fa77da648beab00641b6ad99adb635c7 100644
|
| --- a/gpu/command_buffer/tests/gl_gpu_fence_unittest.cc
|
| +++ b/gpu/command_buffer/tests/gl_gpu_fence_unittest.cc
|
| @@ -20,7 +20,9 @@
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "ui/gfx/gpu_fence.h"
|
| +#include "ui/gfx/gpu_memory_buffer.h"
|
| #include "ui/gl/gl_fence.h"
|
| +#include "ui/gl/gl_image.h"
|
|
|
| using testing::_;
|
| using testing::IgnoreResult;
|
| @@ -46,20 +48,47 @@ TEST_F(GpuFenceTest, Lifecycle) {
|
| // Create the gpu fence.
|
| std::unique_ptr<gfx::GpuFence> fence(gl_.CreateGpuFence());
|
|
|
| - // Check fence.
|
| - bool rv = fence->Wait(base::TimeDelta());
|
| - DCHECK(!rv);
|
| -
|
| // Create the GL fence. This should add the fence ID to the FenceManager.
|
| GLuint fence_id = glCreateFenceCHROMIUM(fence->AsClientFence());
|
| ASSERT_NE(0u, fence_id);
|
| ASSERT_TRUE(gl_.decoder()->GetFenceManager()->LookupFence(fence_id) != NULL);
|
|
|
| - // Wait for 1us on fence.
|
| - rv = fence->Wait(base::TimeDelta::FromMicroseconds(1));
|
| + // Create a gpu memory buffer.
|
| + std::unique_ptr<gfx::GpuMemoryBuffer> buffer(
|
| + gl_.CreateGpuMemoryBuffer(gfx::Size(4, 4), gfx::BufferFormat::RGBA_8888));
|
| +
|
| + // Create an image.
|
| + GLuint image_id =
|
| + glCreateImageCHROMIUM(buffer->AsClientBuffer(), 4, 4, GL_RGBA);
|
| + ASSERT_NE(0u, image_id);
|
| +
|
| + // Create a texture.
|
| + GLuint texture_id = 0;
|
| + glGenTextures(1, &texture_id);
|
| + ASSERT_NE(0u, texture_id);
|
| + glBindTexture(GL_TEXTURE_2D, texture_id);
|
| + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
| + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
| + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
| + nullptr);
|
| +
|
| + // Check fence.
|
| + bool rv = fence->IsSignaled();
|
| + DCHECK(!rv);
|
| +
|
| + // Copy image to texture and signal fence when copy has completed.
|
| + glCopyImageSubDataCHROMIUM(image_id, texture_id, 0, 0, 0, 0, 4, 4, 0,
|
| + fence_id);
|
| +
|
| + // Wait for 1s on fence.
|
| + rv = fence->Wait(base::TimeDelta::FromSeconds(1));
|
| DCHECK(!rv);
|
|
|
| // Clean up.
|
| + glDeleteTextures(1, &texture_id);
|
| + glDestroyImageCHROMIUM(image_id);
|
| glDestroyFenceCHROMIUM(fence_id);
|
| }
|
|
|
|
|