OLD | NEW |
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_LAYER_H_ | 5 #ifndef UI_GFX_COMPOSITOR_LAYER_H_ |
6 #define UI_GFX_COMPOSITOR_LAYER_H_ | 6 #define UI_GFX_COMPOSITOR_LAYER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 18 matching lines...) Expand all Loading... |
29 namespace ui { | 29 namespace ui { |
30 | 30 |
31 class Compositor; | 31 class Compositor; |
32 class LayerAnimator; | 32 class LayerAnimator; |
33 class Texture; | 33 class Texture; |
34 | 34 |
35 // Layer manages a texture, transform and a set of child Layers. Any View that | 35 // Layer manages a texture, transform and a set of child Layers. Any View that |
36 // has enabled layers ends up creating a Layer to manage the texture. | 36 // has enabled layers ends up creating a Layer to manage the texture. |
37 // A Layer can also be created without a texture, in which case it renders | 37 // A Layer can also be created without a texture, in which case it renders |
38 // nothing and is simply used as a node in a hierarchy of layers. | 38 // nothing and is simply used as a node in a hierarchy of layers. |
| 39 // Coordinate system used in layers is DIP (Density Independent Pixel) |
| 40 // coordinates unless explicitly mentioned as pixel coordinates. |
39 // | 41 // |
40 // NOTE: unlike Views, each Layer does *not* own its children views. If you | 42 // NOTE: unlike Views, each Layer does *not* own its children views. If you |
41 // delete a Layer and it has children, the parent of each child layer is set to | 43 // delete a Layer and it has children, the parent of each child layer is set to |
42 // NULL, but the children are not deleted. | 44 // NULL, but the children are not deleted. |
43 class COMPOSITOR_EXPORT Layer : | 45 class COMPOSITOR_EXPORT Layer : |
44 public LayerAnimationDelegate, | 46 public LayerAnimationDelegate, |
45 NON_EXPORTED_BASE(public WebKit::WebContentLayerClient) { | 47 NON_EXPORTED_BASE(public WebKit::WebContentLayerClient) { |
46 public: | 48 public: |
47 Layer(); | 49 Layer(); |
48 explicit Layer(LayerType type); | 50 explicit Layer(LayerType type); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 void ScheduleDraw(); | 188 void ScheduleDraw(); |
187 | 189 |
188 // Sends damaged rectangles recorded in |damaged_region_| to | 190 // Sends damaged rectangles recorded in |damaged_region_| to |
189 // |compostior_| to repaint the content. | 191 // |compostior_| to repaint the content. |
190 void SendDamagedRects(); | 192 void SendDamagedRects(); |
191 | 193 |
192 // Suppresses painting the content by disgarding damaged region and ignoring | 194 // Suppresses painting the content by disgarding damaged region and ignoring |
193 // new paint requests. | 195 // new paint requests. |
194 void SuppressPaint(); | 196 void SuppressPaint(); |
195 | 197 |
| 198 // Notifies the layer that the device scale factor has changed. |
| 199 void OnDeviceScaleFactorChanged(float device_scale_factor); |
| 200 |
| 201 // Sets if the layer should scale the canvas before passing to |
| 202 // |LayerDelegate::OnLayerPaint|. Set to false if the delegate |
| 203 // handles scaling. |
| 204 void set_scale_canvas(bool scale_canvas); |
| 205 |
196 // Sometimes the Layer is being updated by something other than SetCanvas | 206 // Sometimes the Layer is being updated by something other than SetCanvas |
197 // (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT). | 207 // (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT). |
198 bool layer_updated_externally() const { return layer_updated_externally_; } | 208 bool layer_updated_externally() const { return layer_updated_externally_; } |
199 | 209 |
200 // WebContentLayerClient | 210 // WebContentLayerClient |
201 virtual void paintContents(WebKit::WebCanvas*, const WebKit::WebRect& clip); | 211 virtual void paintContents(WebKit::WebCanvas*, const WebKit::WebRect& clip); |
202 | 212 |
203 WebKit::WebLayer web_layer() { return web_layer_; } | 213 WebKit::WebLayer web_layer() { return web_layer_; } |
204 | 214 |
| 215 float device_scale_factor() const { return device_scale_factor_; } |
| 216 |
205 private: | 217 private: |
206 struct LayerProperties { | 218 struct LayerProperties { |
207 public: | 219 public: |
208 ui::Layer* layer; | 220 ui::Layer* layer; |
209 ui::Transform transform_relative_to_root; | 221 ui::Transform transform_relative_to_root; |
210 }; | 222 }; |
211 | 223 |
212 // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than | 224 // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than |
213 // 1.0, we'll render to a separate texture, and then apply the alpha. | 225 // 1.0, we'll render to a separate texture, and then apply the alpha. |
214 // Currently, we multiply our opacity by all our ancestor's opacities and | 226 // Currently, we multiply our opacity by all our ancestor's opacities and |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 gfx::Rect bounds_; | 281 gfx::Rect bounds_; |
270 | 282 |
271 // Visibility of this layer. See SetVisible/IsDrawn for more details. | 283 // Visibility of this layer. See SetVisible/IsDrawn for more details. |
272 bool visible_; | 284 bool visible_; |
273 | 285 |
274 bool fills_bounds_opaquely_; | 286 bool fills_bounds_opaquely_; |
275 | 287 |
276 // If true the layer is always up to date. | 288 // If true the layer is always up to date. |
277 bool layer_updated_externally_; | 289 bool layer_updated_externally_; |
278 | 290 |
279 // Union of damaged rects to be used when compositor is ready to | 291 // Union of damaged rects, in pixel coordinates, to be used when |
280 // paint the content. | 292 // compositor is ready to paint the content. |
281 SkRegion damaged_region_; | 293 SkRegion damaged_region_; |
282 | 294 |
283 float opacity_; | 295 float opacity_; |
284 int background_blur_radius_; | 296 int background_blur_radius_; |
285 | 297 |
286 std::string name_; | 298 std::string name_; |
287 | 299 |
288 LayerDelegate* delegate_; | 300 LayerDelegate* delegate_; |
289 | 301 |
290 scoped_ptr<LayerAnimator> animator_; | 302 scoped_ptr<LayerAnimator> animator_; |
291 | 303 |
292 WebKit::WebLayer web_layer_; | 304 WebKit::WebLayer web_layer_; |
293 bool web_layer_is_accelerated_; | 305 bool web_layer_is_accelerated_; |
294 bool show_debug_borders_; | 306 bool show_debug_borders_; |
295 | 307 |
| 308 // If true, the layer scales the canvas using device scale factor |
| 309 // before passing to LayerDelegate::OnLayerPaint. |
| 310 bool scale_canvas_; |
| 311 |
| 312 // A cached copy of |Compositor::device_scale_factor()|. |
| 313 float device_scale_factor_; |
| 314 |
296 DISALLOW_COPY_AND_ASSIGN(Layer); | 315 DISALLOW_COPY_AND_ASSIGN(Layer); |
297 }; | 316 }; |
298 | 317 |
299 } // namespace ui | 318 } // namespace ui |
300 | 319 |
301 #endif // UI_GFX_COMPOSITOR_LAYER_H_ | 320 #endif // UI_GFX_COMPOSITOR_LAYER_H_ |
OLD | NEW |