Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 10 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 gfx::GpuMemoryBufferHandle | 43 gfx::GpuMemoryBufferHandle |
| 44 GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( | 44 GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( |
| 45 gfx::GpuMemoryBufferId id, | 45 gfx::GpuMemoryBufferId id, |
| 46 const gfx::Size& size, | 46 const gfx::Size& size, |
| 47 gfx::BufferFormat format, | 47 gfx::BufferFormat format, |
| 48 gfx::BufferUsage usage, | 48 gfx::BufferUsage usage, |
| 49 int client_id, | 49 int client_id, |
| 50 gfx::PluginWindowHandle surface_handle) { | 50 gfx::PluginWindowHandle surface_handle) { |
| 51 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( | 51 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( |
| 52 gfx::IOSurfaceManager::CreateIOSurface(size, format)); | 52 gfx::IOSurfaceManager::CreateIOSurface(size, format)); |
| 53 if (!io_surface) | 53 CHECK(io_surface); |
|
reveman
2015/12/01 20:49:04
This makes it possible for a malicious renderer to
| |
| 54 return gfx::GpuMemoryBufferHandle(); | |
| 55 | 54 |
| 56 if (!gfx::IOSurfaceManager::GetInstance()->RegisterIOSurface(id, client_id, | 55 bool register_result = |
| 57 io_surface)) { | 56 gfx::IOSurfaceManager::GetInstance()->RegisterIOSurface(id, client_id, |
| 58 return gfx::GpuMemoryBufferHandle(); | 57 io_surface); |
| 59 } | 58 CHECK(register_result); |
|
reveman
2015/12/01 20:49:04
Is it possible that the browser decides to start a
| |
| 60 | 59 |
| 61 { | 60 { |
| 62 base::AutoLock lock(io_surfaces_lock_); | 61 base::AutoLock lock(io_surfaces_lock_); |
| 63 | 62 |
| 64 IOSurfaceMapKey key(id, client_id); | 63 IOSurfaceMapKey key(id, client_id); |
| 65 DCHECK(io_surfaces_.find(key) == io_surfaces_.end()); | 64 DCHECK(io_surfaces_.find(key) == io_surfaces_.end()); |
| 66 io_surfaces_[key] = io_surface; | 65 io_surfaces_[key] = io_surface; |
|
reveman
2015/12/01 20:49:04
FYI, storing the IOSurface here is actually a bug
| |
| 67 } | 66 } |
| 68 | 67 |
| 69 gfx::GpuMemoryBufferHandle handle; | 68 gfx::GpuMemoryBufferHandle handle; |
| 70 handle.type = gfx::IO_SURFACE_BUFFER; | 69 handle.type = gfx::IO_SURFACE_BUFFER; |
| 71 handle.id = id; | 70 handle.id = id; |
| 72 return handle; | 71 return handle; |
| 73 } | 72 } |
| 74 | 73 |
| 75 gfx::GpuMemoryBufferHandle | 74 gfx::GpuMemoryBufferHandle |
| 76 GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBufferFromHandle( | 75 GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBufferFromHandle( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 | 117 |
| 119 scoped_refptr<gl::GLImageIOSurface> image( | 118 scoped_refptr<gl::GLImageIOSurface> image( |
| 120 new gl::GLImageIOSurface(size, internalformat)); | 119 new gl::GLImageIOSurface(size, internalformat)); |
| 121 if (!image->Initialize(it->second.get(), handle.id, format)) | 120 if (!image->Initialize(it->second.get(), handle.id, format)) |
| 122 return scoped_refptr<gl::GLImage>(); | 121 return scoped_refptr<gl::GLImage>(); |
| 123 | 122 |
| 124 return image; | 123 return image; |
| 125 } | 124 } |
| 126 | 125 |
| 127 } // namespace content | 126 } // namespace content |
| OLD | NEW |