OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 CC_OUTPUT_COMPOSITOR_FRAME_SINK_CLIENT_H_ | 5 #ifndef CC_OUTPUT_COMPOSITOR_FRAME_SINK_CLIENT_H_ |
6 #define CC_OUTPUT_COMPOSITOR_FRAME_SINK_CLIENT_H_ | 6 #define CC_OUTPUT_COMPOSITOR_FRAME_SINK_CLIENT_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
12 #include "cc/output/context_provider.h" | 12 #include "cc/output/context_provider.h" |
13 #include "cc/resources/returned_resource.h" | 13 #include "cc/resources/returned_resource.h" |
14 #include "gpu/command_buffer/common/texture_in_use_response.h" | 14 #include "gpu/command_buffer/common/texture_in_use_response.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 | 16 |
17 namespace gfx { | 17 namespace gfx { |
18 class Transform; | 18 class Transform; |
19 } | 19 } |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 | 22 |
23 class BeginFrameSource; | 23 class BeginFrameSource; |
24 struct ManagedMemoryPolicy; | 24 struct ManagedMemoryPolicy; |
25 | 25 |
26 class CC_EXPORT CompositorFrameSinkClient { | 26 class CC_EXPORT CompositorFrameSinkClient { |
27 public: | 27 public: |
28 // Pass the begin frame source for the client to observe. Client does not own | 28 // Pass the begin frame source for the client to observe. Client does not own |
29 // the BeginFrameSource. CompositorFrameSink should call this once after | 29 // the BeginFrameSource. CompositorFrameSink should call this once after |
30 // binding to | 30 // binding to the client and then call again with a null while detaching. |
31 // the client and then call again with a null while detaching. | |
32 virtual void SetBeginFrameSource(BeginFrameSource* source) = 0; | 31 virtual void SetBeginFrameSource(BeginFrameSource* source) = 0; |
32 | |
33 // Returns resources sent to SubmitCompositorFrame to be reused or freed. | |
33 virtual void ReclaimResources(const ReturnedResourceArray& resources) = 0; | 34 virtual void ReclaimResources(const ReturnedResourceArray& resources) = 0; |
34 // For WebView. | 35 |
35 virtual void SetExternalTilePriorityConstraints( | |
36 const gfx::Rect& viewport_rect, | |
37 const gfx::Transform& transform) = 0; | |
38 // If set, |callback| will be called subsequent to each new tree activation, | 36 // If set, |callback| will be called subsequent to each new tree activation, |
39 // regardless of the compositor visibility or damage. |callback| must remain | 37 // regardless of the compositor visibility or damage. |callback| must remain |
40 // valid for the lifetime of the CompositorFrameSinkClient or until unregisted | 38 // valid for the lifetime of the CompositorFrameSinkClient or until |
41 // -- | 39 // unregisted by giving a null base::Closure. |
sunnyps
2016/10/11 18:32:48
nit: unregistered
danakj
2016/10/13 23:50:22
Done.
| |
42 // use SetTreeActivationCallback(base::Closure()) to unregister it. | |
43 virtual void SetTreeActivationCallback(const base::Closure& callback) = 0; | 40 virtual void SetTreeActivationCallback(const base::Closure& callback) = 0; |
44 // This allows the output surface to ask its client for a draw. | 41 |
42 // Notification that the previous CompositorFrame given to | |
43 // SubmitCompositorFrame() has been processed and that another frame | |
44 // can be submitted. This provides backpressure from the display compositor | |
45 // so that frames are submitted only at the rate it can handle them. | |
46 virtual void DidReceiveCompositorFrameAck() = 0; | |
47 | |
48 // The CompositorFrameSink is lost when the ContextProviders held by it | |
enne (OOO)
2016/10/11 17:26:00
Thanks for these comments in this file. :)
| |
49 // encounter an error. In this case the CompositorFrameSink (and the | |
50 // ContextProviders) must be recreated. | |
51 virtual void DidLoseCompositorFrameSink() = 0; | |
52 | |
53 // For SynchronousCompositor (WebView) to ask the layer compositor to submit | |
54 // a new CompositorFrame synchronously. | |
45 virtual void OnDraw(const gfx::Transform& transform, | 55 virtual void OnDraw(const gfx::Transform& transform, |
46 const gfx::Rect& viewport, | 56 const gfx::Rect& viewport, |
47 bool resourceless_software_draw) = 0; | 57 bool resourceless_software_draw) = 0; |
58 | |
48 // For SynchronousCompositor (WebView) to set how much memory the compositor | 59 // For SynchronousCompositor (WebView) to set how much memory the compositor |
49 // can use without changing visibility. | 60 // can use without changing visibility. |
50 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) = 0; | 61 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) = 0; |
51 | 62 |
52 // ============== BOTH TYPES OF COMPOSITOR ====================== | 63 // For SynchronousCompositor (WebView) to change which tiles should be |
53 | 64 // included in submitted CompositorFrames independently of what the viewport |
54 // For LayerTreeHostImpl, this is more of a OnSwapBuffersAck from the display | 65 // is. |
55 // compositor that it received and will use the frame, unblocking it from | 66 virtual void SetExternalTilePriorityConstraints( |
56 // producing more frames. | 67 const gfx::Rect& viewport_rect, |
57 // For the display compositor this is literally a notification that the swap | 68 const gfx::Transform& transform) = 0; |
58 // to the hardware is complete. | |
59 virtual void DidSwapBuffersComplete() = 0; | |
60 | |
61 // Needs thought, if LTHI has only context providers, it needs to register a | |
62 // lost callback, so we need to support multiple callbacks. | |
63 virtual void DidLoseCompositorFrameSink() = 0; | |
64 | 69 |
65 protected: | 70 protected: |
66 virtual ~CompositorFrameSinkClient() {} | 71 virtual ~CompositorFrameSinkClient() {} |
67 }; | 72 }; |
68 | 73 |
69 } // namespace cc | 74 } // namespace cc |
70 | 75 |
71 #endif // CC_OUTPUT_COMPOSITOR_FRAME_SINK_CLIENT_H_ | 76 #endif // CC_OUTPUT_COMPOSITOR_FRAME_SINK_CLIENT_H_ |
OLD | NEW |