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

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: Rebase to 165444 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 gfx { 14 namespace gfx {
14 class Rect; 15 class Rect;
15 } 16 }
16 17
17 namespace cc { 18 namespace cc {
18 19
19 class Thread; 20 class Thread;
20 class IntSize; 21 class IntSize;
21 struct RenderingStats; 22 struct RenderingStats;
22 struct RendererCapabilities; 23 struct RendererCapabilities;
23 24
24 // Abstract class responsible for proxying commands from the main-thread side of 25 // Abstract class responsible for proxying commands from the main-thread side of
25 // the compositor over to the compositor implementation. 26 // the compositor over to the compositor implementation.
26 class Proxy { 27 class Proxy {
27 public: 28 public:
28 static void setMainThread(Thread*); 29 Thread* mainThread() const;
29 static Thread* mainThread(); 30 bool hasImplThread() const;
30 31 Thread* implThread() const;
31 static bool hasImplThread();
32 static void setImplThread(Thread*);
33 static Thread* implThread();
34 32
35 // Returns 0 if the current thread is neither the main thread nor the impl t hread. 33 // Returns 0 if the current thread is neither the main thread nor the impl t hread.
36 static Thread* currentThread(); 34 Thread* currentThread() const;
35
36 // Debug hooks
37 bool isMainThread() const;
38 bool isImplThread() const;
39 bool isMainThreadBlocked() const;
40 #ifndef NDEBUG
41 void setMainThreadBlocked(bool);
42 void setCurrentThreadIsImplThread(bool);
43 #endif
37 44
38 virtual ~Proxy(); 45 virtual ~Proxy();
39 46
40 virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) = 0; 47 virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) = 0;
41 48
42 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use Anchor, float scale, base::TimeDelta duration) = 0; 49 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use Anchor, float scale, base::TimeDelta duration) = 0;
43 50
44 virtual void finishAllRendering() = 0; 51 virtual void finishAllRendering() = 0;
45 52
46 virtual bool isStarted() const = 0; 53 virtual bool isStarted() const = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 89
83 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t o finish before executing in the GPU 90 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t o finish before executing in the GPU
84 // process. 91 // process.
85 virtual void forceSerializeOnSwapBuffers() = 0; 92 virtual void forceSerializeOnSwapBuffers() = 0;
86 93
87 // Maximum number of sub-region texture updates supported for each commit. 94 // Maximum number of sub-region texture updates supported for each commit.
88 virtual size_t maxPartialTextureUpdates() const = 0; 95 virtual size_t maxPartialTextureUpdates() const = 0;
89 96
90 virtual void acquireLayerTextures() = 0; 97 virtual void acquireLayerTextures() = 0;
91 98
92 // Debug hooks
93 static bool isMainThread();
94 static bool isImplThread();
95 static bool isMainThreadBlocked();
96 #ifndef NDEBUG
97 static void setMainThreadBlocked(bool);
98 #endif
99
100 // Testing hooks 99 // Testing hooks
101 virtual void loseContext() = 0; 100 virtual void loseContext() = 0;
102 101
103 #ifndef NDEBUG
104 static void setCurrentThreadIsImplThread(bool);
105 #endif
106
107 protected: 102 protected:
108 Proxy(); 103 explicit Proxy(scoped_ptr<Thread> implThread);
109 friend class DebugScopedSetImplThread; 104 friend class DebugScopedSetImplThread;
105 friend class DebugScopedSetMainThread;
110 friend class DebugScopedSetMainThreadBlocked; 106 friend class DebugScopedSetMainThreadBlocked;
111 107
112 private: 108 private:
113 DISALLOW_COPY_AND_ASSIGN(Proxy); 109 DISALLOW_COPY_AND_ASSIGN(Proxy);
110
111 scoped_ptr<Thread> m_mainThread;
112 scoped_ptr<Thread> m_implThread;
113 #ifndef NDEBUG
114 bool m_implThreadIsOverridden;
115 bool m_isMainThreadBlocked;
116 #endif
114 }; 117 };
115 118
116 class DebugScopedSetMainThreadBlocked { 119 class DebugScopedSetMainThreadBlocked {
117 public: 120 public:
118 DebugScopedSetMainThreadBlocked() 121 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy)
122 : m_proxy(proxy)
119 { 123 {
120 #ifndef NDEBUG 124 #ifndef NDEBUG
121 DCHECK(!Proxy::isMainThreadBlocked()); 125 DCHECK(!m_proxy->isMainThreadBlocked());
122 Proxy::setMainThreadBlocked(true); 126 m_proxy->setMainThreadBlocked(true);
123 #endif 127 #endif
124 } 128 }
125 ~DebugScopedSetMainThreadBlocked() 129 ~DebugScopedSetMainThreadBlocked()
126 { 130 {
127 #ifndef NDEBUG 131 #ifndef NDEBUG
128 DCHECK(Proxy::isMainThreadBlocked()); 132 DCHECK(m_proxy->isMainThreadBlocked());
129 Proxy::setMainThreadBlocked(false); 133 m_proxy->setMainThreadBlocked(false);
130 #endif 134 #endif
131 } 135 }
136 private:
137 Proxy* m_proxy;
132 }; 138 };
133 139
134 } 140 }
135 141
136 #endif 142 #endif
OLDNEW
« cc/frame_rate_counter.cc ('K') | « cc/prioritized_texture_unittest.cc ('k') | cc/proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698