Chromium Code Reviews| Index: content/browser/compositor/buffered_output_surface.h |
| diff --git a/content/browser/compositor/buffered_output_surface.h b/content/browser/compositor/buffered_output_surface.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7bf21c326b4181193871650fcc254eb2c82d44bc |
| --- /dev/null |
| +++ b/content/browser/compositor/buffered_output_surface.h |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2014 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 CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_ |
| +#define CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_ |
| + |
| +#include <queue> |
| +#include <vector> |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "content/common/content_export.h" |
| +#include "ui/gfx/size.h" |
| + |
| +namespace cc { |
| +class ContextProvider; |
| +} |
| + |
| +namespace content { |
| + |
| +// Provides a surface that manages its own uffers, backed by |
| +// CreateImageCHROMIUM. Double/triple buffering is implemented |
| +// internally. Doublebuffering occurs if PageFlipComplete is called before |
| +// the next BindFramebuffer call, otherwise it creates extra buffers. |
| +class CONTENT_EXPORT BufferedOutputSurface { |
|
piman
2014/09/11 20:25:29
nit: the name BufferedOutputSurface feels like it
achaulk
2014/09/15 16:31:42
Done.
|
| + public: |
| + BufferedOutputSurface(scoped_refptr<cc::ContextProvider> context_provider, |
| + unsigned int internalformat); |
| + ~BufferedOutputSurface(); |
| + |
| + void Initialize(); |
| + |
| + void BindFramebuffer(); |
| + void SwapBuffers(); |
| + void PageFlipComplete(); |
| + void Reshape(const gfx::Size& size, float scale_factor); |
| + |
| + unsigned int current_tex_id() { return current_surface_.first; } |
|
piman
2014/09/11 20:25:29
nit: no abbreviation. current_texture_id() ?
achaulk
2014/09/12 19:51:08
Done.
|
| + |
| + private: |
| + friend class BufferedOutputSurfaceTest; |
| + typedef std::pair<unsigned int, unsigned int> AllocatedSurface; |
|
piman
2014/09/11 20:25:29
nit: can you make this a struct? It helps readabil
achaulk
2014/09/12 19:51:08
Done.
|
| + |
| + void FreeAllSurfaces(); |
| + |
| + void FreeSurface(AllocatedSurface* surface); |
| + |
| + // Return a surface, available to be drawn into. |
| + AllocatedSurface GetNextSurface(); |
| + |
| + gfx::Size size_; |
| + scoped_refptr<cc::ContextProvider> context_provider_; |
| + unsigned int fbo_, depth_rb_; |
| + size_t allocated_count_; |
| + unsigned int internalformat_; |
| + AllocatedSurface current_surface_; // This surface is currently bound. |
| + AllocatedSurface |
| + last_surface_; // This surface has been sent to the hardware. |
|
piman
2014/09/11 20:25:29
nit: keep member identifier and type on the same l
|
| + std::vector<AllocatedSurface> available_surfaces_; // These are free for use. |
| + std::queue<AllocatedSurface> in_flight_surfaces_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_ |