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

Side by Side Diff: cc/output/compositor_frame_sink.h

Issue 2408513002: Move memory observer off OutputSurface/CompositorFrameSink (Closed)
Patch Set: memoryobs-contextprovider: . Created 4 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 | cc/output/compositor_frame_sink.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 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_H_ 5 #ifndef CC_OUTPUT_COMPOSITOR_FRAME_SINK_H_
6 #define CC_OUTPUT_COMPOSITOR_FRAME_SINK_H_ 6 #define CC_OUTPUT_COMPOSITOR_FRAME_SINK_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "base/trace_event/memory_dump_provider.h"
16 #include "cc/base/cc_export.h" 15 #include "cc/base/cc_export.h"
17 #include "cc/output/context_provider.h" 16 #include "cc/output/context_provider.h"
18 #include "cc/output/overlay_candidate_validator.h" 17 #include "cc/output/overlay_candidate_validator.h"
19 #include "cc/output/vulkan_context_provider.h" 18 #include "cc/output/vulkan_context_provider.h"
20 #include "cc/resources/returned_resource.h" 19 #include "cc/resources/returned_resource.h"
21 #include "gpu/command_buffer/common/texture_in_use_response.h" 20 #include "gpu/command_buffer/common/texture_in_use_response.h"
22 #include "ui/gfx/color_space.h" 21 #include "ui/gfx/color_space.h"
23 22
24 namespace ui { 23 namespace ui {
25 class LatencyInfo; 24 class LatencyInfo;
(...skipping 12 matching lines...) Expand all
38 struct ManagedMemoryPolicy; 37 struct ManagedMemoryPolicy;
39 class CompositorFrameSinkClient; 38 class CompositorFrameSinkClient;
40 39
41 // Represents the output surface for a compositor. The compositor owns 40 // Represents the output surface for a compositor. The compositor owns
42 // and manages its destruction. Its lifetime is: 41 // and manages its destruction. Its lifetime is:
43 // 1. Created on the main thread by the LayerTreeHost through its client. 42 // 1. Created on the main thread by the LayerTreeHost through its client.
44 // 2. Passed to the compositor thread and bound to a client via BindToClient. 43 // 2. Passed to the compositor thread and bound to a client via BindToClient.
45 // From here on, it will only be used on the compositor thread. 44 // From here on, it will only be used on the compositor thread.
46 // 3. If the 3D context is lost, then the compositor will delete the output 45 // 3. If the 3D context is lost, then the compositor will delete the output
47 // surface (on the compositor thread) and go back to step 1. 46 // surface (on the compositor thread) and go back to step 1.
48 class CC_EXPORT CompositorFrameSink 47 class CC_EXPORT CompositorFrameSink {
49 : public base::trace_event::MemoryDumpProvider {
50 public: 48 public:
51 struct Capabilities { 49 struct Capabilities {
52 Capabilities() = default; 50 Capabilities() = default;
53 51
54 // Whether ForceReclaimResources can be called to reclaim all resources 52 // Whether ForceReclaimResources can be called to reclaim all resources
55 // from the CompositorFrameSink. 53 // from the CompositorFrameSink.
56 bool can_force_reclaim_resources = false; 54 bool can_force_reclaim_resources = false;
57 // True if sync points for resources are needed when swapping delegated 55 // True if sync points for resources are needed when swapping delegated
58 // frames. 56 // frames.
59 bool delegated_sync_points_required = true; 57 bool delegated_sync_points_required = true;
60 }; 58 };
61 59
62 // Constructor for GL-based and/or software compositing. 60 // Constructor for GL-based and/or software compositing.
63 CompositorFrameSink(scoped_refptr<ContextProvider> context_provider, 61 CompositorFrameSink(scoped_refptr<ContextProvider> context_provider,
64 scoped_refptr<ContextProvider> worker_context_provider); 62 scoped_refptr<ContextProvider> worker_context_provider);
65 63
66 // Constructor for Vulkan-based compositing. 64 // Constructor for Vulkan-based compositing.
67 explicit CompositorFrameSink( 65 explicit CompositorFrameSink(
68 scoped_refptr<VulkanContextProvider> vulkan_context_provider); 66 scoped_refptr<VulkanContextProvider> vulkan_context_provider);
69 67
70 ~CompositorFrameSink() override; 68 virtual ~CompositorFrameSink();
71 69
72 // Called by the compositor on the compositor thread. This is a place where 70 // Called by the compositor on the compositor thread. This is a place where
73 // thread-specific data for the output surface can be initialized, since from 71 // thread-specific data for the output surface can be initialized, since from
74 // this point to when DetachFromClient() is called the output surface will 72 // this point to when DetachFromClient() is called the output surface will
75 // only be used on the compositor thread. 73 // only be used on the compositor thread.
76 // The caller should call DetachFromClient() on the same thread before 74 // The caller should call DetachFromClient() on the same thread before
77 // destroying the CompositorFrameSink, even if this fails. And BindToClient 75 // destroying the CompositorFrameSink, even if this fails. And BindToClient
78 // should not be called twice for a given CompositorFrameSink. 76 // should not be called twice for a given CompositorFrameSink.
79 virtual bool BindToClient(CompositorFrameSinkClient* client); 77 virtual bool BindToClient(CompositorFrameSinkClient* client);
80 78
(...skipping 25 matching lines...) Expand all
106 // 104 //
107 // CompositorFrameSink::Invalidate is called by the compositor to notify that 105 // CompositorFrameSink::Invalidate is called by the compositor to notify that
108 // there's new content. 106 // there's new content.
109 virtual void Invalidate() {} 107 virtual void Invalidate() {}
110 108
111 // For successful swaps, the implementation must call DidSwapBuffersComplete() 109 // For successful swaps, the implementation must call DidSwapBuffersComplete()
112 // (via OnSwapBuffersComplete()) eventually. 110 // (via OnSwapBuffersComplete()) eventually.
113 virtual void SwapBuffers(CompositorFrame frame) = 0; 111 virtual void SwapBuffers(CompositorFrame frame) = 0;
114 virtual void OnSwapBuffersComplete(); 112 virtual void OnSwapBuffersComplete();
115 113
116 // base::trace_event::MemoryDumpProvider implementation.
117 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
118 base::trace_event::ProcessMemoryDump* pmd) override;
119
120 protected: 114 protected:
121 // This is used by both display and delegating implementations. 115 // This is used by both display and delegating implementations.
122 void PostSwapBuffersComplete(); 116 void PostSwapBuffersComplete();
123 117
124 // Bound to the ContextProvider to hear about when it is lost and inform the 118 // Bound to the ContextProvider to hear about when it is lost and inform the
125 // |client_|. 119 // |client_|.
126 void DidLoseCompositorFrameSink(); 120 void DidLoseCompositorFrameSink();
127 121
128 CompositorFrameSinkClient* client_ = nullptr; 122 CompositorFrameSinkClient* client_ = nullptr;
129 123
130 struct CompositorFrameSink::Capabilities capabilities_; 124 struct CompositorFrameSink::Capabilities capabilities_;
131 scoped_refptr<ContextProvider> context_provider_; 125 scoped_refptr<ContextProvider> context_provider_;
132 scoped_refptr<ContextProvider> worker_context_provider_; 126 scoped_refptr<ContextProvider> worker_context_provider_;
133 scoped_refptr<VulkanContextProvider> vulkan_context_provider_; 127 scoped_refptr<VulkanContextProvider> vulkan_context_provider_;
134 base::ThreadChecker client_thread_checker_; 128 base::ThreadChecker client_thread_checker_;
135 129
136 private: 130 private:
137 void DetachFromClientInternal(); 131 void DetachFromClientInternal();
138 132
139 base::WeakPtrFactory<CompositorFrameSink> weak_ptr_factory_; 133 base::WeakPtrFactory<CompositorFrameSink> weak_ptr_factory_;
140 134
141 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSink); 135 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSink);
142 }; 136 };
143 137
144 } // namespace cc 138 } // namespace cc
145 139
146 #endif // CC_OUTPUT_COMPOSITOR_FRAME_SINK_H_ 140 #endif // CC_OUTPUT_COMPOSITOR_FRAME_SINK_H_
OLDNEW
« no previous file with comments | « no previous file | cc/output/compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698