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

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

Issue 1484473003: gl, ozone: enable GLImageBindTest unittests Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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_image_memory.cc ('k') | ui/gl/gl_image_ref_counted_memory_unittest.cc » ('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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/gfx/buffer_types.h" 6 #include "ui/gfx/buffer_types.h"
7 #include "ui/gl/gl_image_ozone_native_pixmap.h" 7 #include "ui/gl/gl_image_ozone_native_pixmap.h"
8 #include "ui/gl/gl_utils.h"
8 #include "ui/gl/test/gl_image_test_template.h" 9 #include "ui/gl/test/gl_image_test_template.h"
10 #include "ui/ozone/public/client_native_pixmap_factory.h"
9 #include "ui/ozone/public/ozone_platform.h" 11 #include "ui/ozone/public/ozone_platform.h"
10 #include "ui/ozone/public/surface_factory_ozone.h" 12 #include "ui/ozone/public/surface_factory_ozone.h"
11 13
12 namespace gl { 14 namespace gl {
13 namespace { 15 namespace {
14 16
15 class GLImageOzoneNativePixmapTestDelegate { 17 template <gfx::BufferFormat format, gfx::BufferUsage usage>
reveman 2015/11/30 21:03:43 Note: this previous test is only useful for chrome
18 class GLImageOzoneNativePixmapTestDelegateForScanout {
16 public: 19 public:
17 scoped_refptr<gl::GLImage> CreateSolidColorImage( 20 scoped_refptr<gl::GLImage> CreateSolidColorImage(
18 const gfx::Size& size, 21 const gfx::Size& size,
19 const uint8_t color[4]) const { 22 const uint8_t color[4]) const {
23 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u);
20 ui::SurfaceFactoryOzone* surface_factory = 24 ui::SurfaceFactoryOzone* surface_factory =
21 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); 25 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone();
22 scoped_refptr<ui::NativePixmap> pixmap = 26 scoped_refptr<ui::NativePixmap> pixmap =
23 surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, 27 surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size,
24 gfx::BufferFormat::RGBA_8888, 28 format, usage);
25 gfx::BufferUsage::SCANOUT);
26 EXPECT_TRUE(pixmap != nullptr); 29 EXPECT_TRUE(pixmap != nullptr);
30 EXPECT_EQ(format, pixmap->GetBufferFormat());
27 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( 31 scoped_refptr<gfx::GLImageOzoneNativePixmap> image(
28 new gfx::GLImageOzoneNativePixmap(size, GL_RGBA)); 32 new gfx::GLImageOzoneNativePixmap(size,
29 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat())); 33 gl::GetTextureFormatFrom(format)));
34 EXPECT_TRUE(image->Initialize(pixmap.get(), format));
30 return image; 35 return image;
31 } 36 }
32 }; 37 };
33 38
34 INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmap, 39 using GLImageTestTypesForScanout = testing::Types<
40 GLImageOzoneNativePixmapTestDelegateForScanout<gfx::BufferFormat::RGBA_8888,
41 gfx::BufferUsage::GPU_READ>,
42 GLImageOzoneNativePixmapTestDelegateForScanout<gfx::BufferFormat::BGRX_8888,
43 gfx::BufferUsage::GPU_READ>,
44 GLImageOzoneNativePixmapTestDelegateForScanout<gfx::BufferFormat::BGRA_8888,
45 gfx::BufferUsage::GPU_READ>,
46 GLImageOzoneNativePixmapTestDelegateForScanout<gfx::BufferFormat::RGBA_8888,
47 gfx::BufferUsage::SCANOUT>,
48 GLImageOzoneNativePixmapTestDelegateForScanout<gfx::BufferFormat::BGRX_8888,
49 gfx::BufferUsage::SCANOUT>,
50 GLImageOzoneNativePixmapTestDelegateForScanout<gfx::BufferFormat::BGRA_8888,
51 gfx::BufferUsage::SCANOUT>>;
52
53 INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmapForScanout,
35 GLImageTest, 54 GLImageTest,
36 GLImageOzoneNativePixmapTestDelegate); 55 GLImageTestTypesForScanout);
56
57 template <gfx::BufferFormat format, gfx::BufferUsage usage>
58 class GLImageOzoneNativePixmapTestDelegateForCPUReadWrite {
59 public:
60 scoped_refptr<gl::GLImage> CreateSolidColorImage(
61 const gfx::Size& size,
62 const uint8_t color[4]) const {
63 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u);
64 ui::SurfaceFactoryOzone* surface_factory =
65 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone();
66 scoped_refptr<ui::NativePixmap> pixmap =
67 surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size,
68 format, usage);
69 EXPECT_TRUE(pixmap != nullptr);
70 EXPECT_EQ(format, pixmap->GetBufferFormat());
71
72 gfx::NativePixmapHandle handle = pixmap->ExportHandle();
73 scoped_ptr<ui::ClientNativePixmap> native_pixmap =
74 ui::ClientNativePixmapFactory::GetInstance()->ImportFromHandle(
75 handle, size, usage);
76 EXPECT_TRUE(native_pixmap != nullptr);
77
78 GLImageTestSupport::SetBufferDataToColor(
79 size.width(), size.height(), handle.stride, format, color,
80 reinterpret_cast<uint8_t*>(native_pixmap->Map()));
81 native_pixmap->Unmap();
82
83 scoped_refptr<gfx::GLImageOzoneNativePixmap> image(
84 new gfx::GLImageOzoneNativePixmap(size,
85 gl::GetTextureFormatFrom(format)));
86 EXPECT_TRUE(image->Initialize(pixmap.get(), format));
87 return image;
88 }
89 };
90
91 using GLImageTestTypesForCPUReadWrite =
92 testing::Types<GLImageOzoneNativePixmapTestDelegateForCPUReadWrite<
93 gfx::BufferFormat::BGRA_8888,
94 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE>,
95 GLImageOzoneNativePixmapTestDelegateForCPUReadWrite<
96 gfx::BufferFormat::BGRA_8888,
97 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT>>;
98
99 INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmapForCPUReadWrite,
100 GLImageTest,
101 GLImageTestTypesForCPUReadWrite);
37 102
38 } // namespace 103 } // namespace
39 } // namespace gl 104 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_memory.cc ('k') | ui/gl/gl_image_ref_counted_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698