| 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.h" | 5 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" | 8 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" |
| 9 #include "ui/gl/gl_image.h" | 9 #include "ui/gl/gl_image.h" |
| 10 #include "ui/gl/gl_image_shared_memory.h" | 10 #include "ui/gl/gl_image_shared_memory.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( | 43 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( |
| 44 const gfx::GpuMemoryBufferHandle& handle, | 44 const gfx::GpuMemoryBufferHandle& handle, |
| 45 const gfx::Size& size, | 45 const gfx::Size& size, |
| 46 unsigned internalformat, | 46 unsigned internalformat, |
| 47 int client_id) override { | 47 int client_id) override { |
| 48 switch (handle.type) { | 48 switch (handle.type) { |
| 49 case gfx::SHARED_MEMORY_BUFFER: { | 49 case gfx::SHARED_MEMORY_BUFFER: { |
| 50 scoped_refptr<gfx::GLImageSharedMemory> image( | 50 scoped_refptr<gfx::GLImageSharedMemory> image( |
| 51 new gfx::GLImageSharedMemory(size, internalformat)); | 51 new gfx::GLImageSharedMemory(size, internalformat)); |
| 52 if (!image->Initialize(handle)) | 52 if (!image->Initialize(handle)) |
| 53 return NULL; | 53 return nullptr; |
| 54 | 54 |
| 55 return image; | 55 return image; |
| 56 } | 56 } |
| 57 case gfx::SURFACE_TEXTURE_BUFFER: { | 57 case gfx::SURFACE_TEXTURE_BUFFER: { |
| 58 // Verify that client is the owner of the buffer we're about to use. | 58 // Verify that client is the owner of the buffer we're about to use. |
| 59 if (handle.global_id.secondary_id != client_id) | 59 if (handle.global_id.secondary_id != client_id) |
| 60 return scoped_refptr<gfx::GLImage>(); | 60 return scoped_refptr<gfx::GLImage>(); |
| 61 | 61 |
| 62 return surface_texture_factory_.CreateImageForGpuMemoryBuffer( | 62 return surface_texture_factory_.CreateImageForGpuMemoryBuffer( |
| 63 handle.global_id, size, internalformat); | 63 handle.global_id, size, internalformat); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 74 | 74 |
| 75 } // namespace | 75 } // namespace |
| 76 | 76 |
| 77 // static | 77 // static |
| 78 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { | 78 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { |
| 79 return make_scoped_ptr<GpuMemoryBufferFactory>( | 79 return make_scoped_ptr<GpuMemoryBufferFactory>( |
| 80 new GpuMemoryBufferFactoryImpl); | 80 new GpuMemoryBufferFactoryImpl); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace content | 83 } // namespace content |
| OLD | NEW |