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" |
(...skipping 12 matching lines...) Expand all Loading... |
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), | 28 tile_manager_(tile_manager), |
29 tile_size_(tile_size), | 29 tile_size_(tile_size), |
30 content_rect_(content_rect), | 30 content_rect_(content_rect), |
31 contents_scale_(contents_scale), | 31 contents_scale_(contents_scale), |
32 opaque_rect_(opaque_rect), | 32 opaque_rect_(opaque_rect), |
33 is_occluded_(false), | |
34 layer_id_(layer_id), | 33 layer_id_(layer_id), |
35 source_frame_number_(source_frame_number), | 34 source_frame_number_(source_frame_number), |
36 flags_(flags), | 35 flags_(flags), |
37 id_(s_next_id_++) { | 36 id_(s_next_id_++) { |
38 set_picture_pile(picture_pile); | 37 set_picture_pile(picture_pile); |
39 } | 38 } |
40 | 39 |
41 Tile::~Tile() { | 40 Tile::~Tile() { |
42 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 41 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
43 TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 42 TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
44 "cc::Tile", this); | 43 "cc::Tile", this); |
45 } | 44 } |
46 | 45 |
47 void Tile::SetPriority(WhichTree tree, const TilePriority& priority) { | 46 void Tile::SetPriority(WhichTree tree, const TilePriority& priority) { |
48 if (priority == priority_[tree]) | 47 if (priority == priority_[tree]) |
49 return; | 48 return; |
50 | 49 |
51 priority_[tree] = priority; | 50 priority_[tree] = priority; |
52 tile_manager_->DidChangeTilePriority(this); | 51 tile_manager_->DidChangeTilePriority(this); |
53 } | 52 } |
54 | 53 |
55 void Tile::MarkRequiredForActivation() { | 54 void Tile::MarkRequiredForActivation() { |
56 if (priority_[PENDING_TREE].required_for_activation) | 55 if (priority_[PENDING_TREE].required_for_activation) |
57 return; | 56 return; |
58 | 57 |
59 priority_[PENDING_TREE].required_for_activation = true; | 58 priority_[PENDING_TREE].required_for_activation = true; |
60 tile_manager_->DidChangeTilePriority(this); | 59 tile_manager_->DidChangeTilePriority(this); |
61 } | 60 } |
62 | 61 |
| 62 void Tile::SetIsOccluded(WhichTree tree, bool occluded) { |
| 63 if (priority_[tree].is_occluded == occluded) |
| 64 return; |
| 65 |
| 66 priority_[tree].is_occluded = occluded; |
| 67 tile_manager_->DidChangeTilePriority(this); |
| 68 } |
| 69 |
63 scoped_ptr<base::Value> Tile::AsValue() const { | 70 scoped_ptr<base::Value> Tile::AsValue() const { |
64 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 71 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
65 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( | 72 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( |
66 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res.get(), "cc::Tile", this); | 73 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res.get(), "cc::Tile", this); |
67 res->Set("picture_pile", | 74 res->Set("picture_pile", |
68 TracedValue::CreateIDRef(picture_pile_.get()).release()); | 75 TracedValue::CreateIDRef(picture_pile_.get()).release()); |
69 res->SetDouble("contents_scale", contents_scale_); | 76 res->SetDouble("contents_scale", contents_scale_); |
70 res->Set("content_rect", MathUtil::AsValue(content_rect_).release()); | 77 res->Set("content_rect", MathUtil::AsValue(content_rect_).release()); |
71 res->SetInteger("layer_id", layer_id_); | 78 res->SetInteger("layer_id", layer_id_); |
72 res->Set("active_priority", priority_[ACTIVE_TREE].AsValue().release()); | 79 res->Set("active_priority", priority_[ACTIVE_TREE].AsValue().release()); |
(...skipping 21 matching lines...) Expand all Loading... |
94 RasterMode Tile::DetermineRasterModeForResolution( | 101 RasterMode Tile::DetermineRasterModeForResolution( |
95 TileResolution resolution) const { | 102 TileResolution resolution) const { |
96 RasterMode current_mode = managed_state_.raster_mode; | 103 RasterMode current_mode = managed_state_.raster_mode; |
97 RasterMode raster_mode = resolution == LOW_RESOLUTION | 104 RasterMode raster_mode = resolution == LOW_RESOLUTION |
98 ? LOW_QUALITY_RASTER_MODE | 105 ? LOW_QUALITY_RASTER_MODE |
99 : HIGH_QUALITY_RASTER_MODE; | 106 : HIGH_QUALITY_RASTER_MODE; |
100 return std::min(raster_mode, current_mode); | 107 return std::min(raster_mode, current_mode); |
101 } | 108 } |
102 | 109 |
103 } // namespace cc | 110 } // namespace cc |
OLD | NEW |