Task Manager: Remove goat teleporter.
[chromium-blink-merge.git] / cc / trees / proxy.h
blob8d72728cfe07bd5cc2820f2a0e91bfcfb6c41c5e
1 // Copyright 2011 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.
5 #ifndef CC_TREES_PROXY_H_
6 #define CC_TREES_PROXY_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/platform_thread.h"
15 #include "base/time/time.h"
16 #include "base/values.h"
17 #include "cc/base/cc_export.h"
19 namespace base {
20 namespace debug {
21 class TracedValue;
23 class SingleThreadTaskRunner;
26 namespace gfx {
27 class Rect;
28 class Vector2d;
31 namespace cc {
32 class BlockingTaskRunner;
33 class LayerTreeDebugState;
34 class OutputSurface;
35 struct RendererCapabilities;
37 // Abstract class responsible for proxying commands from the main-thread side of
38 // the compositor over to the compositor implementation.
39 class CC_EXPORT Proxy {
40 public:
41 base::SingleThreadTaskRunner* MainThreadTaskRunner() const;
42 bool HasImplThread() const;
43 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const;
45 // Debug hooks.
46 bool IsMainThread() const;
47 bool IsImplThread() const;
48 bool IsMainThreadBlocked() const;
49 #if DCHECK_IS_ON
50 void SetMainThreadBlocked(bool is_main_thread_blocked);
51 void SetCurrentThreadIsImplThread(bool is_impl_thread);
52 #endif
54 virtual ~Proxy();
56 virtual void FinishAllRendering() = 0;
58 virtual bool IsStarted() const = 0;
60 // Indicates that the compositing surface associated with our context is
61 // ready to use.
62 virtual void SetLayerTreeHostClientReady() = 0;
64 virtual void SetVisible(bool visible) = 0;
66 virtual const RendererCapabilities& GetRendererCapabilities() const = 0;
68 virtual void SetNeedsAnimate() = 0;
69 virtual void SetNeedsUpdateLayers() = 0;
70 virtual void SetNeedsCommit() = 0;
71 virtual void SetNeedsRedraw(const gfx::Rect& damage_rect) = 0;
72 virtual void SetNextCommitWaitsForActivation() = 0;
74 virtual void NotifyInputThrottledUntilCommit() = 0;
76 // Defers commits until it is reset. It is only supported when in threaded
77 // mode. It's an error to make a sync call like CompositeAndReadback while
78 // commits are deferred.
79 virtual void SetDeferCommits(bool defer_commits) = 0;
81 virtual void MainThreadHasStoppedFlinging() = 0;
83 virtual bool CommitRequested() const = 0;
84 virtual bool BeginMainFrameRequested() const = 0;
86 // Must be called before using the proxy.
87 virtual void Start() = 0;
88 virtual void Stop() = 0; // Must be called before deleting the proxy.
90 // Forces 3D commands on all contexts to wait for all previous SwapBuffers
91 // to finish before executing in the GPU process.
92 virtual void ForceSerializeOnSwapBuffers() = 0;
94 // Maximum number of sub-region texture updates supported for each commit.
95 virtual size_t MaxPartialTextureUpdates() const = 0;
97 virtual bool SupportsImplScrolling() const = 0;
99 virtual void AsValueInto(base::debug::TracedValue* value) const = 0;
101 virtual void SetDebugState(const LayerTreeDebugState& debug_state) = 0;
103 // Testing hooks
104 virtual bool MainFrameWillHappenForTesting() = 0;
106 BlockingTaskRunner* blocking_main_thread_task_runner() const {
107 return blocking_main_thread_task_runner_.get();
110 protected:
111 Proxy(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
112 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
113 friend class DebugScopedSetImplThread;
114 friend class DebugScopedSetMainThread;
115 friend class DebugScopedSetMainThreadBlocked;
117 private:
118 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
119 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_;
120 scoped_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_;
122 #if DCHECK_IS_ON
123 const base::PlatformThreadId main_thread_id_;
124 bool impl_thread_is_overridden_;
125 bool is_main_thread_blocked_;
126 #endif
128 DISALLOW_COPY_AND_ASSIGN(Proxy);
131 #if DCHECK_IS_ON
132 class DebugScopedSetMainThreadBlocked {
133 public:
134 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy) : proxy_(proxy) {
135 DCHECK(!proxy_->IsMainThreadBlocked());
136 proxy_->SetMainThreadBlocked(true);
138 ~DebugScopedSetMainThreadBlocked() {
139 DCHECK(proxy_->IsMainThreadBlocked());
140 proxy_->SetMainThreadBlocked(false);
142 private:
143 Proxy* proxy_;
144 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked);
146 #else
147 class DebugScopedSetMainThreadBlocked {
148 public:
149 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy) {}
150 ~DebugScopedSetMainThreadBlocked() {}
151 private:
152 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked);
154 #endif
156 } // namespace cc
158 #endif // CC_TREES_PROXY_H_