Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: cc/proxy.h

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/time.h" 10 #include "base/time.h"
11 #include "base/memory/scoped_ptr.h"
11 #include <public/WebCompositorOutputSurface.h> 12 #include <public/WebCompositorOutputSurface.h>
12 13
13 namespace cc { 14 namespace cc {
14 15
15 class Thread; 16 class Thread;
16 class IntRect; 17 class IntRect;
17 class IntSize; 18 class IntSize;
18 struct RenderingStats; 19 struct RenderingStats;
19 struct RendererCapabilities; 20 struct RendererCapabilities;
20 21
21 // 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
22 // the compositor over to the compositor implementation. 23 // the compositor over to the compositor implementation.
23 class Proxy { 24 class Proxy {
24 public: 25 public:
25 static void setMainThread(Thread*); 26 Thread* mainThread() const;
26 static Thread* mainThread(); 27 bool hasImplThread() const;
27 28 Thread* implThread() const;
28 static bool hasImplThread();
29 static void setImplThread(Thread*);
30 static Thread* implThread();
31 29
32 // 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.
33 static Thread* currentThread(); 31 Thread* currentThread() const;
32
33 // Debug hooks
34 bool isMainThread() const;
35 bool isImplThread() const;
36 bool isMainThreadBlocked() const;
37 #ifndef NDEBUG
38 void setMainThreadBlocked(bool);
39 void setCurrentThreadIsImplThread(bool);
40 #endif
34 41
35 virtual ~Proxy(); 42 virtual ~Proxy();
36 43
37 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0; 44 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0;
38 45
39 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use Anchor, float scale, base::TimeDelta duration) = 0; 46 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use Anchor, float scale, base::TimeDelta duration) = 0;
40 47
41 virtual void finishAllRendering() = 0; 48 virtual void finishAllRendering() = 0;
42 49
43 virtual bool isStarted() const = 0; 50 virtual bool isStarted() const = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 86
80 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t o finish before executing in the GPU 87 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t o finish before executing in the GPU
81 // process. 88 // process.
82 virtual void forceSerializeOnSwapBuffers() = 0; 89 virtual void forceSerializeOnSwapBuffers() = 0;
83 90
84 // Maximum number of sub-region texture updates supported for each commit. 91 // Maximum number of sub-region texture updates supported for each commit.
85 virtual size_t maxPartialTextureUpdates() const = 0; 92 virtual size_t maxPartialTextureUpdates() const = 0;
86 93
87 virtual void acquireLayerTextures() = 0; 94 virtual void acquireLayerTextures() = 0;
88 95
89 // Debug hooks
90 static bool isMainThread();
91 static bool isImplThread();
92 static bool isMainThreadBlocked();
93 #ifndef NDEBUG
94 static void setMainThreadBlocked(bool);
95 #endif
96
97 // Testing hooks 96 // Testing hooks
98 virtual void loseContext() = 0; 97 virtual void loseContext() = 0;
99 98
100 #ifndef NDEBUG
101 static void setCurrentThreadIsImplThread(bool);
102 #endif
103
104 protected: 99 protected:
105 Proxy(); 100 explicit Proxy(Thread* implThread);
106 friend class DebugScopedSetImplThread; 101 friend class DebugScopedSetImplThread;
102 friend class DebugScopedSetMainThread;
107 friend class DebugScopedSetMainThreadBlocked; 103 friend class DebugScopedSetMainThreadBlocked;
108 104
109 private: 105 private:
110 DISALLOW_COPY_AND_ASSIGN(Proxy); 106 DISALLOW_COPY_AND_ASSIGN(Proxy);
107
108 scoped_ptr<Thread> m_mainThread;
109 scoped_ptr<Thread> m_implThread;
110 #ifndef NDEBUG
111 bool m_implThreadIsOverridden;
112 bool m_isMainThreadBlocked;
113 #endif
111 }; 114 };
112 115
113 class DebugScopedSetMainThreadBlocked { 116 class DebugScopedSetMainThreadBlocked {
114 public: 117 public:
115 DebugScopedSetMainThreadBlocked() 118 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy)
119 : m_proxy(proxy)
116 { 120 {
117 #ifndef NDEBUG 121 #ifndef NDEBUG
118 DCHECK(!Proxy::isMainThreadBlocked()); 122 DCHECK(!m_proxy->isMainThreadBlocked());
119 Proxy::setMainThreadBlocked(true); 123 m_proxy->setMainThreadBlocked(true);
120 #endif 124 #endif
121 } 125 }
122 ~DebugScopedSetMainThreadBlocked() 126 ~DebugScopedSetMainThreadBlocked()
123 { 127 {
124 #ifndef NDEBUG 128 #ifndef NDEBUG
125 DCHECK(Proxy::isMainThreadBlocked()); 129 DCHECK(m_proxy->isMainThreadBlocked());
126 Proxy::setMainThreadBlocked(false); 130 m_proxy->setMainThreadBlocked(false);
127 #endif 131 #endif
128 } 132 }
133 private:
134 Proxy* m_proxy;
129 }; 135 };
130 136
131 } 137 }
132 138
133 #endif 139 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698