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

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

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: rebase Created 6 years, 2 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 "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h" 9 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h"
10 #include "ui/gl/gl_image_io_surface.h" 10 #include "ui/gl/gl_image_io_surface.h"
(...skipping 21 matching lines...) Expand all
32 GpuMemoryBufferFactoryIOSurface::GpuMemoryBufferFactoryIOSurface() { 32 GpuMemoryBufferFactoryIOSurface::GpuMemoryBufferFactoryIOSurface() {
33 } 33 }
34 34
35 GpuMemoryBufferFactoryIOSurface::~GpuMemoryBufferFactoryIOSurface() { 35 GpuMemoryBufferFactoryIOSurface::~GpuMemoryBufferFactoryIOSurface() {
36 } 36 }
37 37
38 gfx::GpuMemoryBufferHandle 38 gfx::GpuMemoryBufferHandle
39 GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( 39 GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer(
40 const gfx::GpuMemoryBufferId& id, 40 const gfx::GpuMemoryBufferId& id,
41 const gfx::Size& size, 41 const gfx::Size& size,
42 unsigned internalformat) { 42 gfx::GpuMemoryBuffer::Format format) {
43 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; 43 base::ScopedCFTypeRef<CFMutableDictionaryRef> properties;
44 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, 44 properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault,
45 0, 45 0,
46 &kCFTypeDictionaryKeyCallBacks, 46 &kCFTypeDictionaryKeyCallBacks,
47 &kCFTypeDictionaryValueCallBacks)); 47 &kCFTypeDictionaryValueCallBacks));
48 AddIntegerValue(properties, kIOSurfaceWidth, size.width()); 48 AddIntegerValue(properties, kIOSurfaceWidth, size.width());
49 AddIntegerValue(properties, kIOSurfaceHeight, size.height()); 49 AddIntegerValue(properties, kIOSurfaceHeight, size.height());
50 AddIntegerValue(properties, 50 AddIntegerValue(properties,
51 kIOSurfaceBytesPerElement, 51 kIOSurfaceBytesPerElement,
52 GpuMemoryBufferImpl::BytesPerPixel(internalformat)); 52 GpuMemoryBufferImpl::BytesPerPixel(format));
53 AddIntegerValue(properties, 53 AddIntegerValue(properties,
54 kIOSurfacePixelFormat, 54 kIOSurfacePixelFormat,
55 GpuMemoryBufferImplIOSurface::PixelFormat(internalformat)); 55 GpuMemoryBufferImplIOSurface::PixelFormat(format));
56 // TODO(reveman): Remove this when using a mach_port_t to transfer 56 // TODO(reveman): Remove this when using a mach_port_t to transfer
57 // IOSurface to browser and renderer process. crbug.com/323304 57 // IOSurface to browser and renderer process. crbug.com/323304
58 AddBooleanValue(properties, kIOSurfaceIsGlobal, true); 58 AddBooleanValue(properties, kIOSurfaceIsGlobal, true);
59 59
60 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties)); 60 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties));
61 if (!io_surface) 61 if (!io_surface)
62 return gfx::GpuMemoryBufferHandle(); 62 return gfx::GpuMemoryBufferHandle();
63 63
64 IOSurfaceMapKey key(id.primary_id, id.secondary_id); 64 IOSurfaceMapKey key(id.primary_id, id.secondary_id);
65 DCHECK(io_surfaces_.find(key) == io_surfaces_.end()); 65 DCHECK(io_surfaces_.find(key) == io_surfaces_.end());
(...skipping 11 matching lines...) Expand all
77 IOSurfaceMapKey key(id.primary_id, id.secondary_id); 77 IOSurfaceMapKey key(id.primary_id, id.secondary_id);
78 IOSurfaceMap::iterator it = io_surfaces_.find(key); 78 IOSurfaceMap::iterator it = io_surfaces_.find(key);
79 if (it != io_surfaces_.end()) 79 if (it != io_surfaces_.end())
80 io_surfaces_.erase(it); 80 io_surfaces_.erase(it);
81 } 81 }
82 82
83 scoped_refptr<gfx::GLImage> 83 scoped_refptr<gfx::GLImage>
84 GpuMemoryBufferFactoryIOSurface::CreateImageForGpuMemoryBuffer( 84 GpuMemoryBufferFactoryIOSurface::CreateImageForGpuMemoryBuffer(
85 const gfx::GpuMemoryBufferId& id, 85 const gfx::GpuMemoryBufferId& id,
86 const gfx::Size& size, 86 const gfx::Size& size,
87 unsigned internalformat) { 87 gfx::GpuMemoryBuffer::Format format) {
88 IOSurfaceMapKey key(id.primary_id, id.secondary_id); 88 IOSurfaceMapKey key(id.primary_id, id.secondary_id);
89 IOSurfaceMap::iterator it = io_surfaces_.find(key); 89 IOSurfaceMap::iterator it = io_surfaces_.find(key);
90 if (it == io_surfaces_.end()) 90 if (it == io_surfaces_.end())
91 return scoped_refptr<gfx::GLImage>(); 91 return scoped_refptr<gfx::GLImage>();
92 92
93 scoped_refptr<gfx::GLImageIOSurface> image(new gfx::GLImageIOSurface(size)); 93 scoped_refptr<gfx::GLImageIOSurface> image(new gfx::GLImageIOSurface(size));
94 if (!image->Initialize(it->second.get())) 94 if (!image->Initialize(it->second.get()))
95 return scoped_refptr<gfx::GLImage>(); 95 return scoped_refptr<gfx::GLImage>();
96 96
97 return image; 97 return image;
98 } 98 }
99 99
100 } // namespace content 100 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_memory_buffer_factory_io_surface.h ('k') | content/common/gpu/gpu_memory_buffer_factory_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698