| 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 void* data = client_pixmap->Map(); | 41 bool mapped = client_pixmap->Map(); |
| 42 EXPECT_TRUE(data); | 42 EXPECT_TRUE(mapped); |
| 43 GLImageTestSupport::SetBufferDataToColor( | 43 |
| 44 size.width(), size.height(), pixmap->GetDmaBufPitch(0), 0, | 44 for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format); |
| 45 pixmap->GetBufferFormat(), color, static_cast<uint8_t*>(data)); | 45 ++plane) { |
| 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 } |
| 46 client_pixmap->Unmap(); | 51 client_pixmap->Unmap(); |
| 47 } | 52 } |
| 48 | 53 |
| 49 scoped_refptr<ui::GLImageOzoneNativePixmap> image( | 54 scoped_refptr<ui::GLImageOzoneNativePixmap> image( |
| 50 new ui::GLImageOzoneNativePixmap( | 55 new ui::GLImageOzoneNativePixmap( |
| 51 size, | 56 size, |
| 52 ui::GLImageOzoneNativePixmap::GetInternalFormatForTesting(format))); | 57 ui::GLImageOzoneNativePixmap::GetInternalFormatForTesting(format))); |
| 53 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat())); | 58 EXPECT_TRUE(image->Initialize(pixmap.get(), pixmap->GetBufferFormat())); |
| 54 return image; | 59 return image; |
| 55 } | 60 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmapReadWrite, | 96 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmapReadWrite, |
| 92 GLImageTest, | 97 GLImageTest, |
| 93 GLImageReadWriteType); | 98 GLImageReadWriteType); |
| 94 | 99 |
| 95 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmap, | 100 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmap, |
| 96 GLImageBindTest, | 101 GLImageBindTest, |
| 97 GLImageBindTestTypes); | 102 GLImageBindTestTypes); |
| 98 | 103 |
| 99 } // namespace | 104 } // namespace |
| 100 } // namespace gl | 105 } // namespace gl |
| OLD | NEW |