| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_DISPLAY_COMPOSITOR_BUFFER_QUEUE_H_ | 5 #ifndef COMPONENTS_DISPLAY_COMPOSITOR_BUFFER_QUEUE_H_ |
| 6 #define COMPONENTS_DISPLAY_COMPOSITOR_BUFFER_QUEUE_H_ | 6 #define COMPONENTS_DISPLAY_COMPOSITOR_BUFFER_QUEUE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "components/display_compositor/display_compositor_export.h" | 16 #include "components/display_compositor/display_compositor_export.h" |
| 17 #include "gpu/ipc/common/surface_handle.h" | 17 #include "gpu/ipc/common/surface_handle.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
| 20 | 20 |
| 21 namespace cc { | |
| 22 class ContextProvider; | |
| 23 } | |
| 24 | |
| 25 namespace gfx { | 21 namespace gfx { |
| 26 class GpuMemoryBuffer; | 22 class GpuMemoryBuffer; |
| 27 } | 23 } |
| 28 | 24 |
| 29 namespace gpu { | 25 namespace gpu { |
| 30 class GpuMemoryBufferManager; | 26 class GpuMemoryBufferManager; |
| 27 |
| 28 namespace gles2 { |
| 29 class GLES2Interface; |
| 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace display_compositor { | 33 namespace display_compositor { |
| 34 | 34 |
| 35 class GLHelper; | 35 class GLHelper; |
| 36 | 36 |
| 37 // Provides a surface that manages its own buffers, backed by GpuMemoryBuffers | 37 // Provides a surface that manages its own buffers, backed by GpuMemoryBuffers |
| 38 // created using CHROMIUM_gpu_memory_buffer_image. Double/triple buffering is | 38 // created using CHROMIUM_gpu_memory_buffer_image. Double/triple buffering is |
| 39 // implemented internally. Doublebuffering occurs if PageFlipComplete is called | 39 // implemented internally. Doublebuffering occurs if PageFlipComplete is called |
| 40 // before the next BindFramebuffer call, otherwise it creates extra buffers. | 40 // before the next BindFramebuffer call, otherwise it creates extra buffers. |
| 41 class DISPLAY_COMPOSITOR_EXPORT BufferQueue { | 41 class DISPLAY_COMPOSITOR_EXPORT BufferQueue { |
| 42 public: | 42 public: |
| 43 BufferQueue(scoped_refptr<cc::ContextProvider> context_provider, | 43 BufferQueue(gpu::gles2::GLES2Interface* gl, |
| 44 unsigned int texture_target, | 44 unsigned int texture_target, |
| 45 unsigned int internalformat, | 45 unsigned int internalformat, |
| 46 GLHelper* gl_helper, | 46 GLHelper* gl_helper, |
| 47 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 47 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 48 gpu::SurfaceHandle surface_handle); | 48 gpu::SurfaceHandle surface_handle); |
| 49 virtual ~BufferQueue(); | 49 virtual ~BufferQueue(); |
| 50 | 50 |
| 51 void Initialize(); | 51 void Initialize(); |
| 52 | 52 |
| 53 void BindFramebuffer(); | 53 void BindFramebuffer(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 const gfx::Rect& old_damage); | 92 const gfx::Rect& old_damage); |
| 93 | 93 |
| 94 void UpdateBufferDamage(const gfx::Rect& damage); | 94 void UpdateBufferDamage(const gfx::Rect& damage); |
| 95 | 95 |
| 96 // Return a surface, available to be drawn into. | 96 // Return a surface, available to be drawn into. |
| 97 std::unique_ptr<AllocatedSurface> GetNextSurface(); | 97 std::unique_ptr<AllocatedSurface> GetNextSurface(); |
| 98 | 98 |
| 99 std::unique_ptr<AllocatedSurface> RecreateBuffer( | 99 std::unique_ptr<AllocatedSurface> RecreateBuffer( |
| 100 std::unique_ptr<AllocatedSurface> surface); | 100 std::unique_ptr<AllocatedSurface> surface); |
| 101 | 101 |
| 102 gpu::gles2::GLES2Interface* const gl_; |
| 102 gfx::Size size_; | 103 gfx::Size size_; |
| 103 scoped_refptr<cc::ContextProvider> context_provider_; | |
| 104 unsigned int fbo_; | 104 unsigned int fbo_; |
| 105 size_t allocated_count_; | 105 size_t allocated_count_; |
| 106 unsigned int texture_target_; | 106 unsigned int texture_target_; |
| 107 unsigned int internal_format_; | 107 unsigned int internal_format_; |
| 108 // This surface is currently bound. This may be nullptr if no surface has | 108 // This surface is currently bound. This may be nullptr if no surface has |
| 109 // been bound, or if allocation failed at bind. | 109 // been bound, or if allocation failed at bind. |
| 110 std::unique_ptr<AllocatedSurface> current_surface_; | 110 std::unique_ptr<AllocatedSurface> current_surface_; |
| 111 // The surface currently on the screen, if any. | 111 // The surface currently on the screen, if any. |
| 112 std::unique_ptr<AllocatedSurface> displayed_surface_; | 112 std::unique_ptr<AllocatedSurface> displayed_surface_; |
| 113 // These are free for use, and are not nullptr. | 113 // These are free for use, and are not nullptr. |
| 114 std::vector<std::unique_ptr<AllocatedSurface>> available_surfaces_; | 114 std::vector<std::unique_ptr<AllocatedSurface>> available_surfaces_; |
| 115 // These have been swapped but are not displayed yet. Entries of this deque | 115 // These have been swapped but are not displayed yet. Entries of this deque |
| 116 // may be nullptr, if they represent frames that have been destroyed. | 116 // may be nullptr, if they represent frames that have been destroyed. |
| 117 std::deque<std::unique_ptr<AllocatedSurface>> in_flight_surfaces_; | 117 std::deque<std::unique_ptr<AllocatedSurface>> in_flight_surfaces_; |
| 118 GLHelper* gl_helper_; | 118 GLHelper* gl_helper_; |
| 119 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 119 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 120 gpu::SurfaceHandle surface_handle_; | 120 gpu::SurfaceHandle surface_handle_; |
| 121 | 121 |
| 122 DISALLOW_COPY_AND_ASSIGN(BufferQueue); | 122 DISALLOW_COPY_AND_ASSIGN(BufferQueue); |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 } // namespace display_compositor | 125 } // namespace display_compositor |
| 126 | 126 |
| 127 #endif // COMPONENTS_DISPLAY_COMPOSITOR_BUFFER_QUEUE_H_ | 127 #endif // COMPONENTS_DISPLAY_COMPOSITOR_BUFFER_QUEUE_H_ |
| OLD | NEW |