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

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

Issue 11415089: ui/compositor: use cc/ directly instead of webkit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac Created 8 years 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_COMPOSITOR_LAYER_H_ 5 #ifndef UI_COMPOSITOR_LAYER_H_
6 #define UI_COMPOSITOR_LAYER_H_ 6 #define UI_COMPOSITOR_LAYER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebContentLayerClie nt.h" 15 #include "cc/content_layer_client.h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureL ayerClient.h" 16 #include "cc/texture_layer_client.h"
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebContentLayer.h"
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebSolidColorLayer. h"
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureL ayer.h"
21 #include "third_party/skia/include/core/SkColor.h" 17 #include "third_party/skia/include/core/SkColor.h"
22 #include "third_party/skia/include/core/SkRegion.h" 18 #include "third_party/skia/include/core/SkRegion.h"
23 #include "ui/compositor/compositor.h" 19 #include "ui/compositor/compositor.h"
24 #include "ui/compositor/layer_animation_delegate.h" 20 #include "ui/compositor/layer_animation_delegate.h"
25 #include "ui/compositor/layer_delegate.h" 21 #include "ui/compositor/layer_delegate.h"
26 #include "ui/compositor/layer_type.h" 22 #include "ui/compositor/layer_type.h"
27 #include "ui/gfx/rect.h" 23 #include "ui/gfx/rect.h"
28 #include "ui/gfx/transform.h" 24 #include "ui/gfx/transform.h"
29 25
30 class SkCanvas; 26 class SkCanvas;
31 27
28 namespace cc {
29 class ContentLayer;
30 class Layer;
31 class ResourceUpdateQueue;
32 class SolidColorLayer;
33 class TextureLayer;
34 }
35
32 namespace ui { 36 namespace ui {
33 37
34 class Compositor; 38 class Compositor;
35 class LayerAnimator; 39 class LayerAnimator;
36 class Texture; 40 class Texture;
37 41
38 // Layer manages a texture, transform and a set of child Layers. Any View that 42 // Layer manages a texture, transform and a set of child Layers. Any View that
39 // has enabled layers ends up creating a Layer to manage the texture. 43 // has enabled layers ends up creating a Layer to manage the texture.
40 // A Layer can also be created without a texture, in which case it renders 44 // A Layer can also be created without a texture, in which case it renders
41 // nothing and is simply used as a node in a hierarchy of layers. 45 // nothing and is simply used as a node in a hierarchy of layers.
42 // Coordinate system used in layers is DIP (Density Independent Pixel) 46 // Coordinate system used in layers is DIP (Density Independent Pixel)
43 // coordinates unless explicitly mentioned as pixel coordinates. 47 // coordinates unless explicitly mentioned as pixel coordinates.
44 // 48 //
45 // NOTE: unlike Views, each Layer does *not* own its children views. If you 49 // NOTE: unlike Views, each Layer does *not* own its children views. If you
46 // delete a Layer and it has children, the parent of each child layer is set to 50 // delete a Layer and it has children, the parent of each child layer is set to
47 // NULL, but the children are not deleted. 51 // NULL, but the children are not deleted.
48 class COMPOSITOR_EXPORT Layer 52 class COMPOSITOR_EXPORT Layer
49 : public LayerAnimationDelegate, 53 : public LayerAnimationDelegate,
50 NON_EXPORTED_BASE(public WebKit::WebContentLayerClient), 54 NON_EXPORTED_BASE(public cc::ContentLayerClient),
51 NON_EXPORTED_BASE(public WebKit::WebExternalTextureLayerClient) { 55 NON_EXPORTED_BASE(public cc::TextureLayerClient) {
52 public: 56 public:
53 Layer(); 57 Layer();
54 explicit Layer(LayerType type); 58 explicit Layer(LayerType type);
55 virtual ~Layer(); 59 virtual ~Layer();
56 60
57 // Retrieves the Layer's compositor. The Layer will walk up its parent chain 61 // Retrieves the Layer's compositor. The Layer will walk up its parent chain
58 // to locate it. Returns NULL if the Layer is not attached to a compositor. 62 // to locate it. Returns NULL if the Layer is not attached to a compositor.
59 Compositor* GetCompositor(); 63 Compositor* GetCompositor();
60 64
61 // Called by the compositor when the Layer is set as its root Layer. This can 65 // Called by the compositor when the Layer is set as its root Layer. This can
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // not apply to the canvas passed to the pending draw. 263 // not apply to the canvas passed to the pending draw.
260 void set_scale_content(bool scale_content) { scale_content_ = scale_content; } 264 void set_scale_content(bool scale_content) { scale_content_ = scale_content; }
261 265
262 // Returns true if the layer scales its content. 266 // Returns true if the layer scales its content.
263 bool scale_content() const { return scale_content_; } 267 bool scale_content() const { return scale_content_; }
264 268
265 // Sometimes the Layer is being updated by something other than SetCanvas 269 // Sometimes the Layer is being updated by something other than SetCanvas
266 // (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT). 270 // (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT).
267 bool layer_updated_externally() const { return layer_updated_externally_; } 271 bool layer_updated_externally() const { return layer_updated_externally_; }
268 272
269 // WebContentLayerClient 273 // ContentLayerClient
270 virtual void paintContents(WebKit::WebCanvas*, 274 virtual void paintContents(
271 const WebKit::WebRect& clip, 275 SkCanvas*, const gfx::Rect& clip, gfx::RectF& opaque) OVERRIDE;
272 #if WEBCONTENTLAYERCLIENT_HAS_CANPAINTLCDTEXT
273 bool can_paint_lcd_text,
274 #endif // WEBCONTENTLAYERCLIENT_HAS_CANPAINTLCDTEXT
275 WebKit::WebFloatRect& opaque) OVERRIDE;
276 276
277 WebKit::WebLayer* web_layer() { return web_layer_; } 277 cc::Layer* cc_layer() { return cc_layer_; }
278 278
279 // WebExternalTextureLayerClient 279 // TextureLayerClient
280 virtual unsigned prepareTexture( 280 virtual unsigned prepareTexture(cc::ResourceUpdateQueue&) OVERRIDE;
281 WebKit::WebTextureUpdater& /* updater */) OVERRIDE;
282 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; 281 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE;
283 282
284 float device_scale_factor() const { return device_scale_factor_; } 283 float device_scale_factor() const { return device_scale_factor_; }
285 284
286 // Forces a render surface to be used on this layer. This has no positive 285 // Forces a render surface to be used on this layer. This has no positive
287 // impact, and is only used for benchmarking/testing purpose. 286 // impact, and is only used for benchmarking/testing purpose.
288 void SetForceRenderSurface(bool force); 287 void SetForceRenderSurface(bool force);
289 bool force_render_surface() const { return force_render_surface_; } 288 bool force_render_surface() const { return force_render_surface_; }
290 289
291 private: 290 private:
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 int zoom_inset_; 400 int zoom_inset_;
402 401
403 std::string name_; 402 std::string name_;
404 403
405 LayerDelegate* delegate_; 404 LayerDelegate* delegate_;
406 405
407 scoped_refptr<LayerAnimator> animator_; 406 scoped_refptr<LayerAnimator> animator_;
408 407
409 // Ownership of the layer is held through one of the strongly typed layer 408 // Ownership of the layer is held through one of the strongly typed layer
410 // pointers, depending on which sort of layer this is. 409 // pointers, depending on which sort of layer this is.
411 scoped_ptr<WebKit::WebContentLayer> content_layer_; 410 scoped_refptr<cc::ContentLayer> content_layer_;
412 scoped_ptr<WebKit::WebExternalTextureLayer> texture_layer_; 411 scoped_refptr<cc::TextureLayer> texture_layer_;
413 scoped_ptr<WebKit::WebSolidColorLayer> solid_color_layer_; 412 scoped_refptr<cc::SolidColorLayer> solid_color_layer_;
414 WebKit::WebLayer* web_layer_; 413 cc::Layer* cc_layer_;
415 bool web_layer_is_accelerated_; 414 bool cc_layer_is_accelerated_;
416 415
417 // If true, the layer scales the canvas and the texture with the device scale 416 // If true, the layer scales the canvas and the texture with the device scale
418 // factor as appropriate. When true, the texture size is in DIP. 417 // factor as appropriate. When true, the texture size is in DIP.
419 bool scale_content_; 418 bool scale_content_;
420 419
421 // A cached copy of |Compositor::device_scale_factor()|. 420 // A cached copy of |Compositor::device_scale_factor()|.
422 float device_scale_factor_; 421 float device_scale_factor_;
423 422
424 DISALLOW_COPY_AND_ASSIGN(Layer); 423 DISALLOW_COPY_AND_ASSIGN(Layer);
425 }; 424 };
426 425
427 } // namespace ui 426 } // namespace ui
428 427
429 #endif // UI_COMPOSITOR_LAYER_H_ 428 #endif // UI_COMPOSITOR_LAYER_H_
OLDNEW
« cc/proxy.h ('K') | « ui/compositor/compositor.gyp ('k') | ui/compositor/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698