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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/gfx/buffer_format_util.h" | 9 #include "ui/gfx/buffer_format_util.h" |
10 #include "ui/gfx/mac/io_surface_manager.h" | 10 #include "ui/gfx/mac/io_surface.h" |
11 #include "ui/gl/gl_image_io_surface.h" | 11 #include "ui/gl/gl_image_io_surface.h" |
12 #include "ui/gl/test/gl_image_test_template.h" | 12 #include "ui/gl/test/gl_image_test_template.h" |
13 | 13 |
14 namespace gl { | 14 namespace gl { |
15 namespace { | 15 namespace { |
16 | 16 |
17 template <gfx::BufferFormat format> | 17 template <gfx::BufferFormat format> |
18 class GLImageIOSurfaceTestDelegate { | 18 class GLImageIOSurfaceTestDelegate { |
19 public: | 19 public: |
20 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size, | 20 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size, |
21 const uint8_t color[4]) const { | 21 const uint8_t color[4]) const { |
22 scoped_refptr<GLImageIOSurface> image(new GLImageIOSurface( | 22 scoped_refptr<GLImageIOSurface> image(new GLImageIOSurface( |
23 size, GLImageIOSurface::GetInternalFormatForTesting(format))); | 23 size, GLImageIOSurface::GetInternalFormatForTesting(format))); |
24 IOSurfaceRef surface_ref = | 24 IOSurfaceRef surface_ref = gfx::CreateIOSurface(size, format); |
25 gfx::IOSurfaceManager::CreateIOSurface(size, format); | |
26 IOReturn status = IOSurfaceLock(surface_ref, 0, nullptr); | 25 IOReturn status = IOSurfaceLock(surface_ref, 0, nullptr); |
27 EXPECT_NE(status, kIOReturnCannotLock); | 26 EXPECT_NE(status, kIOReturnCannotLock); |
28 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format); | 27 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format); |
29 ++plane) { | 28 ++plane) { |
30 void* data = IOSurfaceGetBaseAddressOfPlane(surface_ref, plane); | 29 void* data = IOSurfaceGetBaseAddressOfPlane(surface_ref, plane); |
31 GLImageTestSupport::SetBufferDataToColor( | 30 GLImageTestSupport::SetBufferDataToColor( |
32 size.width(), size.height(), | 31 size.width(), size.height(), |
33 IOSurfaceGetBytesPerRowOfPlane(surface_ref, plane), plane, format, | 32 IOSurfaceGetBytesPerRowOfPlane(surface_ref, plane), plane, format, |
34 color, static_cast<uint8_t*>(data)); | 33 color, static_cast<uint8_t*>(data)); |
35 } | 34 } |
(...skipping 14 matching lines...) Expand all Loading... |
50 | 49 |
51 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, GLImageTest, GLImageTestTypes); | 50 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, GLImageTest, GLImageTestTypes); |
52 | 51 |
53 INSTANTIATE_TYPED_TEST_CASE_P( | 52 INSTANTIATE_TYPED_TEST_CASE_P( |
54 GLImageIOSurface, | 53 GLImageIOSurface, |
55 GLImageCopyTest, | 54 GLImageCopyTest, |
56 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::YUV_420_BIPLANAR>); | 55 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::YUV_420_BIPLANAR>); |
57 | 56 |
58 } // namespace | 57 } // namespace |
59 } // namespace gl | 58 } // namespace gl |
OLD | NEW |