Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: content/browser/compositor/buffer_queue.h

Issue 1423843003: Make content::BufferQueue use scoped ptrs for AllocatedSurfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@surfaceless_only
Patch Set: More feedback Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/compositor/buffer_queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 {
54 return current_surface_ ? current_surface_->texture : 0;
55 }
55 unsigned int fbo() const { return fbo_; } 56 unsigned int fbo() const { return fbo_; }
56 57
57 private: 58 private:
58 friend class BufferQueueTest; 59 friend class BufferQueueTest;
60 friend class AllocatedSurface;
59 61
60 struct CONTENT_EXPORT AllocatedSurface { 62 struct CONTENT_EXPORT AllocatedSurface {
61 AllocatedSurface(); 63 AllocatedSurface(BufferQueue* buffer_queue,
62 AllocatedSurface(scoped_ptr<gfx::GpuMemoryBuffer> buffer, 64 scoped_ptr<gfx::GpuMemoryBuffer> buffer,
63 unsigned int texture, 65 unsigned int texture,
64 unsigned int image, 66 unsigned int image,
65 const gfx::Rect& rect); 67 const gfx::Rect& rect);
66 ~AllocatedSurface(); 68 ~AllocatedSurface();
67 // TODO(ccameron): Change this to be a scoped_ptr, and change all use of 69 BufferQueue* const buffer_queue;
68 // AllocatedSurface to use scoped_ptr as well. 70 scoped_ptr<gfx::GpuMemoryBuffer> buffer;
69 linked_ptr<gfx::GpuMemoryBuffer> buffer; 71 const unsigned int texture;
70 unsigned int texture; 72 const unsigned int image;
71 unsigned int image;
72 gfx::Rect damage; // This is the damage for this frame from the previous. 73 gfx::Rect damage; // This is the damage for this frame from the previous.
73 }; 74 };
74 75
75 void FreeAllSurfaces(); 76 void FreeAllSurfaces();
76 77
77 void FreeSurface(AllocatedSurface* surface); 78 void FreeSurfaceResources(AllocatedSurface* surface);
78 79
79 // Copy everything that is in |copy_rect|, except for what is in 80 // Copy everything that is in |copy_rect|, except for what is in
80 // |exclude_rect| from |source_texture| to |texture|. 81 // |exclude_rect| from |source_texture| to |texture|.
81 virtual void CopyBufferDamage(int texture, 82 virtual void CopyBufferDamage(int texture,
82 int source_texture, 83 int source_texture,
83 const gfx::Rect& new_damage, 84 const gfx::Rect& new_damage,
84 const gfx::Rect& old_damage); 85 const gfx::Rect& old_damage);
85 86
86 void UpdateBufferDamage(const gfx::Rect& damage); 87 void UpdateBufferDamage(const gfx::Rect& damage);
87 88
88 // Return a surface, available to be drawn into. 89 // Return a surface, available to be drawn into.
89 AllocatedSurface GetNextSurface(); 90 scoped_ptr<AllocatedSurface> GetNextSurface();
90 91
91 AllocatedSurface RecreateBuffer(AllocatedSurface* surface); 92 scoped_ptr<AllocatedSurface> RecreateBuffer(
93 scoped_ptr<AllocatedSurface> surface);
92 94
93 gfx::Size size_; 95 gfx::Size size_;
94 scoped_refptr<cc::ContextProvider> context_provider_; 96 scoped_refptr<cc::ContextProvider> context_provider_;
95 unsigned int fbo_; 97 unsigned int fbo_;
96 size_t allocated_count_; 98 size_t allocated_count_;
97 unsigned int texture_target_; 99 unsigned int texture_target_;
98 unsigned int internal_format_; 100 unsigned int internal_format_;
99 AllocatedSurface current_surface_; // This surface is currently bound. 101 // This surface is currently bound. This may be nullptr if no surface has
100 AllocatedSurface displayed_surface_; // The surface currently on the screen. 102 // been bound, or if allocation failed at bind.
101 std::vector<AllocatedSurface> available_surfaces_; // These are free for use. 103 scoped_ptr<AllocatedSurface> current_surface_;
102 std::deque<AllocatedSurface> in_flight_surfaces_; 104 // The surface currently on the screen, if any.
105 scoped_ptr<AllocatedSurface> displayed_surface_;
106 // These are free for use, and are not nullptr.
107 std::vector<scoped_ptr<AllocatedSurface>> available_surfaces_;
108 // These have been swapped but are not displayed yet. Entries of this deque
109 // may be nullptr, if they represent frames that have been destroyed.
110 std::deque<scoped_ptr<AllocatedSurface>> in_flight_surfaces_;
103 GLHelper* gl_helper_; 111 GLHelper* gl_helper_;
104 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager_; 112 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager_;
105 int surface_id_; 113 int surface_id_;
106 114
107 DISALLOW_COPY_AND_ASSIGN(BufferQueue); 115 DISALLOW_COPY_AND_ASSIGN(BufferQueue);
108 }; 116 };
109 117
110 } // namespace content 118 } // namespace content
111 119
112 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_ 120 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/compositor/buffer_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698