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

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: address reveman's comments 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
« no previous file with comments | « ui/gl/gl.gyp ('k') | ui/gl/gl_image_memory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 return false;
54 }
43 }; 55 };
44 56
45 using GLImageTestTypes = testing::Types< 57 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface,
46 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::RGBA_8888>, 58 GLImageTest,
47 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::BGRA_8888>, 59 GLImageIOSurfaceTestDelegate);
48 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::YUV_420_BIPLANAR>>;
49 60
50 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface, GLImageTest, GLImageTestTypes); 61 class GLImageIOSurfaceCopyTestDelegate : public GLImageIOSurfaceTestDelegate {
62 static bool IsSupported(gfx::BufferFormat format) {
63 switch (format) {
64 case gfx::BufferFormat::YUV_420_BIPLANAR:
65 return true;
66 default:
67 return false;
68 }
69 return false;
70 }
71 };
51 72
52 INSTANTIATE_TYPED_TEST_CASE_P( 73 INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface,
53 GLImageIOSurface, 74 GLImageCopyTest,
54 GLImageCopyTest, 75 GLImageIOSurfaceCopyTestDelegate);
55 GLImageIOSurfaceTestDelegate<gfx::BufferFormat::YUV_420_BIPLANAR>);
56 76
57 } // namespace 77 } // namespace
58 } // namespace gl 78 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl.gyp ('k') | ui/gl/gl_image_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698