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 "gpu/ipc/service/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.h" |
9 #include "ui/ozone/public/client_native_pixmap_factory.h" | 9 #include "ui/ozone/public/client_native_pixmap_factory.h" |
10 #include "ui/ozone/public/ozone_platform.h" | 10 #include "ui/ozone/public/ozone_platform.h" |
11 #include "ui/ozone/public/surface_factory_ozone.h" | 11 #include "ui/ozone/public/surface_factory_ozone.h" |
12 | 12 |
13 namespace content { | 13 namespace gpu { |
14 | 14 |
15 GpuMemoryBufferFactoryOzoneNativePixmap:: | 15 GpuMemoryBufferFactoryOzoneNativePixmap:: |
16 GpuMemoryBufferFactoryOzoneNativePixmap() {} | 16 GpuMemoryBufferFactoryOzoneNativePixmap() {} |
17 | 17 |
18 GpuMemoryBufferFactoryOzoneNativePixmap:: | 18 GpuMemoryBufferFactoryOzoneNativePixmap:: |
19 ~GpuMemoryBufferFactoryOzoneNativePixmap() {} | 19 ~GpuMemoryBufferFactoryOzoneNativePixmap() {} |
20 | 20 |
21 gfx::GpuMemoryBufferHandle | 21 gfx::GpuMemoryBufferHandle |
22 GpuMemoryBufferFactoryOzoneNativePixmap::CreateGpuMemoryBuffer( | 22 GpuMemoryBufferFactoryOzoneNativePixmap::CreateGpuMemoryBuffer( |
23 gfx::GpuMemoryBufferId id, | 23 gfx::GpuMemoryBufferId id, |
24 const gfx::Size& size, | 24 const gfx::Size& size, |
25 gfx::BufferFormat format, | 25 gfx::BufferFormat format, |
26 gfx::BufferUsage usage, | 26 gfx::BufferUsage usage, |
27 int client_id, | 27 int client_id, |
28 gpu::SurfaceHandle surface_handle) { | 28 SurfaceHandle surface_handle) { |
29 scoped_refptr<ui::NativePixmap> pixmap = | 29 scoped_refptr<ui::NativePixmap> pixmap = |
30 ui::OzonePlatform::GetInstance() | 30 ui::OzonePlatform::GetInstance() |
31 ->GetSurfaceFactoryOzone() | 31 ->GetSurfaceFactoryOzone() |
32 ->CreateNativePixmap(surface_handle, size, format, usage); | 32 ->CreateNativePixmap(surface_handle, size, format, usage); |
33 if (!pixmap.get()) { | 33 if (!pixmap.get()) { |
34 DLOG(ERROR) << "Failed to create pixmap " << size.width() << "x" | 34 DLOG(ERROR) << "Failed to create pixmap " << size.width() << "x" |
35 << size.height() << " format " << static_cast<int>(format) | 35 << size.height() << " format " << static_cast<int>(format) |
36 << ", usage " << static_cast<int>(usage); | 36 << ", usage " << static_cast<int>(usage); |
37 return gfx::GpuMemoryBufferHandle(); | 37 return gfx::GpuMemoryBufferHandle(); |
38 } | 38 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 void GpuMemoryBufferFactoryOzoneNativePixmap::DestroyGpuMemoryBuffer( | 87 void GpuMemoryBufferFactoryOzoneNativePixmap::DestroyGpuMemoryBuffer( |
88 gfx::GpuMemoryBufferId id, | 88 gfx::GpuMemoryBufferId id, |
89 int client_id) { | 89 int client_id) { |
90 base::AutoLock lock(native_pixmaps_lock_); | 90 base::AutoLock lock(native_pixmaps_lock_); |
91 auto it = native_pixmaps_.find(NativePixmapMapKey(id.id, client_id)); | 91 auto it = native_pixmaps_.find(NativePixmapMapKey(id.id, client_id)); |
92 DCHECK(it != native_pixmaps_.end()); | 92 DCHECK(it != native_pixmaps_.end()); |
93 native_pixmaps_.erase(it); | 93 native_pixmaps_.erase(it); |
94 } | 94 } |
95 | 95 |
96 gpu::ImageFactory* GpuMemoryBufferFactoryOzoneNativePixmap::AsImageFactory() { | 96 ImageFactory* GpuMemoryBufferFactoryOzoneNativePixmap::AsImageFactory() { |
97 return this; | 97 return this; |
98 } | 98 } |
99 | 99 |
100 scoped_refptr<gl::GLImage> | 100 scoped_refptr<gl::GLImage> |
101 GpuMemoryBufferFactoryOzoneNativePixmap::CreateImageForGpuMemoryBuffer( | 101 GpuMemoryBufferFactoryOzoneNativePixmap::CreateImageForGpuMemoryBuffer( |
102 const gfx::GpuMemoryBufferHandle& handle, | 102 const gfx::GpuMemoryBufferHandle& handle, |
103 const gfx::Size& size, | 103 const gfx::Size& size, |
104 gfx::BufferFormat format, | 104 gfx::BufferFormat format, |
105 unsigned internalformat, | 105 unsigned internalformat, |
106 int client_id) { | 106 int client_id) { |
(...skipping 11 matching lines...) Expand all Loading... |
118 | 118 |
119 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( | 119 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( |
120 new gfx::GLImageOzoneNativePixmap(size, internalformat)); | 120 new gfx::GLImageOzoneNativePixmap(size, internalformat)); |
121 if (!image->Initialize(pixmap.get(), format)) { | 121 if (!image->Initialize(pixmap.get(), format)) { |
122 LOG(ERROR) << "Failed to create GLImage"; | 122 LOG(ERROR) << "Failed to create GLImage"; |
123 return nullptr; | 123 return nullptr; |
124 } | 124 } |
125 return image; | 125 return image; |
126 } | 126 } |
127 | 127 |
128 } // namespace content | 128 } // namespace gpu |
OLD | NEW |