Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: ui/gl/gl_image_io_surface_unittest.cc

Issue 1484473003: gl, ozone: enable GLImageBindTest unittests Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix for win and mac, but cros need crrev.com/1208603002 Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.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>
18 class GLImageIOSurfaceTestDelegate { 17 class GLImageIOSurfaceTestDelegate {
19 public: 18 public:
20 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size, 19 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size,
20 gfx::BufferFormat format,
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 = gfx::CreateIOSurface(size, format); 24 IOSurfaceRef surface_ref = gfx::CreateIOSurface(size, format);
25 IOReturn status = IOSurfaceLock(surface_ref, 0, nullptr); 25 IOReturn status = IOSurfaceLock(surface_ref, 0, nullptr);
26 EXPECT_NE(status, kIOReturnCannotLock); 26 EXPECT_NE(status, kIOReturnCannotLock);
27 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format); 27 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format);
28 ++plane) { 28 ++plane) {
29 void* data = IOSurfaceGetBaseAddressOfPlane(surface_ref, plane); 29 void* data = IOSurfaceGetBaseAddressOfPlane(surface_ref, plane);
30 GLImageTestSupport::SetBufferDataToColor( 30 GLImageTestSupport::SetBufferDataToColor(
31 size.width(), size.height(), 31 size.width(), size.height(),
32 IOSurfaceGetBytesPerRowOfPlane(surface_ref, plane), plane, format, 32 IOSurfaceGetBytesPerRowOfPlane(surface_ref, plane), plane, format,
33 color, static_cast<uint8_t*>(data)); 33 color, static_cast<uint8_t*>(data));
34 } 34 }
35 IOSurfaceUnlock(surface_ref, 0, nullptr); 35 IOSurfaceUnlock(surface_ref, 0, nullptr);
36 36
37 bool rv = 37 bool rv =
38 image->Initialize(surface_ref, gfx::GenericSharedMemoryId(1), format); 38 image->Initialize(surface_ref, gfx::GenericSharedMemoryId(1), format);
39 EXPECT_TRUE(rv); 39 EXPECT_TRUE(rv);
40 40
41 return image; 41 return image;
42 } 42 }
43
44 static bool IsSupported(gfx::BufferFormat format) {
45 switch (format) {
46 case gfx::BufferFormat::RGBA_8888:
47 case gfx::BufferFormat::BGRA_8888:
48 case gfx::BufferFormat::YUV_420_BIPLANAR:
49 return true;
50 default:
51 return false;
52 }
53 NOTREACHED();
54 return false;
55 }
43 }; 56 };
44 57
45 using GLImageTestTypes = testing::Types< 58 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface,
46 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::RGBA_8888>, 59 GLImageTest,
47 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::BGRA_8888>, 60 GLImageIOSurfaceTestDelegate);
48 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::YUV_420_BIPLANAR>>;
49 61
50 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, GLImageTest, GLImageTestTypes); 62 class GLImageIOSurfaceCopyTestDelegate : public GLImageIOSurfaceTestDelegate {
63 public:
64 static bool IsSupported(gfx::BufferFormat format) {
65 switch (format) {
66 case gfx::BufferFormat::YUV_420_BIPLANAR:
67 return true;
68 default:
69 return false;
70 }
71 NOTREACHED();
72 return false;
73 }
74 };
51 75
52 INSTANTIATE_TYPED_TEST_CASE_P( 76 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface,
53 GLImageIOSurface, 77 GLImageCopyTest,
54 GLImageCopyTest, 78 GLImageIOSurfaceCopyTestDelegate);
55 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::YUV_420_BIPLANAR>);
56 79
57 } // namespace 80 } // namespace
58 } // namespace gl 81 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl.gyp ('k') | ui/gl/gl_image_memory.h » ('j') | ui/gl/gl_utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698