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

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: Created 6 years, 3 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
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
23 class GLHelper;
24
21 // Provides a surface that manages its own uffers, backed by 25 // Provides a surface that manages its own uffers, backed by
22 // CreateImageCHROMIUM. Double/triple buffering is implemented 26 // CreateImageCHROMIUM. Double/triple buffering is implemented
23 // internally. Doublebuffering occurs if PageFlipComplete is called before 27 // internally. Doublebuffering occurs if PageFlipComplete is called before
24 // the next BindFramebuffer call, otherwise it creates extra buffers. 28 // the next BindFramebuffer call, otherwise it creates extra buffers.
25 class CONTENT_EXPORT BufferQueue { 29 class CONTENT_EXPORT BufferQueue {
26 public: 30 public:
27 BufferQueue(scoped_refptr<cc::ContextProvider> context_provider, 31 BufferQueue(scoped_refptr<cc::ContextProvider> context_provider,
32 GLHelper* gl_helper,
28 unsigned int internalformat); 33 unsigned int internalformat);
29 ~BufferQueue(); 34 virtual ~BufferQueue();
30 35
31 bool Initialize(); 36 bool Initialize();
32 37
33 void BindFramebuffer(); 38 void BindFramebuffer();
34 void SwapBuffers(); 39 void SwapBuffers(const gfx::Rect& damage);
35 void PageFlipComplete(); 40 void PageFlipComplete();
36 void Reshape(const gfx::Size& size, float scale_factor); 41 void Reshape(const gfx::Size& size, float scale_factor);
37 42
38 unsigned int current_texture_id() { return current_surface_.texture; } 43 unsigned int current_texture_id() { return current_surface_.texture; }
39 44
40 private: 45 private:
41 friend class BufferQueueTest; 46 friend class BufferQueueTest;
47
42 struct AllocatedSurface { 48 struct AllocatedSurface {
43 AllocatedSurface() : texture(0), image(0) {} 49 AllocatedSurface() : texture(0), image(0) {}
44 AllocatedSurface(unsigned int texture, unsigned int image) 50 AllocatedSurface(unsigned int texture,
45 : texture(texture), image(image) {} 51 unsigned int image,
52 const gfx::Rect& rect)
53 : texture(texture), image(image), damage(rect) {}
46 unsigned int texture; 54 unsigned int texture;
47 unsigned int image; 55 unsigned int image;
56 gfx::Rect damage; // This is the damage for this frame from the previous.
48 }; 57 };
49 58
50 void FreeAllSurfaces(); 59 void FreeAllSurfaces();
51 60
52 void FreeSurface(AllocatedSurface* surface); 61 void FreeSurface(AllocatedSurface* surface);
53 62
63 // Copy everything that is in |copy_rect|, except for what is in
64 // |exclude_rect| from |source_texture| to |texture|
alexst (slow to review) 2014/09/17 20:34:06 nit: period at the end.
65 virtual void CopyBufferDamage(int texture,
66 int source_texture,
67 const gfx::Rect& exclude_rect,
alexst (slow to review) 2014/09/17 20:34:05 can you keep the names consistent with GLHelper as
achaulk 2014/09/17 20:41:57 Done.
68 const gfx::Rect& copy_rect);
69
54 // Return a surface, available to be drawn into. 70 // Return a surface, available to be drawn into.
55 AllocatedSurface GetNextSurface(); 71 AllocatedSurface GetNextSurface();
56 72
57 gfx::Size size_; 73 gfx::Size size_;
58 scoped_refptr<cc::ContextProvider> context_provider_; 74 scoped_refptr<cc::ContextProvider> context_provider_;
59 unsigned int fbo_; 75 unsigned int fbo_;
60 size_t allocated_count_; 76 size_t allocated_count_;
61 unsigned int internalformat_; 77 unsigned int internalformat_;
62 AllocatedSurface current_surface_; // This surface is currently bound. 78 AllocatedSurface current_surface_; // This surface is currently bound.
63 std::vector<AllocatedSurface> available_surfaces_; // These are free for use. 79 std::vector<AllocatedSurface> available_surfaces_; // These are free for use.
64 std::queue<AllocatedSurface> in_flight_surfaces_; 80 std::deque<AllocatedSurface> in_flight_surfaces_;
81 GLHelper* gl_helper_;
65 82
66 DISALLOW_COPY_AND_ASSIGN(BufferQueue); 83 DISALLOW_COPY_AND_ASSIGN(BufferQueue);
67 }; 84 };
68 85
69 } // namespace content 86 } // namespace content
70 87
71 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_H_ 88 #endif // CONTENT_BROWSER_COMPOSITOR_BUFFERED_OUTPUT_SURFACE_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