OLD | NEW |
| (Empty) |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_OUTPUT_SURFACE_H_ | |
6 #define CC_OUTPUT_SURFACE_H_ | |
7 | |
8 #define USE_CC_OUTPUT_SURFACE // TODO(danakj): Remove this. | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "cc/base/cc_export.h" | |
13 #include "cc/software_output_device.h" | |
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | |
15 | |
16 namespace gfx { | |
17 class Rect; | |
18 class Size; | |
19 } | |
20 | |
21 namespace cc { | |
22 | |
23 class CompositorFrame; | |
24 class OutputSurfaceClient; | |
25 | |
26 // Represents the output surface for a compositor. The compositor owns | |
27 // and manages its destruction. Its lifetime is: | |
28 // 1. Created on the main thread by the LayerTreeHost through its client. | |
29 // 2. Passed to the compositor thread and bound to a client via BindToClient. | |
30 // From here on, it will only be used on the compositor thread. | |
31 // 3. If the 3D context is lost, then the compositor will delete the output | |
32 // surface (on the compositor thread) and go back to step 1. | |
33 class CC_EXPORT OutputSurface { | |
34 public: | |
35 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); | |
36 | |
37 OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); | |
38 | |
39 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, | |
40 scoped_ptr<cc::SoftwareOutputDevice> software_device); | |
41 | |
42 virtual ~OutputSurface(); | |
43 | |
44 struct Capabilities { | |
45 Capabilities() | |
46 : has_parent_compositor(false), | |
47 max_frames_pending(0) {} | |
48 | |
49 bool has_parent_compositor; | |
50 int max_frames_pending; | |
51 }; | |
52 | |
53 const Capabilities& capabilities() const { | |
54 return capabilities_; | |
55 } | |
56 | |
57 // Obtain the 3d context or the software device associated with this output | |
58 // surface. Either of these may return a null pointer, but not both. | |
59 // In the event of a lost context, the entire output surface should be | |
60 // recreated. | |
61 WebKit::WebGraphicsContext3D* context3d() const { | |
62 return context3d_.get(); | |
63 } | |
64 | |
65 SoftwareOutputDevice* software_device() const { | |
66 return software_device_.get(); | |
67 } | |
68 | |
69 // Called by the compositor on the compositor thread. This is a place where | |
70 // thread-specific data for the output surface can be initialized, since from | |
71 // this point on the output surface will only be used on the compositor | |
72 // thread. | |
73 virtual bool BindToClient(OutputSurfaceClient*); | |
74 | |
75 // Sends frame data to the parent compositor. This should only be called when | |
76 // capabilities().has_parent_compositor. The implementation may destroy or | |
77 // steal the contents of the CompositorFrame passed in. | |
78 virtual void SendFrameToParentCompositor(CompositorFrame*); | |
79 | |
80 virtual void EnsureBackbuffer(); | |
81 virtual void DiscardBackbuffer(); | |
82 | |
83 virtual void Reshape(gfx::Size size); | |
84 | |
85 virtual void BindFramebuffer(); | |
86 | |
87 virtual void PostSubBuffer(gfx::Rect rect); | |
88 virtual void SwapBuffers(); | |
89 | |
90 // Notifies frame-rate smoothness preference. If true, all non-critical | |
91 // processing should be stopped, or lowered in priority. | |
92 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} | |
93 | |
94 protected: | |
95 OutputSurfaceClient* client_; | |
96 struct cc::OutputSurface::Capabilities capabilities_; | |
97 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; | |
98 scoped_ptr<cc::SoftwareOutputDevice> software_device_; | |
99 bool has_gl_discard_backbuffer_; | |
100 | |
101 private: | |
102 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | |
103 }; | |
104 | |
105 } // namespace cc | |
106 | |
107 #endif // CC_OUTPUT_SURFACE_H_ | |
OLD | NEW |