| 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 <public/WebCompositorOutputSurface.h> | 9 #include <public/WebCompositorOutputSurface.h> |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 class CCThread; | 13 class Thread; |
| 14 class IntRect; | 14 class IntRect; |
| 15 class IntSize; | 15 class IntSize; |
| 16 struct CCRenderingStats; | 16 struct RenderingStats; |
| 17 struct RendererCapabilities; | 17 struct RendererCapabilities; |
| 18 | 18 |
| 19 // Abstract class responsible for proxying commands from the main-thread side of | 19 // Abstract class responsible for proxying commands from the main-thread side of |
| 20 // the compositor over to the compositor implementation. | 20 // the compositor over to the compositor implementation. |
| 21 class CCProxy { | 21 class Proxy { |
| 22 public: | 22 public: |
| 23 static void setMainThread(CCThread*); | 23 static void setMainThread(Thread*); |
| 24 static CCThread* mainThread(); | 24 static Thread* mainThread(); |
| 25 | 25 |
| 26 static bool hasImplThread(); | 26 static bool hasImplThread(); |
| 27 static void setImplThread(CCThread*); | 27 static void setImplThread(Thread*); |
| 28 static CCThread* implThread(); | 28 static Thread* implThread(); |
| 29 | 29 |
| 30 // 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. |
| 31 static CCThread* currentThread(); | 31 static Thread* currentThread(); |
| 32 | 32 |
| 33 virtual ~CCProxy(); | 33 virtual ~Proxy(); |
| 34 | 34 |
| 35 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0; | 35 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0; |
| 36 | 36 |
| 37 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use
Anchor, float scale, double durationSec) = 0; | 37 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use
Anchor, float scale, double durationSec) = 0; |
| 38 | 38 |
| 39 virtual void finishAllRendering() = 0; | 39 virtual void finishAllRendering() = 0; |
| 40 | 40 |
| 41 virtual bool isStarted() const = 0; | 41 virtual bool isStarted() const = 0; |
| 42 | 42 |
| 43 // Attempts to initialize a context to use for rendering. Returns false if t
he context could not be created. | 43 // Attempts to initialize a context to use for rendering. Returns false if t
he context could not be created. |
| 44 // The context will not be used and no frames may be produced until initiali
zeRenderer() is called. | 44 // The context will not be used and no frames may be produced until initiali
zeRenderer() is called. |
| 45 virtual bool initializeContext() = 0; | 45 virtual bool initializeContext() = 0; |
| 46 | 46 |
| 47 // Indicates that the compositing surface associated with our context is rea
dy to use. | 47 // Indicates that the compositing surface associated with our context is rea
dy to use. |
| 48 virtual void setSurfaceReady() = 0; | 48 virtual void setSurfaceReady() = 0; |
| 49 | 49 |
| 50 virtual void setVisible(bool) = 0; | 50 virtual void setVisible(bool) = 0; |
| 51 | 51 |
| 52 // Attempts to initialize the layer renderer. Returns false if the context i
sn't usable for compositing. | 52 // Attempts to initialize the layer renderer. Returns false if the context i
sn't usable for compositing. |
| 53 virtual bool initializeRenderer() = 0; | 53 virtual bool initializeRenderer() = 0; |
| 54 | 54 |
| 55 // Attempts to recreate the context and layer renderer after a context lost.
Returns false if the renderer couldn't be | 55 // Attempts to recreate the context and layer renderer after a context lost.
Returns false if the renderer couldn't be |
| 56 // reinitialized. | 56 // reinitialized. |
| 57 virtual bool recreateContext() = 0; | 57 virtual bool recreateContext() = 0; |
| 58 | 58 |
| 59 virtual void renderingStats(CCRenderingStats*) = 0; | 59 virtual void renderingStats(RenderingStats*) = 0; |
| 60 | 60 |
| 61 virtual const RendererCapabilities& rendererCapabilities() const = 0; | 61 virtual const RendererCapabilities& rendererCapabilities() const = 0; |
| 62 | 62 |
| 63 virtual void setNeedsAnimate() = 0; | 63 virtual void setNeedsAnimate() = 0; |
| 64 virtual void setNeedsCommit() = 0; | 64 virtual void setNeedsCommit() = 0; |
| 65 virtual void setNeedsRedraw() = 0; | 65 virtual void setNeedsRedraw() = 0; |
| 66 | 66 |
| 67 virtual void didAddAnimation() = 0; | 67 virtual void didAddAnimation() = 0; |
| 68 | 68 |
| 69 virtual bool commitRequested() const = 0; | 69 virtual bool commitRequested() const = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 89 #endif | 89 #endif |
| 90 | 90 |
| 91 // Testing hooks | 91 // Testing hooks |
| 92 virtual void loseContext() = 0; | 92 virtual void loseContext() = 0; |
| 93 | 93 |
| 94 #ifndef NDEBUG | 94 #ifndef NDEBUG |
| 95 static void setCurrentThreadIsImplThread(bool); | 95 static void setCurrentThreadIsImplThread(bool); |
| 96 #endif | 96 #endif |
| 97 | 97 |
| 98 protected: | 98 protected: |
| 99 CCProxy(); | 99 Proxy(); |
| 100 friend class DebugScopedSetImplThread; | 100 friend class DebugScopedSetImplThread; |
| 101 friend class DebugScopedSetMainThreadBlocked; | 101 friend class DebugScopedSetMainThreadBlocked; |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 DISALLOW_COPY_AND_ASSIGN(CCProxy); | 104 DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 class DebugScopedSetMainThreadBlocked { | 107 class DebugScopedSetMainThreadBlocked { |
| 108 public: | 108 public: |
| 109 DebugScopedSetMainThreadBlocked() | 109 DebugScopedSetMainThreadBlocked() |
| 110 { | 110 { |
| 111 #if !ASSERT_DISABLED | 111 #if !ASSERT_DISABLED |
| 112 ASSERT(!CCProxy::isMainThreadBlocked()); | 112 ASSERT(!Proxy::isMainThreadBlocked()); |
| 113 CCProxy::setMainThreadBlocked(true); | 113 Proxy::setMainThreadBlocked(true); |
| 114 #endif | 114 #endif |
| 115 } | 115 } |
| 116 ~DebugScopedSetMainThreadBlocked() | 116 ~DebugScopedSetMainThreadBlocked() |
| 117 { | 117 { |
| 118 #if !ASSERT_DISABLED | 118 #if !ASSERT_DISABLED |
| 119 ASSERT(CCProxy::isMainThreadBlocked()); | 119 ASSERT(Proxy::isMainThreadBlocked()); |
| 120 CCProxy::setMainThreadBlocked(false); | 120 Proxy::setMainThreadBlocked(false); |
| 121 #endif | 121 #endif |
| 122 } | 122 } |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 } | 125 } |
| 126 | 126 |
| 127 #endif | 127 #endif |
| OLD | NEW |