| 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 20 matching lines...) Expand all Loading... |
| 31 const uint8_t color[4]) const { | 31 const uint8_t color[4]) const { |
| 32 ui::SurfaceFactoryOzone* surface_factory = | 32 ui::SurfaceFactoryOzone* surface_factory = |
| 33 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); | 33 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); |
| 34 scoped_refptr<ui::NativePixmap> pixmap = | 34 scoped_refptr<ui::NativePixmap> pixmap = |
| 35 surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, | 35 surface_factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, |
| 36 format, usage); | 36 format, usage); |
| 37 DCHECK(pixmap); | 37 DCHECK(pixmap); |
| 38 if (usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE) { | 38 if (usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE) { |
| 39 auto client_pixmap = client_pixmap_factory_->ImportFromHandle( | 39 auto client_pixmap = client_pixmap_factory_->ImportFromHandle( |
| 40 pixmap->ExportHandle(), size, usage); | 40 pixmap->ExportHandle(), size, usage); |
| 41 bool mapped = client_pixmap->Map(); | 41 void* data = client_pixmap->Map(); |
| 42 EXPECT_TRUE(mapped); | 42 EXPECT_TRUE(data); |
| 43 | 43 GLImageTestSupport::SetBufferDataToColor( |
| 44 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format); | 44 size.width(), size.height(), pixmap->GetDmaBufPitch(0), 0, |
| 45 ++plane) { | 45 pixmap->GetBufferFormat(), color, static_cast<uint8_t*>(data)); |
| 46 void* data = client_pixmap->GetMemoryAddress(plane); | |
| 47 GLImageTestSupport::SetBufferDataToColor( | |
| 48 size.width(), size.height(), pixmap->GetDmaBufPitch(plane), plane, | |
| 49 pixmap->GetBufferFormat(), color, static_cast<uint8_t*>(data)); | |
| 50 } | |
| 51 client_pixmap->Unmap(); | 46 client_pixmap->Unmap(); |
| 52 } | 47 } |
| 53 | 48 |
| 54 scoped_refptr<ui::GLImageOzoneNativePixmap> image( | 49 scoped_refptr<ui::GLImageOzoneNativePixmap> image( |
| 55 new ui::GLImageOzoneNativePixmap( | 50 new ui::GLImageOzoneNativePixmap( |
| 56 size, | 51 size, |
| 57 ui::GLImageOzoneNativePixmap::GetInternalFormatForTesting(format))); | 52 ui::GLImageOzoneNativePixmap::GetInternalFormatForTesting(format))); |
| 58 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat())); | 53 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat())); |
| 59 return image; | 54 return image; |
| 60 } | 55 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmapReadWrite, | 91 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmapReadWrite, |
| 97 GLImageTest, | 92 GLImageTest, |
| 98 GLImageReadWriteType); | 93 GLImageReadWriteType); |
| 99 | 94 |
| 100 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmap, | 95 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmap, |
| 101 GLImageBindTest, | 96 GLImageBindTest, |
| 102 GLImageBindTestTypes); | 97 GLImageBindTestTypes); |
| 103 | 98 |
| 104 } // namespace | 99 } // namespace |
| 105 } // namespace gl | 100 } // namespace gl |
| OLD | NEW |