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 GPU_COMMAND_BUFFER_CLIENT_GPU_MEMORY_BUFFER_H_ | 5 #ifndef GPU_UI_GFX_GPU_MEMORY_BUFFER_H_ |
6 #define GPU_COMMAND_BUFFER_CLIENT_GPU_MEMORY_BUFFER_H_ | 6 #define GPU_UI_GFX_GPU_MEMORY_BUFFER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "gles2_impl_export.h" | 10 #include "ui/base/ui_export.h" |
11 | 11 |
12 namespace gpu { | 12 #if defined(OS_ANDROID) |
13 #include <third_party/khronos/EGL/egl.h> | |
kaanb
2013/07/24 03:31:23
I had added a define for EGL_NATIVE_BUFFER_ANDROID
reveman
2013/07/24 05:47:12
Oh, would it be more appropriate to include gl_bin
reveman
2013/07/25 19:50:25
Removed your EGL_NATIVE_BUFFER_ANDROID define from
| |
14 #endif | |
15 | |
16 namespace gfx { | |
17 | |
18 enum GpuMemoryBufferType { | |
19 EMPTY_BUFFER, | |
20 SHARED_MEMORY_BUFFER, | |
21 EGL_CLIENT_BUFFER | |
22 }; | |
23 | |
24 struct GpuMemoryBufferHandle { | |
25 GpuMemoryBufferHandle() : type(EMPTY_BUFFER) {} | |
26 GpuMemoryBufferHandle( | |
27 base::SharedMemoryHandle handle_, GpuMemoryBufferType type_) | |
28 : type(type_), | |
29 handle(handle_) { | |
30 DCHECK(!is_null()); | |
31 } | |
32 bool is_null() const { return type == EMPTY_BUFFER; } | |
33 GpuMemoryBufferType type; | |
34 base::SharedMemoryHandle handle; | |
35 #if defined(OS_ANDROID) | |
36 EGLClientBuffer native_buffer; | |
37 #endif | |
38 }; | |
13 | 39 |
14 // Interface for creating and accessing a zero-copy GPU memory buffer. | 40 // Interface for creating and accessing a zero-copy GPU memory buffer. |
15 // This design evolved from the generalization of GraphicBuffer API | 41 // This design evolved from the generalization of GraphicBuffer API |
16 // of Android framework. | 42 // of Android framework. |
17 // | 43 // |
18 // THREADING CONSIDERATIONS: | 44 // THREADING CONSIDERATIONS: |
19 // | 45 // |
20 // This interface is thread-safe. However, multiple threads mapping | 46 // This interface is thread-safe. However, multiple threads mapping |
21 // a buffer for Write or ReadOrWrite simultaneously may result in undefined | 47 // a buffer for Write or ReadOrWrite simultaneously may result in undefined |
22 // behavior and is not allowed. | 48 // behavior and is not allowed. |
23 class GLES2_IMPL_EXPORT GpuMemoryBuffer { | 49 class UI_EXPORT GpuMemoryBuffer { |
24 public: | 50 public: |
25 enum AccessMode { | 51 enum AccessMode { |
26 READ_ONLY, | 52 READ_ONLY, |
27 WRITE_ONLY, | 53 WRITE_ONLY, |
28 READ_WRITE, | 54 READ_WRITE, |
29 }; | 55 }; |
30 | 56 |
31 // Frees a previously allocated buffer. Freeing a buffer that is still | 57 // Frees a previously allocated buffer. Freeing a buffer that is still |
32 // mapped in any process is undefined behavior. | 58 // mapped in any process is undefined behavior. |
33 virtual ~GpuMemoryBuffer() {} | 59 virtual ~GpuMemoryBuffer() {} |
34 | 60 |
35 // Maps the buffer so the client can write the bitmap data in |*vaddr| | 61 // Maps the buffer so the client can write the bitmap data in |*vaddr| |
36 // subsequently. This call may block, for instance if the hardware needs | 62 // subsequently. This call may block, for instance if the hardware needs |
37 // to finish rendering or if CPU caches need to be synchronized. | 63 // to finish rendering or if CPU caches need to be synchronized. |
38 virtual void Map(AccessMode mode, void** vaddr) = 0; | 64 virtual void Map(AccessMode mode, void** vaddr) = 0; |
39 | 65 |
40 // Unmaps the buffer. Called after all changes to the buffer are | 66 // Unmaps the buffer. Called after all changes to the buffer are |
41 // completed. | 67 // completed. |
42 virtual void Unmap() = 0; | 68 virtual void Unmap() = 0; |
43 | 69 |
44 // Returns true iff the buffer is mapped. | 70 // Returns true iff the buffer is mapped. |
45 virtual bool IsMapped() = 0; | 71 virtual bool IsMapped() const = 0; |
46 | |
47 // Returns the native pointer for the buffer. | |
48 virtual void* GetNativeBuffer() = 0; | |
49 | 72 |
50 // Returns the stride in bytes for the buffer. | 73 // Returns the stride in bytes for the buffer. |
51 virtual uint32 GetStride() = 0; | 74 virtual uint32 GetStride() const = 0; |
75 | |
76 // Returns a platform specific handle for this buffer. | |
77 virtual GpuMemoryBufferHandle GetHandle() const = 0; | |
52 }; | 78 }; |
53 | 79 |
54 } // namespace gpu | 80 } // namespace gfx |
55 | 81 |
56 #endif // GPU_COMMAND_BUFFER_CLIENT_GPU_MEMORY_BUFFER_H_ | 82 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
OLD | NEW |