| 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" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 template <gfx::BufferUsage usage, gfx::BufferFormat format> | 29 template <gfx::BufferUsage usage, gfx::BufferFormat format> |
| 30 class GLImageNativePixmapTestDelegate { | 30 class GLImageNativePixmapTestDelegate { |
| 31 public: | 31 public: |
| 32 GLImageNativePixmapTestDelegate() { | 32 GLImageNativePixmapTestDelegate() { |
| 33 client_pixmap_factory_ = ui::CreateClientNativePixmapFactoryOzone(); | 33 client_pixmap_factory_ = ui::CreateClientNativePixmapFactoryOzone(); |
| 34 } | 34 } |
| 35 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size, | 35 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size, |
| 36 const uint8_t color[4]) const { | 36 const uint8_t color[4]) const { |
| 37 ui::SurfaceFactoryOzone* surface_factory = | 37 ui::SurfaceFactoryOzone* surface_factory = |
| 38 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); | 38 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); |
| 39 scoped_refptr<ui::NativePixmap> pixmap = | 39 scoped_refptr<gfx::NativePixmap> pixmap = |
| 40 surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, | 40 surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, |
| 41 format, usage); | 41 format, usage); |
| 42 DCHECK(pixmap); | 42 DCHECK(pixmap); |
| 43 if (usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE) { | 43 if (usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE) { |
| 44 auto client_pixmap = client_pixmap_factory_->ImportFromHandle( | 44 auto client_pixmap = client_pixmap_factory_->ImportFromHandle( |
| 45 pixmap->ExportHandle(), size, usage); | 45 pixmap->ExportHandle(), size, usage); |
| 46 bool mapped = client_pixmap->Map(); | 46 bool mapped = client_pixmap->Map(); |
| 47 EXPECT_TRUE(mapped); | 47 EXPECT_TRUE(mapped); |
| 48 | 48 |
| 49 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format); | 49 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format); |
| 50 ++plane) { | 50 ++plane) { |
| 51 void* data = client_pixmap->GetMemoryAddress(plane); | 51 void* data = client_pixmap->GetMemoryAddress(plane); |
| 52 GLImageTestSupport::SetBufferDataToColor( | 52 GLImageTestSupport::SetBufferDataToColor( |
| 53 size.width(), size.height(), pixmap->GetDmaBufPitch(plane), plane, | 53 size.width(), size.height(), pixmap->GetDmaBufPitch(plane), plane, |
| 54 pixmap->GetBufferFormat(), color, static_cast<uint8_t*>(data)); | 54 pixmap->GetBufferFormat(), color, static_cast<uint8_t*>(data)); |
| 55 } | 55 } |
| 56 client_pixmap->Unmap(); | 56 client_pixmap->Unmap(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 scoped_refptr<ui::GLImageNativePixmap> image(new ui::GLImageNativePixmap( | 59 scoped_refptr<gl::GLImageNativePixmap> image(new gl::GLImageNativePixmap( |
| 60 size, ui::GLImageNativePixmap::GetInternalFormatForTesting(format))); | 60 size, gl::GLImageNativePixmap::GetInternalFormatForTesting(format))); |
| 61 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat())); | 61 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat())); |
| 62 return image; | 62 return image; |
| 63 } | 63 } |
| 64 | 64 |
| 65 unsigned GetTextureTarget() const { return GL_TEXTURE_EXTERNAL_OES; } | 65 unsigned GetTextureTarget() const { return GL_TEXTURE_EXTERNAL_OES; } |
| 66 | 66 |
| 67 const uint8_t* GetImageColor() { | 67 const uint8_t* GetImageColor() { |
| 68 if (format == gfx::BufferFormat::R_8) { | 68 if (format == gfx::BufferFormat::R_8) { |
| 69 return kRed; | 69 return kRed; |
| 70 } else if (format == gfx::BufferFormat::YVU_420) { | 70 } else if (format == gfx::BufferFormat::YVU_420) { |
| 71 return kYvuColor; | 71 return kYvuColor; |
| 72 } | 72 } |
| 73 return kGreen; | 73 return kGreen; |
| 74 } | 74 } |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 std::unique_ptr<ui::ClientNativePixmapFactory> client_pixmap_factory_; | 77 std::unique_ptr<gfx::ClientNativePixmapFactory> client_pixmap_factory_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 using GLImageScanoutType = testing::Types< | 80 using GLImageScanoutType = testing::Types< |
| 81 GLImageNativePixmapTestDelegate<gfx::BufferUsage::SCANOUT, | 81 GLImageNativePixmapTestDelegate<gfx::BufferUsage::SCANOUT, |
| 82 gfx::BufferFormat::BGRA_8888>>; | 82 gfx::BufferFormat::BGRA_8888>>; |
| 83 | 83 |
| 84 INSTANTIATE_TYPED_TEST_CASE_P(GLImageNativePixmapScanout, | 84 INSTANTIATE_TYPED_TEST_CASE_P(GLImageNativePixmapScanout, |
| 85 GLImageTest, | 85 GLImageTest, |
| 86 GLImageScanoutType); | 86 GLImageScanoutType); |
| 87 | 87 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 105 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageNativePixmapReadWrite, | 105 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageNativePixmapReadWrite, |
| 106 GLImageTest, | 106 GLImageTest, |
| 107 GLImageReadWriteType); | 107 GLImageReadWriteType); |
| 108 | 108 |
| 109 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageNativePixmap, | 109 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageNativePixmap, |
| 110 GLImageBindTest, | 110 GLImageBindTest, |
| 111 GLImageBindTestTypes); | 111 GLImageBindTestTypes); |
| 112 | 112 |
| 113 } // namespace | 113 } // namespace |
| 114 } // namespace gl | 114 } // namespace gl |
| OLD | NEW |