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