Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "testing/gtest/include/gtest/gtest.h" | |
| 6 #include "ui/gfx/mac/io_surface_manager.h" | |
| 7 #include "ui/gl/gl_image_io_surface.h" | |
| 8 #include "ui/gl/test/gl_image_test_template.h" | |
| 9 | |
| 10 namespace gfx { | |
| 11 namespace { | |
| 12 | |
| 13 class GLImageIOSurface420vTestDelegate { | |
| 14 public: | |
| 15 scoped_refptr<gl::GLImage> CreateSolidColorImage( | |
| 16 const Size& size, | |
| 17 const uint8_t color[4]) const { | |
| 18 scoped_refptr<gl::GLImageIOSurface> image( | |
| 19 new gl::GLImageIOSurface(size, GL_RGB_YCBCR_420V_CHROMIUM)); | |
| 20 IOSurfaceRef surface_ref = | |
| 21 IOSurfaceManager::CreateIOSurface(size, BufferFormat::YUV_420_BIPLANAR); | |
| 22 IOReturn status = IOSurfaceLock(surface_ref, 0, nullptr); | |
| 23 EXPECT_NE(status, kIOReturnCannotLock); | |
| 24 void* y_data = IOSurfaceGetBaseAddressOfPlane(surface_ref, 0); | |
| 25 void* uv_data = IOSurfaceGetBaseAddressOfPlane(surface_ref, 1); | |
| 26 | |
| 27 GLImageTestSupport::SetBufferDataToColor( | |
| 28 size.width(), size.height(), | |
| 29 IOSurfaceGetBytesPerRowOfPlane(surface_ref, 0), 0, | |
| 30 BufferFormat::YUV_420_BIPLANAR, color, static_cast<uint8_t*>(y_data)); | |
| 31 GLImageTestSupport::SetBufferDataToColor( | |
| 32 size.width(), size.height(), | |
| 33 IOSurfaceGetBytesPerRowOfPlane(surface_ref, 1), 1, | |
| 34 BufferFormat::YUV_420_BIPLANAR, color, static_cast<uint8_t*>(uv_data)); | |
| 35 IOSurfaceUnlock(surface_ref, 0, nullptr); | |
| 36 | |
| 37 bool rv = image->Initialize(surface_ref, GenericSharedMemoryId(1), | |
| 38 BufferFormat::YUV_420_BIPLANAR); | |
| 39 EXPECT_TRUE(rv); | |
| 40 | |
| 41 return image; | |
| 42 } | |
| 43 }; | |
| 44 | |
| 45 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, | |
| 46 GLImageTest, | |
| 47 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.
| |
| 48 | |
| 49 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, | |
| 50 GLImageCopyTest, | |
| 51 GLImageIOSurface420vTestDelegate); | |
| 52 | |
| 53 } // namespace | |
| 54 } // namespace gfx | |
| OLD | NEW |