| 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/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/time.h" | 14 #include "base/time.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "cc/base/cc_export.h" | 16 #include "cc/base/cc_export.h" |
| 16 #include "skia/ext/refptr.h" | 17 #include "skia/ext/refptr.h" |
| 17 #include "third_party/skia/include/core/SkPicture.h" | 18 #include "third_party/skia/include/core/SkPicture.h" |
| 18 | 19 |
| 20 namespace base { class SingleThreadTaskRunner; } |
| 21 |
| 19 namespace gfx { | 22 namespace gfx { |
| 20 class Rect; | 23 class Rect; |
| 21 class Vector2d; | 24 class Vector2d; |
| 22 } | 25 } |
| 23 | 26 |
| 24 namespace cc { | 27 namespace cc { |
| 25 | 28 |
| 26 class OutputSurface; | 29 class OutputSurface; |
| 27 class Thread; | |
| 28 struct RendererCapabilities; | 30 struct RendererCapabilities; |
| 29 | 31 |
| 30 // Abstract class responsible for proxying commands from the main-thread side of | 32 // Abstract class responsible for proxying commands from the main-thread side of |
| 31 // the compositor over to the compositor implementation. | 33 // the compositor over to the compositor implementation. |
| 32 class CC_EXPORT Proxy { | 34 class CC_EXPORT Proxy { |
| 33 public: | 35 public: |
| 34 Thread* MainThread() const; | 36 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; |
| 35 bool HasImplThread() const; | 37 bool HasImplThread() const; |
| 36 Thread* ImplThread() const; | 38 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; |
| 37 | |
| 38 // Returns 0 if the current thread is neither the main thread nor the impl | |
| 39 // thread. | |
| 40 Thread* CurrentThread() const; | |
| 41 | 39 |
| 42 // Debug hooks. | 40 // Debug hooks. |
| 43 bool IsMainThread() const; | 41 bool IsMainThread() const; |
| 44 bool IsImplThread() const; | 42 bool IsImplThread() const; |
| 45 bool IsMainThreadBlocked() const; | 43 bool IsMainThreadBlocked() const; |
| 46 #ifndef NDEBUG | 44 #ifndef NDEBUG |
| 47 void SetMainThreadBlocked(bool is_main_thread_blocked); | 45 void SetMainThreadBlocked(bool is_main_thread_blocked); |
| 48 void SetCurrentThreadIsImplThread(bool is_impl_thread); | 46 void SetCurrentThreadIsImplThread(bool is_impl_thread); |
| 49 #endif | 47 #endif |
| 50 | 48 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 virtual void AcquireLayerTextures() = 0; | 94 virtual void AcquireLayerTextures() = 0; |
| 97 | 95 |
| 98 virtual skia::RefPtr<SkPicture> CapturePicture() = 0; | 96 virtual skia::RefPtr<SkPicture> CapturePicture() = 0; |
| 99 virtual scoped_ptr<base::Value> AsValue() const = 0; | 97 virtual scoped_ptr<base::Value> AsValue() const = 0; |
| 100 | 98 |
| 101 // Testing hooks | 99 // Testing hooks |
| 102 virtual bool CommitPendingForTesting() = 0; | 100 virtual bool CommitPendingForTesting() = 0; |
| 103 virtual std::string SchedulerStateAsStringForTesting(); | 101 virtual std::string SchedulerStateAsStringForTesting(); |
| 104 | 102 |
| 105 protected: | 103 protected: |
| 106 explicit Proxy(scoped_ptr<Thread> impl_thread); | 104 explicit Proxy( |
| 105 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
| 107 friend class DebugScopedSetImplThread; | 106 friend class DebugScopedSetImplThread; |
| 108 friend class DebugScopedSetMainThread; | 107 friend class DebugScopedSetMainThread; |
| 109 friend class DebugScopedSetMainThreadBlocked; | 108 friend class DebugScopedSetMainThreadBlocked; |
| 110 | 109 |
| 111 private: | 110 private: |
| 112 scoped_ptr<Thread> main_thread_; | 111 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 113 scoped_ptr<Thread> impl_thread_; | 112 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; |
| 114 #ifndef NDEBUG | 113 #ifndef NDEBUG |
| 115 bool impl_thread_is_overridden_; | 114 bool impl_thread_is_overridden_; |
| 116 bool is_main_thread_blocked_; | 115 bool is_main_thread_blocked_; |
| 117 #endif | 116 #endif |
| 118 | 117 |
| 119 DISALLOW_COPY_AND_ASSIGN(Proxy); | 118 DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 120 }; | 119 }; |
| 121 | 120 |
| 122 #ifndef NDEBUG | 121 #ifndef NDEBUG |
| 123 class DebugScopedSetMainThreadBlocked { | 122 class DebugScopedSetMainThreadBlocked { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 140 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy) {} | 139 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy) {} |
| 141 ~DebugScopedSetMainThreadBlocked() {} | 140 ~DebugScopedSetMainThreadBlocked() {} |
| 142 private: | 141 private: |
| 143 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked); | 142 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked); |
| 144 }; | 143 }; |
| 145 #endif | 144 #endif |
| 146 | 145 |
| 147 } // namespace cc | 146 } // namespace cc |
| 148 | 147 |
| 149 #endif // CC_TREES_PROXY_H_ | 148 #endif // CC_TREES_PROXY_H_ |
| OLD | NEW |