Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: cc/tile.h

Issue 12353003: cc: Refactored Tile::GetResourceId (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_TILE_H_ 5 #ifndef CC_TILE_H_
6 #define CC_TILE_H_ 6 #define CC_TILE_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 #include "cc/layer_tree_host_impl.h" 11 #include "cc/layer_tree_host_impl.h"
12 #include "cc/managed_tile_state.h"
12 #include "cc/picture_pile_impl.h" 13 #include "cc/picture_pile_impl.h"
13 #include "cc/resource_provider.h"
14 #include "cc/tile_manager.h"
15 #include "cc/tile_priority.h" 14 #include "cc/tile_priority.h"
16 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
17 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
18 17
19 namespace cc { 18 namespace cc {
20 19
21 class Tile; 20 class Tile;
21 class TileManager;
22 22
23 class CC_EXPORT Tile : public base::RefCounted<Tile> { 23 class CC_EXPORT Tile : public base::RefCounted<Tile> {
24 public: 24 public:
25 Tile(TileManager* tile_manager, 25 Tile(TileManager* tile_manager,
26 PicturePileImpl* picture_pile, 26 PicturePileImpl* picture_pile,
27 gfx::Size tile_size, 27 gfx::Size tile_size,
28 GLenum format, 28 GLenum format,
29 gfx::Rect content_rect, 29 gfx::Rect content_rect,
30 gfx::Rect opaque_rect, 30 gfx::Rect opaque_rect,
31 float contents_scale, 31 float contents_scale,
32 int layer_id); 32 int layer_id);
33 33
34 PicturePileImpl* picture_pile() { 34 PicturePileImpl* picture_pile() {
35 return picture_pile_.get(); 35 return picture_pile_.get();
36 } 36 }
37 37
38 const TilePriority& priority(WhichTree tree) const { 38 const TilePriority& priority(WhichTree tree) const {
39 return priority_[tree]; 39 return priority_[tree];
40 } 40 }
41 41
42 TilePriority combined_priority() const { 42 TilePriority combined_priority() const {
43 return TilePriority(priority_[ACTIVE_TREE], 43 return TilePriority(priority_[ACTIVE_TREE],
44 priority_[PENDING_TREE]); 44 priority_[PENDING_TREE]);
45 } 45 }
46 46
47 void set_priority(WhichTree tree, const TilePriority& priority) { 47 void set_priority(WhichTree tree, const TilePriority& priority) {
reveman 2013/03/12 22:47:02 I think this should be named SetPriority and imple
48 tile_manager_->WillModifyTilePriority(this, tree, priority); 48 tile_manager_->WillModifyTilePriority(this, tree, priority);
49 priority_[tree] = priority; 49 priority_[tree] = priority;
50 } 50 }
51 51
52 scoped_ptr<base::Value> AsValue() const; 52 scoped_ptr<base::Value> AsValue() const;
53 53
54 // Returns 0 if not drawable. 54 const ManagedTileState::DrawingInfo& drawing_info() const {
55 ResourceProvider::ResourceId GetResourceId() const { 55 return managed_state_.drawing_info;
56 if (!managed_state_.resource)
57 return 0;
58 if (managed_state_.resource_is_being_initialized)
59 return 0;
60
61 return managed_state_.resource->id();
62 } 56 }
63 57 ManagedTileState::DrawingInfo& drawing_info() {
64 bool IsReadyToDraw() const; 58 return managed_state_.drawing_info;
65
66 bool is_solid_color() const {
67 return managed_state_.picture_pile_analysis.is_solid_color;
68 }
69
70 bool is_transparent() const {
71 return managed_state_.picture_pile_analysis.is_transparent;
72 }
73
74 SkColor solid_color() const {
75 DCHECK(managed_state_.picture_pile_analysis.is_solid_color);
76 return managed_state_.picture_pile_analysis.solid_color;
77 } 59 }
78 60
79 const gfx::Rect& opaque_rect() const { return opaque_rect_; } 61 const gfx::Rect& opaque_rect() const { return opaque_rect_; }
80 62
81 bool contents_swizzled() const { return managed_state_.contents_swizzled; }
82
83 float contents_scale() const { return contents_scale_; } 63 float contents_scale() const { return contents_scale_; }
84 gfx::Rect content_rect() const { return content_rect_; } 64 gfx::Rect content_rect() const { return content_rect_; }
85 65
86 int layer_id() const { return layer_id_; } 66 int layer_id() const { return layer_id_; }
87 67
88 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { 68 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) {
89 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); 69 DCHECK(pile->CanRaster(contents_scale_, content_rect_));
90 picture_pile_ = pile; 70 picture_pile_ = pile;
91 } 71 }
92 72
93 ManagedTileState& ManagedStateForTesting() { return managed_state_; }
94
95 private: 73 private:
96 // Methods called by by tile manager. 74 // Methods called by by tile manager.
97 friend class TileManager; 75 friend class TileManager;
98 friend class BinComparator; 76 friend class BinComparator;
99 ManagedTileState& managed_state() { return managed_state_; } 77 ManagedTileState& managed_state() { return managed_state_; }
100 const ManagedTileState& managed_state() const { return managed_state_; } 78 const ManagedTileState& managed_state() const { return managed_state_; }
101 79
102 inline size_t bytes_consumed_if_allocated() const { 80 inline size_t bytes_consumed_if_allocated() const {
103 DCHECK(format_ == GL_RGBA); 81 DCHECK(format_ == GL_RGBA);
104 return 4 * tile_size_.width() * tile_size_.height(); 82 return 4 * tile_size_.width() * tile_size_.height();
(...skipping 13 matching lines...) Expand all
118 gfx::Rect opaque_rect_; 96 gfx::Rect opaque_rect_;
119 97
120 TilePriority priority_[NUM_BIN_PRIORITIES]; 98 TilePriority priority_[NUM_BIN_PRIORITIES];
121 ManagedTileState managed_state_; 99 ManagedTileState managed_state_;
122 int layer_id_; 100 int layer_id_;
123 }; 101 };
124 102
125 } // namespace cc 103 } // namespace cc
126 104
127 #endif // CC_TILE_H_ 105 #endif // CC_TILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698