Chromium Code Reviews| Index: ui/gl/gl_image_io_surface_unittest.cc |
| diff --git a/ui/gl/gl_image_io_surface_unittest.cc b/ui/gl/gl_image_io_surface_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d58908cffe751852bed14b818859bf40cfa81596 |
| --- /dev/null |
| +++ b/ui/gl/gl_image_io_surface_unittest.cc |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "ui/gfx/mac/io_surface_manager.h" |
| +#include "ui/gl/gl_image_io_surface.h" |
| +#include "ui/gl/test/gl_image_test_template.h" |
| + |
| +namespace gfx { |
| +namespace { |
| + |
| +class GLImageIOSurface420vTestDelegate { |
| + public: |
| + scoped_refptr<gl::GLImage> CreateSolidColorImage( |
| + const Size& size, |
| + const uint8_t color[4]) const { |
| + scoped_refptr<gl::GLImageIOSurface> image( |
| + new gl::GLImageIOSurface(size, GL_RGB_YCBCR_420V_CHROMIUM)); |
| + IOSurfaceRef surface_ref = |
| + IOSurfaceManager::CreateIOSurface(size, BufferFormat::YUV_420_BIPLANAR); |
| + IOReturn status = IOSurfaceLock(surface_ref, 0, nullptr); |
| + EXPECT_NE(status, kIOReturnCannotLock); |
| + void* y_data = IOSurfaceGetBaseAddressOfPlane(surface_ref, 0); |
| + void* uv_data = IOSurfaceGetBaseAddressOfPlane(surface_ref, 1); |
| + |
| + GLImageTestSupport::SetBufferDataToColor( |
| + size.width(), size.height(), |
| + IOSurfaceGetBytesPerRowOfPlane(surface_ref, 0), 0, |
| + BufferFormat::YUV_420_BIPLANAR, color, static_cast<uint8_t*>(y_data)); |
| + GLImageTestSupport::SetBufferDataToColor( |
| + size.width(), size.height(), |
| + IOSurfaceGetBytesPerRowOfPlane(surface_ref, 1), 1, |
| + BufferFormat::YUV_420_BIPLANAR, color, static_cast<uint8_t*>(uv_data)); |
| + IOSurfaceUnlock(surface_ref, 0, nullptr); |
| + |
| + bool rv = image->Initialize(surface_ref, GenericSharedMemoryId(1), |
| + BufferFormat::YUV_420_BIPLANAR); |
| + EXPECT_TRUE(rv); |
| + |
| + return image; |
| + } |
| +}; |
| + |
| +INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, |
| + GLImageTest, |
| + GLImageIOSurface420vTestDelegate); |
|
reveman
2015/11/02 01:09:44
nit: we should run this test for every format we s
Daniele Castagna
2015/11/02 19:35:51
Done.
|
| + |
| +INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, |
| + GLImageCopyTest, |
| + GLImageIOSurface420vTestDelegate); |
| + |
| +} // namespace |
| +} // namespace gfx |