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

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: . 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Update the layer's size in pixel using |compositor|'s device_scale_factor.
199 void UpdateLayerSize(const Compositor* compositor);
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
205 private: 215 private:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 virtual void SetTransformFromAnimation(const Transform& transform) OVERRIDE; 252 virtual void SetTransformFromAnimation(const Transform& transform) OVERRIDE;
243 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; 253 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE;
244 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE; 254 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE;
245 virtual void ScheduleDrawForAnimation() OVERRIDE; 255 virtual void ScheduleDrawForAnimation() OVERRIDE;
246 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; 256 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE;
247 virtual const Transform& GetTransformForAnimation() const OVERRIDE; 257 virtual const Transform& GetTransformForAnimation() const OVERRIDE;
248 virtual float GetOpacityForAnimation() const OVERRIDE; 258 virtual float GetOpacityForAnimation() const OVERRIDE;
249 virtual bool GetVisibilityForAnimation() const OVERRIDE; 259 virtual bool GetVisibilityForAnimation() const OVERRIDE;
250 260
251 void CreateWebLayer(); 261 void CreateWebLayer();
252 void RecomputeTransform(); 262 void RecomputeTransform(const Compositor* compositor);
253 void RecomputeDrawsContentAndUVRect(); 263 void RecomputeDrawsContentAndUVRect(const Compositor* compositor);
254 void RecomputeDebugBorderColor(); 264 void RecomputeDebugBorderColor();
265 void ScheduleDraw(Compositor* compositor);
266 bool SchedulePaint(Compositor* compositor,
267 const gfx::Rect& invalid_rect);
255 268
256 const LayerType type_; 269 const LayerType type_;
257 270
258 Compositor* compositor_; 271 Compositor* compositor_;
259 272
260 scoped_refptr<ui::Texture> texture_; 273 scoped_refptr<ui::Texture> texture_;
261 274
262 Layer* parent_; 275 Layer* parent_;
263 276
264 // This layer's children, in bottom-to-top stacking order. 277 // This layer's children, in bottom-to-top stacking order.
265 std::vector<Layer*> children_; 278 std::vector<Layer*> children_;
266 279
267 ui::Transform transform_; 280 ui::Transform transform_;
268 281
269 gfx::Rect bounds_; 282 gfx::Rect bounds_;
270 283
271 // Visibility of this layer. See SetVisible/IsDrawn for more details. 284 // Visibility of this layer. See SetVisible/IsDrawn for more details.
272 bool visible_; 285 bool visible_;
273 286
274 bool fills_bounds_opaquely_; 287 bool fills_bounds_opaquely_;
275 288
276 // If true the layer is always up to date. 289 // If true the layer is always up to date.
277 bool layer_updated_externally_; 290 bool layer_updated_externally_;
278 291
279 // Union of damaged rects to be used when compositor is ready to 292 // Union of damaged rects, in pixel coordinates, to be used when
280 // paint the content. 293 // compositor is ready to paint the content.
281 SkRegion damaged_region_; 294 SkRegion damaged_region_;
282 295
283 float opacity_; 296 float opacity_;
284 int background_blur_radius_; 297 int background_blur_radius_;
285 298
286 std::string name_; 299 std::string name_;
287 300
288 LayerDelegate* delegate_; 301 LayerDelegate* delegate_;
289 302
290 scoped_ptr<LayerAnimator> animator_; 303 scoped_ptr<LayerAnimator> animator_;
291 304
292 WebKit::WebLayer web_layer_; 305 WebKit::WebLayer web_layer_;
293 bool web_layer_is_accelerated_; 306 bool web_layer_is_accelerated_;
294 bool show_debug_borders_; 307 bool show_debug_borders_;
295 308
309 // If true, the layer scales the canvas using device scale factor
310 // before passing to LayerDelegate::OnLayerPaint.
311 bool scale_canvas_;
312
296 DISALLOW_COPY_AND_ASSIGN(Layer); 313 DISALLOW_COPY_AND_ASSIGN(Layer);
297 }; 314 };
298 315
299 } // namespace ui 316 } // namespace ui
300 317
301 #endif // UI_GFX_COMPOSITOR_LAYER_H_ 318 #endif // UI_GFX_COMPOSITOR_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698