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/buffer_types.h" |
18 #include "ui/gfx/color_space.h" | 19 #include "ui/gfx/color_space.h" |
19 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
20 #include "ui/gfx/geometry/size.h" | 21 #include "ui/gfx/geometry/size.h" |
21 | 22 |
22 namespace gfx { | 23 namespace gfx { |
23 class GpuMemoryBuffer; | 24 class GpuMemoryBuffer; |
24 } | 25 } |
25 | 26 |
26 namespace gpu { | 27 namespace gpu { |
27 class GpuMemoryBufferManager; | 28 class GpuMemoryBufferManager; |
28 | 29 |
29 namespace gles2 { | 30 namespace gles2 { |
30 class GLES2Interface; | 31 class GLES2Interface; |
31 } | 32 } |
32 } | 33 } |
33 | 34 |
34 namespace display_compositor { | 35 namespace display_compositor { |
35 | 36 |
36 class GLHelper; | 37 class GLHelper; |
37 | 38 |
38 // Provides a surface that manages its own buffers, backed by GpuMemoryBuffers | 39 // Provides a surface that manages its own buffers, backed by GpuMemoryBuffers |
39 // created using CHROMIUM_gpu_memory_buffer_image. Double/triple buffering is | 40 // created using CHROMIUM_gpu_memory_buffer_image. Double/triple buffering is |
40 // implemented internally. Doublebuffering occurs if PageFlipComplete is called | 41 // implemented internally. Doublebuffering occurs if PageFlipComplete is called |
41 // before the next BindFramebuffer call, otherwise it creates extra buffers. | 42 // before the next BindFramebuffer call, otherwise it creates extra buffers. |
42 class DISPLAY_COMPOSITOR_EXPORT BufferQueue { | 43 class DISPLAY_COMPOSITOR_EXPORT BufferQueue { |
43 public: | 44 public: |
44 BufferQueue(gpu::gles2::GLES2Interface* gl, | 45 BufferQueue(gpu::gles2::GLES2Interface* gl, |
45 uint32_t texture_target, | 46 uint32_t texture_target, |
46 uint32_t internal_format, | 47 uint32_t internal_format, |
| 48 gfx::BufferFormat format, |
47 GLHelper* gl_helper, | 49 GLHelper* gl_helper, |
48 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 50 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
49 gpu::SurfaceHandle surface_handle); | 51 gpu::SurfaceHandle surface_handle); |
50 virtual ~BufferQueue(); | 52 virtual ~BufferQueue(); |
51 | 53 |
52 void Initialize(); | 54 void Initialize(); |
53 | 55 |
54 void BindFramebuffer(); | 56 void BindFramebuffer(); |
55 void SwapBuffers(const gfx::Rect& damage); | 57 void SwapBuffers(const gfx::Rect& damage); |
56 void PageFlipComplete(); | 58 void PageFlipComplete(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 std::unique_ptr<AllocatedSurface> RecreateBuffer( | 105 std::unique_ptr<AllocatedSurface> RecreateBuffer( |
104 std::unique_ptr<AllocatedSurface> surface); | 106 std::unique_ptr<AllocatedSurface> surface); |
105 | 107 |
106 gpu::gles2::GLES2Interface* const gl_; | 108 gpu::gles2::GLES2Interface* const gl_; |
107 gfx::Size size_; | 109 gfx::Size size_; |
108 gfx::ColorSpace color_space_; | 110 gfx::ColorSpace color_space_; |
109 uint32_t fbo_; | 111 uint32_t fbo_; |
110 size_t allocated_count_; | 112 size_t allocated_count_; |
111 uint32_t texture_target_; | 113 uint32_t texture_target_; |
112 uint32_t internal_format_; | 114 uint32_t internal_format_; |
| 115 gfx::BufferFormat format_; |
113 // This surface is currently bound. This may be nullptr if no surface has | 116 // This surface is currently bound. This may be nullptr if no surface has |
114 // been bound, or if allocation failed at bind. | 117 // been bound, or if allocation failed at bind. |
115 std::unique_ptr<AllocatedSurface> current_surface_; | 118 std::unique_ptr<AllocatedSurface> current_surface_; |
116 // The surface currently on the screen, if any. | 119 // The surface currently on the screen, if any. |
117 std::unique_ptr<AllocatedSurface> displayed_surface_; | 120 std::unique_ptr<AllocatedSurface> displayed_surface_; |
118 // These are free for use, and are not nullptr. | 121 // These are free for use, and are not nullptr. |
119 std::vector<std::unique_ptr<AllocatedSurface>> available_surfaces_; | 122 std::vector<std::unique_ptr<AllocatedSurface>> available_surfaces_; |
120 // These have been swapped but are not displayed yet. Entries of this deque | 123 // These have been swapped but are not displayed yet. Entries of this deque |
121 // may be nullptr, if they represent frames that have been destroyed. | 124 // may be nullptr, if they represent frames that have been destroyed. |
122 std::deque<std::unique_ptr<AllocatedSurface>> in_flight_surfaces_; | 125 std::deque<std::unique_ptr<AllocatedSurface>> in_flight_surfaces_; |
123 GLHelper* gl_helper_; | 126 GLHelper* gl_helper_; |
124 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 127 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
125 gpu::SurfaceHandle surface_handle_; | 128 gpu::SurfaceHandle surface_handle_; |
126 | 129 |
127 DISALLOW_COPY_AND_ASSIGN(BufferQueue); | 130 DISALLOW_COPY_AND_ASSIGN(BufferQueue); |
128 }; | 131 }; |
129 | 132 |
130 } // namespace display_compositor | 133 } // namespace display_compositor |
131 | 134 |
132 #endif // COMPONENTS_DISPLAY_COMPOSITOR_BUFFER_QUEUE_H_ | 135 #endif // COMPONENTS_DISPLAY_COMPOSITOR_BUFFER_QUEUE_H_ |
OLD | NEW |