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

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: Created 5 years, 1 month 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 <queue>
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"
13 #include "cc/base/scoped_ptr_deque.h"
14 #include "cc/base/scoped_ptr_vector.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/geometry/size.h" 17 #include "ui/gfx/geometry/size.h"
17 18
18 namespace cc { 19 namespace cc {
19 class ContextProvider; 20 class ContextProvider;
20 } 21 }
21 22
22 namespace gfx { 23 namespace gfx {
23 class GpuMemoryBuffer; 24 class GpuMemoryBuffer;
(...skipping 20 matching lines...) Expand all
44 45
45 void Initialize(); 46 void Initialize();
46 47
47 void BindFramebuffer(); 48 void BindFramebuffer();
48 void SwapBuffers(const gfx::Rect& damage); 49 void SwapBuffers(const gfx::Rect& damage);
49 void PageFlipComplete(); 50 void PageFlipComplete();
50 void Reshape(const gfx::Size& size, float scale_factor); 51 void Reshape(const gfx::Size& size, float scale_factor);
51 52
52 void RecreateBuffers(); 53 void RecreateBuffers();
53 54
54 unsigned int current_texture_id() const { return current_surface_.texture; } 55 unsigned int current_texture_id() const { return current_surface_->texture; }
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;
59 60
60 struct CONTENT_EXPORT AllocatedSurface { 61 struct CONTENT_EXPORT AllocatedSurface {
61 AllocatedSurface(); 62 AllocatedSurface();
62 AllocatedSurface(scoped_ptr<gfx::GpuMemoryBuffer> buffer, 63 AllocatedSurface(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 scoped_ptr<gfx::GpuMemoryBuffer> buffer;
68 // AllocatedSurface to use scoped_ptr as well.
69 linked_ptr<gfx::GpuMemoryBuffer> buffer;
70 unsigned int texture; 69 unsigned int texture;
71 unsigned int image; 70 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 FreeSurface(scoped_ptr<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.
100 AllocatedSurface displayed_surface_; // The surface currently on the screen. 100 scoped_ptr<AllocatedSurface> current_surface_;
101 std::vector<AllocatedSurface> available_surfaces_; // These are free for use. 101 // The surface currently on the screen.
102 std::deque<AllocatedSurface> in_flight_surfaces_; 102 scoped_ptr<AllocatedSurface> displayed_surface_;
103 // These are free for use.
104 cc::ScopedPtrVector<AllocatedSurface> available_surfaces_;
reveman 2015/10/27 17:03:44 could we use base::ScopedVector instead?
105 cc::ScopedPtrDeque<AllocatedSurface> in_flight_surfaces_;
106 size_t deleted_in_flight_surface_count_;
103 GLHelper* gl_helper_; 107 GLHelper* gl_helper_;
104 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager_; 108 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager_;
105 int surface_id_; 109 int surface_id_;
106 110
107 DISALLOW_COPY_AND_ASSIGN(BufferQueue); 111 DISALLOW_COPY_AND_ASSIGN(BufferQueue);
108 }; 112 };
109 113
110 } // namespace content 114 } // namespace content
111 115
112 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_ 116 #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