Chromium Code Reviews| Index: components/exo/buffer.h |
| diff --git a/components/exo/buffer.h b/components/exo/buffer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fc55f991f70865ac6a0a59c7a88a643e9eace5ec |
| --- /dev/null |
| +++ b/components/exo/buffer.h |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_EXO_BUFFER_H_ |
| +#define COMPONENTS_EXO_BUFFER_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "gpu/command_buffer/common/sync_token.h" |
| +#include "ui/gfx/buffer_types.h" |
| +#include "ui/gfx/geometry/size.h" |
| + |
| +namespace base { |
| +namespace trace_event { |
| +class TracedValue; |
| +} |
| +} |
| + |
| +namespace cc { |
| +class SingleReleaseCallback; |
| +class TextureMailbox; |
| +} |
| + |
| +namespace gfx { |
| +class GpuMemoryBuffer; |
| +} |
| + |
| +namespace exo { |
| + |
| +// This class provides the content for a Surface. The mechanism by which a |
| +// client provides and updates the contents is the responsibility of the client |
| +// and not defined as part of this class. |
| +class Buffer { |
| + public: |
| + Buffer(scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer, |
| + unsigned texture_target); |
| + ~Buffer(); |
| + |
| + // Set the callback to run when the buffer is no longer used by the |
| + // compositor. The client is free to re-use or destroy this buffer and |
| + // its backing storage after this has been called. |
| + void set_release_callback(const base::Closure& release_callback) { |
| + release_callback_ = release_callback; |
| + } |
| + |
| + // This function can be used to get a texture mailbox that is bound to |
| + // the buffer. Returns a release callback on success. The release |
| + // callback must be called before a new texture mailbox can be acquired. |
| + scoped_ptr<cc::SingleReleaseCallback> GetTextureMailbox( |
|
piman
2015/11/17 02:43:53
nit: AcquireTextureMailbox? GetTextureMailbox make
reveman
2015/11/17 18:04:04
Done.
|
| + cc::TextureMailbox* mailbox); |
| + |
| + // Returns a trace value representing the state of the buffer. |
| + scoped_refptr<base::trace_event::TracedValue> AsTracedValue() const; |
| + |
| + private: |
| + static void Release(base::WeakPtr<Buffer> buffer, |
| + unsigned texture_target, |
| + unsigned texture_id, |
| + unsigned image_id, |
| + const gpu::SyncToken& sync_token, |
| + bool is_lost); |
| + |
| + scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; |
| + const gfx::Size size_; |
| + const unsigned texture_target_; |
| + unsigned texture_id_; |
| + unsigned image_id_; |
| + base::Closure release_callback_; |
| + |
| + base::WeakPtrFactory<Buffer> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Buffer); |
| +}; |
| + |
| +} // namespace exo |
| + |
| +#endif // COMPONENTS_EXO_BUFFER_H_ |