Remove WebKitTestRunner::setClientWindowRect.
[chromium-blink-merge.git] / ui / gfx / gpu_memory_buffer.h
blob17bb6693858fc5e43a63da1d7c7193b08b62227d
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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_GPU_MEMORY_BUFFER_H_
6 #define UI_GFX_GPU_MEMORY_BUFFER_H_
8 #include "base/memory/shared_memory.h"
9 #include "build/build_config.h"
10 #include "ui/gfx/gfx_export.h"
12 #if defined(OS_ANDROID)
13 #include <third_party/khronos/EGL/egl.h>
14 #endif
16 namespace gfx {
18 enum GpuMemoryBufferType {
19 EMPTY_BUFFER,
20 SHARED_MEMORY_BUFFER,
21 EGL_CLIENT_BUFFER
24 struct GpuMemoryBufferHandle {
25 GpuMemoryBufferHandle()
26 : type(EMPTY_BUFFER),
27 handle(base::SharedMemory::NULLHandle())
28 #if defined(OS_ANDROID)
29 , native_buffer(NULL)
30 #endif
33 bool is_null() const { return type == EMPTY_BUFFER; }
34 GpuMemoryBufferType type;
35 base::SharedMemoryHandle handle;
36 #if defined(OS_ANDROID)
37 EGLClientBuffer native_buffer;
38 #endif
41 // Interface for creating and accessing a zero-copy GPU memory buffer.
42 // This design evolved from the generalization of GraphicBuffer API
43 // of Android framework.
45 // THREADING CONSIDERATIONS:
47 // This interface is thread-safe. However, multiple threads mapping
48 // a buffer for Write or ReadOrWrite simultaneously may result in undefined
49 // behavior and is not allowed.
50 class GFX_EXPORT GpuMemoryBuffer {
51 public:
52 enum AccessMode {
53 READ_ONLY,
54 WRITE_ONLY,
55 READ_WRITE,
58 GpuMemoryBuffer();
59 virtual ~GpuMemoryBuffer();
61 // Maps the buffer so the client can write the bitmap data in |*vaddr|
62 // subsequently. This call may block, for instance if the hardware needs
63 // to finish rendering or if CPU caches need to be synchronized.
64 virtual void Map(AccessMode mode, void** vaddr) = 0;
66 // Unmaps the buffer. Called after all changes to the buffer are
67 // completed.
68 virtual void Unmap() = 0;
70 // Returns true iff the buffer is mapped.
71 virtual bool IsMapped() const = 0;
73 // Returns the stride in bytes for the buffer.
74 virtual uint32 GetStride() const = 0;
76 // Returns a platform specific handle for this buffer.
77 virtual GpuMemoryBufferHandle GetHandle() const = 0;
80 } // namespace gfx
82 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_