OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "ui/gfx/buffer_format_util.h" | 6 #include "ui/gfx/buffer_format_util.h" |
7 #include "ui/gfx/mac/io_surface_manager.h" | 7 #include "ui/gfx/mac/io_surface.h" |
8 #include "ui/gl/gl_image_io_surface.h" | 8 #include "ui/gl/gl_image_io_surface.h" |
9 #include "ui/gl/test/gl_image_test_template.h" | 9 #include "ui/gl/test/gl_image_test_template.h" |
10 | 10 |
11 namespace gl { | 11 namespace gl { |
12 namespace { | 12 namespace { |
13 | 13 |
14 template <gfx::BufferFormat format> | 14 template <gfx::BufferFormat format> |
15 class GLImageIOSurfaceTestDelegate { | 15 class GLImageIOSurfaceTestDelegate { |
16 public: | 16 public: |
17 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size, | 17 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size, |
18 const uint8_t color[4]) const { | 18 const uint8_t color[4]) const { |
19 scoped_refptr<GLImageIOSurface> image(new GLImageIOSurface( | 19 scoped_refptr<GLImageIOSurface> image(new GLImageIOSurface( |
20 size, GLImageIOSurface::GetInternalFormatForTesting(format))); | 20 size, GLImageIOSurface::GetInternalFormatForTesting(format))); |
21 IOSurfaceRef surface_ref = | 21 IOSurfaceRef surface_ref = gfx::CreateIOSurface(size, format); |
22 gfx::IOSurfaceManager::CreateIOSurface(size, format); | |
23 IOReturn status = IOSurfaceLock(surface_ref, 0, nullptr); | 22 IOReturn status = IOSurfaceLock(surface_ref, 0, nullptr); |
24 EXPECT_NE(status, kIOReturnCannotLock); | 23 EXPECT_NE(status, kIOReturnCannotLock); |
25 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format); | 24 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format); |
26 ++plane) { | 25 ++plane) { |
27 void* data = IOSurfaceGetBaseAddressOfPlane(surface_ref, plane); | 26 void* data = IOSurfaceGetBaseAddressOfPlane(surface_ref, plane); |
28 GLImageTestSupport::SetBufferDataToColor( | 27 GLImageTestSupport::SetBufferDataToColor( |
29 size.width(), size.height(), | 28 size.width(), size.height(), |
30 IOSurfaceGetBytesPerRowOfPlane(surface_ref, plane), plane, format, | 29 IOSurfaceGetBytesPerRowOfPlane(surface_ref, plane), plane, format, |
31 color, static_cast<uint8_t*>(data)); | 30 color, static_cast<uint8_t*>(data)); |
32 } | 31 } |
(...skipping 14 matching lines...) Expand all Loading... |
47 | 46 |
48 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, GLImageTest, GLImageTestTypes); | 47 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, GLImageTest, GLImageTestTypes); |
49 | 48 |
50 INSTANTIATE_TYPED_TEST_CASE_P( | 49 INSTANTIATE_TYPED_TEST_CASE_P( |
51 GLImageIOSurface, | 50 GLImageIOSurface, |
52 GLImageCopyTest, | 51 GLImageCopyTest, |
53 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::YUV_420_BIPLANAR>); | 52 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::YUV_420_BIPLANAR>); |
54 | 53 |
55 } // namespace | 54 } // namespace |
56 } // namespace gl | 55 } // namespace gl |
OLD | NEW |