| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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_TREES_LAYER_TREE_HOST_INTERFACE_H_ | |
| 6 #define CC_TREES_LAYER_TREE_HOST_INTERFACE_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "cc/base/cc_export.h" | |
| 10 #include "cc/debug/micro_benchmark.h" | |
| 11 #include "cc/input/top_controls_state.h" | |
| 12 | |
| 13 namespace base { | |
| 14 class TimeTicks; | |
| 15 } // namespace base | |
| 16 | |
| 17 namespace gfx { | |
| 18 class Rect; | |
| 19 } // namespace gfx | |
| 20 | |
| 21 namespace cc { | |
| 22 class InputHandler; | |
| 23 class LayerTree; | |
| 24 class LayerTreeDebugState; | |
| 25 class LayerTreeMutator; | |
| 26 class LayerTreeSettings; | |
| 27 class OutputSurface; | |
| 28 class SwapPromiseMonitor; | |
| 29 class TaskRunnerProvider; | |
| 30 class UIResourceManager; | |
| 31 | |
| 32 // TODO(khushalsagar): Will be renamed to LayerTreeHost. | |
| 33 class CC_EXPORT LayerTreeHostInterface { | |
| 34 public: | |
| 35 virtual ~LayerTreeHostInterface() {} | |
| 36 | |
| 37 // Returns the process global unique identifier for this LayerTreeHost. | |
| 38 virtual int GetId() const = 0; | |
| 39 | |
| 40 // The current source frame number. This is incremented for each main frame | |
| 41 // update(commit) pushed to the compositor thread. | |
| 42 virtual int SourceFrameNumber() const = 0; | |
| 43 | |
| 44 // Returns the LayerTree that holds the main frame state pushed to the | |
| 45 // LayerTreeImpl on commit. | |
| 46 virtual LayerTree* GetLayerTree() = 0; | |
| 47 virtual const LayerTree* GetLayerTree() const = 0; | |
| 48 | |
| 49 // Returns the UIResourceManager used to create UIResources for | |
| 50 // UIResourceLayers pushed to the LayerTree. | |
| 51 virtual UIResourceManager* GetUIResourceManager() const = 0; | |
| 52 | |
| 53 // Returns the TaskRunnerProvider used to access the main and compositor | |
| 54 // thread task runners. | |
| 55 virtual TaskRunnerProvider* GetTaskRunnerProvider() const = 0; | |
| 56 | |
| 57 // Returns the settings used by this host. | |
| 58 virtual const LayerTreeSettings& GetSettings() const = 0; | |
| 59 | |
| 60 // Sets the client id used to generate the SurfaceId that uniquely identifies | |
| 61 // the Surfaces produced by this compositor. | |
| 62 virtual void SetSurfaceClientId(uint32_t client_id) = 0; | |
| 63 | |
| 64 // Sets the LayerTreeMutator interface used to directly mutate the compositor | |
| 65 // state on the compositor thread. (Compositor-Worker) | |
| 66 virtual void SetLayerTreeMutator( | |
| 67 std::unique_ptr<LayerTreeMutator> mutator) = 0; | |
| 68 | |
| 69 // Call this function when you expect there to be a swap buffer. | |
| 70 // See swap_promise.h for how to use SwapPromise. | |
| 71 virtual void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) = 0; | |
| 72 | |
| 73 // Returns the SwapPromiseManager used to create SwapPromiseMonitors for this | |
| 74 // host. | |
| 75 virtual SwapPromiseManager* GetSwapPromiseManager() = 0; | |
| 76 | |
| 77 // Sets whether the content is suitable to use Gpu Rasterization. | |
| 78 virtual void SetHasGpuRasterizationTrigger(bool has_trigger) = 0; | |
| 79 | |
| 80 // Visibility and OutputSurface ------------------------------- | |
| 81 | |
| 82 virtual void SetVisible(bool visible) = 0; | |
| 83 virtual bool IsVisible() const = 0; | |
| 84 | |
| 85 // Called in response to an OutputSurface request made to the client using | |
| 86 // LayerTreeHostClient::RequestNewOutputSurface. The client will be informed | |
| 87 // of the OutputSurface initialization status using DidInitializaOutputSurface | |
| 88 // or DidFailToInitializeOutputSurface. The request is completed when the host | |
| 89 // successfully initializes an OutputSurface. | |
| 90 virtual void SetOutputSurface( | |
| 91 std::unique_ptr<OutputSurface> output_surface) = 0; | |
| 92 | |
| 93 // Forces the host to immediately release all references to the OutputSurface, | |
| 94 // if any. Can be safely called any time. | |
| 95 virtual std::unique_ptr<OutputSurface> ReleaseOutputSurface() = 0; | |
| 96 | |
| 97 // Frame Scheduling (main and compositor frames) requests ------- | |
| 98 | |
| 99 // Requests a main frame update even if no content has changed. This is used, | |
| 100 // for instance in the case of RequestAnimationFrame from blink to ensure the | |
| 101 // main frame update is run on the next tick without pre-emptively forcing a | |
| 102 // full commit synchronization or layer updates. | |
| 103 virtual void SetNeedsAnimate() = 0; | |
| 104 | |
| 105 // Requests a main frame update and also ensure that the host pulls layer | |
| 106 // updates from the client, even if no content might have changed, without | |
| 107 // forcing a full commit synchronization. | |
| 108 virtual void SetNeedsUpdateLayers() = 0; | |
| 109 | |
| 110 // Requests that the next main frame update performs a full commit | |
| 111 // synchronization. | |
| 112 virtual void SetNeedsCommit() = 0; | |
| 113 | |
| 114 // Returns true if a main frame (for any pipeline stage above) has been | |
| 115 // requested. | |
| 116 virtual bool BeginMainFrameRequested() const = 0; | |
| 117 | |
| 118 // Returns true if a main frame with commit synchronization has been | |
| 119 // requested. | |
| 120 virtual bool CommitRequested() const = 0; | |
| 121 | |
| 122 // Enables/disables the compositor from requesting main frame updates from the | |
| 123 // client. | |
| 124 virtual void SetDeferCommits(bool defer_commits) = 0; | |
| 125 | |
| 126 // Synchronously performs a main frame update and layer updates. Used only in | |
| 127 // single threaded mode when the compositor's internal scheduling is disabled. | |
| 128 virtual void LayoutAndUpdateLayers() = 0; | |
| 129 | |
| 130 // Synchronously performs a complete main frame update, commit and compositor | |
| 131 // frame. Used only in single threaded mode when the compositor's internal | |
| 132 // scheduling is disabled. | |
| 133 virtual void Composite(base::TimeTicks frame_begin_time) = 0; | |
| 134 | |
| 135 // Requests a redraw (compositor frame) for the complete viewport. | |
| 136 virtual void SetNeedsRedraw() = 0; | |
| 137 | |
| 138 // Requests a redraw (compositor frame) for the given rect. | |
| 139 virtual void SetNeedsRedrawRect(const gfx::Rect& damage_rect) = 0; | |
| 140 | |
| 141 // Requests a main frame (including layer updates) and ensures that this main | |
| 142 // frame results in a redraw for the complete viewport when producing the | |
| 143 // CompositorFrame. | |
| 144 virtual void SetNextCommitForcesRedraw() = 0; | |
| 145 | |
| 146 // Input Handling --------------------------------------------- | |
| 147 | |
| 148 // Notifies the compositor that input from the browser is being throttled till | |
| 149 // the next commit. The compositor will prioritize activation of the pending | |
| 150 // tree so a commit can be performed. | |
| 151 virtual void NotifyInputThrottledUntilCommit() = 0; | |
| 152 | |
| 153 // Sets the state of the top controls. (Used for URL bar animations on | |
| 154 // android). | |
| 155 virtual void UpdateTopControlsState(TopControlsState constraints, | |
| 156 TopControlsState current, | |
| 157 bool animate) = 0; | |
| 158 | |
| 159 // Returns a reference to the InputHandler used to respond to input events on | |
| 160 // the compositor thread. | |
| 161 virtual const base::WeakPtr<InputHandler>& GetInputHandler() const = 0; | |
| 162 | |
| 163 // Informs the compositor that an active fling gesture being processed on the | |
| 164 // main thread has been finished. | |
| 165 virtual void DidStopFlinging() = 0; | |
| 166 | |
| 167 // Debugging and benchmarks --------------------------------- | |
| 168 virtual void SetDebugState(const LayerTreeDebugState& debug_state) = 0; | |
| 169 virtual const LayerTreeDebugState& GetDebugState() const = 0; | |
| 170 | |
| 171 // Returns the id of the benchmark on success, 0 otherwise. | |
| 172 virtual int ScheduleMicroBenchmark( | |
| 173 const std::string& benchmark_name, | |
| 174 std::unique_ptr<base::Value> value, | |
| 175 const MicroBenchmark::DoneCallback& callback) = 0; | |
| 176 | |
| 177 // Returns true if the message was successfully delivered and handled. | |
| 178 virtual bool SendMessageToMicroBenchmark( | |
| 179 int id, | |
| 180 std::unique_ptr<base::Value> value) = 0; | |
| 181 | |
| 182 // Methods used internally in cc. These are not intended to be a part of the | |
| 183 // public API for use by the embedder ---------------------- | |
| 184 virtual SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() = 0; | |
| 185 }; | |
| 186 | |
| 187 } // namespace cc | |
| 188 | |
| 189 #endif // CC_TREES_LAYER_TREE_HOST_INTERFACE_H_ | |
| OLD | NEW |