[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] | 8d8e2f6 | 2013-03-13 05:05:21 | [diff] [blame] | 12 | #include "cc/managed_tile_state.h" |
[email protected] | 91e89bc | 2012-11-29 12:58:18 | [diff] [blame] | 13 | #include "cc/picture_pile_impl.h" |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 14 | #include "cc/tile_priority.h" |
| 15 | #include "ui/gfx/rect.h" |
| 16 | #include "ui/gfx/size.h" |
| 17 | |
| 18 | namespace cc { |
| 19 | |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 20 | class Tile; |
[email protected] | 8d8e2f6 | 2013-03-13 05:05:21 | [diff] [blame] | 21 | class TileManager; |
[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] | d298967 | 2013-02-16 04:55:36 | [diff] [blame] | 30 | gfx::Rect opaque_rect, |
[email protected] | df41c04 | 2013-02-27 16:01:29 | [diff] [blame] | 31 | float contents_scale, |
| 32 | int layer_id); |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 33 | |
[email protected] | fb545064 | 2012-12-05 23:26:52 | [diff] [blame] | 34 | PicturePileImpl* picture_pile() { |
[email protected] | 91e89bc | 2012-11-29 12:58:18 | [diff] [blame] | 35 | return picture_pile_.get(); |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 36 | } |
| 37 | |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 38 | const TilePriority& priority(WhichTree tree) const { |
| 39 | return priority_[tree]; |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 40 | } |
| 41 | |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 42 | TilePriority combined_priority() const { |
| 43 | return TilePriority(priority_[ACTIVE_TREE], |
| 44 | priority_[PENDING_TREE]); |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 45 | } |
| 46 | |
[email protected] | 8d8e2f6 | 2013-03-13 05:05:21 | [diff] [blame] | 47 | void SetPriority(WhichTree tree, const TilePriority& priority); |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 48 | |
[email protected] | 131a0c2 | 2013-02-12 18:31:08 | [diff] [blame] | 49 | scoped_ptr<base::Value> AsValue() const; |
| 50 | |
[email protected] | 8d8e2f6 | 2013-03-13 05:05:21 | [diff] [blame] | 51 | const ManagedTileState::DrawingInfo& drawing_info() const { |
| 52 | return managed_state_.drawing_info; |
[email protected] | a3bca5f3 | 2013-02-02 01:51:58 | [diff] [blame] | 53 | } |
[email protected] | 8d8e2f6 | 2013-03-13 05:05:21 | [diff] [blame] | 54 | ManagedTileState::DrawingInfo& drawing_info() { |
| 55 | return managed_state_.drawing_info; |
[email protected] | 785145ba | 2013-03-07 23:52:24 | [diff] [blame] | 56 | } |
| 57 | |
[email protected] | 9b18c10 | 2012-11-15 19:57:03 | [diff] [blame] | 58 | const gfx::Rect& opaque_rect() const { return opaque_rect_; } |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 59 | |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 60 | float contents_scale() const { return contents_scale_; } |
| 61 | gfx::Rect content_rect() const { return content_rect_; } |
| 62 | |
[email protected] | df41c04 | 2013-02-27 16:01:29 | [diff] [blame] | 63 | int layer_id() const { return layer_id_; } |
| 64 | |
[email protected] | b221a22 | 2013-01-22 21:38:56 | [diff] [blame] | 65 | void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { |
[email protected] | b06a972d | 2013-02-27 02:03:04 | [diff] [blame] | 66 | DCHECK(pile->CanRaster(contents_scale_, content_rect_)); |
[email protected] | b221a22 | 2013-01-22 21:38:56 | [diff] [blame] | 67 | picture_pile_ = pile; |
| 68 | } |
| 69 | |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 70 | private: |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 71 | // Methods called by by tile manager. |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 72 | friend class TileManager; |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 73 | friend class BinComparator; |
| 74 | ManagedTileState& managed_state() { return managed_state_; } |
| 75 | const ManagedTileState& managed_state() const { return managed_state_; } |
[email protected] | a3bca5f3 | 2013-02-02 01:51:58 | [diff] [blame] | 76 | |
| 77 | inline size_t bytes_consumed_if_allocated() const { |
| 78 | DCHECK(format_ == GL_RGBA); |
| 79 | return 4 * tile_size_.width() * tile_size_.height(); |
| 80 | } |
| 81 | |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 82 | |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 83 | // Normal private methods. |
| 84 | friend class base::RefCounted<Tile>; |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 85 | ~Tile(); |
| 86 | |
| 87 | TileManager* tile_manager_; |
[email protected] | 91e89bc | 2012-11-29 12:58:18 | [diff] [blame] | 88 | scoped_refptr<PicturePileImpl> picture_pile_; |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 89 | gfx::Rect tile_size_; |
[email protected] | 76858dd38 | 2012-11-10 09:38:07 | [diff] [blame] | 90 | GLenum format_; |
[email protected] | be03793 | 2012-12-08 08:48:21 | [diff] [blame] | 91 | gfx::Rect content_rect_; |
[email protected] | ac1d20a | 2012-12-05 01:15:54 | [diff] [blame] | 92 | float contents_scale_; |
[email protected] | 9b18c10 | 2012-11-15 19:57:03 | [diff] [blame] | 93 | gfx::Rect opaque_rect_; |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 94 | |
[email protected] | 768c8ac | 2013-02-13 03:29:57 | [diff] [blame] | 95 | TilePriority priority_[NUM_BIN_PRIORITIES]; |
[email protected] | 0f0609c | 2012-11-16 10:00:47 | [diff] [blame] | 96 | ManagedTileState managed_state_; |
[email protected] | df41c04 | 2013-02-27 16:01:29 | [diff] [blame] | 97 | int layer_id_; |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 98 | }; |
| 99 | |
[email protected] | 18134fc | 2012-11-08 22:42:34 | [diff] [blame] | 100 | } // namespace cc |
[email protected] | ffaa2a63 | 2012-11-11 14:47:50 | [diff] [blame] | 101 | |
| 102 | #endif // CC_TILE_H_ |