| 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 int flags) | 24 int flags) |
| 25 : RefCountedManaged<Tile>(tile_manager), | 25 : RefCountedManaged<Tile>(tile_manager), |
| 26 tile_manager_(tile_manager), | 26 tile_manager_(tile_manager), |
| 27 tile_size_(tile_size), | 27 tile_size_(tile_size), |
| 28 content_rect_(content_rect), | 28 content_rect_(content_rect), |
| 29 contents_scale_(contents_scale), | 29 contents_scale_(contents_scale), |
| 30 opaque_rect_(opaque_rect), | 30 opaque_rect_(opaque_rect), |
| 31 layer_id_(layer_id), | 31 layer_id_(layer_id), |
| 32 source_frame_number_(source_frame_number), | 32 source_frame_number_(source_frame_number), |
| 33 flags_(flags), | 33 flags_(flags), |
| 34 required_for_activation_(false), | |
| 35 is_visible_(false), | |
| 36 id_(s_next_id_++) { | 34 id_(s_next_id_++) { |
| 37 set_picture_pile(picture_pile); | 35 set_picture_pile(picture_pile); |
| 38 } | 36 } |
| 39 | 37 |
| 40 Tile::~Tile() { | 38 Tile::~Tile() { |
| 41 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 39 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 42 TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 40 TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 43 "cc::Tile", this); | 41 "cc::Tile", this); |
| 44 } | 42 } |
| 45 | 43 |
| 46 void Tile::MarkRequiredForActivation() { | 44 void Tile::SetPriority(WhichTree tree, const TilePriority& priority) { |
| 47 if (required_for_activation_) | 45 if (priority == priority_[tree]) |
| 48 return; | 46 return; |
| 49 | 47 |
| 50 required_for_activation_ = true; | 48 priority_[tree] = priority; |
| 51 tile_manager_->DidChangeTilePriority(this); | 49 tile_manager_->DidChangeTilePriority(this); |
| 52 } | 50 } |
| 53 | 51 |
| 52 void Tile::MarkRequiredForActivation() { |
| 53 if (priority_[PENDING_TREE].required_for_activation) |
| 54 return; |
| 55 |
| 56 priority_[PENDING_TREE].required_for_activation = true; |
| 57 tile_manager_->DidChangeTilePriority(this); |
| 58 } |
| 59 |
| 54 scoped_ptr<base::Value> Tile::AsValue() const { | 60 scoped_ptr<base::Value> Tile::AsValue() const { |
| 55 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 61 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
| 56 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( | 62 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( |
| 57 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res.get(), "cc::Tile", this); | 63 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res.get(), "cc::Tile", this); |
| 58 res->Set("picture_pile", | 64 res->Set("picture_pile", |
| 59 TracedValue::CreateIDRef(picture_pile_.get()).release()); | 65 TracedValue::CreateIDRef(picture_pile_.get()).release()); |
| 60 res->SetDouble("contents_scale", contents_scale_); | 66 res->SetDouble("contents_scale", contents_scale_); |
| 61 res->Set("content_rect", MathUtil::AsValue(content_rect_).release()); | 67 res->Set("content_rect", MathUtil::AsValue(content_rect_).release()); |
| 62 res->SetInteger("layer_id", layer_id_); | 68 res->SetInteger("layer_id", layer_id_); |
| 69 res->Set("active_priority", priority_[ACTIVE_TREE].AsValue().release()); |
| 70 res->Set("pending_priority", priority_[PENDING_TREE].AsValue().release()); |
| 63 res->Set("managed_state", managed_state_.AsValue().release()); | 71 res->Set("managed_state", managed_state_.AsValue().release()); |
| 64 res->SetBoolean("can_use_lcd_text", can_use_lcd_text()); | 72 res->SetBoolean("can_use_lcd_text", can_use_lcd_text()); |
| 65 res->SetBoolean("use_gpu_rasterization", use_gpu_rasterization()); | 73 res->SetBoolean("use_gpu_rasterization", use_gpu_rasterization()); |
| 66 res->SetBoolean("required_for_activation", required_for_activation_); | |
| 67 return res.PassAs<base::Value>(); | 74 return res.PassAs<base::Value>(); |
| 68 } | 75 } |
| 69 | 76 |
| 70 size_t Tile::GPUMemoryUsageInBytes() const { | 77 size_t Tile::GPUMemoryUsageInBytes() const { |
| 71 size_t total_size = 0; | 78 size_t total_size = 0; |
| 72 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) | 79 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) |
| 73 total_size += managed_state_.tile_versions[mode].GPUMemoryUsageInBytes(); | 80 total_size += managed_state_.tile_versions[mode].GPUMemoryUsageInBytes(); |
| 74 return total_size; | 81 return total_size; |
| 75 } | 82 } |
| 76 | 83 |
| 77 } // namespace cc | 84 } // namespace cc |
| OLD | NEW |