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

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

Issue 571623003: Partial swap implementation for surfaceless (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplify some of the swap logic. verified works Created 6 years, 2 months 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_BUFFERED_OUTPUT_SURFACE_H_ 5 #ifndef CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_
6 #define CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_ 6 #define CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "ui/gfx/rect.h"
13 #include "ui/gfx/size.h" 15 #include "ui/gfx/size.h"
14 16
15 namespace cc { 17 namespace cc {
16 class ContextProvider; 18 class ContextProvider;
17 } 19 }
18 20
19 namespace content { 21 namespace content {
20 22
21 // Provides a surface that manages its own uffers, backed by 23 // Provides a surface that manages its own uffers, backed by
22 // CreateImageCHROMIUM. Double/triple buffering is implemented 24 // CreateImageCHROMIUM. Double/triple buffering is implemented
23 // internally. Doublebuffering occurs if PageFlipComplete is called before 25 // internally. Doublebuffering occurs if PageFlipComplete is called before
24 // the next BindFramebuffer call, otherwise it creates extra buffers. 26 // the next BindFramebuffer call, otherwise it creates extra buffers.
25 class CONTENT_EXPORT BufferQueue { 27 class CONTENT_EXPORT BufferQueue {
26 public: 28 public:
27 BufferQueue(scoped_refptr<cc::ContextProvider> context_provider, 29 BufferQueue(scoped_refptr<cc::ContextProvider> context_provider,
28 unsigned int internalformat); 30 unsigned int internalformat);
29 ~BufferQueue(); 31 virtual ~BufferQueue();
30 32
31 bool Initialize(); 33 bool Initialize();
32 34
33 void BindFramebuffer(); 35 void BindFramebuffer();
34 void SwapBuffers(); 36 void SwapBuffers(const gfx::Rect& damage);
35 void PageFlipComplete(); 37 void PageFlipComplete();
36 void Reshape(const gfx::Size& size, float scale_factor); 38 void Reshape(const gfx::Size& size, float scale_factor);
37 39
38 unsigned int current_texture_id() { return current_surface_.texture; } 40 unsigned int current_texture_id() { return current_surface_.texture; }
39 41
40 private: 42 private:
41 friend class BufferQueueTest; 43 friend class BufferQueueTest;
44
42 struct AllocatedSurface { 45 struct AllocatedSurface {
43 AllocatedSurface() : texture(0), image(0) {} 46 AllocatedSurface() : texture(0), image(0) {}
44 AllocatedSurface(unsigned int texture, unsigned int image) 47 AllocatedSurface(unsigned int texture,
45 : texture(texture), image(image) {} 48 unsigned int image,
49 const gfx::Rect& rect)
50 : texture(texture), image(image), damage(rect) {}
46 unsigned int texture; 51 unsigned int texture;
47 unsigned int image; 52 unsigned int image;
53 gfx::Rect damage; // This is the damage for this frame from the previous.
48 }; 54 };
49 55
50 void FreeAllSurfaces(); 56 void FreeAllSurfaces();
51 57
52 void FreeSurface(AllocatedSurface* surface); 58 void FreeSurface(AllocatedSurface* surface);
53 59
60 // Copy everything that is in |copy_rect|, except for what is in
61 // |exclude_rect| from |source_texture| to |texture|.
62 virtual void CopyBufferDamage(int texture,
63 int source_texture,
64 const gfx::Rect& new_damage,
65 const gfx::Rect& old_damage);
66
67 void UpdateBufferDamage(const gfx::Rect& damage);
68
54 // Return a surface, available to be drawn into. 69 // Return a surface, available to be drawn into.
55 AllocatedSurface GetNextSurface(); 70 AllocatedSurface GetNextSurface();
56 71
57 gfx::Size size_; 72 gfx::Size size_;
58 scoped_refptr<cc::ContextProvider> context_provider_; 73 scoped_refptr<cc::ContextProvider> context_provider_;
59 unsigned int fbo_; 74 unsigned int fbo_;
60 size_t allocated_count_; 75 size_t allocated_count_;
61 unsigned int internalformat_; 76 unsigned int internalformat_;
62 AllocatedSurface current_surface_; // This surface is currently bound. 77 AllocatedSurface current_surface_; // This surface is currently bound.
63 std::vector<AllocatedSurface> available_surfaces_; // These are free for use. 78 std::vector<AllocatedSurface> available_surfaces_; // These are free for use.
64 std::queue<AllocatedSurface> in_flight_surfaces_; 79 std::deque<AllocatedSurface> in_flight_surfaces_;
65 80
66 DISALLOW_COPY_AND_ASSIGN(BufferQueue); 81 DISALLOW_COPY_AND_ASSIGN(BufferQueue);
67 }; 82 };
68 83
69 } // namespace content 84 } // namespace content
70 85
71 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_ 86 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_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