Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/gfx/gpu_memory_buffer.h" | 10 #include "ui/gfx/gpu_memory_buffer.h" |
| 11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 class GpuMemoryBufferFactoryHost; | |
| 14 | 15 |
| 15 // Provides common implementation of a GPU memory buffer. | 16 // Provides common implementation of a GPU memory buffer. |
| 16 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { | 17 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { |
| 17 public: | 18 public: |
| 18 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> | 19 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> |
| 19 AllocationCallback; | 20 AllocationCallback; |
| 20 | 21 |
| 21 virtual ~GpuMemoryBufferImpl(); | 22 virtual ~GpuMemoryBufferImpl(); |
| 22 | 23 |
| 23 // Creates a GPU memory buffer instance with |size| and |internalformat| for | 24 // Creates a GPU memory buffer instance with |size| and |internalformat| for |
| 24 // |usage|. | 25 // |usage|. |
| 25 static scoped_ptr<GpuMemoryBufferImpl> Create(const gfx::Size& size, | 26 static scoped_ptr<GpuMemoryBufferImpl> Create(const gfx::Size& size, |
| 26 unsigned internalformat, | 27 unsigned internalformat, |
| 27 unsigned usage); | 28 unsigned usage); |
| 28 | 29 |
| 29 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| | 30 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| |
| 30 // by |child_process|. The |handle| returned can be used by the | 31 // by |child_process|. The |handle| returned can be used by the |
| 31 // |child_process| to create an instance of this class. | 32 // |child_process| to create an instance of this class. |
| 32 static void AllocateForChildProcess(const gfx::Size& size, | 33 // The buffer is being allocated for |client_id| and |gpu_factory_host| can |
| 33 unsigned internalformat, | 34 // be used to talk to the GPU process. |
|
reveman
2014/08/11 19:43:05
I'm not sure we should mention GPU process here. F
achaulk
2014/08/12 19:03:56
Acknowledged.
| |
| 34 unsigned usage, | 35 static void AllocateForChildProcess( |
| 35 base::ProcessHandle child_process, | 36 const gfx::Size& size, |
| 36 const AllocationCallback& callback); | 37 unsigned internalformat, |
| 38 unsigned usage, | |
| 39 base::ProcessHandle child_process, | |
| 40 int client_id, | |
|
reveman
2014/08/11 19:43:05
does child_id make more sense here? this is the fi
achaulk
2014/08/12 19:03:56
Probably yeah
| |
| 41 GpuMemoryBufferFactoryHost* gpu_factory_host, | |
|
reveman
2014/08/11 19:43:05
The implementation of this interface should not be
achaulk
2014/08/12 19:03:56
Done.
| |
| 42 const AllocationCallback& callback); | |
| 37 | 43 |
| 38 // Notify that GPU memory buffer has been deleted by |child_process|. | 44 // Notify that GPU memory buffer has been deleted by |child_process|. |
| 39 static void DeletedByChildProcess(gfx::GpuMemoryBufferType type, | 45 static void DeletedByChildProcess(gfx::GpuMemoryBufferType type, |
| 40 const gfx::GpuMemoryBufferId& id, | 46 const gfx::GpuMemoryBufferId& id, |
| 41 base::ProcessHandle child_process); | 47 base::ProcessHandle child_process); |
| 42 | 48 |
| 43 // Creates an instance from the given |handle|. |size| and |internalformat| | 49 // Creates an instance from the given |handle|. |size| and |internalformat| |
| 44 // should match what was used to allocate the |handle|. | 50 // should match what was used to allocate the |handle|. |
| 45 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( | 51 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( |
| 46 const gfx::GpuMemoryBufferHandle& handle, | 52 const gfx::GpuMemoryBufferHandle& handle, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 66 const gfx::Size size_; | 72 const gfx::Size size_; |
| 67 const unsigned internalformat_; | 73 const unsigned internalformat_; |
| 68 bool mapped_; | 74 bool mapped_; |
| 69 | 75 |
| 70 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); | 76 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); |
| 71 }; | 77 }; |
| 72 | 78 |
| 73 } // namespace content | 79 } // namespace content |
| 74 | 80 |
| 75 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 81 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
| OLD | NEW |