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

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: ui/gfx/test/gfx_test_utils x4 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 // Returns the size of the widget that is being drawn to. 133 // Returns the size of the widget that is being drawn to.
134 const gfx::Size& size() { return size_; } 134 const gfx::Size& size() { return size_; }
135 135
136 // Compositor does not own observers. It is the responsibility of the 136 // Compositor does not own observers. It is the responsibility of the
137 // observer to remove itself when it is done observing. 137 // observer to remove itself when it is done observing.
138 void AddObserver(CompositorObserver* observer); 138 void AddObserver(CompositorObserver* observer);
139 void RemoveObserver(CompositorObserver* observer); 139 void RemoveObserver(CompositorObserver* observer);
140 bool HasObserver(CompositorObserver* observer); 140 bool HasObserver(CompositorObserver* observer);
141 141
142 static void set_compositor_factory_for_testing(
143 ui::Compositor*(*factory)(ui::CompositorDelegate* owner)) {
144 compositor_factory_ = factory;
145 }
146
147 static ui::Compositor* (*compositor_factory())(
148 ui::CompositorDelegate* owner) {
149 return compositor_factory_;
150 }
151
142 protected: 152 protected:
143 Compositor(CompositorDelegate* delegate, const gfx::Size& size); 153 Compositor(CompositorDelegate* delegate, const gfx::Size& size);
144 virtual ~Compositor(); 154 virtual ~Compositor();
145 155
146 // Notifies the compositor that compositing is about to start. 156 // Notifies the compositor that compositing is about to start.
147 virtual void OnNotifyStart(bool clear) = 0; 157 virtual void OnNotifyStart(bool clear) = 0;
148 158
149 // Notifies the compositor that compositing is complete. 159 // Notifies the compositor that compositing is complete.
150 virtual void OnNotifyEnd() = 0; 160 virtual void OnNotifyEnd() = 0;
151 161
(...skipping 10 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