Don't consider a Bluetooth adapter present until it has an address.
[chromium-blink-merge.git] / cc / CCSingleThreadProxy.h
blobacdf4cfaee5338a2aad5fcb4622f721433014726
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
3 // found in the LICENSE file.
5 #ifndef CCSingleThreadProxy_h
6 #define CCSingleThreadProxy_h
8 #include "CCAnimationEvents.h"
9 #include "CCLayerTreeHostImpl.h"
10 #include "CCProxy.h"
11 #include <limits>
12 #include <wtf/OwnPtr.h>
14 namespace WebCore {
16 class CCLayerTreeHost;
18 class CCSingleThreadProxy : public CCProxy, CCLayerTreeHostImplClient {
19 public:
20 static PassOwnPtr<CCProxy> create(CCLayerTreeHost*);
21 virtual ~CCSingleThreadProxy();
23 // CCProxy implementation
24 virtual bool compositeAndReadback(void *pixels, const IntRect&) OVERRIDE;
25 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration) OVERRIDE;
26 virtual void finishAllRendering() OVERRIDE;
27 virtual bool isStarted() const OVERRIDE;
28 virtual bool initializeContext() OVERRIDE;
29 virtual void setSurfaceReady() OVERRIDE;
30 virtual void setVisible(bool) OVERRIDE;
31 virtual bool initializeRenderer() OVERRIDE;
32 virtual bool recreateContext() OVERRIDE;
33 virtual void implSideRenderingStats(CCRenderingStats&) OVERRIDE;
34 virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE;
35 virtual void loseContext() OVERRIDE;
36 virtual void setNeedsAnimate() OVERRIDE;
37 virtual void setNeedsCommit() OVERRIDE;
38 virtual void setNeedsRedraw() OVERRIDE;
39 virtual bool commitRequested() const OVERRIDE;
40 virtual void didAddAnimation() OVERRIDE;
41 virtual void start() OVERRIDE;
42 virtual void stop() OVERRIDE;
43 virtual size_t maxPartialTextureUpdates() const OVERRIDE { return std::numeric_limits<size_t>::max(); }
44 virtual void acquireLayerTextures() OVERRIDE { }
45 virtual void forceSerializeOnSwapBuffers() OVERRIDE;
47 // CCLayerTreeHostImplClient implementation
48 virtual void didLoseContextOnImplThread() OVERRIDE { }
49 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { ASSERT_NOT_REACHED(); }
50 virtual void onVSyncParametersChanged(double monotonicTimebase, double intervalInSeconds) OVERRIDE { }
51 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { }
52 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_layerTreeHost->scheduleComposite(); }
53 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_layerTreeHost->scheduleComposite(); }
54 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE;
56 // Called by the legacy path where RenderWidget does the scheduling.
57 void compositeImmediately();
59 private:
60 explicit CCSingleThreadProxy(CCLayerTreeHost*);
62 bool commitAndComposite();
63 void doCommit(CCTextureUpdateQueue&);
64 bool doComposite();
65 void didSwapFrame();
67 // Accessed on main thread only.
68 CCLayerTreeHost* m_layerTreeHost;
69 bool m_contextLost;
71 // Holds on to the context between initializeContext() and initializeRenderer() calls. Shouldn't
72 // be used for anything else.
73 OwnPtr<CCGraphicsContext> m_contextBeforeInitialization;
75 // Used on the CCThread, but checked on main thread during initialization/shutdown.
76 OwnPtr<CCLayerTreeHostImpl> m_layerTreeHostImpl;
77 bool m_rendererInitialized;
78 RendererCapabilities m_RendererCapabilitiesForMainThread;
80 bool m_nextFrameIsNewlyCommittedFrame;
83 // For use in the single-threaded case. In debug builds, it pretends that the
84 // code is running on the impl thread to satisfy assertion checks.
85 class DebugScopedSetImplThread {
86 public:
87 DebugScopedSetImplThread()
89 #if !ASSERT_DISABLED
90 CCProxy::setCurrentThreadIsImplThread(true);
91 #endif
93 ~DebugScopedSetImplThread()
95 #if !ASSERT_DISABLED
96 CCProxy::setCurrentThreadIsImplThread(false);
97 #endif
101 // For use in the single-threaded case. In debug builds, it pretends that the
102 // code is running on the main thread to satisfy assertion checks.
103 class DebugScopedSetMainThread {
104 public:
105 DebugScopedSetMainThread()
107 #if !ASSERT_DISABLED
108 CCProxy::setCurrentThreadIsImplThread(false);
109 #endif
111 ~DebugScopedSetMainThread()
113 #if !ASSERT_DISABLED
114 CCProxy::setCurrentThreadIsImplThread(true);
115 #endif
119 // For use in the single-threaded case. In debug builds, it pretends that the
120 // code is running on the impl thread and that the main thread is blocked to
121 // satisfy assertion checks
122 class DebugScopedSetImplThreadAndMainThreadBlocked {
123 private:
124 DebugScopedSetImplThread m_implThread;
125 DebugScopedSetMainThreadBlocked m_mainThreadBlocked;
128 } // namespace WebCore
130 #endif