OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 COMPONENTS_EXO_BUFFER_H_ | |
6 #define COMPONENTS_EXO_BUFFER_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/macros.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "gpu/command_buffer/common/sync_token.h" | |
13 #include "ui/gfx/buffer_types.h" | |
14 #include "ui/gfx/geometry/size.h" | |
15 | |
16 namespace base { | |
17 namespace trace_event { | |
18 class TracedValue; | |
19 } | |
20 } | |
21 | |
22 namespace cc { | |
23 class SingleReleaseCallback; | |
24 class TextureMailbox; | |
25 } | |
26 | |
27 namespace gfx { | |
28 class GpuMemoryBuffer; | |
29 } | |
30 | |
31 namespace exo { | |
32 | |
33 // This class provides the content for a Surface. The mechanism by which a | |
34 // client provides and updates the contents is the responsibility of the client | |
35 // and not defined as part of this class. | |
36 class Buffer { | |
37 public: | |
38 Buffer(scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer, | |
39 unsigned texture_target); | |
40 ~Buffer(); | |
41 | |
42 // Set the callback to run when the buffer is no longer used by the | |
43 // compositor. The client is free to re-use or destroy this buffer and | |
44 // its backing storage after this has been called. | |
45 void set_release_callback(const base::Closure& release_callback) { | |
46 release_callback_ = release_callback; | |
47 } | |
48 | |
49 // This function can be used to get a texture mailbox that is bound to | |
50 // the buffer. Returns a release callback on success. The release | |
51 // callback must be called before a new texture mailbox can be acquired. | |
52 scoped_ptr<cc::SingleReleaseCallback> GetTextureMailbox( | |
piman
2015/11/17 02:43:53
nit: AcquireTextureMailbox? GetTextureMailbox make
reveman
2015/11/17 18:04:04
Done.
| |
53 cc::TextureMailbox* mailbox); | |
54 | |
55 // Returns a trace value representing the state of the buffer. | |
56 scoped_refptr<base::trace_event::TracedValue> AsTracedValue() const; | |
57 | |
58 private: | |
59 static void Release(base::WeakPtr<Buffer> buffer, | |
60 unsigned texture_target, | |
61 unsigned texture_id, | |
62 unsigned image_id, | |
63 const gpu::SyncToken& sync_token, | |
64 bool is_lost); | |
65 | |
66 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; | |
67 const gfx::Size size_; | |
68 const unsigned texture_target_; | |
69 unsigned texture_id_; | |
70 unsigned image_id_; | |
71 base::Closure release_callback_; | |
72 | |
73 base::WeakPtrFactory<Buffer> weak_ptr_factory_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(Buffer); | |
76 }; | |
77 | |
78 } // namespace exo | |
79 | |
80 #endif // COMPONENTS_EXO_BUFFER_H_ | |
OLD | NEW |