OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_ |
| 6 #define CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_ |
| 7 |
| 8 #include <queue> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "content/common/content_export.h" |
| 13 #include "ui/gfx/size.h" |
| 14 |
| 15 namespace cc { |
| 16 class ContextProvider; |
| 17 } |
| 18 |
| 19 namespace content { |
| 20 |
| 21 // Provides a surface that manages its own uffers, backed by |
| 22 // CreateImageCHROMIUM. Double/triple buffering is implemented |
| 23 // internally. Doublebuffering occurs if PageFlipComplete is called before |
| 24 // the next BindFramebuffer call, otherwise it creates extra buffers. |
| 25 class CONTENT_EXPORT BufferedOutputSurface { |
| 26 public: |
| 27 BufferedOutputSurface(scoped_refptr<cc::ContextProvider> context_provider, |
| 28 unsigned int internalformat); |
| 29 ~BufferedOutputSurface(); |
| 30 |
| 31 void Initialize(); |
| 32 |
| 33 void BindFramebuffer(); |
| 34 void SwapBuffers(); |
| 35 void PageFlipComplete(); |
| 36 void Reshape(const gfx::Size& size, float scale_factor); |
| 37 |
| 38 unsigned int current_tex_id() { return current_surface_.first; } |
| 39 |
| 40 private: |
| 41 friend class BufferedOutputSurfaceTest; |
| 42 typedef std::pair<unsigned int, unsigned int> AllocatedSurface; |
| 43 |
| 44 void FreeAllSurfaces(); |
| 45 |
| 46 void FreeSurface(AllocatedSurface* surface); |
| 47 |
| 48 // Return a surface, available to be drawn into. |
| 49 AllocatedSurface GetNextSurface(); |
| 50 |
| 51 gfx::Size size_; |
| 52 scoped_refptr<cc::ContextProvider> context_provider_; |
| 53 unsigned int fbo_, depth_rb_; |
| 54 size_t allocated_count_; |
| 55 unsigned int internalformat_; |
| 56 AllocatedSurface current_surface_; // This surface is currently bound. |
| 57 AllocatedSurface |
| 58 last_surface_; // This surface has been sent to the hardware. |
| 59 std::vector<AllocatedSurface> available_surfaces_; // These are free for use. |
| 60 std::queue<AllocatedSurface> in_flight_surfaces_; |
| 61 }; |
| 62 |
| 63 } // namespace content |
| 64 |
| 65 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_ |
OLD | NEW |