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 "ui/gl/gl_image.h" | 8 #include "ui/gl/gl_image.h" |
9 #include "ui/gl/gl_image_shared_memory.h" | 9 #include "ui/gl/gl_image_shared_memory.h" |
10 #include "ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h" | 10 #include "ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( | 45 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( |
46 const gfx::GpuMemoryBufferHandle& handle, | 46 const gfx::GpuMemoryBufferHandle& handle, |
47 const gfx::Size& size, | 47 const gfx::Size& size, |
48 unsigned internalformat, | 48 unsigned internalformat, |
49 int client_id) override { | 49 int client_id) override { |
50 switch (handle.type) { | 50 switch (handle.type) { |
51 case gfx::SHARED_MEMORY_BUFFER: { | 51 case gfx::SHARED_MEMORY_BUFFER: { |
52 scoped_refptr<gfx::GLImageSharedMemory> image( | 52 scoped_refptr<gfx::GLImageSharedMemory> image( |
53 new gfx::GLImageSharedMemory(size, internalformat)); | 53 new gfx::GLImageSharedMemory(size, internalformat)); |
54 if (!image->Initialize(handle)) | 54 if (!image->Initialize(handle)) |
55 return NULL; | 55 return nullptr; |
56 | 56 |
57 return image; | 57 return image; |
58 } | 58 } |
59 case gfx::OZONE_NATIVE_BUFFER: | 59 case gfx::OZONE_NATIVE_BUFFER: |
60 // Verify that client is the owner of the buffer we're about to use. | 60 // Verify that client is the owner of the buffer we're about to use. |
61 if (handle.global_id.secondary_id != client_id) | 61 if (handle.global_id.secondary_id != client_id) |
62 return scoped_refptr<gfx::GLImage>(); | 62 return scoped_refptr<gfx::GLImage>(); |
63 | 63 |
64 return ozone_buffer_factory_.CreateImageForGpuMemoryBuffer( | 64 return ozone_buffer_factory_.CreateImageForGpuMemoryBuffer( |
65 handle.global_id, size, internalformat); | 65 handle.global_id, size, internalformat); |
66 default: | 66 default: |
67 NOTREACHED(); | 67 NOTREACHED(); |
68 return scoped_refptr<gfx::GLImage>(); | 68 return scoped_refptr<gfx::GLImage>(); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 private: | 72 private: |
73 ui::GpuMemoryBufferFactoryOzoneNativeBuffer ozone_buffer_factory_; | 73 ui::GpuMemoryBufferFactoryOzoneNativeBuffer ozone_buffer_factory_; |
74 }; | 74 }; |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 | 77 |
78 // static | 78 // static |
79 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { | 79 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { |
80 return make_scoped_ptr<GpuMemoryBufferFactory>( | 80 return make_scoped_ptr<GpuMemoryBufferFactory>( |
81 new GpuMemoryBufferFactoryImpl); | 81 new GpuMemoryBufferFactoryImpl); |
82 } | 82 } |
83 | 83 |
84 } // namespace content | 84 } // namespace content |
OLD | NEW |