blob: 3440028d792c0fb9436270e2fd4156df8565cade [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]8d8e2f62013-03-13 05:05:2112#include "cc/managed_tile_state.h"
[email protected]91e89bc2012-11-29 12:58:1813#include "cc/picture_pile_impl.h"
[email protected]18134fc2012-11-08 22:42:3414#include "cc/tile_priority.h"
15#include "ui/gfx/rect.h"
16#include "ui/gfx/size.h"
17
18namespace cc {
19
[email protected]76858dd382012-11-10 09:38:0720class Tile;
[email protected]8d8e2f62013-03-13 05:05:2121class TileManager;
[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]d2989672013-02-16 04:55:3630 gfx::Rect opaque_rect,
[email protected]df41c042013-02-27 16:01:2931 float contents_scale,
32 int layer_id);
[email protected]76858dd382012-11-10 09:38:0733
[email protected]fb5450642012-12-05 23:26:5234 PicturePileImpl* picture_pile() {
[email protected]91e89bc2012-11-29 12:58:1835 return picture_pile_.get();
[email protected]76858dd382012-11-10 09:38:0736 }
37
[email protected]0f0609c2012-11-16 10:00:4738 const TilePriority& priority(WhichTree tree) const {
39 return priority_[tree];
[email protected]76858dd382012-11-10 09:38:0740 }
41
[email protected]0f0609c2012-11-16 10:00:4742 TilePriority combined_priority() const {
43 return TilePriority(priority_[ACTIVE_TREE],
44 priority_[PENDING_TREE]);
[email protected]76858dd382012-11-10 09:38:0745 }
46
[email protected]8d8e2f62013-03-13 05:05:2147 void SetPriority(WhichTree tree, const TilePriority& priority);
[email protected]18134fc2012-11-08 22:42:3448
[email protected]131a0c22013-02-12 18:31:0849 scoped_ptr<base::Value> AsValue() const;
50
[email protected]8d8e2f62013-03-13 05:05:2151 const ManagedTileState::DrawingInfo& drawing_info() const {
52 return managed_state_.drawing_info;
[email protected]a3bca5f32013-02-02 01:51:5853 }
[email protected]8d8e2f62013-03-13 05:05:2154 ManagedTileState::DrawingInfo& drawing_info() {
55 return managed_state_.drawing_info;
[email protected]785145ba2013-03-07 23:52:2456 }
57
[email protected]9b18c102012-11-15 19:57:0358 const gfx::Rect& opaque_rect() const { return opaque_rect_; }
[email protected]0f0609c2012-11-16 10:00:4759
[email protected]166db5c82013-01-09 23:54:3160 float contents_scale() const { return contents_scale_; }
61 gfx::Rect content_rect() const { return content_rect_; }
62
[email protected]df41c042013-02-27 16:01:2963 int layer_id() const { return layer_id_; }
64
[email protected]b221a222013-01-22 21:38:5665 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) {
[email protected]b06a972d2013-02-27 02:03:0466 DCHECK(pile->CanRaster(contents_scale_, content_rect_));
[email protected]b221a222013-01-22 21:38:5667 picture_pile_ = pile;
68 }
69
[email protected]18134fc2012-11-08 22:42:3470 private:
[email protected]0f0609c2012-11-16 10:00:4771 // Methods called by by tile manager.
[email protected]18134fc2012-11-08 22:42:3472 friend class TileManager;
[email protected]0f0609c2012-11-16 10:00:4773 friend class BinComparator;
74 ManagedTileState& managed_state() { return managed_state_; }
75 const ManagedTileState& managed_state() const { return managed_state_; }
[email protected]a3bca5f32013-02-02 01:51:5876
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]18134fc2012-11-08 22:42:3482
[email protected]0f0609c2012-11-16 10:00:4783 // Normal private methods.
84 friend class base::RefCounted<Tile>;
[email protected]18134fc2012-11-08 22:42:3485 ~Tile();
86
87 TileManager* tile_manager_;
[email protected]91e89bc2012-11-29 12:58:1888 scoped_refptr<PicturePileImpl> picture_pile_;
[email protected]18134fc2012-11-08 22:42:3489 gfx::Rect tile_size_;
[email protected]76858dd382012-11-10 09:38:0790 GLenum format_;
[email protected]be037932012-12-08 08:48:2191 gfx::Rect content_rect_;
[email protected]ac1d20a2012-12-05 01:15:5492 float contents_scale_;
[email protected]9b18c102012-11-15 19:57:0393 gfx::Rect opaque_rect_;
[email protected]0f0609c2012-11-16 10:00:4794
[email protected]768c8ac2013-02-13 03:29:5795 TilePriority priority_[NUM_BIN_PRIORITIES];
[email protected]0f0609c2012-11-16 10:00:4796 ManagedTileState managed_state_;
[email protected]df41c042013-02-27 16:01:2997 int layer_id_;
[email protected]18134fc2012-11-08 22:42:3498};
99
[email protected]18134fc2012-11-08 22:42:34100} // namespace cc
[email protected]ffaa2a632012-11-11 14:47:50101
102#endif // CC_TILE_H_