| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 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_TREES_PROXY_H_ | 5 #ifndef CC_TREES_PROXY_H_ |
| 6 #define CC_TREES_PROXY_H_ | 6 #define CC_TREES_PROXY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "cc/base/cc_export.h" | 17 #include "cc/base/cc_export.h" |
| 18 #include "cc/input/top_controls_state.h" | 18 #include "cc/input/top_controls_state.h" |
| 19 | 19 #include "cc/trees/thread_verifier.h" |
| 20 namespace base { | |
| 21 namespace trace_event { | |
| 22 class TracedValue; | |
| 23 } | |
| 24 class SingleThreadTaskRunner; | |
| 25 } | |
| 26 | 20 |
| 27 namespace gfx { | 21 namespace gfx { |
| 28 class Rect; | 22 class Rect; |
| 29 class Vector2d; | 23 class Vector2d; |
| 30 } | 24 } |
| 31 | 25 |
| 32 namespace cc { | 26 namespace cc { |
| 33 class BlockingTaskRunner; | |
| 34 class LayerTreeDebugState; | 27 class LayerTreeDebugState; |
| 35 class OutputSurface; | 28 class OutputSurface; |
| 36 struct RendererCapabilities; | 29 struct RendererCapabilities; |
| 37 | 30 |
| 38 // Abstract class responsible for proxying commands from the main-thread side of | 31 // Abstract class responsible for proxying commands from the main-thread side of |
| 39 // the compositor over to the compositor implementation. | 32 // the compositor over to the compositor implementation. |
| 40 class CC_EXPORT Proxy { | 33 class CC_EXPORT Proxy : public ThreadVerifier { |
| 41 public: | 34 public: |
| 42 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; | 35 ~Proxy() override; |
| 43 bool HasImplThread() const; | |
| 44 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; | |
| 45 | |
| 46 // Debug hooks. | |
| 47 bool IsMainThread() const; | |
| 48 bool IsImplThread() const; | |
| 49 bool IsMainThreadBlocked() const; | |
| 50 #if DCHECK_IS_ON() | |
| 51 void SetMainThreadBlocked(bool is_main_thread_blocked); | |
| 52 void SetCurrentThreadIsImplThread(bool is_impl_thread); | |
| 53 #endif | |
| 54 | |
| 55 virtual ~Proxy(); | |
| 56 | 36 |
| 57 virtual void FinishAllRendering() = 0; | 37 virtual void FinishAllRendering() = 0; |
| 58 | 38 |
| 59 virtual bool IsStarted() const = 0; | 39 virtual bool IsStarted() const = 0; |
| 60 virtual bool CommitToActiveTree() const = 0; | 40 virtual bool CommitToActiveTree() const = 0; |
| 61 | 41 |
| 62 // Will call LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted | 42 // Will call LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted |
| 63 // with the result of this function. | 43 // with the result of this function. |
| 64 virtual void SetOutputSurface(OutputSurface* output_surface) = 0; | 44 virtual void SetOutputSurface(OutputSurface* output_surface) = 0; |
| 65 | 45 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 virtual void SetAuthoritativeVSyncInterval( | 79 virtual void SetAuthoritativeVSyncInterval( |
| 100 const base::TimeDelta& interval) = 0; | 80 const base::TimeDelta& interval) = 0; |
| 101 | 81 |
| 102 virtual void UpdateTopControlsState(TopControlsState constraints, | 82 virtual void UpdateTopControlsState(TopControlsState constraints, |
| 103 TopControlsState current, | 83 TopControlsState current, |
| 104 bool animate) = 0; | 84 bool animate) = 0; |
| 105 | 85 |
| 106 // Testing hooks | 86 // Testing hooks |
| 107 virtual bool MainFrameWillHappenForTesting() = 0; | 87 virtual bool MainFrameWillHappenForTesting() = 0; |
| 108 | 88 |
| 109 BlockingTaskRunner* blocking_main_thread_task_runner() const { | |
| 110 return blocking_main_thread_task_runner_.get(); | |
| 111 } | |
| 112 | |
| 113 protected: | 89 protected: |
| 114 Proxy(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 90 Proxy(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 115 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 91 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
| 116 friend class DebugScopedSetImplThread; | |
| 117 friend class DebugScopedSetMainThread; | |
| 118 friend class DebugScopedSetMainThreadBlocked; | |
| 119 | 92 |
| 120 private: | 93 private: |
| 121 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
| 122 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; | |
| 123 scoped_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_; | |
| 124 | |
| 125 #if DCHECK_IS_ON() | |
| 126 const base::PlatformThreadId main_thread_id_; | |
| 127 bool impl_thread_is_overridden_; | |
| 128 bool is_main_thread_blocked_; | |
| 129 #endif | |
| 130 | |
| 131 DISALLOW_COPY_AND_ASSIGN(Proxy); | 94 DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 132 }; | 95 }; |
| 133 | 96 |
| 134 #if DCHECK_IS_ON() | |
| 135 class DebugScopedSetMainThreadBlocked { | |
| 136 public: | |
| 137 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy) : proxy_(proxy) { | |
| 138 DCHECK(!proxy_->IsMainThreadBlocked()); | |
| 139 proxy_->SetMainThreadBlocked(true); | |
| 140 } | |
| 141 ~DebugScopedSetMainThreadBlocked() { | |
| 142 DCHECK(proxy_->IsMainThreadBlocked()); | |
| 143 proxy_->SetMainThreadBlocked(false); | |
| 144 } | |
| 145 private: | |
| 146 Proxy* proxy_; | |
| 147 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked); | |
| 148 }; | |
| 149 #else | |
| 150 class DebugScopedSetMainThreadBlocked { | |
| 151 public: | |
| 152 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy) {} | |
| 153 ~DebugScopedSetMainThreadBlocked() {} | |
| 154 private: | |
| 155 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked); | |
| 156 }; | |
| 157 #endif | |
| 158 | |
| 159 } // namespace cc | 97 } // namespace cc |
| 160 | 98 |
| 161 #endif // CC_TREES_PROXY_H_ | 99 #endif // CC_TREES_PROXY_H_ |
| OLD | NEW |