blob: 7d41e6a8cb9b2f83ea88a76af82e0982f0694c8a [file] [log] [blame]
[email protected]18134fc2012-11-08 22:42:341// 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]76858dd382012-11-10 09:38:079#include "base/memory/scoped_ptr.h"
10#include "base/memory/scoped_vector.h"
[email protected]0f0609c2012-11-16 10:00:4711#include "cc/layer_tree_host_impl.h"
[email protected]91e89bc2012-11-29 12:58:1812#include "cc/picture_pile_impl.h"
[email protected]18134fc2012-11-08 22:42:3413#include "cc/resource_provider.h"
[email protected]0f0609c2012-11-16 10:00:4714#include "cc/tile_manager.h"
[email protected]18134fc2012-11-08 22:42:3415#include "cc/tile_priority.h"
16#include "ui/gfx/rect.h"
17#include "ui/gfx/size.h"
18
19namespace cc {
20
[email protected]76858dd382012-11-10 09:38:0721class Tile;
[email protected]18134fc2012-11-08 22:42:3422
[email protected]cd696272012-11-21 19:15:2723class CC_EXPORT Tile : public base::RefCounted<Tile> {
[email protected]0f0609c2012-11-16 10:00:4724 public:
25 Tile(TileManager* tile_manager,
[email protected]91e89bc2012-11-29 12:58:1826 PicturePileImpl* picture_pile,
[email protected]0f0609c2012-11-16 10:00:4727 gfx::Size tile_size,
28 GLenum format,
[email protected]be037932012-12-08 08:48:2129 gfx::Rect content_rect,
[email protected]ac1d20a2012-12-05 01:15:5430 float contents_scale);
[email protected]76858dd382012-11-10 09:38:0731
[email protected]fb5450642012-12-05 23:26:5232 PicturePileImpl* picture_pile() {
[email protected]91e89bc2012-11-29 12:58:1833 return picture_pile_.get();
[email protected]76858dd382012-11-10 09:38:0734 }
35
[email protected]0f0609c2012-11-16 10:00:4736 const TilePriority& priority(WhichTree tree) const {
37 return priority_[tree];
[email protected]76858dd382012-11-10 09:38:0738 }
39
[email protected]0f0609c2012-11-16 10:00:4740 TilePriority combined_priority() const {
41 return TilePriority(priority_[ACTIVE_TREE],
42 priority_[PENDING_TREE]);
[email protected]76858dd382012-11-10 09:38:0743 }
44
[email protected]0f0609c2012-11-16 10:00:4745 void set_priority(WhichTree tree, const TilePriority& priority);
[email protected]18134fc2012-11-08 22:42:3446
[email protected]76858dd382012-11-10 09:38:0747 // Returns 0 if not drawable.
[email protected]d142a47d2012-12-07 08:18:3748 ResourceProvider::ResourceId GetResourceId() const;
[email protected]76858dd382012-11-10 09:38:0749
[email protected]9b18c102012-11-15 19:57:0350 const gfx::Rect& opaque_rect() const { return opaque_rect_; }
[email protected]0f0609c2012-11-16 10:00:4751
[email protected]af668e9b2012-11-30 01:38:0152 bool contents_swizzled() const { return managed_state_.contents_swizzled; }
[email protected]9b18c102012-11-15 19:57:0353
[email protected]166db5c82013-01-09 23:54:3154 float contents_scale() const { return contents_scale_; }
55 gfx::Rect content_rect() const { return content_rect_; }
56
[email protected]18134fc2012-11-08 22:42:3457 private:
[email protected]0f0609c2012-11-16 10:00:4758 // Methods called by by tile manager.
[email protected]18134fc2012-11-08 22:42:3459 friend class TileManager;
[email protected]0f0609c2012-11-16 10:00:4760 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]18134fc2012-11-08 22:42:3464
[email protected]0f0609c2012-11-16 10:00:4765 // Normal private methods.
66 friend class base::RefCounted<Tile>;
[email protected]18134fc2012-11-08 22:42:3467 ~Tile();
68
69 TileManager* tile_manager_;
[email protected]91e89bc2012-11-29 12:58:1870 scoped_refptr<PicturePileImpl> picture_pile_;
[email protected]18134fc2012-11-08 22:42:3471 gfx::Rect tile_size_;
[email protected]76858dd382012-11-10 09:38:0772 GLenum format_;
[email protected]be037932012-12-08 08:48:2173 gfx::Rect content_rect_;
[email protected]ac1d20a2012-12-05 01:15:5474 float contents_scale_;
[email protected]9b18c102012-11-15 19:57:0375 gfx::Rect opaque_rect_;
[email protected]0f0609c2012-11-16 10:00:4776
77 TilePriority priority_[2];
78 ManagedTileState managed_state_;
[email protected]18134fc2012-11-08 22:42:3479};
80
[email protected]18134fc2012-11-08 22:42:3481} // namespace cc
[email protected]ffaa2a632012-11-11 14:47:5082
83#endif // CC_TILE_H_