| OLD | NEW |
| 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 #include "cc/resources/tile.h" | 5 #include "cc/resources/tile.h" |
| 6 | 6 |
| 7 #include "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
| 8 #include "cc/debug/traced_value.h" | 8 #include "cc/debug/traced_value.h" |
| 9 #include "cc/resources/tile_manager.h" | 9 #include "cc/resources/tile_manager.h" |
| 10 #include "third_party/khronos/GLES2/gl2.h" | 10 #include "third_party/khronos/GLES2/gl2.h" |
| 11 | 11 |
| 12 namespace cc { | 12 namespace cc { |
| 13 | 13 |
| 14 Tile::Id Tile::s_next_id_ = 0; | 14 Tile::Id Tile::s_next_id_ = 1; |
| 15 | 15 |
| 16 Tile::Tile(TileManager* tile_manager, | 16 Tile::Tile(TileManager* tile_manager) |
| 17 PicturePileImpl* picture_pile, | |
| 18 gfx::Size tile_size, | |
| 19 gfx::Rect content_rect, | |
| 20 gfx::Rect opaque_rect, | |
| 21 float contents_scale, | |
| 22 int layer_id, | |
| 23 int source_frame_number, | |
| 24 bool can_use_lcd_text) | |
| 25 : RefCountedManaged<Tile>(tile_manager), | 17 : RefCountedManaged<Tile>(tile_manager), |
| 26 tile_manager_(tile_manager), | 18 tile_manager_(tile_manager), |
| 27 tile_size_(tile_size), | 19 id_(0) {} |
| 28 content_rect_(content_rect), | |
| 29 contents_scale_(contents_scale), | |
| 30 opaque_rect_(opaque_rect), | |
| 31 layer_id_(layer_id), | |
| 32 source_frame_number_(source_frame_number), | |
| 33 can_use_lcd_text_(can_use_lcd_text), | |
| 34 id_(s_next_id_++) { | |
| 35 set_picture_pile(picture_pile); | |
| 36 } | |
| 37 | 20 |
| 38 Tile::~Tile() { | 21 Tile::~Tile() { |
| 39 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 22 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 40 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," | 23 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," |
| 41 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), | 24 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), |
| 42 "cc::Tile", this); | 25 "cc::Tile", this); |
| 43 } | 26 } |
| 44 | 27 |
| 28 void Tile::Reset(PicturePileImpl* picture_pile, |
| 29 gfx::Size tile_size, |
| 30 gfx::Rect content_rect, |
| 31 gfx::Rect opaque_rect, |
| 32 float contents_scale, |
| 33 int layer_id, |
| 34 int source_frame_number, |
| 35 bool can_use_lcd_text) { |
| 36 tile_size_ = tile_size; |
| 37 content_rect_ = content_rect; |
| 38 contents_scale_ = contents_scale; |
| 39 opaque_rect_ = opaque_rect; |
| 40 layer_id_ = layer_id; |
| 41 source_frame_number_ = source_frame_number; |
| 42 can_use_lcd_text_ = can_use_lcd_text; |
| 43 set_picture_pile(picture_pile); |
| 44 id_ = s_next_id_++; |
| 45 } |
| 46 |
| 45 void Tile::SetPriority(WhichTree tree, const TilePriority& priority) { | 47 void Tile::SetPriority(WhichTree tree, const TilePriority& priority) { |
| 46 if (priority == priority_[tree]) | 48 if (priority == priority_[tree]) |
| 47 return; | 49 return; |
| 48 | 50 |
| 49 priority_[tree] = priority; | 51 priority_[tree] = priority; |
| 50 tile_manager_->DidChangeTilePriority(this); | 52 tile_manager_->DidChangeTilePriority(this); |
| 51 } | 53 } |
| 52 | 54 |
| 53 void Tile::MarkRequiredForActivation() { | 55 void Tile::MarkRequiredForActivation() { |
| 54 if (priority_[PENDING_TREE].required_for_activation) | 56 if (priority_[PENDING_TREE].required_for_activation) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 74 } | 76 } |
| 75 | 77 |
| 76 size_t Tile::GPUMemoryUsageInBytes() const { | 78 size_t Tile::GPUMemoryUsageInBytes() const { |
| 77 size_t total_size = 0; | 79 size_t total_size = 0; |
| 78 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) | 80 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) |
| 79 total_size += managed_state_.tile_versions[mode].GPUMemoryUsageInBytes(); | 81 total_size += managed_state_.tile_versions[mode].GPUMemoryUsageInBytes(); |
| 80 return total_size; | 82 return total_size; |
| 81 } | 83 } |
| 82 | 84 |
| 83 } // namespace cc | 85 } // namespace cc |
| OLD | NEW |