blob: 51c61b7bf0beb3a53b9ed90845ed040257e194fa [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]18134fc2012-11-08 22:42:3454 private:
[email protected]0f0609c2012-11-16 10:00:4755 // Methods called by by tile manager.
[email protected]18134fc2012-11-08 22:42:3456 friend class TileManager;
[email protected]0f0609c2012-11-16 10:00:4757 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]ac1d20a2012-12-05 01:15:5461 float contents_scale() const { return contents_scale_; }
[email protected]18134fc2012-11-08 22:42:3462
[email protected]0f0609c2012-11-16 10:00:4763 // Normal private methods.
64 friend class base::RefCounted<Tile>;
[email protected]18134fc2012-11-08 22:42:3465 ~Tile();
66
67 TileManager* tile_manager_;
[email protected]91e89bc2012-11-29 12:58:1868 scoped_refptr<PicturePileImpl> picture_pile_;
[email protected]18134fc2012-11-08 22:42:3469 gfx::Rect tile_size_;
[email protected]76858dd382012-11-10 09:38:0770 GLenum format_;
[email protected]be037932012-12-08 08:48:2171 gfx::Rect content_rect_;
[email protected]ac1d20a2012-12-05 01:15:5472 float contents_scale_;
[email protected]9b18c102012-11-15 19:57:0373 gfx::Rect opaque_rect_;
[email protected]0f0609c2012-11-16 10:00:4774
75 TilePriority priority_[2];
76 ManagedTileState managed_state_;
[email protected]18134fc2012-11-08 22:42:3477};
78
[email protected]18134fc2012-11-08 22:42:3479} // namespace cc
[email protected]ffaa2a632012-11-11 14:47:5080
81#endif // CC_TILE_H_