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

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

Issue 10221028: Move DIP translation from ui/aura to ui/compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove dip from gyp 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_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
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 const Transform& transform() const { return transform_; } 108 const Transform& transform() const { return transform_; }
107 109
108 // Return the target transform if animator is running, or the current 110 // Return the target transform if animator is running, or the current
109 // transform otherwise. 111 // transform otherwise.
110 Transform GetTargetTransform() const; 112 Transform GetTargetTransform() const;
111 113
112 // The bounds, relative to the parent. 114 // The bounds, relative to the parent.
113 void SetBounds(const gfx::Rect& bounds); 115 void SetBounds(const gfx::Rect& bounds);
114 const gfx::Rect& bounds() const { return bounds_; } 116 const gfx::Rect& bounds() const { return bounds_; }
115 117
118 // Sets/Gets the bounds in pixel coordinates, relative to the parent.
119 void SetBoundsInPixel(const gfx::Rect& bounds_in_dip);
120 gfx::Rect GetBoundsInPixel() const;
piman 2012/05/04 18:46:06 Are these called publicly (or at all?)
121
116 // Return the target bounds if animator is running, or the current bounds 122 // Return the target bounds if animator is running, or the current bounds
117 // otherwise. 123 // otherwise.
118 gfx::Rect GetTargetBounds() const; 124 gfx::Rect GetTargetBounds() const;
119 125
120 // Sets/gets whether or not drawing of child layers should be clipped to the 126 // Sets/gets whether or not drawing of child layers should be clipped to the
121 // bounds of this layer. 127 // bounds of this layer.
122 void SetMasksToBounds(bool masks_to_bounds); 128 void SetMasksToBounds(bool masks_to_bounds);
123 bool GetMasksToBounds() const; 129 bool GetMasksToBounds() const;
124 130
125 // The opacity of the layer. The opacity is applied to each pixel of the 131 // The opacity of the layer. The opacity is applied to each pixel of the
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 void ScheduleDraw(); 192 void ScheduleDraw();
187 193
188 // Sends damaged rectangles recorded in |damaged_region_| to 194 // Sends damaged rectangles recorded in |damaged_region_| to
189 // |compostior_| to repaint the content. 195 // |compostior_| to repaint the content.
190 void SendDamagedRects(); 196 void SendDamagedRects();
191 197
192 // Suppresses painting the content by disgarding damaged region and ignoring 198 // Suppresses painting the content by disgarding damaged region and ignoring
193 // new paint requests. 199 // new paint requests.
194 void SuppressPaint(); 200 void SuppressPaint();
195 201
202 // Update the layer's size in pixel using the current device scale factor.
203 void UpdateLayerSize();
204
205 // Sets if the layer should scale the canvas before passing to
206 // |LayerDelegate::OnLayerPaint|. Set to false if the delegate
207 // handles scaling.
208 void set_scale_canvas(bool scale_canvas);
209
196 // Sometimes the Layer is being updated by something other than SetCanvas 210 // Sometimes the Layer is being updated by something other than SetCanvas
197 // (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT). 211 // (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT).
198 bool layer_updated_externally() const { return layer_updated_externally_; } 212 bool layer_updated_externally() const { return layer_updated_externally_; }
199 213
200 // WebContentLayerClient 214 // WebContentLayerClient
201 virtual void paintContents(WebKit::WebCanvas*, const WebKit::WebRect& clip); 215 virtual void paintContents(WebKit::WebCanvas*, const WebKit::WebRect& clip);
202 216
203 WebKit::WebLayer web_layer() { return web_layer_; } 217 WebKit::WebLayer web_layer() { return web_layer_; }
204 218
205 private: 219 private:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 gfx::Rect bounds_; 283 gfx::Rect bounds_;
270 284
271 // Visibility of this layer. See SetVisible/IsDrawn for more details. 285 // Visibility of this layer. See SetVisible/IsDrawn for more details.
272 bool visible_; 286 bool visible_;
273 287
274 bool fills_bounds_opaquely_; 288 bool fills_bounds_opaquely_;
275 289
276 // If true the layer is always up to date. 290 // If true the layer is always up to date.
277 bool layer_updated_externally_; 291 bool layer_updated_externally_;
278 292
279 // Union of damaged rects to be used when compositor is ready to 293 // Union of damaged rects, in pixel coordinates, to be used when
280 // paint the content. 294 // compositor is ready to paint the content.
281 SkRegion damaged_region_; 295 SkRegion damaged_region_;
282 296
283 float opacity_; 297 float opacity_;
284 int background_blur_radius_; 298 int background_blur_radius_;
285 299
286 std::string name_; 300 std::string name_;
287 301
288 LayerDelegate* delegate_; 302 LayerDelegate* delegate_;
289 303
290 scoped_ptr<LayerAnimator> animator_; 304 scoped_ptr<LayerAnimator> animator_;
291 305
292 WebKit::WebLayer web_layer_; 306 WebKit::WebLayer web_layer_;
293 bool web_layer_is_accelerated_; 307 bool web_layer_is_accelerated_;
294 bool show_debug_borders_; 308 bool show_debug_borders_;
295 309
310 // If true, the layer scales the canvas using device scale factor
311 // before passing to LayerDelegate::OnLayerPaitn.
piman 2012/05/04 18:46:06 nit: OnLayerPaitn -> OnLayerPaint
312 bool scale_canvas_;
313
296 DISALLOW_COPY_AND_ASSIGN(Layer); 314 DISALLOW_COPY_AND_ASSIGN(Layer);
297 }; 315 };
298 316
299 } // namespace ui 317 } // namespace ui
300 318
301 #endif // UI_GFX_COMPOSITOR_LAYER_H_ 319 #endif // UI_GFX_COMPOSITOR_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698