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 width_in_bytes = | |
98 GpuMemoryBufferImpl::StrideInBytes(size.width(), format); | |
99 DCHECK_EQ(width_in_bytes % size.width(), 0u); | |
97 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; | 100 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; |
98 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, | 101 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, |
99 0, | 102 0, |
100 &kCFTypeDictionaryKeyCallBacks, | 103 &kCFTypeDictionaryKeyCallBacks, |
101 &kCFTypeDictionaryValueCallBacks)); | 104 &kCFTypeDictionaryValueCallBacks)); |
102 AddIntegerValue(properties, kIOSurfaceWidth, size.width()); | 105 AddIntegerValue(properties, kIOSurfaceWidth, size.width()); |
103 AddIntegerValue(properties, kIOSurfaceHeight, size.height()); | 106 AddIntegerValue(properties, kIOSurfaceHeight, size.height()); |
104 AddIntegerValue(properties, kIOSurfaceBytesPerElement, BytesPerPixel(format)); | 107 AddIntegerValue(properties, kIOSurfaceBytesPerElement, |
108 width_in_bytes / size.width()); | |
reveman
2014/12/18 18:49:57
nit: Please keep using BytesPerPixel here instead.
christiank
2015/01/12 10:35:22
Alright, I missed that this file actually had its
| |
105 AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); | 109 AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); |
106 // TODO(reveman): Remove this when using a mach_port_t to transfer | 110 // TODO(reveman): Remove this when using a mach_port_t to transfer |
107 // IOSurface to browser and renderer process. crbug.com/323304 | 111 // IOSurface to browser and renderer process. crbug.com/323304 |
108 AddBooleanValue(properties, kIOSurfaceIsGlobal, true); | 112 AddBooleanValue(properties, kIOSurfaceIsGlobal, true); |
109 | 113 |
110 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties)); | 114 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties)); |
111 if (!io_surface) | 115 if (!io_surface) |
112 return gfx::GpuMemoryBufferHandle(); | 116 return gfx::GpuMemoryBufferHandle(); |
113 | 117 |
114 { | 118 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 return scoped_refptr<gfx::GLImage>(); | 161 return scoped_refptr<gfx::GLImage>(); |
158 | 162 |
159 scoped_refptr<gfx::GLImageIOSurface> image(new gfx::GLImageIOSurface(size)); | 163 scoped_refptr<gfx::GLImageIOSurface> image(new gfx::GLImageIOSurface(size)); |
160 if (!image->Initialize(it->second.get())) | 164 if (!image->Initialize(it->second.get())) |
161 return scoped_refptr<gfx::GLImage>(); | 165 return scoped_refptr<gfx::GLImage>(); |
162 | 166 |
163 return image; | 167 return image; |
164 } | 168 } |
165 | 169 |
166 } // namespace content | 170 } // namespace content |
OLD | NEW |