OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h" | 5 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h" |
6 | 6 |
7 #include "ui/gl/gl_image_ozone_native_pixmap.h" | 7 #include "ui/gl/gl_image_ozone_native_pixmap.h" |
| 8 #include "ui/ozone/public/client_native_pixmap.h" |
8 #include "ui/ozone/public/client_native_pixmap_factory.h" | 9 #include "ui/ozone/public/client_native_pixmap_factory.h" |
9 #include "ui/ozone/public/ozone_platform.h" | 10 #include "ui/ozone/public/ozone_platform.h" |
10 #include "ui/ozone/public/surface_factory_ozone.h" | 11 #include "ui/ozone/public/surface_factory_ozone.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 namespace { | 14 namespace { |
14 | 15 |
15 void GetSupportedConfigurations( | 16 void GetSupportedConfigurations( |
16 std::vector<GpuMemoryBufferFactory::Configuration>* configurations) { | 17 std::vector<GpuMemoryBufferFactory::Configuration>* configurations) { |
17 if (!ui::ClientNativePixmapFactory::GetInstance()) { | 18 if (!ui::ClientNativePixmapFactory::GetInstance()) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 scoped_refptr<ui::NativePixmap> pixmap = | 68 scoped_refptr<ui::NativePixmap> pixmap = |
68 ui::OzonePlatform::GetInstance() | 69 ui::OzonePlatform::GetInstance() |
69 ->GetSurfaceFactoryOzone() | 70 ->GetSurfaceFactoryOzone() |
70 ->CreateNativePixmap(surface_handle, size, format, usage); | 71 ->CreateNativePixmap(surface_handle, size, format, usage); |
71 if (!pixmap.get()) { | 72 if (!pixmap.get()) { |
72 LOG(ERROR) << "Failed to create pixmap " << size.width() << "x" | 73 LOG(ERROR) << "Failed to create pixmap " << size.width() << "x" |
73 << size.height() << " format " << static_cast<int>(format) | 74 << size.height() << " format " << static_cast<int>(format) |
74 << ", usage " << static_cast<int>(usage); | 75 << ", usage " << static_cast<int>(usage); |
75 return gfx::GpuMemoryBufferHandle(); | 76 return gfx::GpuMemoryBufferHandle(); |
76 } | 77 } |
77 base::AutoLock lock(native_pixmaps_lock_); | |
78 NativePixmapMapKey key(id.id, client_id); | |
79 DCHECK(native_pixmaps_.find(key) == native_pixmaps_.end()) | |
80 << "pixmap with this key must not exist"; | |
81 native_pixmaps_[key] = pixmap; | |
82 | 78 |
83 gfx::GpuMemoryBufferHandle handle; | 79 gfx::GpuMemoryBufferHandle handle; |
84 handle.type = gfx::OZONE_NATIVE_PIXMAP; | 80 handle.type = gfx::OZONE_NATIVE_PIXMAP; |
85 handle.id = id; | 81 handle.id = id; |
| 82 handle.native_pixmap_handle = pixmap->ExportHandle(); |
| 83 |
| 84 { |
| 85 base::AutoLock lock(native_pixmaps_lock_); |
| 86 NativePixmapMapKey key(id.id, client_id); |
| 87 DCHECK(native_pixmaps_.find(key) == native_pixmaps_.end()); |
| 88 native_pixmaps_[key] = pixmap; |
| 89 } |
| 90 |
86 return handle; | 91 return handle; |
87 } | 92 } |
88 | 93 |
89 void GpuMemoryBufferFactoryOzoneNativePixmap::DestroyGpuMemoryBuffer( | 94 void GpuMemoryBufferFactoryOzoneNativePixmap::DestroyGpuMemoryBuffer( |
90 gfx::GpuMemoryBufferId id, | 95 gfx::GpuMemoryBufferId id, |
91 int client_id) { | 96 int client_id) { |
92 base::AutoLock lock(native_pixmaps_lock_); | 97 base::AutoLock lock(native_pixmaps_lock_); |
93 auto it = native_pixmaps_.find(NativePixmapMapKey(id.id, client_id)); | 98 auto it = native_pixmaps_.find(NativePixmapMapKey(id.id, client_id)); |
94 DCHECK(it != native_pixmaps_.end()) << "pixmap with this key must exist"; | 99 DCHECK(it != native_pixmaps_.end()); |
95 native_pixmaps_.erase(it); | 100 native_pixmaps_.erase(it); |
96 } | 101 } |
97 | 102 |
98 gpu::ImageFactory* GpuMemoryBufferFactoryOzoneNativePixmap::AsImageFactory() { | 103 gpu::ImageFactory* GpuMemoryBufferFactoryOzoneNativePixmap::AsImageFactory() { |
99 return this; | 104 return this; |
100 } | 105 } |
101 | 106 |
102 scoped_refptr<gfx::GLImage> | 107 scoped_refptr<gfx::GLImage> |
103 GpuMemoryBufferFactoryOzoneNativePixmap::CreateImageForGpuMemoryBuffer( | 108 GpuMemoryBufferFactoryOzoneNativePixmap::CreateImageForGpuMemoryBuffer( |
104 const gfx::GpuMemoryBufferHandle& handle, | 109 const gfx::GpuMemoryBufferHandle& handle, |
(...skipping 16 matching lines...) Expand all Loading... |
121 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( | 126 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( |
122 new gfx::GLImageOzoneNativePixmap(size, internalformat)); | 127 new gfx::GLImageOzoneNativePixmap(size, internalformat)); |
123 if (!image->Initialize(pixmap.get(), format)) { | 128 if (!image->Initialize(pixmap.get(), format)) { |
124 LOG(ERROR) << "Failed to create GLImage"; | 129 LOG(ERROR) << "Failed to create GLImage"; |
125 return nullptr; | 130 return nullptr; |
126 } | 131 } |
127 return image; | 132 return image; |
128 } | 133 } |
129 | 134 |
130 } // namespace content | 135 } // namespace content |
OLD | NEW |