blob: baa255747a7bfdf8b7f081afe47bfc28353a6460 [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,
29 gfx::Rect rect_inside_picture);
[email protected]76858dd382012-11-10 09:38:0730
[email protected]91e89bc2012-11-29 12:58:1831 const PicturePileImpl* picture_pile() const {
32 return picture_pile_.get();
[email protected]76858dd382012-11-10 09:38:0733 }
34
[email protected]0f0609c2012-11-16 10:00:4735 const TilePriority& priority(WhichTree tree) const {
36 return priority_[tree];
[email protected]76858dd382012-11-10 09:38:0737 }
38
[email protected]0f0609c2012-11-16 10:00:4739 TilePriority combined_priority() const {
40 return TilePriority(priority_[ACTIVE_TREE],
41 priority_[PENDING_TREE]);
[email protected]76858dd382012-11-10 09:38:0742 }
43
[email protected]0f0609c2012-11-16 10:00:4744 void set_priority(WhichTree tree, const TilePriority& priority);
[email protected]18134fc2012-11-08 22:42:3445
[email protected]76858dd382012-11-10 09:38:0746 // Returns 0 if not drawable.
[email protected]0f0609c2012-11-16 10:00:4747 ResourceProvider::ResourceId resource_id() const { return managed_state_.resource_id; }
[email protected]76858dd382012-11-10 09:38:0748
[email protected]9b18c102012-11-15 19:57:0349 const gfx::Rect& opaque_rect() const { return opaque_rect_; }
[email protected]0f0609c2012-11-16 10:00:4750
[email protected]9b18c102012-11-15 19:57:0351 // TODO(enne): Make this real
52 bool contents_swizzled() const { return false; }
53
[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]18134fc2012-11-08 22:42:3461
[email protected]0f0609c2012-11-16 10:00:4762 // Normal private methods.
63 friend class base::RefCounted<Tile>;
[email protected]18134fc2012-11-08 22:42:3464 ~Tile();
65
66 TileManager* tile_manager_;
[email protected]91e89bc2012-11-29 12:58:1867 scoped_refptr<PicturePileImpl> picture_pile_;
[email protected]18134fc2012-11-08 22:42:3468 gfx::Rect tile_size_;
[email protected]76858dd382012-11-10 09:38:0769 GLenum format_;
[email protected]18134fc2012-11-08 22:42:3470 gfx::Rect rect_inside_picture_;
[email protected]9b18c102012-11-15 19:57:0371 gfx::Rect opaque_rect_;
[email protected]0f0609c2012-11-16 10:00:4772
73 TilePriority priority_[2];
74 ManagedTileState managed_state_;
[email protected]18134fc2012-11-08 22:42:3475};
76
[email protected]18134fc2012-11-08 22:42:3477} // namespace cc
[email protected]ffaa2a632012-11-11 14:47:5078
79#endif // CC_TILE_H_