| OLD | NEW |
| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/gfx/buffer_types.h" | 10 #include "ui/gfx/buffer_types.h" |
| 11 #include "ui/gl/test/gl_image_test_template.h" | 11 #include "ui/gl/test/gl_image_test_template.h" |
| 12 #include "ui/ozone/gl/gl_image_ozone_native_pixmap.h" | 12 #include "ui/ozone/gl/gl_image_ozone_native_pixmap.h" |
| 13 #include "ui/ozone/public/client_native_pixmap.h" | 13 #include "ui/ozone/public/client_native_pixmap.h" |
| 14 #include "ui/ozone/public/client_native_pixmap_factory.h" | 14 #include "ui/ozone/public/client_native_pixmap_factory.h" |
| 15 #include "ui/ozone/public/ozone_platform.h" | 15 #include "ui/ozone/public/ozone_platform.h" |
| 16 #include "ui/ozone/public/surface_factory_ozone.h" | 16 #include "ui/ozone/public/surface_factory_ozone.h" |
| 17 | 17 |
| 18 namespace gl { | 18 namespace gl { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const uint8_t kRed[] = {0xF0, 0x0, 0x0, 0xFF}; | 21 const uint8_t kRed[] = {0xF0, 0x0, 0x0, 0xFF}; |
| 22 const uint8_t kGreen[] = {0x0, 0xFF, 0x0, 0xFF}; | 22 const uint8_t kGreen[] = {0x0, 0xFF, 0x0, 0xFF}; |
| 23 | 23 |
| 24 // These values are picked so that RGB -> YVU on the CPU converted |
| 25 // back to RGB on the GPU produces the original RGB values without |
| 26 // any error. |
| 27 const uint8_t kYvuColor[] = {0x10, 0x20, 0, 0xFF}; |
| 28 |
| 24 template <gfx::BufferUsage usage, gfx::BufferFormat format> | 29 template <gfx::BufferUsage usage, gfx::BufferFormat format> |
| 25 class GLImageOzoneNativePixmapTestDelegate { | 30 class GLImageOzoneNativePixmapTestDelegate { |
| 26 public: | 31 public: |
| 27 GLImageOzoneNativePixmapTestDelegate() { | 32 GLImageOzoneNativePixmapTestDelegate() { |
| 28 client_pixmap_factory_ = ui::ClientNativePixmapFactory::Create(); | 33 client_pixmap_factory_ = ui::ClientNativePixmapFactory::Create(); |
| 29 } | 34 } |
| 30 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size, | 35 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size, |
| 31 const uint8_t color[4]) const { | 36 const uint8_t color[4]) const { |
| 32 ui::SurfaceFactoryOzone* surface_factory = | 37 ui::SurfaceFactoryOzone* surface_factory = |
| 33 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); | 38 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 55 new ui::GLImageOzoneNativePixmap( | 60 new ui::GLImageOzoneNativePixmap( |
| 56 size, | 61 size, |
| 57 ui::GLImageOzoneNativePixmap::GetInternalFormatForTesting(format))); | 62 ui::GLImageOzoneNativePixmap::GetInternalFormatForTesting(format))); |
| 58 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat())); | 63 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat())); |
| 59 return image; | 64 return image; |
| 60 } | 65 } |
| 61 | 66 |
| 62 unsigned GetTextureTarget() const { return GL_TEXTURE_EXTERNAL_OES; } | 67 unsigned GetTextureTarget() const { return GL_TEXTURE_EXTERNAL_OES; } |
| 63 | 68 |
| 64 const uint8_t* GetImageColor() { | 69 const uint8_t* GetImageColor() { |
| 65 return format == gfx::BufferFormat::R_8 ? kRed : kGreen; | 70 if (format == gfx::BufferFormat::R_8) { |
| 71 return kRed; |
| 72 } else if (format == gfx::BufferFormat::YVU_420) { |
| 73 return kYvuColor; |
| 74 } |
| 75 return kGreen; |
| 66 } | 76 } |
| 67 | 77 |
| 68 private: | 78 private: |
| 69 std::unique_ptr<ui::ClientNativePixmapFactory> client_pixmap_factory_; | 79 std::unique_ptr<ui::ClientNativePixmapFactory> client_pixmap_factory_; |
| 70 }; | 80 }; |
| 71 | 81 |
| 72 using GLImageScanoutType = testing::Types< | 82 using GLImageScanoutType = testing::Types< |
| 73 GLImageOzoneNativePixmapTestDelegate<gfx::BufferUsage::SCANOUT, | 83 GLImageOzoneNativePixmapTestDelegate<gfx::BufferUsage::SCANOUT, |
| 74 gfx::BufferFormat::BGRA_8888>>; | 84 gfx::BufferFormat::BGRA_8888>>; |
| 75 | 85 |
| 76 INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmapScanout, | 86 INSTANTIATE_TYPED_TEST_CASE_P(GLImageOzoneNativePixmapScanout, |
| 77 GLImageTest, | 87 GLImageTest, |
| 78 GLImageScanoutType); | 88 GLImageScanoutType); |
| 79 | 89 |
| 80 using GLImageReadWriteType = | 90 using GLImageReadWriteType = |
| 81 testing::Types<GLImageOzoneNativePixmapTestDelegate< | 91 testing::Types<GLImageOzoneNativePixmapTestDelegate< |
| 82 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, | 92 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, |
| 83 gfx::BufferFormat::R_8>>; | 93 gfx::BufferFormat::R_8>>; |
| 84 | 94 |
| 85 using GLImageBindTestTypes = | 95 using GLImageBindTestTypes = |
| 86 testing::Types<GLImageOzoneNativePixmapTestDelegate< | 96 testing::Types<GLImageOzoneNativePixmapTestDelegate< |
| 87 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, | 97 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, |
| 88 gfx::BufferFormat::BGRA_8888>, | 98 gfx::BufferFormat::BGRA_8888>, |
| 89 GLImageOzoneNativePixmapTestDelegate< | 99 GLImageOzoneNativePixmapTestDelegate< |
| 90 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, | 100 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, |
| 91 gfx::BufferFormat::R_8>>; | 101 gfx::BufferFormat::R_8>, |
| 102 GLImageOzoneNativePixmapTestDelegate< |
| 103 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, |
| 104 gfx::BufferFormat::YVU_420>>; |
| 92 | 105 |
| 93 // These tests are disabled since the trybots are running with Ozone X11 | 106 // These tests are disabled since the trybots are running with Ozone X11 |
| 94 // implementation that doesn't support creating ClientNativePixmap. | 107 // implementation that doesn't support creating ClientNativePixmap. |
| 95 // TODO(dcastagna): Implement ClientNativePixmapFactory on Ozone X11. | 108 // TODO(dcastagna): Implement ClientNativePixmapFactory on Ozone X11. |
| 96 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmapReadWrite, | 109 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmapReadWrite, |
| 97 GLImageTest, | 110 GLImageTest, |
| 98 GLImageReadWriteType); | 111 GLImageReadWriteType); |
| 99 | 112 |
| 100 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmap, | 113 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmap, |
| 101 GLImageBindTest, | 114 GLImageBindTest, |
| 102 GLImageBindTestTypes); | 115 GLImageBindTestTypes); |
| 103 | 116 |
| 104 } // namespace | 117 } // namespace |
| 105 } // namespace gl | 118 } // namespace gl |
| OLD | NEW |