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

Unified Diff: cc/blimp/layer_tree_host_remote.h

Issue 2362073002: cc/blimp: Add a LayerTreeHostRemote implementation. (Closed)
Patch Set: Remaining comments from #4 Created 4 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 side-by-side diff with in-line comments
Download patch
Index: cc/blimp/layer_tree_host_remote.h
diff --git a/cc/blimp/layer_tree_host_remote.h b/cc/blimp/layer_tree_host_remote.h
new file mode 100644
index 0000000000000000000000000000000000000000..dfe66c5d1ac42ee9520ec64727668d9a566a0bfc
--- /dev/null
+++ b/cc/blimp/layer_tree_host_remote.h
@@ -0,0 +1,153 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_BLIMP_LAYER_TREE_HOST_REMOTE_H_
+#define CC_BLIMP_LAYER_TREE_HOST_REMOTE_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "cc/base/cc_export.h"
+#include "cc/blimp/compositor_proto_state_sink_client.h"
+#include "cc/debug/layer_tree_debug_state.h"
+#include "cc/trees/layer_tree_host.h"
+#include "cc/trees/layer_tree_settings.h"
+#include "cc/trees/surface_sequence_generator.h"
+#include "cc/trees/swap_promise_manager.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
+
+namespace cc {
+class AnimationHost;
+class CompositorProtoStateSink;
+class LayerTreeHostClient;
+
+class CC_EXPORT LayerTreeHostRemote : public LayerTreeHost,
+ public CompositorProtoStateSinkClient {
+ public:
+ // The remote LayerTreeHost doesn't perform any compositing, so we don't need
+ // any resources (OutputSurface, TaskGraphRunner, etc.) needed by the
+ // compositor.
+ struct InitParams {
+ LayerTreeHostClient* client = nullptr;
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner;
+ std::unique_ptr<AnimationHost> animation_host;
+ std::unique_ptr<CompositorProtoStateSink> compositor_proto_state_sink;
+ LayerTreeSettings const* settings = nullptr;
+
+ InitParams();
+ ~InitParams();
+ };
+
+ explicit LayerTreeHostRemote(InitParams* params);
+ ~LayerTreeHostRemote() override;
+
+ // LayerTreeHost implementation.
+ int GetId() const override;
+ int SourceFrameNumber() const override;
+ LayerTree* GetLayerTree() override;
+ const LayerTree* GetLayerTree() const override;
+ UIResourceManager* GetUIResourceManager() override;
+ TaskRunnerProvider* GetTaskRunnerProvider() const override;
+ const LayerTreeSettings& GetSettings() const override;
+ void SetSurfaceClientId(uint32_t client_id) override;
+ void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override;
+ void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) override;
+ SwapPromiseManager* GetSwapPromiseManager() override;
+ void SetHasGpuRasterizationTrigger(bool has_trigger) override;
+ void SetVisible(bool visible) override;
+ bool IsVisible() const override;
+ void SetCompositorFrameSink(
+ std::unique_ptr<CompositorFrameSink> compositor_frame_sink) override;
+ std::unique_ptr<CompositorFrameSink> ReleaseCompositorFrameSink() override;
+ void SetNeedsAnimate() override;
+ void SetNeedsUpdateLayers() override;
+ void SetNeedsCommit() override;
+ bool BeginMainFrameRequested() const override;
+ bool CommitRequested() const override;
+ void SetDeferCommits(bool defer_commits) override;
+ void LayoutAndUpdateLayers() override;
+ void Composite(base::TimeTicks frame_begin_time) override;
+ void SetNeedsRedraw() override;
+ void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override;
+ void SetNextCommitForcesRedraw() override;
+ void NotifyInputThrottledUntilCommit() override;
+ void UpdateTopControlsState(TopControlsState constraints,
+ TopControlsState current,
+ bool animate) override;
+ const base::WeakPtr<InputHandler>& GetInputHandler() const override;
+ void DidStopFlinging() override;
+ void SetDebugState(const LayerTreeDebugState& debug_state) override;
+ const LayerTreeDebugState& GetDebugState() const override;
+ int ScheduleMicroBenchmark(
+ const std::string& benchmark_name,
+ std::unique_ptr<base::Value> value,
+ const MicroBenchmark::DoneCallback& callback) override;
+ bool SendMessageToMicroBenchmark(int id,
+ std::unique_ptr<base::Value> value) override;
+ SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() override;
+ void SetNextCommitWaitsForActivation() override;
+ void ResetGpuRasterizationTracking() override;
+
+ protected:
+ // Protected for testing. Allows tests to inject the LayerTree.
+ LayerTreeHostRemote(InitParams* params,
+ std::unique_ptr<LayerTree> layer_tree);
+
+ private:
+ enum class FramePipelineStage { NONE, ANIMATE, UPDATE_LAYERS, COMMIT };
+
+ // CompositorProtoStateSinkClient implementation.
+ void BeginMainFrame() override;
+ base::SingleThreadTaskRunner* GetMainTaskRunner() override;
+
+ void MainFrameRequested(FramePipelineStage requested_pipeline_stage);
+ void ScheduleMainFrameIfNecessary();
+ void MainFrameComplete();
+ void DispatchDrawAndSwapCallbacks();
+
+ int id_;
+ int source_frame_number_;
+ bool visible_;
+ bool defer_commits_;
+
+ // Set to true if a main frame request is pending on the
+ // CompositorProtoStateSink.
+ bool main_frame_requested_from_state_sink_;
+
+ // Set to the pipeline stage we are currently at if we are inside a main frame
+ // update.
+ FramePipelineStage current_pipeline_stage_;
+
+ // Set to the pipeline stage we need to go to for the current main frame
+ // update, if we are inside a main frame update.
+ FramePipelineStage max_pipeline_stage_for_current_frame_;
+
+ // Set to the pipeline stage requested for the next BeginMainFrame.
+ FramePipelineStage requested_pipeline_stage_for_next_frame_;
+
+ LayerTreeHostClient* client_;
+ std::unique_ptr<TaskRunnerProvider> task_runner_provider_;
+
+ // The CompositorProtoStateSink used to submit frame updates to the client.
+ std::unique_ptr<CompositorProtoStateSink> compositor_proto_state_sink_;
+
+ LayerTreeSettings settings_;
+ LayerTreeDebugState debug_state_;
+
+ // The LayerTree holds the root layer and other state on the engine.
+ std::unique_ptr<LayerTree> layer_tree_;
+
+ SwapPromiseManager swap_promise_manager_;
+ SurfaceSequenceGenerator surface_sequence_generator_;
+
+ base::WeakPtr<InputHandler> input_handler_weak_ptr_;
+
+ base::WeakPtrFactory<LayerTreeHostRemote> weak_factory_;
+};
+
+} // namespace cc
+
+#endif // CC_BLIMP_LAYER_TREE_HOST_REMOTE_H_

Powered by Google App Engine
This is Rietveld 408576698