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 | 14 |
15 // Provides common implementation of a GPU memory buffer. | 15 // Provides common implementation of a GPU memory buffer. |
16 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { | 16 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { |
17 public: | 17 public: |
18 typedef base::Callback<void(scoped_ptr<GpuMemoryBufferImpl> buffer)> | 18 typedef base::Callback<void(scoped_ptr<GpuMemoryBufferImpl> buffer)> |
19 CreationCallback; | 19 CreationCallback; |
20 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> | 20 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> |
21 AllocationCallback; | 21 AllocationCallback; |
22 typedef base::Callback<void(uint32 sync_point)> DestructionCallback; | 22 typedef base::Callback<void(uint32 sync_point)> DestructionCallback; |
23 | 23 |
24 ~GpuMemoryBufferImpl() override; | 24 ~GpuMemoryBufferImpl() override; |
25 | 25 |
26 // Creates a GPU memory buffer instance with |size| and |format| for |usage| | 26 // Creates a GPU memory buffer instance with |size| and |format| for |usage| |
27 // by the current process and |client_id|. | 27 // by the current process and |client_id|. |
28 static void Create(const gfx::Size& size, | 28 static void Create(gfx::GpuMemoryBufferId id, |
| 29 const gfx::Size& size, |
29 Format format, | 30 Format format, |
30 Usage usage, | 31 Usage usage, |
31 int client_id, | 32 int client_id, |
32 const CreationCallback& callback); | 33 const CreationCallback& callback); |
33 | 34 |
34 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| | 35 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| |
35 // by |child_process| and |child_client_id|. The |handle| returned can be | 36 // by |child_process| and |child_client_id|. The |handle| returned can be |
36 // used by the |child_process| to create an instance of this class. | 37 // used by the |child_process| to create an instance of this class. |
37 static void AllocateForChildProcess(const gfx::Size& size, | 38 static void AllocateForChildProcess(gfx::GpuMemoryBufferId id, |
| 39 const gfx::Size& size, |
38 Format format, | 40 Format format, |
39 Usage usage, | 41 Usage usage, |
40 base::ProcessHandle child_process, | 42 base::ProcessHandle child_process, |
41 int child_client_id, | 43 int child_client_id, |
42 const AllocationCallback& callback); | 44 const AllocationCallback& callback); |
43 | 45 |
44 // Notify that GPU memory buffer has been deleted by |child_process|. | 46 // Notify that GPU memory buffer has been deleted by |child_process|. |
45 static void DeletedByChildProcess(gfx::GpuMemoryBufferType type, | 47 static void DeletedByChildProcess(gfx::GpuMemoryBufferType type, |
46 const gfx::GpuMemoryBufferId& id, | 48 gfx::GpuMemoryBufferId id, |
47 base::ProcessHandle child_process, | 49 base::ProcessHandle child_process, |
48 int child_client_id, | 50 int child_client_id, |
49 uint32 sync_point); | 51 uint32 sync_point); |
50 | 52 |
51 // Creates an instance from the given |handle|. |size| and |internalformat| | 53 // Creates an instance from the given |handle|. |size| and |internalformat| |
52 // should match what was used to allocate the |handle|. |callback| is | 54 // should match what was used to allocate the |handle|. |callback| is |
53 // called when instance is deleted, which is not necessarily on the same | 55 // called when instance is deleted, which is not necessarily on the same |
54 // thread as this function was called on and instance was created on. | 56 // thread as this function was called on and instance was created on. |
55 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( | 57 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( |
56 const gfx::GpuMemoryBufferHandle& handle, | 58 const gfx::GpuMemoryBufferHandle& handle, |
(...skipping 11 matching lines...) Expand all Loading... |
68 // Overridden from gfx::GpuMemoryBuffer: | 70 // Overridden from gfx::GpuMemoryBuffer: |
69 bool IsMapped() const override; | 71 bool IsMapped() const override; |
70 Format GetFormat() const override; | 72 Format GetFormat() const override; |
71 ClientBuffer AsClientBuffer() override; | 73 ClientBuffer AsClientBuffer() override; |
72 | 74 |
73 void set_destruction_sync_point(uint32 sync_point) { | 75 void set_destruction_sync_point(uint32 sync_point) { |
74 destruction_sync_point_ = sync_point; | 76 destruction_sync_point_ = sync_point; |
75 } | 77 } |
76 | 78 |
77 protected: | 79 protected: |
78 GpuMemoryBufferImpl(const gfx::Size& size, | 80 GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id, |
| 81 const gfx::Size& size, |
79 Format format, | 82 Format format, |
80 const DestructionCallback& callback); | 83 const DestructionCallback& callback); |
81 | 84 |
| 85 const gfx::GpuMemoryBufferId id_; |
82 const gfx::Size size_; | 86 const gfx::Size size_; |
83 const Format format_; | 87 const Format format_; |
84 const DestructionCallback callback_; | 88 const DestructionCallback callback_; |
85 bool mapped_; | 89 bool mapped_; |
86 uint32 destruction_sync_point_; | 90 uint32 destruction_sync_point_; |
87 | 91 |
88 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); | 92 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); |
89 }; | 93 }; |
90 | 94 |
91 } // namespace content | 95 } // namespace content |
92 | 96 |
93 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 97 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
OLD | NEW |