1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "cc/layer_tree_host_impl.h"
12 #include "cc/picture_pile_impl.h"
13 #include "cc/resource_provider.h"
14 #include "cc/tile_manager.h"
15 #include "cc/tile_priority.h"
16 #include "ui/gfx/rect.h"
17 #include "ui/gfx/size.h"
23 class CC_EXPORT Tile
: public base::RefCounted
<Tile
> {
25 Tile(TileManager
* tile_manager
,
26 PicturePileImpl
* picture_pile
,
29 gfx::Rect content_rect
,
30 float contents_scale
);
32 PicturePileImpl
* picture_pile() {
33 return picture_pile_
.get();
36 const TilePriority
& priority(WhichTree tree
) const {
37 return priority_
[tree
];
40 TilePriority
combined_priority() const {
41 return TilePriority(priority_
[ACTIVE_TREE
],
42 priority_
[PENDING_TREE
]);
45 void set_priority(WhichTree tree
, const TilePriority
& priority
);
47 // Returns 0 if not drawable.
48 ResourceProvider::ResourceId
GetResourceId() const;
50 const gfx::Rect
& opaque_rect() const { return opaque_rect_
; }
52 bool contents_swizzled() const { return managed_state_
.contents_swizzled
; }
55 // Methods called by by tile manager.
56 friend class TileManager
;
57 friend class BinComparator
;
58 ManagedTileState
& managed_state() { return managed_state_
; }
59 const ManagedTileState
& managed_state() const { return managed_state_
; }
60 size_t bytes_consumed_if_allocated() const;
61 float contents_scale() const { return contents_scale_
; }
63 // Normal private methods.
64 friend class base::RefCounted
<Tile
>;
67 TileManager
* tile_manager_
;
68 scoped_refptr
<PicturePileImpl
> picture_pile_
;
71 gfx::Rect content_rect_
;
72 float contents_scale_
;
73 gfx::Rect opaque_rect_
;
75 TilePriority priority_
[2];
76 ManagedTileState managed_state_
;