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/buffer_format_util.h" | |
7 #include "ui/gfx/mac/io_surface_manager.h" | |
8 #include "ui/gl/gl_image_io_surface.h" | |
9 #include "ui/gl/test/gl_image_test_template.h" | |
10 | |
11 namespace gfx { | |
12 namespace { | |
13 | |
14 template <BufferFormat format> | |
15 class GLImageIOSurface420vTestDelegate { | |
reveman
2015/11/03 02:44:34
nit: s/GLImageIOSurface420vTestDelegate/GLImageIOS
Daniele Castagna
2015/11/04 20:41:33
Done.
| |
16 public: | |
17 scoped_refptr<gl::GLImage> CreateSolidColorImage( | |
18 const Size& size, | |
19 const uint8_t color[4]) const { | |
20 scoped_refptr<gl::GLImageIOSurface> image( | |
21 new gl::GLImageIOSurface(size, GL_RGB_YCBCR_420V_CHROMIUM)); | |
reveman
2015/11/03 02:47:18
nit: GL_RGB_YCBCR_420V_CHROMIUM is not correct if
Daniele Castagna
2015/11/04 20:41:33
Done.
| |
22 IOSurfaceRef surface_ref = IOSurfaceManager::CreateIOSurface(size, format); | |
23 IOReturn status = IOSurfaceLock(surface_ref, 0, nullptr); | |
24 EXPECT_NE(status, kIOReturnCannotLock); | |
25 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format); | |
26 ++plane) { | |
27 void* data = IOSurfaceGetBaseAddressOfPlane(surface_ref, plane); | |
28 GLImageTestSupport::SetBufferDataToColor( | |
29 size.width(), size.height(), | |
30 IOSurfaceGetBytesPerRowOfPlane(surface_ref, plane), plane, format, | |
31 color, static_cast<uint8_t*>(data)); | |
32 } | |
33 IOSurfaceUnlock(surface_ref, 0, nullptr); | |
34 | |
35 bool rv = image->Initialize(surface_ref, GenericSharedMemoryId(1), format); | |
36 EXPECT_TRUE(rv); | |
37 | |
38 return image; | |
39 } | |
40 }; | |
41 | |
42 using GLImageTestTypes = testing::Types< | |
43 GLImageIOSurface420vTestDelegate<BufferFormat::RGBA_8888>, | |
44 GLImageIOSurface420vTestDelegate<BufferFormat::BGRA_8888>, | |
45 GLImageIOSurface420vTestDelegate<BufferFormat::YUV_420_BIPLANAR>>; | |
46 | |
47 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, GLImageTest, GLImageTestTypes); | |
48 | |
49 INSTANTIATE_TYPED_TEST_CASE_P( | |
50 GLImageIOSurface, | |
51 GLImageCopyTest, | |
52 GLImageIOSurface420vTestDelegate<BufferFormat::YUV_420_BIPLANAR>); | |
53 | |
54 } // namespace | |
55 } // namespace gfx | |
OLD | NEW |