OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CC_RESOURCES_GRAPHIC_BUFFER_H_ | |
6 #define CC_RESOURCES_GRAPHIC_BUFFER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/callback.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 | |
12 namespace gfx { | |
13 class Size; | |
14 } | |
15 | |
16 namespace cc { | |
17 | |
18 // Interface for creating and accessing a zero-copy buffer such as GraphicBuffer | |
19 // of Android framework. | |
20 // | |
21 // THREADING CONSIDERATIONS: | |
22 // | |
23 // It is legal for several different threads to lock a buffer from | |
24 // read access, none of the threads are blocked. | |
25 // However, locking a buffer simultaneously for write or read/write is | |
26 // undefined, but: | |
27 // - shall not result in termination of the process | |
28 // - shall not block the caller | |
29 // It is acceptable to return an error or to leave the buffer's content | |
30 // into an indeterminate state. | |
31 class GraphicBuffer { | |
32 public: | |
33 // The factory is set by the ContentRendererClient::GetGraphicBufferFactory() | |
34 // method. | |
35 typedef base::Callback<scoped_ptr<cc::GraphicBuffer>(const gfx::Size&)> | |
jamesr
2013/04/03 03:14:38
gfx::Size should be passed by value, not const ref
kaanb
2013/04/03 04:39:53
Done.
| |
36 Factory; | |
jamesr
2013/04/03 03:14:38
call this Create, not Factory
kaanb
2013/04/03 04:39:53
Done.
| |
37 virtual ~GraphicBuffer() {} | |
38 | |
39 // Locks the buffer for the usage specified so the client | |
jamesr
2013/04/03 03:14:38
if these are analogous to map/unmap in other parts
kaanb
2013/04/03 04:39:53
Done.
| |
40 // can read or write the bitmap data in |*vaddr| subsequently. | |
41 // This call may block, for instance if the h/w needs | |
42 // to finish rendering or if CPU caches need to be synchronized. | |
43 // Returns true on success, false on failure. | |
jamesr
2013/04/03 03:14:38
returning a bool on this API is useless unless the
kaanb
2013/04/03 04:39:53
Done.
| |
44 virtual bool LockForRead(void** vaddr) = 0; | |
jamesr
2013/04/03 03:14:38
LockForRead() isn't used at all in the big patch a
kaanb
2013/04/03 04:39:53
Done.
kaanb
2013/04/03 04:39:53
Done.
| |
45 virtual bool LockForWrite(void** vaddr) = 0; | |
46 // Unlocks the buffer. Returns true on success, false otherwise. | |
jamesr
2013/04/03 03:14:38
leave a blank line between functions.
how could u
kaanb
2013/04/03 04:39:53
Done.
| |
47 virtual bool Unlock() = 0; | |
48 // Returns the size of the buffer | |
jamesr
2013/04/03 03:14:38
do you need a size getter? whoever allocates this
kaanb
2013/04/03 04:39:53
Done.
| |
49 virtual gfx::Size GetSize() = 0; | |
50 // Returns the native pointer for the graphic buffer. | |
51 virtual void* GetNativeBuffer() = 0; | |
52 // Returns the stride for the graphic buffer. | |
53 virtual uint32 GetStride() = 0; | |
54 }; | |
55 | |
56 } // namespace cc | |
57 | |
58 #endif // CC_RESOURCES_GRAPHIC_BUFFER_H_ | |
OLD | NEW |