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

Side by Side Diff: ui/gfx/compositor/compositor.h

Issue 8240006: Use a mocked compositor for unit tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years, 2 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 UI_GFX_COMPOSITOR_COMPOSITOR_H_ 5 #ifndef UI_GFX_COMPOSITOR_COMPOSITOR_H_
6 #define UI_GFX_COMPOSITOR_COMPOSITOR_H_ 6 #define UI_GFX_COMPOSITOR_COMPOSITOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 // Returns the size of the widget that is being drawn to. 131 // Returns the size of the widget that is being drawn to.
132 const gfx::Size& size() { return size_; } 132 const gfx::Size& size() { return size_; }
133 133
134 // Compositor does not own observers. It is the responsibility of the 134 // Compositor does not own observers. It is the responsibility of the
135 // observer to remove itself when it is done observing. 135 // observer to remove itself when it is done observing.
136 void AddObserver(CompositorObserver* observer); 136 void AddObserver(CompositorObserver* observer);
137 void RemoveObserver(CompositorObserver* observer); 137 void RemoveObserver(CompositorObserver* observer);
138 bool HasObserver(CompositorObserver* observer); 138 bool HasObserver(CompositorObserver* observer);
139 139
140 static void set_compositor_factory_for_testing(
141 ui::Compositor*(*factory)(ui::CompositorDelegate* owner)) {
142 compositor_factory_ = factory;
143 }
144
145 static ui::Compositor* (*compositor_factory())(
146 ui::CompositorDelegate* owner) {
147 return compositor_factory_;
148 }
149
140 protected: 150 protected:
141 Compositor(CompositorDelegate* delegate, const gfx::Size& size); 151 Compositor(CompositorDelegate* delegate, const gfx::Size& size);
142 virtual ~Compositor(); 152 virtual ~Compositor();
143 153
144 // Notifies the compositor that compositing is about to start. 154 // Notifies the compositor that compositing is about to start.
145 virtual void OnNotifyStart(bool clear) = 0; 155 virtual void OnNotifyStart(bool clear) = 0;
146 156
147 // Notifies the compositor that compositing is complete. 157 // Notifies the compositor that compositing is complete.
148 virtual void OnNotifyEnd() = 0; 158 virtual void OnNotifyEnd() = 0;
149 159
(...skipping 12 matching lines...) Expand all
162 void NotifyEnd(); 172 void NotifyEnd();
163 173
164 CompositorDelegate* delegate_; 174 CompositorDelegate* delegate_;
165 gfx::Size size_; 175 gfx::Size size_;
166 176
167 // The root of the Layer tree drawn by this compositor. 177 // The root of the Layer tree drawn by this compositor.
168 Layer* root_layer_; 178 Layer* root_layer_;
169 179
170 ObserverList<CompositorObserver> observer_list_; 180 ObserverList<CompositorObserver> observer_list_;
171 181
182 // Factory used to create Compositors. Settable by tests.
183 // The delegate can be NULL if you don't wish to catch the ScheduleDraw()
184 // calls to it.
185 static ui::Compositor*(*compositor_factory_)(
186 ui::CompositorDelegate* delegate);
187
172 friend class base::RefCounted<Compositor>; 188 friend class base::RefCounted<Compositor>;
173 }; 189 };
174 190
175 } // namespace ui 191 } // namespace ui
176 192
177 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ 193 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698