[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 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. | ||||
4 | |||||
5 | #ifndef CC_TILE_H_ | ||||
6 | #define CC_TILE_H_ | ||||
7 | |||||
8 | #include "base/memory/ref_counted.h" | ||||
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 9 | #include "base/memory/scoped_ptr.h" |
10 | #include "base/memory/scoped_vector.h" | ||||
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 11 | #include "cc/layer_tree_host_impl.h" |
[email protected] | 91e89bc | 2012-11-29 12:58:18 | [diff] [blame] | 12 | #include "cc/picture_pile_impl.h" |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 13 | #include "cc/resource_provider.h" |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 14 | #include "cc/tile_manager.h" |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 15 | #include "cc/tile_priority.h" |
16 | #include "ui/gfx/rect.h" | ||||
17 | #include "ui/gfx/size.h" | ||||
18 | |||||
19 | namespace cc { | ||||
20 | |||||
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 21 | class Tile; |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 22 | |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 23 | class CC_EXPORT Tile : public base::RefCounted<Tile> { |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 24 | public: |
25 | Tile(TileManager* tile_manager, | ||||
[email protected] | 91e89bc | 2012-11-29 12:58:18 | [diff] [blame] | 26 | PicturePileImpl* picture_pile, |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 27 | gfx::Size tile_size, |
28 | GLenum format, | ||||
[email protected] | be03793 | 2012-12-08 08:48:21 | [diff] [blame] | 29 | gfx::Rect content_rect, |
[email protected] | ac1d20a | 2012-12-05 01:15:54 | [diff] [blame] | 30 | float contents_scale); |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 31 | |
[email protected] | fb545064 | 2012-12-05 23:26:52 | [diff] [blame] | 32 | PicturePileImpl* picture_pile() { |
[email protected] | 91e89bc | 2012-11-29 12:58:18 | [diff] [blame] | 33 | return picture_pile_.get(); |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 34 | } |
35 | |||||
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 36 | const TilePriority& priority(WhichTree tree) const { |
37 | return priority_[tree]; | ||||
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 38 | } |
39 | |||||
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 40 | TilePriority combined_priority() const { |
41 | return TilePriority(priority_[ACTIVE_TREE], | ||||
42 | priority_[PENDING_TREE]); | ||||
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 43 | } |
44 | |||||
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 45 | void set_priority(WhichTree tree, const TilePriority& priority); |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 46 | |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 47 | // Returns 0 if not drawable. |
[email protected] | d142a47d | 2012-12-07 08:18:37 | [diff] [blame] | 48 | ResourceProvider::ResourceId GetResourceId() const; |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 49 | |
[email protected] | 9b18c10 | 2012-11-15 19:57:03 | [diff] [blame] | 50 | const gfx::Rect& opaque_rect() const { return opaque_rect_; } |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 51 | |
[email protected] | af668e9b | 2012-11-30 01:38:01 | [diff] [blame] | 52 | bool contents_swizzled() const { return managed_state_.contents_swizzled; } |
[email protected] | 9b18c10 | 2012-11-15 19:57:03 | [diff] [blame] | 53 | |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 54 | float contents_scale() const { return contents_scale_; } |
55 | gfx::Rect content_rect() const { return content_rect_; } | ||||
56 | |||||
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 57 | private: |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 58 | // Methods called by by tile manager. |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 59 | friend class TileManager; |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 60 | friend class BinComparator; |
61 | ManagedTileState& managed_state() { return managed_state_; } | ||||
62 | const ManagedTileState& managed_state() const { return managed_state_; } | ||||
63 | size_t bytes_consumed_if_allocated() const; | ||||
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 64 | |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 65 | // Normal private methods. |
66 | friend class base::RefCounted<Tile>; | ||||
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 67 | ~Tile(); |
68 | |||||
69 | TileManager* tile_manager_; | ||||
[email protected] | 91e89bc | 2012-11-29 12:58:18 | [diff] [blame] | 70 | scoped_refptr<PicturePileImpl> picture_pile_; |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 71 | gfx::Rect tile_size_; |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 72 | GLenum format_; |
[email protected] | be03793 | 2012-12-08 08:48:21 | [diff] [blame] | 73 | gfx::Rect content_rect_; |
[email protected] | ac1d20a | 2012-12-05 01:15:54 | [diff] [blame] | 74 | float contents_scale_; |
[email protected] | 9b18c10 | 2012-11-15 19:57:03 | [diff] [blame] | 75 | gfx::Rect opaque_rect_; |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 76 | |
77 | TilePriority priority_[2]; | ||||
78 | ManagedTileState managed_state_; | ||||
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 79 | }; |
80 | |||||
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 81 | } // namespace cc |
[email protected] | ffaa2a63 | 2012-11-11 14:47:50 | [diff] [blame] | 82 | |
83 | #endif // CC_TILE_H_ |