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_io_surface.h" | 5 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/gl/gl_image_io_surface.h" | 10 #include "ui/gl/gl_image_io_surface.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 | 88 |
89 gfx::GpuMemoryBufferHandle | 89 gfx::GpuMemoryBufferHandle |
90 GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( | 90 GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( |
91 gfx::GpuMemoryBufferId id, | 91 gfx::GpuMemoryBufferId id, |
92 const gfx::Size& size, | 92 const gfx::Size& size, |
93 gfx::GpuMemoryBuffer::Format format, | 93 gfx::GpuMemoryBuffer::Format format, |
94 gfx::GpuMemoryBuffer::Usage usage, | 94 gfx::GpuMemoryBuffer::Usage usage, |
95 int client_id, | 95 int client_id, |
96 gfx::PluginWindowHandle surface_handle) { | 96 gfx::PluginWindowHandle surface_handle) { |
| 97 size_t bits_per_pixel = GpuMemoryBufferImpl::BitsPerPixel(format); |
97 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; | 98 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; |
98 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, | 99 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, |
99 0, | 100 0, |
100 &kCFTypeDictionaryKeyCallBacks, | 101 &kCFTypeDictionaryKeyCallBacks, |
101 &kCFTypeDictionaryValueCallBacks)); | 102 &kCFTypeDictionaryValueCallBacks)); |
102 AddIntegerValue(properties, kIOSurfaceWidth, size.width()); | 103 AddIntegerValue(properties, kIOSurfaceWidth, size.width()); |
103 AddIntegerValue(properties, kIOSurfaceHeight, size.height()); | 104 AddIntegerValue(properties, kIOSurfaceHeight, size.height()); |
104 AddIntegerValue(properties, kIOSurfaceBytesPerElement, BytesPerPixel(format)); | 105 AddIntegerValue(properties, kIOSurfaceBytesPerElement, |
| 106 BitsPerPixel(format) / 8); |
105 AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); | 107 AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); |
106 // TODO(reveman): Remove this when using a mach_port_t to transfer | 108 // TODO(reveman): Remove this when using a mach_port_t to transfer |
107 // IOSurface to browser and renderer process. crbug.com/323304 | 109 // IOSurface to browser and renderer process. crbug.com/323304 |
108 AddBooleanValue(properties, kIOSurfaceIsGlobal, true); | 110 AddBooleanValue(properties, kIOSurfaceIsGlobal, true); |
109 | 111 |
110 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties)); | 112 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties)); |
111 if (!io_surface) | 113 if (!io_surface) |
112 return gfx::GpuMemoryBufferHandle(); | 114 return gfx::GpuMemoryBufferHandle(); |
113 | 115 |
114 { | 116 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return scoped_refptr<gfx::GLImage>(); | 159 return scoped_refptr<gfx::GLImage>(); |
158 | 160 |
159 scoped_refptr<gfx::GLImageIOSurface> image(new gfx::GLImageIOSurface(size)); | 161 scoped_refptr<gfx::GLImageIOSurface> image(new gfx::GLImageIOSurface(size)); |
160 if (!image->Initialize(it->second.get())) | 162 if (!image->Initialize(it->second.get())) |
161 return scoped_refptr<gfx::GLImage>(); | 163 return scoped_refptr<gfx::GLImage>(); |
162 | 164 |
163 return image; | 165 return image; |
164 } | 166 } |
165 | 167 |
166 } // namespace content | 168 } // namespace content |
OLD | NEW |