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

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

Issue 10221028: Move DIP translation from ui/aura to ui/compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert change i made by accident Created 8 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/hash_tables.h" 9 #include "base/hash_tables.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 gfx::Size size() const { return size_; } 104 gfx::Size size() const { return size_; }
105 105
106 protected: 106 protected:
107 virtual ~Texture(); 107 virtual ~Texture();
108 108
109 private: 109 private:
110 friend class base::RefCounted<Texture>; 110 friend class base::RefCounted<Texture>;
111 111
112 unsigned int texture_id_; 112 unsigned int texture_id_;
113 bool flipped_; 113 bool flipped_;
114 gfx::Size size_; 114 gfx::Size size_; // in pixel
115 115
116 DISALLOW_COPY_AND_ASSIGN(Texture); 116 DISALLOW_COPY_AND_ASSIGN(Texture);
117 }; 117 };
118 118
119 // An interface to allow the compositor to communicate with its owner. 119 // An interface to allow the compositor to communicate with its owner.
120 class COMPOSITOR_EXPORT CompositorDelegate { 120 class COMPOSITOR_EXPORT CompositorDelegate {
121 public: 121 public:
122 // Requests the owner to schedule a redraw of the layer tree. 122 // Requests the owner to schedule a redraw of the layer tree.
123 virtual void ScheduleDraw() = 0; 123 virtual void ScheduleDraw() = 0;
124 124
125 protected: 125 protected:
126 virtual ~CompositorDelegate() {} 126 virtual ~CompositorDelegate() {}
127 }; 127 };
128 128
129 // Compositor object to take care of GPU painting. 129 // Compositor object to take care of GPU painting.
130 // A Browser compositor object is responsible for generating the final 130 // A Browser compositor object is responsible for generating the final
131 // displayable form of pixels comprising a single widget's contents. It draws an 131 // displayable form of pixels comprising a single widget's contents. It draws an
132 // appropriately transformed texture for each transformed view in the widget's 132 // appropriately transformed texture for each transformed view in the widget's
133 // view hierarchy. 133 // view hierarchy.
134 class COMPOSITOR_EXPORT Compositor 134 class COMPOSITOR_EXPORT Compositor
135 : NON_EXPORTED_BASE(public WebKit::WebLayerTreeViewClient) { 135 : NON_EXPORTED_BASE(public WebKit::WebLayerTreeViewClient) {
136 public: 136 public:
137 Compositor(CompositorDelegate* delegate, 137 Compositor(CompositorDelegate* delegate,
138 gfx::AcceleratedWidget widget, 138 gfx::AcceleratedWidget widget);
139 const gfx::Size& size);
140 virtual ~Compositor(); 139 virtual ~Compositor();
141 140
142 static void Initialize(bool useThread); 141 static void Initialize(bool useThread);
143 static void Terminate(); 142 static void Terminate();
144 143
145 // Schedules a redraw of the layer tree associated with this compositor. 144 // Schedules a redraw of the layer tree associated with this compositor.
146 void ScheduleDraw(); 145 void ScheduleDraw();
147 146
148 // Sets the root of the layer tree drawn by this Compositor. The root layer 147 // Sets the root of the layer tree drawn by this Compositor. The root layer
149 // must have no parent. The compositor's root layer is reset if the root layer 148 // must have no parent. The compositor's root layer is reset if the root layer
150 // is destroyed. NULL can be passed to reset the root layer, in which case the 149 // is destroyed. NULL can be passed to reset the root layer, in which case the
151 // compositor will stop drawing anything. 150 // compositor will stop drawing anything.
152 // The Compositor does not own the root layer. 151 // The Compositor does not own the root layer.
153 const Layer* root_layer() const { return root_layer_; } 152 const Layer* root_layer() const { return root_layer_; }
154 Layer* root_layer() { return root_layer_; } 153 Layer* root_layer() { return root_layer_; }
155 void SetRootLayer(Layer* root_layer); 154 void SetRootLayer(Layer* root_layer);
156 155
156 // The scale factor of the device that this compositor is
157 // compositing layers on.
158 float device_scale_factor() const { return device_scale_factor_; }
159
157 // Draws the scene created by the layer tree and any visual effects. If 160 // Draws the scene created by the layer tree and any visual effects. If
158 // |force_clear| is true, this will cause the compositor to clear before 161 // |force_clear| is true, this will cause the compositor to clear before
159 // compositing. 162 // compositing.
160 void Draw(bool force_clear); 163 void Draw(bool force_clear);
161 164
162 // Where possible, draws are scissored to a damage region calculated from 165 // Where possible, draws are scissored to a damage region calculated from
163 // changes to layer properties. This bypasses that and indicates that 166 // changes to layer properties. This bypasses that and indicates that
164 // the whole frame needs to be drawn. 167 // the whole frame needs to be drawn.
165 void ScheduleFullDraw(); 168 void ScheduleFullDraw();
166 169
167 // Reads the region |bounds| of the contents of the last rendered frame 170 // Reads the region |bounds_in_pixel| of the contents of the last rendered
168 // into the given bitmap. 171 // frame into the given bitmap.
169 // Returns false if the pixels could not be read. 172 // Returns false if the pixels could not be read.
170 bool ReadPixels(SkBitmap* bitmap, const gfx::Rect& bounds); 173 bool ReadPixels(SkBitmap* bitmap, const gfx::Rect& bounds_in_pixel);
171 174
172 // Notifies the compositor that the size of the widget that it is 175 // Notifies the compositor that the device scale factor and size of
173 // drawing to has changed. 176 // the widget that it is drawing to has changed.
174 void WidgetSizeChanged(const gfx::Size& size); 177 void WidgetScaleOrSizeChanged(float scale, const gfx::Size& size_in_pixel);
175 178
176 // Returns the size of the widget that is being drawn to. 179 // Returns the size of the widget that is being drawn to in pixel coordinates.
177 const gfx::Size& size() const { return size_; } 180 const gfx::Size& size() const { return size_; }
178 181
179 // Returns the widget for this compositor. 182 // Returns the widget for this compositor.
180 gfx::AcceleratedWidget widget() const { return widget_; } 183 gfx::AcceleratedWidget widget() const { return widget_; }
181 184
182 // Compositor does not own observers. It is the responsibility of the 185 // Compositor does not own observers. It is the responsibility of the
183 // observer to remove itself when it is done observing. 186 // observer to remove itself when it is done observing.
184 void AddObserver(CompositorObserver* observer); 187 void AddObserver(CompositorObserver* observer);
185 void RemoveObserver(CompositorObserver* observer); 188 void RemoveObserver(CompositorObserver* observer);
186 bool HasObserver(CompositorObserver* observer); 189 bool HasObserver(CompositorObserver* observer);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 ObserverList<CompositorObserver> observer_list_; 233 ObserverList<CompositorObserver> observer_list_;
231 234
232 gfx::AcceleratedWidget widget_; 235 gfx::AcceleratedWidget widget_;
233 WebKit::WebLayer root_web_layer_; 236 WebKit::WebLayer root_web_layer_;
234 WebKit::WebLayerTreeView host_; 237 WebKit::WebLayerTreeView host_;
235 238
236 // This is set to true when the swap buffers has been posted and we're waiting 239 // This is set to true when the swap buffers has been posted and we're waiting
237 // for completion. 240 // for completion.
238 bool swap_posted_; 241 bool swap_posted_;
239 242
243 // The device scale factor of the monitor that this compositor is compositing
244 // layers on.
245 float device_scale_factor_;
246
240 friend class base::RefCounted<Compositor>; 247 friend class base::RefCounted<Compositor>;
241 }; 248 };
242 249
243 } // namespace ui 250 } // namespace ui
244 251
245 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ 252 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698