| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/debug/traced_value.h" | 10 #include "cc/debug/traced_value.h" |
| 11 #include "cc/resources/tile_manager.h" | 11 #include "cc/resources/tile_manager.h" |
| 12 #include "third_party/khronos/GLES2/gl2.h" | 12 #include "third_party/khronos/GLES2/gl2.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 Tile::Id Tile::s_next_id_ = 0; | 16 Tile::Id Tile::s_next_id_ = 0; |
| 17 | 17 |
| 18 Tile::Tile(TileManager* tile_manager, | 18 Tile::Tile(TileManager* tile_manager, |
| 19 PicturePileImpl* picture_pile, | 19 PicturePileImpl* picture_pile, |
| 20 const gfx::Size& tile_size, | 20 const gfx::Size& tile_size, |
| 21 const gfx::Rect& content_rect, | 21 const gfx::Rect& content_rect, |
| 22 const gfx::Rect& opaque_rect, | 22 const gfx::Rect& opaque_rect, |
| 23 float contents_scale, | 23 float contents_scale, |
| 24 int layer_id, | 24 int layer_id, |
| 25 int source_frame_number, | 25 int source_frame_number, |
| 26 int flags) | 26 int flags) |
| 27 : RefCountedManaged<Tile>(tile_manager), | 27 : RefCountedManaged<Tile>(tile_manager), |
| 28 tile_manager_(tile_manager), | |
| 29 tile_size_(tile_size), | 28 tile_size_(tile_size), |
| 30 content_rect_(content_rect), | 29 content_rect_(content_rect), |
| 31 contents_scale_(contents_scale), | 30 contents_scale_(contents_scale), |
| 32 opaque_rect_(opaque_rect), | 31 opaque_rect_(opaque_rect), |
| 33 layer_id_(layer_id), | 32 layer_id_(layer_id), |
| 34 source_frame_number_(source_frame_number), | 33 source_frame_number_(source_frame_number), |
| 35 flags_(flags), | 34 flags_(flags), |
| 36 id_(s_next_id_++) { | 35 id_(s_next_id_++) { |
| 37 set_picture_pile(picture_pile); | 36 set_picture_pile(picture_pile); |
| 38 } | 37 } |
| 39 | 38 |
| 40 Tile::~Tile() { | 39 Tile::~Tile() { |
| 41 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 40 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 42 TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 41 TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 43 "cc::Tile", this); | 42 "cc::Tile", this); |
| 44 } | 43 } |
| 45 | 44 |
| 46 void Tile::SetPriority(WhichTree tree, const TilePriority& priority) { | 45 void Tile::SetPriority(WhichTree tree, const TilePriority& priority) { |
| 47 if (priority == priority_[tree]) | |
| 48 return; | |
| 49 | |
| 50 priority_[tree] = priority; | 46 priority_[tree] = priority; |
| 51 tile_manager_->DidChangeTilePriority(this); | |
| 52 } | 47 } |
| 53 | 48 |
| 54 void Tile::MarkRequiredForActivation() { | 49 void Tile::MarkRequiredForActivation() { |
| 55 if (priority_[PENDING_TREE].required_for_activation) | |
| 56 return; | |
| 57 | |
| 58 priority_[PENDING_TREE].required_for_activation = true; | 50 priority_[PENDING_TREE].required_for_activation = true; |
| 59 tile_manager_->DidChangeTilePriority(this); | |
| 60 } | 51 } |
| 61 | 52 |
| 62 scoped_ptr<base::Value> Tile::AsValue() const { | 53 scoped_ptr<base::Value> Tile::AsValue() const { |
| 63 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 54 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
| 64 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( | 55 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( |
| 65 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res.get(), "cc::Tile", this); | 56 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res.get(), "cc::Tile", this); |
| 66 res->Set("picture_pile", | 57 res->Set("picture_pile", |
| 67 TracedValue::CreateIDRef(picture_pile_.get()).release()); | 58 TracedValue::CreateIDRef(picture_pile_.get()).release()); |
| 68 res->SetDouble("contents_scale", contents_scale_); | 59 res->SetDouble("contents_scale", contents_scale_); |
| 69 res->Set("content_rect", MathUtil::AsValue(content_rect_).release()); | 60 res->Set("content_rect", MathUtil::AsValue(content_rect_).release()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 93 RasterMode Tile::DetermineRasterModeForResolution( | 84 RasterMode Tile::DetermineRasterModeForResolution( |
| 94 TileResolution resolution) const { | 85 TileResolution resolution) const { |
| 95 RasterMode current_mode = managed_state_.raster_mode; | 86 RasterMode current_mode = managed_state_.raster_mode; |
| 96 RasterMode raster_mode = resolution == LOW_RESOLUTION | 87 RasterMode raster_mode = resolution == LOW_RESOLUTION |
| 97 ? LOW_QUALITY_RASTER_MODE | 88 ? LOW_QUALITY_RASTER_MODE |
| 98 : HIGH_QUALITY_RASTER_MODE; | 89 : HIGH_QUALITY_RASTER_MODE; |
| 99 return std::min(raster_mode, current_mode); | 90 return std::min(raster_mode, current_mode); |
| 100 } | 91 } |
| 101 | 92 |
| 102 } // namespace cc | 93 } // namespace cc |
| OLD | NEW |