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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "ui/gfx/gpu_memory_buffer.h" | 10 #include "ui/gfx/gpu_memory_buffer.h" |
10 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
15 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> | |
16 AllocationCallback; | |
reveman
2014/05/19 18:57:57
nit: I think this should be in the GpuMemoryBuffer
| |
17 | |
14 // Provides common implementation of a GPU memory buffer. | 18 // Provides common implementation of a GPU memory buffer. |
15 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { | 19 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { |
16 public: | 20 public: |
17 virtual ~GpuMemoryBufferImpl(); | 21 virtual ~GpuMemoryBufferImpl(); |
18 | 22 |
19 // Creates a GPU memory buffer instance with |size| and |internalformat| for | 23 // Creates a GPU memory buffer instance with |size| and |internalformat| for |
20 // |usage|. | 24 // |usage|. |
21 static scoped_ptr<GpuMemoryBufferImpl> Create(const gfx::Size& size, | 25 static scoped_ptr<GpuMemoryBufferImpl> Create(const gfx::Size& size, |
22 unsigned internalformat, | 26 unsigned internalformat, |
23 unsigned usage); | 27 unsigned usage); |
24 | 28 |
25 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| | 29 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| |
26 // by |child_process|. The |handle| returned can be used by the | 30 // by |child_process|. The |handle| returned can be used by the |
27 // |child_process| to create an instance of this class. | 31 // |child_process| to create an instance of this class. |
28 static void AllocateForChildProcess(const gfx::Size& size, | 32 static void AllocateForChildProcess(const gfx::Size& size, |
29 unsigned internalformat, | 33 unsigned internalformat, |
30 unsigned usage, | 34 unsigned usage, |
31 base::ProcessHandle child_process, | 35 base::ProcessHandle child_process, |
32 gfx::GpuMemoryBufferHandle* handle); | 36 const AllocationCallback& callback); |
33 | 37 |
34 // Creates an instance from the given |handle|. |size| and |internalformat| | 38 // Creates an instance from the given |handle|. |size| and |internalformat| |
35 // should match what was used to allocate the |handle|. | 39 // should match what was used to allocate the |handle|. |
36 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( | 40 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( |
37 gfx::GpuMemoryBufferHandle handle, | 41 gfx::GpuMemoryBufferHandle handle, |
38 const gfx::Size& size, | 42 const gfx::Size& size, |
39 unsigned internalformat); | 43 unsigned internalformat); |
40 | 44 |
41 // Returns true if |internalformat| is a format recognized by this base class. | 45 // Returns true if |internalformat| is a format recognized by this base class. |
42 static bool IsFormatValid(unsigned internalformat); | 46 static bool IsFormatValid(unsigned internalformat); |
(...skipping 14 matching lines...) Expand all Loading... | |
57 const gfx::Size size_; | 61 const gfx::Size size_; |
58 const unsigned internalformat_; | 62 const unsigned internalformat_; |
59 bool mapped_; | 63 bool mapped_; |
60 | 64 |
61 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); | 65 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); |
62 }; | 66 }; |
63 | 67 |
64 } // namespace content | 68 } // namespace content |
65 | 69 |
66 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 70 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
OLD | NEW |