Chromium Code Reviews| 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 CCProxy_h | 5 #ifndef CCProxy_h |
| 6 #define CCProxy_h | 6 #define CCProxy_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/scoped_ptr.h" | |
| 10 #include <public/WebCompositorOutputSurface.h> | 11 #include <public/WebCompositorOutputSurface.h> |
| 12 #include <public/WebThread.h> | |
|
jamesr
2012/10/22 22:00:36
again, not great :( cc::CCThread?
| |
| 11 | 13 |
| 12 namespace cc { | 14 namespace cc { |
| 13 | 15 |
| 14 class CCThread; | 16 class CCThread; |
| 15 class IntRect; | 17 class IntRect; |
| 16 class IntSize; | 18 class IntSize; |
| 17 struct CCRenderingStats; | 19 struct CCRenderingStats; |
| 18 struct RendererCapabilities; | 20 struct RendererCapabilities; |
| 19 | 21 |
| 20 // Abstract class responsible for proxying commands from the main-thread side of | 22 // Abstract class responsible for proxying commands from the main-thread side of |
| 21 // the compositor over to the compositor implementation. | 23 // the compositor over to the compositor implementation. |
| 22 class CCProxy { | 24 class CCProxy { |
| 23 public: | 25 public: |
| 24 static void setMainThread(CCThread*); | 26 CCThread* mainThread() const; |
| 25 static CCThread* mainThread(); | 27 bool hasImplThread() const; |
| 26 | 28 CCThread* implThread() const; |
| 27 static bool hasImplThread(); | |
| 28 static void setImplThread(CCThread*); | |
| 29 static CCThread* implThread(); | |
| 30 | 29 |
| 31 // Returns 0 if the current thread is neither the main thread nor the impl t hread. | 30 // Returns 0 if the current thread is neither the main thread nor the impl t hread. |
| 32 static CCThread* currentThread(); | 31 CCThread* currentThread() const; |
| 32 | |
| 33 // Debug hooks | |
| 34 bool isMainThread() const; | |
| 35 bool isImplThread() const; | |
| 36 bool isMainThreadBlocked() const; | |
| 37 void setMainThread(CCThread*); | |
| 38 void setImplThread(CCThread*); | |
| 39 #ifndef NDEBUG | |
| 40 void setMainThreadBlocked(bool); | |
| 41 void setCurrentThreadIsImplThread(bool); | |
| 42 #endif | |
| 43 | |
| 33 | 44 |
| 34 virtual ~CCProxy(); | 45 virtual ~CCProxy(); |
| 35 | 46 |
| 36 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0; | 47 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0; |
| 37 | 48 |
| 38 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use Anchor, float scale, double durationSec) = 0; | 49 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use Anchor, float scale, double durationSec) = 0; |
| 39 | 50 |
| 40 virtual void finishAllRendering() = 0; | 51 virtual void finishAllRendering() = 0; |
| 41 | 52 |
| 42 virtual bool isStarted() const = 0; | 53 virtual bool isStarted() const = 0; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 | 85 |
| 75 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t o finish before executing in the GPU | 86 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t o finish before executing in the GPU |
| 76 // process. | 87 // process. |
| 77 virtual void forceSerializeOnSwapBuffers() = 0; | 88 virtual void forceSerializeOnSwapBuffers() = 0; |
| 78 | 89 |
| 79 // Maximum number of sub-region texture updates supported for each commit. | 90 // Maximum number of sub-region texture updates supported for each commit. |
| 80 virtual size_t maxPartialTextureUpdates() const = 0; | 91 virtual size_t maxPartialTextureUpdates() const = 0; |
| 81 | 92 |
| 82 virtual void acquireLayerTextures() = 0; | 93 virtual void acquireLayerTextures() = 0; |
| 83 | 94 |
| 84 // Debug hooks | |
| 85 static bool isMainThread(); | |
| 86 static bool isImplThread(); | |
| 87 static bool isMainThreadBlocked(); | |
| 88 #ifndef NDEBUG | |
| 89 static void setMainThreadBlocked(bool); | |
| 90 #endif | |
| 91 | |
| 92 // Testing hooks | 95 // Testing hooks |
| 93 virtual void loseContext() = 0; | 96 virtual void loseContext() = 0; |
| 94 | 97 |
| 95 #ifndef NDEBUG | |
| 96 static void setCurrentThreadIsImplThread(bool); | |
| 97 #endif | |
| 98 | |
| 99 protected: | 98 protected: |
| 100 CCProxy(); | 99 explicit CCProxy(WebKit::WebThread* implThread); |
| 101 friend class DebugScopedSetImplThread; | 100 friend class DebugScopedSetImplThread; |
| 102 friend class DebugScopedSetMainThreadBlocked; | 101 friend class DebugScopedSetMainThreadBlocked; |
| 103 | 102 |
| 104 private: | 103 private: |
| 105 DISALLOW_COPY_AND_ASSIGN(CCProxy); | 104 DISALLOW_COPY_AND_ASSIGN(CCProxy); |
| 105 | |
| 106 CompositorSupportState* m_compositorSupportState; | |
| 107 #ifndef NDEBUG | |
| 108 bool m_implThreadIsOverridden; | |
| 109 bool m_isMainThreadBlocked; | |
| 110 base::PlatformThreadId m_threadIDOverridenToBeImplThread; | |
| 111 #endif | |
| 106 }; | 112 }; |
| 107 | 113 |
| 108 class DebugScopedSetMainThreadBlocked { | 114 class DebugScopedSetMainThreadBlocked { |
| 109 public: | 115 public: |
| 110 DebugScopedSetMainThreadBlocked() | 116 DebugScopedSetMainThreadBlocked() |
| 111 { | 117 { |
| 112 #ifndef NDEBUG | 118 #ifndef NDEBUG |
| 113 DCHECK(!CCProxy::isMainThreadBlocked()); | 119 DCHECK(!CCProxy::isMainThreadBlocked()); |
| 114 CCProxy::setMainThreadBlocked(true); | 120 CCProxy::setMainThreadBlocked(true); |
| 115 #endif | 121 #endif |
| 116 } | 122 } |
| 117 ~DebugScopedSetMainThreadBlocked() | 123 ~DebugScopedSetMainThreadBlocked() |
| 118 { | 124 { |
| 119 #ifndef NDEBUG | 125 #ifndef NDEBUG |
| 120 DCHECK(CCProxy::isMainThreadBlocked()); | 126 DCHECK(CCProxy::isMainThreadBlocked()); |
| 121 CCProxy::setMainThreadBlocked(false); | 127 CCProxy::setMainThreadBlocked(false); |
| 122 #endif | 128 #endif |
| 123 } | 129 } |
| 124 }; | 130 }; |
| 125 | 131 |
| 126 } | 132 } |
| 127 | 133 |
| 128 #endif | 134 #endif |
| OLD | NEW |