Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: content/common/gpu/gpu_memory_buffer_factory_io_surface.cc

Issue 1282313002: Add YUV_420_BIPLANAR to gfx::BufferFormat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gmb-planes
Patch Set: Fix ozone build Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "content/common/mac/io_surface_manager.h" 12 #include "content/common/mac/io_surface_manager.h"
13 #include "ui/gl/gl_image_io_surface.h" 13 #include "ui/gl/gl_image_io_surface.h"
14 14
15 namespace content { 15 namespace content {
16 namespace { 16 namespace {
17 17
18 void AddIntegerValue(CFMutableDictionaryRef dictionary, 18 void AddIntegerValue(CFMutableDictionaryRef dictionary,
19 const CFStringRef key, 19 const CFStringRef key,
20 int32 value) { 20 int32 value) {
21 base::ScopedCFTypeRef<CFNumberRef> number( 21 base::ScopedCFTypeRef<CFNumberRef> number(
22 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); 22 CFNumberCreate(NULL, kCFNumberSInt32Type, &value));
23 CFDictionaryAddValue(dictionary, key, number.get()); 23 CFDictionaryAddValue(dictionary, key, number.get());
24 } 24 }
25 25
26 int32 BytesPerPixel(gfx::BufferFormat format) { 26 int32 BytesPerPixel(gfx::BufferFormat format) {
27 switch (format) { 27 switch (format) {
28 case gfx::BufferFormat::R_8: 28 case gfx::BufferFormat::R_8:
29 case gfx::BufferFormat::YUV_420_BIPLANAR:
29 return 1; 30 return 1;
30 case gfx::BufferFormat::BGRA_8888: 31 case gfx::BufferFormat::BGRA_8888:
31 return 4; 32 return 4;
32 case gfx::BufferFormat::ATC: 33 case gfx::BufferFormat::ATC:
33 case gfx::BufferFormat::ATCIA: 34 case gfx::BufferFormat::ATCIA:
34 case gfx::BufferFormat::DXT1: 35 case gfx::BufferFormat::DXT1:
35 case gfx::BufferFormat::DXT5: 36 case gfx::BufferFormat::DXT5:
36 case gfx::BufferFormat::ETC1: 37 case gfx::BufferFormat::ETC1:
37 case gfx::BufferFormat::RGBA_4444: 38 case gfx::BufferFormat::RGBA_4444:
38 case gfx::BufferFormat::RGBA_8888: 39 case gfx::BufferFormat::RGBA_8888:
39 case gfx::BufferFormat::RGBX_8888: 40 case gfx::BufferFormat::RGBX_8888:
40 case gfx::BufferFormat::YUV_420: 41 case gfx::BufferFormat::YUV_420:
41 NOTREACHED(); 42 NOTREACHED();
42 return 0; 43 return 0;
43 } 44 }
44 45
45 NOTREACHED(); 46 NOTREACHED();
46 return 0; 47 return 0;
47 } 48 }
48 49
49 int32 PixelFormat(gfx::BufferFormat format) { 50 int32 PixelFormat(gfx::BufferFormat format) {
50 switch (format) { 51 switch (format) {
51 case gfx::BufferFormat::R_8: 52 case gfx::BufferFormat::R_8:
52 return 'L008'; 53 return 'L008';
53 case gfx::BufferFormat::BGRA_8888: 54 case gfx::BufferFormat::BGRA_8888:
54 return 'BGRA'; 55 return 'BGRA';
56 case gfx::BufferFormat::YUV_420_BIPLANAR:
57 return '420v';
55 case gfx::BufferFormat::ATC: 58 case gfx::BufferFormat::ATC:
56 case gfx::BufferFormat::ATCIA: 59 case gfx::BufferFormat::ATCIA:
57 case gfx::BufferFormat::DXT1: 60 case gfx::BufferFormat::DXT1:
58 case gfx::BufferFormat::DXT5: 61 case gfx::BufferFormat::DXT5:
59 case gfx::BufferFormat::ETC1: 62 case gfx::BufferFormat::ETC1:
60 case gfx::BufferFormat::RGBA_4444: 63 case gfx::BufferFormat::RGBA_4444:
61 case gfx::BufferFormat::RGBA_8888: 64 case gfx::BufferFormat::RGBA_8888:
62 case gfx::BufferFormat::RGBX_8888: 65 case gfx::BufferFormat::RGBX_8888:
63 case gfx::BufferFormat::YUV_420: 66 case gfx::BufferFormat::YUV_420:
64 NOTREACHED(); 67 NOTREACHED();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 int client_id, 115 int client_id,
113 gfx::PluginWindowHandle surface_handle) { 116 gfx::PluginWindowHandle surface_handle) {
114 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; 117 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties;
115 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, 118 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault,
116 0, 119 0,
117 &kCFTypeDictionaryKeyCallBacks, 120 &kCFTypeDictionaryKeyCallBacks,
118 &kCFTypeDictionaryValueCallBacks)); 121 &kCFTypeDictionaryValueCallBacks));
119 AddIntegerValue(properties, kIOSurfaceWidth, size.width()); 122 AddIntegerValue(properties, kIOSurfaceWidth, size.width());
120 AddIntegerValue(properties, kIOSurfaceHeight, size.height()); 123 AddIntegerValue(properties, kIOSurfaceHeight, size.height());
121 AddIntegerValue(properties, kIOSurfaceBytesPerElement, BytesPerPixel(format)); 124 AddIntegerValue(properties, kIOSurfaceBytesPerElement, BytesPerPixel(format));
122 AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); 125 AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format));
ccameron 2015/08/10 19:35:08 I think that, for biplanar, this part needs a dict
Andre 2015/08/10 20:15:25 Yep, I'm working on that on a follow-up patch, whi
reveman 2015/08/10 20:28:16 It's fine to save that for a follow up patch but I
Andre 2015/08/10 21:09:48 The follow up patch is https://codereview.chromium
123 126
124 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties)); 127 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties));
125 if (!io_surface) 128 if (!io_surface)
126 return gfx::GpuMemoryBufferHandle(); 129 return gfx::GpuMemoryBufferHandle();
127 130
128 if (!IOSurfaceManager::GetInstance()->RegisterIOSurface(id, client_id, 131 if (!IOSurfaceManager::GetInstance()->RegisterIOSurface(id, client_id,
129 io_surface)) { 132 io_surface)) {
130 return gfx::GpuMemoryBufferHandle(); 133 return gfx::GpuMemoryBufferHandle();
131 } 134 }
132 135
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 182
180 scoped_refptr<gfx::GLImageIOSurface> image( 183 scoped_refptr<gfx::GLImageIOSurface> image(
181 new gfx::GLImageIOSurface(size, internalformat)); 184 new gfx::GLImageIOSurface(size, internalformat));
182 if (!image->Initialize(it->second.get(), format)) 185 if (!image->Initialize(it->second.get(), format))
183 return scoped_refptr<gfx::GLImage>(); 186 return scoped_refptr<gfx::GLImage>();
184 187
185 return image; 188 return image;
186 } 189 }
187 190
188 } // namespace content 191 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698