Chromium Code Reviews| 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 CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_ | 5 #ifndef CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_ |
| 6 #define CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_ | 6 #define CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <deque> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/linked_ptr.h" | |
| 12 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 14 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 17 | 16 |
| 18 namespace cc { | 17 namespace cc { |
| 19 class ContextProvider; | 18 class ContextProvider; |
| 20 } | 19 } |
| 21 | 20 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 44 | 43 |
| 45 void Initialize(); | 44 void Initialize(); |
| 46 | 45 |
| 47 void BindFramebuffer(); | 46 void BindFramebuffer(); |
| 48 void SwapBuffers(const gfx::Rect& damage); | 47 void SwapBuffers(const gfx::Rect& damage); |
| 49 void PageFlipComplete(); | 48 void PageFlipComplete(); |
| 50 void Reshape(const gfx::Size& size, float scale_factor); | 49 void Reshape(const gfx::Size& size, float scale_factor); |
| 51 | 50 |
| 52 void RecreateBuffers(); | 51 void RecreateBuffers(); |
| 53 | 52 |
| 54 unsigned int current_texture_id() const { return current_surface_.texture; } | 53 unsigned int current_texture_id() const { return current_surface_->texture; } |
|
danakj
2015/12/10 01:36:02
do callers need to worry about null here? can they
ccameron
2015/12/10 07:39:27
Callers should worry. I'll preserve the old behavi
| |
| 55 unsigned int fbo() const { return fbo_; } | 54 unsigned int fbo() const { return fbo_; } |
| 56 | 55 |
| 57 private: | 56 private: |
| 58 friend class BufferQueueTest; | 57 friend class BufferQueueTest; |
| 58 friend class AllocatedSurface; | |
| 59 | 59 |
| 60 struct CONTENT_EXPORT AllocatedSurface { | 60 struct CONTENT_EXPORT AllocatedSurface { |
| 61 AllocatedSurface(); | 61 AllocatedSurface(BufferQueue* buffer_queue, |
| 62 AllocatedSurface(scoped_ptr<gfx::GpuMemoryBuffer> buffer, | 62 scoped_ptr<gfx::GpuMemoryBuffer> buffer, |
| 63 unsigned int texture, | 63 unsigned int texture, |
| 64 unsigned int image, | 64 unsigned int image, |
| 65 const gfx::Rect& rect); | 65 const gfx::Rect& rect); |
| 66 ~AllocatedSurface(); | 66 ~AllocatedSurface(); |
| 67 // TODO(ccameron): Change this to be a scoped_ptr, and change all use of | 67 BufferQueue* const buffer_queue; |
| 68 // AllocatedSurface to use scoped_ptr as well. | 68 scoped_ptr<gfx::GpuMemoryBuffer> buffer; |
| 69 linked_ptr<gfx::GpuMemoryBuffer> buffer; | 69 const unsigned int texture; |
| 70 unsigned int texture; | 70 const unsigned int image; |
| 71 unsigned int image; | |
| 72 gfx::Rect damage; // This is the damage for this frame from the previous. | 71 gfx::Rect damage; // This is the damage for this frame from the previous. |
| 73 }; | 72 }; |
| 74 | 73 |
| 75 void FreeAllSurfaces(); | 74 void FreeAllSurfaces(); |
| 76 | 75 |
| 77 void FreeSurface(AllocatedSurface* surface); | 76 void FreeSurfaceResources(AllocatedSurface* surface); |
| 78 | 77 |
| 79 // Copy everything that is in |copy_rect|, except for what is in | 78 // Copy everything that is in |copy_rect|, except for what is in |
| 80 // |exclude_rect| from |source_texture| to |texture|. | 79 // |exclude_rect| from |source_texture| to |texture|. |
| 81 virtual void CopyBufferDamage(int texture, | 80 virtual void CopyBufferDamage(int texture, |
| 82 int source_texture, | 81 int source_texture, |
| 83 const gfx::Rect& new_damage, | 82 const gfx::Rect& new_damage, |
| 84 const gfx::Rect& old_damage); | 83 const gfx::Rect& old_damage); |
| 85 | 84 |
| 86 void UpdateBufferDamage(const gfx::Rect& damage); | 85 void UpdateBufferDamage(const gfx::Rect& damage); |
| 87 | 86 |
| 88 // Return a surface, available to be drawn into. | 87 // Return a surface, available to be drawn into. |
| 89 AllocatedSurface GetNextSurface(); | 88 scoped_ptr<AllocatedSurface> GetNextSurface(); |
| 90 | 89 |
| 91 AllocatedSurface RecreateBuffer(AllocatedSurface* surface); | 90 scoped_ptr<AllocatedSurface> RecreateBuffer( |
| 91 scoped_ptr<AllocatedSurface> surface); | |
| 92 | 92 |
| 93 gfx::Size size_; | 93 gfx::Size size_; |
| 94 scoped_refptr<cc::ContextProvider> context_provider_; | 94 scoped_refptr<cc::ContextProvider> context_provider_; |
| 95 unsigned int fbo_; | 95 unsigned int fbo_; |
| 96 size_t allocated_count_; | 96 size_t allocated_count_; |
| 97 unsigned int texture_target_; | 97 unsigned int texture_target_; |
| 98 unsigned int internal_format_; | 98 unsigned int internal_format_; |
| 99 AllocatedSurface current_surface_; // This surface is currently bound. | 99 // This surface is currently bound. This may be nullptr if no surface has |
| 100 AllocatedSurface displayed_surface_; // The surface currently on the screen. | 100 // been bound, or if allocation failed at bind. |
| 101 std::vector<AllocatedSurface> available_surfaces_; // These are free for use. | 101 scoped_ptr<AllocatedSurface> current_surface_; |
| 102 std::deque<AllocatedSurface> in_flight_surfaces_; | 102 // The surface currently on the screen, if any. |
| 103 scoped_ptr<AllocatedSurface> displayed_surface_; | |
| 104 // These are free for use, and are not nullptr. | |
| 105 std::vector<scoped_ptr<AllocatedSurface>> available_surfaces_; | |
| 106 // These have been swapped but are not displayed yet. Entries of this deque | |
| 107 // may be nullptr, if they represent frames that have been destroyed. | |
| 108 std::deque<scoped_ptr<AllocatedSurface>> in_flight_surfaces_; | |
| 103 GLHelper* gl_helper_; | 109 GLHelper* gl_helper_; |
| 104 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager_; | 110 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 105 int surface_id_; | 111 int surface_id_; |
| 106 | 112 |
| 107 DISALLOW_COPY_AND_ASSIGN(BufferQueue); | 113 DISALLOW_COPY_AND_ASSIGN(BufferQueue); |
| 108 }; | 114 }; |
| 109 | 115 |
| 110 } // namespace content | 116 } // namespace content |
| 111 | 117 |
| 112 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_ | 118 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_ |
| OLD | NEW |