| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CC_TREES_PROXY_H_ | |
| 6 #define CC_TREES_PROXY_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 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" | |
| 18 | |
| 19 namespace base { | |
| 20 namespace trace_event { | |
| 21 class TracedValue; | |
| 22 } | |
| 23 class SingleThreadTaskRunner; | |
| 24 } | |
| 25 | |
| 26 namespace gfx { | |
| 27 class Rect; | |
| 28 class Vector2d; | |
| 29 } | |
| 30 | |
| 31 namespace cc { | |
| 32 class BlockingTaskRunner; | |
| 33 class LayerTreeDebugState; | |
| 34 class OutputSurface; | |
| 35 struct RendererCapabilities; | |
| 36 | |
| 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; | |
| 44 | |
| 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 | |
| 53 | |
| 54 virtual ~Proxy(); | |
| 55 | |
| 56 virtual void FinishAllRendering() = 0; | |
| 57 | |
| 58 virtual bool IsStarted() const = 0; | |
| 59 virtual bool CommitToActiveTree() const = 0; | |
| 60 | |
| 61 // Will call LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted | |
| 62 // with the result of this function. | |
| 63 virtual void SetOutputSurface(scoped_ptr<OutputSurface> output_surface) = 0; | |
| 64 | |
| 65 // Indicates that the compositing surface associated with our context is | |
| 66 // ready to use. | |
| 67 virtual void SetLayerTreeHostClientReady() = 0; | |
| 68 | |
| 69 virtual void SetVisible(bool visible) = 0; | |
| 70 | |
| 71 virtual void SetThrottleFrameProduction(bool throttle) = 0; | |
| 72 | |
| 73 virtual const RendererCapabilities& GetRendererCapabilities() const = 0; | |
| 74 | |
| 75 virtual void SetNeedsAnimate() = 0; | |
| 76 virtual void SetNeedsUpdateLayers() = 0; | |
| 77 virtual void SetNeedsCommit() = 0; | |
| 78 virtual void SetNeedsRedraw(const gfx::Rect& damage_rect) = 0; | |
| 79 virtual void SetNextCommitWaitsForActivation() = 0; | |
| 80 | |
| 81 virtual void NotifyInputThrottledUntilCommit() = 0; | |
| 82 | |
| 83 // Defers commits until it is reset. It is only supported when using a | |
| 84 // scheduler. | |
| 85 virtual void SetDeferCommits(bool defer_commits) = 0; | |
| 86 | |
| 87 virtual void MainThreadHasStoppedFlinging() = 0; | |
| 88 | |
| 89 virtual bool CommitRequested() const = 0; | |
| 90 virtual bool BeginMainFrameRequested() const = 0; | |
| 91 | |
| 92 // Must be called before using the proxy. | |
| 93 virtual void Start() = 0; | |
| 94 virtual void Stop() = 0; // Must be called before deleting the proxy. | |
| 95 | |
| 96 // Forces 3D commands on all contexts to wait for all previous SwapBuffers | |
| 97 // to finish before executing in the GPU process. | |
| 98 virtual void ForceSerializeOnSwapBuffers() = 0; | |
| 99 | |
| 100 // Maximum number of sub-region texture updates supported for each commit. | |
| 101 virtual size_t MaxPartialTextureUpdates() const = 0; | |
| 102 | |
| 103 virtual bool SupportsImplScrolling() const = 0; | |
| 104 | |
| 105 virtual void SetDebugState(const LayerTreeDebugState& debug_state) = 0; | |
| 106 | |
| 107 virtual void SetChildrenNeedBeginFrames(bool children_need_begin_frames) = 0; | |
| 108 | |
| 109 // Testing hooks | |
| 110 virtual bool MainFrameWillHappenForTesting() = 0; | |
| 111 | |
| 112 BlockingTaskRunner* blocking_main_thread_task_runner() const { | |
| 113 return blocking_main_thread_task_runner_.get(); | |
| 114 } | |
| 115 | |
| 116 protected: | |
| 117 Proxy(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
| 118 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | |
| 119 friend class DebugScopedSetImplThread; | |
| 120 friend class DebugScopedSetMainThread; | |
| 121 friend class DebugScopedSetMainThreadBlocked; | |
| 122 | |
| 123 private: | |
| 124 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
| 125 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; | |
| 126 scoped_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_; | |
| 127 | |
| 128 #if DCHECK_IS_ON() | |
| 129 const base::PlatformThreadId main_thread_id_; | |
| 130 bool impl_thread_is_overridden_; | |
| 131 bool is_main_thread_blocked_; | |
| 132 #endif | |
| 133 | |
| 134 DISALLOW_COPY_AND_ASSIGN(Proxy); | |
| 135 }; | |
| 136 | |
| 137 #if DCHECK_IS_ON() | |
| 138 class DebugScopedSetMainThreadBlocked { | |
| 139 public: | |
| 140 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy) : proxy_(proxy) { | |
| 141 DCHECK(!proxy_->IsMainThreadBlocked()); | |
| 142 proxy_->SetMainThreadBlocked(true); | |
| 143 } | |
| 144 ~DebugScopedSetMainThreadBlocked() { | |
| 145 DCHECK(proxy_->IsMainThreadBlocked()); | |
| 146 proxy_->SetMainThreadBlocked(false); | |
| 147 } | |
| 148 private: | |
| 149 Proxy* proxy_; | |
| 150 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked); | |
| 151 }; | |
| 152 #else | |
| 153 class DebugScopedSetMainThreadBlocked { | |
| 154 public: | |
| 155 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy) {} | |
| 156 ~DebugScopedSetMainThreadBlocked() {} | |
| 157 private: | |
| 158 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked); | |
| 159 }; | |
| 160 #endif | |
| 161 | |
| 162 } // namespace cc | |
| 163 | |
| 164 #endif // CC_TREES_PROXY_H_ | |
| OLD | NEW |