| 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/debug/traced_value.h" | 7 #include "cc/debug/traced_value.h" |
| 8 #include "cc/resources/tile_manager.h" | 8 #include "cc/resources/tile_manager.h" |
| 9 #include "third_party/khronos/GLES2/gl2.h" | 9 #include "third_party/khronos/GLES2/gl2.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 Tile::Id Tile::s_next_id_ = 0; |
| 14 |
| 13 Tile::Tile(TileManager* tile_manager, | 15 Tile::Tile(TileManager* tile_manager, |
| 14 PicturePileImpl* picture_pile, | 16 PicturePileImpl* picture_pile, |
| 15 gfx::Size tile_size, | 17 gfx::Size tile_size, |
| 16 gfx::Rect content_rect, | 18 gfx::Rect content_rect, |
| 17 gfx::Rect opaque_rect, | 19 gfx::Rect opaque_rect, |
| 18 float contents_scale, | 20 float contents_scale, |
| 19 int layer_id, | 21 int layer_id, |
| 20 int source_frame_number) | 22 int source_frame_number) |
| 21 : tile_manager_(tile_manager), | 23 : tile_manager_(tile_manager), |
| 22 tile_size_(tile_size), | 24 tile_size_(tile_size), |
| 23 content_rect_(content_rect), | 25 content_rect_(content_rect), |
| 24 contents_scale_(contents_scale), | 26 contents_scale_(contents_scale), |
| 25 opaque_rect_(opaque_rect), | 27 opaque_rect_(opaque_rect), |
| 26 layer_id_(layer_id), | 28 layer_id_(layer_id), |
| 27 source_frame_number_(source_frame_number) { | 29 source_frame_number_(source_frame_number), |
| 30 id_(s_next_id_++) { |
| 28 set_picture_pile(picture_pile); | 31 set_picture_pile(picture_pile); |
| 29 tile_manager_->RegisterTile(this); | 32 tile_manager_->RegisterTile(this); |
| 30 } | 33 } |
| 31 | 34 |
| 32 Tile::~Tile() { | 35 Tile::~Tile() { |
| 33 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 36 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 34 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::Tile", this); | 37 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::Tile", this); |
| 35 tile_manager_->UnregisterTile(this); | 38 tile_manager_->UnregisterTile(this); |
| 36 } | 39 } |
| 37 | 40 |
| 38 scoped_ptr<base::Value> Tile::AsValue() const { | 41 scoped_ptr<base::Value> Tile::AsValue() const { |
| 39 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 42 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
| 40 TracedValue::MakeDictIntoImplicitSnapshot(res.get(), "cc::Tile", this); | 43 TracedValue::MakeDictIntoImplicitSnapshot(res.get(), "cc::Tile", this); |
| 41 res->Set("picture_pile", | 44 res->Set("picture_pile", |
| 42 TracedValue::CreateIDRef(picture_pile_.get()).release()); | 45 TracedValue::CreateIDRef(picture_pile_.get()).release()); |
| 43 res->SetDouble("contents_scale", contents_scale_); | 46 res->SetDouble("contents_scale", contents_scale_); |
| 44 res->Set("active_priority", priority_[ACTIVE_TREE].AsValue().release()); | 47 res->Set("active_priority", priority_[ACTIVE_TREE].AsValue().release()); |
| 45 res->Set("pending_priority", priority_[PENDING_TREE].AsValue().release()); | 48 res->Set("pending_priority", priority_[PENDING_TREE].AsValue().release()); |
| 46 res->Set("managed_state", managed_state_.AsValue().release()); | 49 res->Set("managed_state", managed_state_.AsValue().release()); |
| 47 return res.PassAs<base::Value>(); | 50 return res.PassAs<base::Value>(); |
| 48 } | 51 } |
| 49 | 52 |
| 50 } // namespace cc | 53 } // namespace cc |
| OLD | NEW |