| 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 UI_GFX_GPU_MEMORY_BUFFER_H_ | 5 #ifndef UI_GFX_GPU_MEMORY_BUFFER_H_ |
| 6 #define UI_GFX_GPU_MEMORY_BUFFER_H_ | 6 #define UI_GFX_GPU_MEMORY_BUFFER_H_ |
| 7 | 7 |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/gfx/gfx_export.h" | 10 #include "ui/gfx/gfx_export.h" |
| 11 | 11 |
| 12 #if defined(USE_X11) | 12 #if defined(USE_X11) |
| 13 #include "ui/gfx/x/x11_types.h" | 13 #include "ui/gfx/x/x11_types.h" |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 extern "C" typedef struct _ClientBuffer* ClientBuffer; |
| 17 |
| 16 namespace gfx { | 18 namespace gfx { |
| 17 | 19 |
| 18 enum GpuMemoryBufferType { | 20 enum GpuMemoryBufferType { |
| 19 EMPTY_BUFFER, | 21 EMPTY_BUFFER, |
| 20 SHARED_MEMORY_BUFFER, | 22 SHARED_MEMORY_BUFFER, |
| 21 IO_SURFACE_BUFFER, | 23 IO_SURFACE_BUFFER, |
| 22 ANDROID_NATIVE_BUFFER, | 24 ANDROID_NATIVE_BUFFER, |
| 23 SURFACE_TEXTURE_BUFFER, | 25 SURFACE_TEXTURE_BUFFER, |
| 24 X11_PIXMAP_BUFFER, | 26 X11_PIXMAP_BUFFER, |
| 25 OZONE_NATIVE_BUFFER, | 27 OZONE_NATIVE_BUFFER, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #if defined(USE_X11) | 64 #if defined(USE_X11) |
| 63 XID pixmap; | 65 XID pixmap; |
| 64 #endif | 66 #endif |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 // This interface typically correspond to a type of shared memory that is also | 69 // This interface typically correspond to a type of shared memory that is also |
| 68 // shared with the GPU. A GPU memory buffer can be written to directly by | 70 // shared with the GPU. A GPU memory buffer can be written to directly by |
| 69 // regular CPU code, but can also be read by the GPU. | 71 // regular CPU code, but can also be read by the GPU. |
| 70 class GFX_EXPORT GpuMemoryBuffer { | 72 class GFX_EXPORT GpuMemoryBuffer { |
| 71 public: | 73 public: |
| 72 GpuMemoryBuffer(); | 74 // The format needs to be taken into account when mapping a buffer into the |
| 73 virtual ~GpuMemoryBuffer(); | 75 // client's address space. |
| 76 enum Format { RGBA_8888, RGBX_8888, BGRA_8888, FORMAT_LAST = BGRA_8888 }; |
| 77 |
| 78 // The usage mode affects how a buffer can be used. Only buffers created with |
| 79 // MAP can be mapped into the client's address space and accessed by the CPU. |
| 80 enum Usage { MAP, SCANOUT, USAGE_LAST = SCANOUT }; |
| 81 |
| 82 virtual ~GpuMemoryBuffer() {} |
| 74 | 83 |
| 75 // Maps the buffer into the client's address space so it can be written to by | 84 // Maps the buffer into the client's address space so it can be written to by |
| 76 // the CPU. This call may block, for instance if the GPU needs to finish | 85 // the CPU. This call may block, for instance if the GPU needs to finish |
| 77 // accessing the buffer or if CPU caches need to be synchronized. Returns NULL | 86 // accessing the buffer or if CPU caches need to be synchronized. Returns NULL |
| 78 // on failure. | 87 // on failure. |
| 79 virtual void* Map() = 0; | 88 virtual void* Map() = 0; |
| 80 | 89 |
| 81 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after | 90 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after |
| 82 // this has been called. | 91 // this has been called. |
| 83 virtual void Unmap() = 0; | 92 virtual void Unmap() = 0; |
| 84 | 93 |
| 85 // Returns true iff the buffer is mapped. | 94 // Returns true iff the buffer is mapped. |
| 86 virtual bool IsMapped() const = 0; | 95 virtual bool IsMapped() const = 0; |
| 87 | 96 |
| 97 // Returns the format for the buffer. |
| 98 virtual Format GetFormat() const = 0; |
| 99 |
| 88 // Returns the stride in bytes for the buffer. | 100 // Returns the stride in bytes for the buffer. |
| 89 virtual uint32 GetStride() const = 0; | 101 virtual uint32 GetStride() const = 0; |
| 90 | 102 |
| 91 // Returns a platform specific handle for this buffer. | 103 // Returns a platform specific handle for this buffer. |
| 92 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 104 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
| 105 |
| 106 // Type-checking downcast routine. |
| 107 virtual ClientBuffer AsClientBuffer() = 0; |
| 93 }; | 108 }; |
| 94 | 109 |
| 95 } // namespace gfx | 110 } // namespace gfx |
| 96 | 111 |
| 97 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 112 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
| OLD | NEW |