| 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 20 matching lines...) Expand all Loading... |
| 46 #if defined(USE_X11) | 48 #if defined(USE_X11) |
| 47 XID pixmap; | 49 XID pixmap; |
| 48 #endif | 50 #endif |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 // This interface typically correspond to a type of shared memory that is also | 53 // This interface typically correspond to a type of shared memory that is also |
| 52 // shared with the GPU. A GPU memory buffer can be written to directly by | 54 // shared with the GPU. A GPU memory buffer can be written to directly by |
| 53 // regular CPU code, but can also be read by the GPU. | 55 // regular CPU code, but can also be read by the GPU. |
| 54 class GFX_EXPORT GpuMemoryBuffer { | 56 class GFX_EXPORT GpuMemoryBuffer { |
| 55 public: | 57 public: |
| 56 GpuMemoryBuffer(); | 58 // The format needs to be taken into account when mapping a buffer into the |
| 57 virtual ~GpuMemoryBuffer(); | 59 // client's address space. |
| 60 enum Format { RGBA_8888, RGBX_8888, BGRA_8888, FORMAT_LAST = BGRA_8888 }; |
| 61 |
| 62 // The usage mode affects how a buffer can be used. Only buffers created with |
| 63 // MAP can be mapped into the client's address space and accessed by the CPU. |
| 64 enum Usage { MAP, SCANOUT, USAGE_LAST = SCANOUT }; |
| 65 |
| 66 virtual ~GpuMemoryBuffer() {} |
| 58 | 67 |
| 59 // Maps the buffer into the client's address space so it can be written to by | 68 // Maps the buffer into the client's address space so it can be written to by |
| 60 // the CPU. This call may block, for instance if the GPU needs to finish | 69 // the CPU. This call may block, for instance if the GPU needs to finish |
| 61 // accessing the buffer or if CPU caches need to be synchronized. Returns NULL | 70 // accessing the buffer or if CPU caches need to be synchronized. Returns NULL |
| 62 // on failure. | 71 // on failure. |
| 63 virtual void* Map() = 0; | 72 virtual void* Map() = 0; |
| 64 | 73 |
| 65 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after | 74 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after |
| 66 // this has been called. | 75 // this has been called. |
| 67 virtual void Unmap() = 0; | 76 virtual void Unmap() = 0; |
| 68 | 77 |
| 69 // Returns true iff the buffer is mapped. | 78 // Returns true iff the buffer is mapped. |
| 70 virtual bool IsMapped() const = 0; | 79 virtual bool IsMapped() const = 0; |
| 71 | 80 |
| 81 // Returns the format for the buffer. |
| 82 virtual Format GetFormat() const = 0; |
| 83 |
| 72 // Returns the stride in bytes for the buffer. | 84 // Returns the stride in bytes for the buffer. |
| 73 virtual uint32 GetStride() const = 0; | 85 virtual uint32 GetStride() const = 0; |
| 74 | 86 |
| 75 // Returns a platform specific handle for this buffer. | 87 // Returns a platform specific handle for this buffer. |
| 76 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 88 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
| 89 |
| 90 // Type-checking downcast routine. |
| 91 virtual ClientBuffer AsClientBuffer() = 0; |
| 77 }; | 92 }; |
| 78 | 93 |
| 79 } // namespace gfx | 94 } // namespace gfx |
| 80 | 95 |
| 81 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 96 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
| OLD | NEW |