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

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

Issue 1907433002: gl: Add ozone native pixmap bind test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | 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 2016 The Chromium Authors. All rights reserved.
reveman 2016/04/21 02:31:31 nit: I don't think we update the year in chromium
Daniele Castagna 2016/04/22 07:45:39 Done.
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/buffer_types.h" 8 #include "ui/gfx/buffer_types.h"
9 #include "ui/gl/gl_image_ozone_native_pixmap.h" 9 #include "ui/gl/gl_image_ozone_native_pixmap.h"
10 #include "ui/gl/test/gl_image_test_template.h" 10 #include "ui/gl/test/gl_image_test_template.h"
11 #include "ui/ozone/public/client_native_pixmap.h"
12 #include "ui/ozone/public/client_native_pixmap_factory.h"
11 #include "ui/ozone/public/ozone_platform.h" 13 #include "ui/ozone/public/ozone_platform.h"
12 #include "ui/ozone/public/surface_factory_ozone.h" 14 #include "ui/ozone/public/surface_factory_ozone.h"
13 15
14 namespace gl { 16 namespace gl {
15 namespace { 17 namespace {
16 18
19 template <gfx::BufferUsage usage>
17 class GLImageOzoneNativePixmapTestDelegate { 20 class GLImageOzoneNativePixmapTestDelegate {
18 public: 21 public:
19 scoped_refptr<gl::GLImage> CreateSolidColorImage( 22 scoped_refptr<gl::GLImage> CreateSolidColorImage(
20 const gfx::Size& size, 23 const gfx::Size& size,
21 const uint8_t color[4]) const { 24 const uint8_t color[4]) const {
22 ui::SurfaceFactoryOzone* surface_factory = 25 ui::SurfaceFactoryOzone* surface_factory =
23 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); 26 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone();
24 scoped_refptr<ui::NativePixmap> pixmap = 27 scoped_refptr<ui::NativePixmap> pixmap =
25 surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, 28 surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size,
26 gfx::BufferFormat::RGBA_8888, 29 gfx::BufferFormat::RGBA_8888,
27 gfx::BufferUsage::SCANOUT); 30 usage);
28 EXPECT_TRUE(pixmap != nullptr); 31 EXPECT_TRUE(pixmap != nullptr);
32 if (usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE) {
33 auto client_pixmap_factory = ui::ClientNativePixmapFactory::Create();
reveman 2016/04/21 02:31:31 Would it make more sense to have the factory be a
Daniele Castagna 2016/04/22 07:45:39 Moved.
34 auto client_pixmap = client_pixmap_factory->ImportFromHandle(
35 pixmap->ExportHandle(), size, usage);
36 void* data = client_pixmap->Map();
37 EXPECT_TRUE(data);
38 GLImageTestSupport::SetBufferDataToColor(
39 size.width(), size.height(), pixmap->GetDmaBufPitch(), 0,
40 pixmap->GetBufferFormat(), color, static_cast<uint8_t*>(data));
41 client_pixmap->Unmap();
42 }
43
29 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( 44 scoped_refptr<gfx::GLImageOzoneNativePixmap> image(
30 new gfx::GLImageOzoneNativePixmap(size, GL_RGBA)); 45 new gfx::GLImageOzoneNativePixmap(size, GL_RGBA));
31 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat())); 46 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat()));
32 return image; 47 return image;
33 } 48 }
34 49
35 unsigned GetTextureTarget() const { return GL_TEXTURE_2D; } 50 unsigned GetTextureTarget() const { return GL_TEXTURE_2D; }
36 }; 51 };
37 52
53 INSTANTIATE_TYPED_TEST_CASE_P(
54 GLImageOzoneNativePixmap,
55 GLImageTest,
56 GLImageOzoneNativePixmapTestDelegate<gfx::BufferUsage::SCANOUT>);
57
38 INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmap, 58 INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmap,
39 GLImageTest, 59 GLImageBindTest,
40 GLImageOzoneNativePixmapTestDelegate); 60 GLImageOzoneNativePixmapTestDelegate<
61 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE>);
41 62
42 } // namespace 63 } // namespace
43 } // namespace gl 64 } // namespace gl
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698