[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] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 12 | #include "cc/picture_pile.h" |
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] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 23 | class Tile : public base::RefCounted<Tile> { |
24 | public: | ||||
25 | Tile(TileManager* tile_manager, | ||||
26 | PicturePile* picture_pile, | ||||
27 | gfx::Size tile_size, | ||||
28 | GLenum format, | ||||
29 | gfx::Rect rect_inside_picture); | ||||
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 30 | |
31 | const PicturePile* picture_pile() const { | ||||
32 | return picture_pile_; | ||||
33 | } | ||||
34 | |||||
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 35 | const TilePriority& priority(WhichTree tree) const { |
36 | return priority_[tree]; | ||||
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 37 | } |
38 | |||||
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 39 | TilePriority combined_priority() const { |
40 | return TilePriority(priority_[ACTIVE_TREE], | ||||
41 | priority_[PENDING_TREE]); | ||||
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 42 | } |
43 | |||||
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 44 | void set_priority(WhichTree tree, const TilePriority& priority); |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 45 | |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 46 | // Returns 0 if not drawable. |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 47 | ResourceProvider::ResourceId resource_id() const { return managed_state_.resource_id; } |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 48 | |
[email protected] | 9b18c10 | 2012-11-15 19:57:03 | [diff] [blame] | 49 | const gfx::Rect& opaque_rect() const { return opaque_rect_; } |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 50 | |
[email protected] | 9b18c10 | 2012-11-15 19:57:03 | [diff] [blame] | 51 | // TODO(enne): Make this real |
52 | bool contents_swizzled() const { return false; } | ||||
53 | |||||
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 54 | private: |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 55 | // Methods called by by tile manager. |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 56 | friend class TileManager; |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 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; | ||||
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 61 | |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 62 | // Normal private methods. |
63 | friend class base::RefCounted<Tile>; | ||||
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 64 | ~Tile(); |
65 | |||||
66 | TileManager* tile_manager_; | ||||
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 67 | PicturePile* picture_pile_; |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 68 | gfx::Rect tile_size_; |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 69 | GLenum format_; |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 70 | gfx::Rect rect_inside_picture_; |
[email protected] | 9b18c10 | 2012-11-15 19:57:03 | [diff] [blame] | 71 | gfx::Rect opaque_rect_; |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame^] | 72 | |
73 | TilePriority priority_[2]; | ||||
74 | ManagedTileState managed_state_; | ||||
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 75 | }; |
76 | |||||
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 77 | } // namespace cc |
[email protected] | ffaa2a63 | 2012-11-11 14:47:50 | [diff] [blame] | 78 | |
79 | #endif // CC_TILE_H_ |