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::Closure DestructionCallback; | |
22 | 23 |
23 virtual ~GpuMemoryBufferImpl(); | 24 virtual ~GpuMemoryBufferImpl(); |
24 | 25 |
25 // Creates a GPU memory buffer instance with |size| and |internalformat| for | 26 // Creates a GPU memory buffer instance with |size| and |internalformat| for |
26 // |usage| by the current process and |client_id|. | 27 // |usage| by the current process and |client_id|. |
27 static void Create(const gfx::Size& size, | 28 static void Create(const gfx::Size& size, |
28 unsigned internalformat, | 29 unsigned internalformat, |
29 unsigned usage, | 30 unsigned usage, |
30 int client_id, | 31 int client_id, |
31 const CreationCallback& callback); | 32 const CreationCallback& callback); |
(...skipping 11 matching lines...) Expand all Loading... | |
43 // Notify that GPU memory buffer has been deleted by |child_process|. | 44 // Notify that GPU memory buffer has been deleted by |child_process|. |
44 static void DeletedByChildProcess(gfx::GpuMemoryBufferType type, | 45 static void DeletedByChildProcess(gfx::GpuMemoryBufferType type, |
45 const gfx::GpuMemoryBufferId& id, | 46 const gfx::GpuMemoryBufferId& id, |
46 base::ProcessHandle child_process); | 47 base::ProcessHandle child_process); |
47 | 48 |
48 // Creates an instance from the given |handle|. |size| and |internalformat| | 49 // Creates an instance from the given |handle|. |size| and |internalformat| |
49 // should match what was used to allocate the |handle|. | 50 // should match what was used to allocate the |handle|. |
50 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( | 51 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( |
51 const gfx::GpuMemoryBufferHandle& handle, | 52 const gfx::GpuMemoryBufferHandle& handle, |
52 const gfx::Size& size, | 53 const gfx::Size& size, |
53 unsigned internalformat); | 54 unsigned internalformat, |
55 const DestructionCallback& callback); | |
piman
2014/09/24 03:19:10
nit: I think it should be documented explicitly th
reveman
2014/09/24 06:03:38
Done.
| |
54 | 56 |
55 // Returns true if |internalformat| is a format recognized by this base class. | 57 // Returns true if |internalformat| is a format recognized by this base class. |
56 static bool IsFormatValid(unsigned internalformat); | 58 static bool IsFormatValid(unsigned internalformat); |
57 | 59 |
58 // Returns true if |usage| is recognized by this base class. | 60 // Returns true if |usage| is recognized by this base class. |
59 static bool IsUsageValid(unsigned usage); | 61 static bool IsUsageValid(unsigned usage); |
60 | 62 |
61 // Returns the number of bytes per pixel that must be used by an | 63 // Returns the number of bytes per pixel that must be used by an |
62 // implementation when using |internalformat|. | 64 // implementation when using |internalformat|. |
63 static size_t BytesPerPixel(unsigned internalformat); | 65 static size_t BytesPerPixel(unsigned internalformat); |
64 | 66 |
65 // Overridden from gfx::GpuMemoryBuffer: | 67 // Overridden from gfx::GpuMemoryBuffer: |
66 virtual bool IsMapped() const OVERRIDE; | 68 virtual bool IsMapped() const OVERRIDE; |
67 | 69 |
68 protected: | 70 protected: |
69 GpuMemoryBufferImpl(const gfx::Size& size, unsigned internalformat); | 71 GpuMemoryBufferImpl(const gfx::Size& size, unsigned internalformat); |
70 | 72 |
71 const gfx::Size size_; | 73 const gfx::Size size_; |
72 const unsigned internalformat_; | 74 const unsigned internalformat_; |
73 bool mapped_; | 75 bool mapped_; |
74 | 76 |
75 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); | 77 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); |
76 }; | 78 }; |
77 | 79 |
78 } // namespace content | 80 } // namespace content |
79 | 81 |
80 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ | 82 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ |
OLD | NEW |