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

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

Issue 516663003: Surfaceless OutputSurface implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: implement GenRenderbuffers 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_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ 5 #ifndef CONTENT_BROWSER_COMPOSITOR_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_
6 #define CONTENT_BROWSER_COMPOSITOR_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ 6 #define CONTENT_BROWSER_COMPOSITOR_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_
7 7
8 #include "content/browser/compositor/browser_compositor_output_surface.h" 8 #include "content/browser/compositor/browser_compositor_output_surface.h"
9 9
10 #include "cc/output/context_provider.h"
11 #include "content/common/content_export.h"
12
10 namespace ui { 13 namespace ui {
11 class CompositorVSyncManager; 14 class CompositorVSyncManager;
12 } 15 }
13 16
14 namespace cc { 17 namespace cc {
15 class OverlayCandidateValidator; 18 class OverlayCandidateValidator;
16 } 19 }
17 20
18 namespace content { 21 namespace content {
19 22
20 // Adapts a WebGraphicsContext3DCommandBufferImpl into a 23 // Adapts a WebGraphicsContext3DCommandBufferImpl into a
21 // cc::OutputSurface that also handles vsync parameter updates 24 // cc::OutputSurface that also handles vsync parameter updates
22 // arriving from the GPU process. 25 // arriving from the GPU process.
23 class GpuBrowserCompositorOutputSurface 26 class GpuBrowserCompositorOutputSurface
24 : public BrowserCompositorOutputSurface { 27 : public BrowserCompositorOutputSurface {
25 public: 28 public:
26 GpuBrowserCompositorOutputSurface( 29 GpuBrowserCompositorOutputSurface(
27 const scoped_refptr<ContextProviderCommandBuffer>& context, 30 const scoped_refptr<ContextProviderCommandBuffer>& context,
28 int surface_id, 31 int surface_id,
29 IDMap<BrowserCompositorOutputSurface>* output_surface_map, 32 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
30 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, 33 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
31 scoped_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator); 34 scoped_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator);
32 35
33 virtual ~GpuBrowserCompositorOutputSurface(); 36 virtual ~GpuBrowserCompositorOutputSurface();
34 37
35 private: 38 protected:
36 // cc::OutputSurface implementation. 39 // cc::OutputSurface implementation.
37 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE; 40 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE;
38 41
39 DISALLOW_COPY_AND_ASSIGN(GpuBrowserCompositorOutputSurface); 42 DISALLOW_COPY_AND_ASSIGN(GpuBrowserCompositorOutputSurface);
40 }; 43 };
41 44
45 // Provides a surface that manages its own uffers, backed by
46 // CreateImageCHROMIUM. Double/triple buffering is implemented
47 // internally. Doublebuffering occurs if PageFlipComplete is called before
48 // the next BindFramebuffer call, otherwise it creates extra buffers.
49 class CONTENT_EXPORT BufferedOutputSurface {
alexst (slow to review) 2014/09/02 13:15:59 Let's move this into a separate file.
50 public:
51 BufferedOutputSurface(scoped_refptr<cc::ContextProvider> context_provider,
52 unsigned int internalformat);
53 ~BufferedOutputSurface();
54
55 void BindFramebuffer();
56 void SwapBuffers();
57 void PageFlipComplete();
58 void Reshape(const gfx::Size& size, float scale_factor);
59
60 unsigned int tex_id() { return tex_id_; }
61
62 private:
63 friend class BufferedOutputSurfaceTest;
64
65 void FreeAllSurfaces();
66
67 void FreeSurface(unsigned int* surface);
68
69 // Return a surface, available to be drawn into.
70 unsigned int GetNextSurface();
71
72 gfx::Size size_;
73 scoped_refptr<cc::ContextProvider> context_provider_;
74 unsigned int fbo_, depth_rb_, tex_id_;
75 unsigned int internalformat_;
76 unsigned int current_surface_; // This surface is currently bound.
77 unsigned int last_surface_; // This surface has been sent to the hardware.
78 unsigned int available_surface_; // This surface is free for use.
79 unsigned int in_flight_surface_; // This surface is waiting for the callback.
80 };
81
82 class GpuSurfacelessBrowserCompositorOutputSurface
alexst (slow to review) 2014/09/02 13:16:00 Let's put this in a separate file too.
83 : public GpuBrowserCompositorOutputSurface {
84 public:
85 GpuSurfacelessBrowserCompositorOutputSurface(
86 const scoped_refptr<ContextProviderCommandBuffer>& context,
87 int surface_id,
88 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
89 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
90 scoped_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator,
91 unsigned internalformat,
92 int z_order);
93 virtual ~GpuSurfacelessBrowserCompositorOutputSurface();
94
95 private:
96 // cc::OutputSurface implementation.
97 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE;
98 virtual void OnSwapBuffersComplete() OVERRIDE;
99 virtual void BindFramebuffer() OVERRIDE;
100 virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE;
101 virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE;
102
103 int z_order_;
104 bool expects_pageflip_messages_;
105 unsigned int internalformat_;
106 scoped_ptr<BufferedOutputSurface> output_surface_;
107 };
108
42 } // namespace content 109 } // namespace content
43 110
44 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ 111 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698