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

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

Issue 1419733005: gpu: Add YCbCr 420v extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address piman's comments. Created 5 years, 1 month 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
(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 GLImageIOSurfaceTestDelegate {
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(new gl::GLImageIOSurface(
21 size, gl::GLImageIOSurface::GetInternalFormatForTesting(format)));
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 GLImageIOSurfaceTestDelegate<BufferFormat::RGBA_8888>,
44 GLImageIOSurfaceTestDelegate<BufferFormat::BGRA_8888>,
45 GLImageIOSurfaceTestDelegate<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 GLImageIOSurfaceTestDelegate<BufferFormat::YUV_420_BIPLANAR>);
53
54 } // namespace
55 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698