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

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: Use vector<scoped_ptr<T>> 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
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 { return current_surface_->texture; }
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();
62 AllocatedSurface(scoped_ptr<gfx::GpuMemoryBuffer> buffer, 62 AllocatedSurface(BufferQueue* buffer_queue,
63 scoped_ptr<gfx::GpuMemoryBuffer> buffer,
63 unsigned int texture, 64 unsigned int texture,
64 unsigned int image, 65 unsigned int image,
65 const gfx::Rect& rect); 66 const gfx::Rect& rect);
66 ~AllocatedSurface(); 67 ~AllocatedSurface();
67 // TODO(ccameron): Change this to be a scoped_ptr, and change all use of 68 BufferQueue* buffer_queue;
68 // AllocatedSurface to use scoped_ptr as well. 69 scoped_ptr<gfx::GpuMemoryBuffer> buffer;
69 linked_ptr<gfx::GpuMemoryBuffer> buffer;
70 unsigned int texture; 70 unsigned int texture;
71 unsigned int image; 71 unsigned int image;
72 gfx::Rect damage; // This is the damage for this frame from the previous. 72 gfx::Rect damage; // This is the damage for this frame from the previous.
73 }; 73 };
74 74
75 void FreeAllSurfaces(); 75 void FreeAllSurfaces();
76 76
77 void FreeSurface(AllocatedSurface* surface); 77 void FreeSurfaceResources(AllocatedSurface* surface);
78 78
79 // Copy everything that is in |copy_rect|, except for what is in 79 // Copy everything that is in |copy_rect|, except for what is in
80 // |exclude_rect| from |source_texture| to |texture|. 80 // |exclude_rect| from |source_texture| to |texture|.
81 virtual void CopyBufferDamage(int texture, 81 virtual void CopyBufferDamage(int texture,
82 int source_texture, 82 int source_texture,
83 const gfx::Rect& new_damage, 83 const gfx::Rect& new_damage,
84 const gfx::Rect& old_damage); 84 const gfx::Rect& old_damage);
85 85
86 void UpdateBufferDamage(const gfx::Rect& damage); 86 void UpdateBufferDamage(const gfx::Rect& damage);
87 87
88 // Return a surface, available to be drawn into. 88 // Return a surface, available to be drawn into.
89 AllocatedSurface GetNextSurface(); 89 scoped_ptr<AllocatedSurface> GetNextSurface();
90 90
91 AllocatedSurface RecreateBuffer(AllocatedSurface* surface); 91 scoped_ptr<AllocatedSurface> RecreateBuffer(
92 scoped_ptr<AllocatedSurface> surface);
92 93
93 gfx::Size size_; 94 gfx::Size size_;
94 scoped_refptr<cc::ContextProvider> context_provider_; 95 scoped_refptr<cc::ContextProvider> context_provider_;
95 unsigned int fbo_; 96 unsigned int fbo_;
96 size_t allocated_count_; 97 size_t allocated_count_;
97 unsigned int texture_target_; 98 unsigned int texture_target_;
98 unsigned int internal_format_; 99 unsigned int internal_format_;
99 AllocatedSurface current_surface_; // This surface is currently bound. 100 // This surface is currently bound.
100 AllocatedSurface displayed_surface_; // The surface currently on the screen. 101 scoped_ptr<AllocatedSurface> current_surface_;
101 std::vector<AllocatedSurface> available_surfaces_; // These are free for use. 102 // The surface currently on the screen.
102 std::deque<AllocatedSurface> in_flight_surfaces_; 103 scoped_ptr<AllocatedSurface> displayed_surface_;
104 // These are free for use.
105 std::vector<scoped_ptr<AllocatedSurface>> available_surfaces_;
106 // These have been swapped but are not displayed yet.
107 std::deque<scoped_ptr<AllocatedSurface>> in_flight_surfaces_;
103 GLHelper* gl_helper_; 108 GLHelper* gl_helper_;
104 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager_; 109 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager_;
105 int surface_id_; 110 int surface_id_;
106 111
107 DISALLOW_COPY_AND_ASSIGN(BufferQueue); 112 DISALLOW_COPY_AND_ASSIGN(BufferQueue);
108 }; 113 };
109 114
110 } // namespace content 115 } // namespace content
111 116
112 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_ 117 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/compositor/buffer_queue.cc » ('j') | content/browser/compositor/buffer_queue.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698