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
3 // found in the LICENSE file.
5 #include "cc/resources/tile.h"
9 #include "base/trace_event/trace_event_argument.h"
10 #include "cc/base/math_util.h"
11 #include "cc/debug/traced_value.h"
12 #include "cc/resources/tile_manager.h"
16 Tile::Id
Tile::s_next_id_
= 0;
18 Tile::Tile(TileManager
* tile_manager
,
19 RasterSource
* raster_source
,
20 const gfx::Size
& desired_texture_size
,
21 const gfx::Rect
& content_rect
,
24 int source_frame_number
,
26 : RefCountedManaged
<Tile
>(tile_manager
),
27 desired_texture_size_(desired_texture_size
),
28 content_rect_(content_rect
),
29 contents_scale_(contents_scale
),
31 source_frame_number_(source_frame_number
),
35 required_for_activation_(false),
36 required_for_draw_(false),
38 scheduled_priority_(0) {
39 set_raster_source(raster_source
);
43 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
44 TRACE_DISABLED_BY_DEFAULT("cc.debug"),
48 void Tile::AsValueWithPriorityInto(const TilePriority
& priority
,
49 base::trace_event::TracedValue
* res
) const {
50 TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
51 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res
, "cc::Tile", this);
52 TracedValue::SetIDRef(raster_source_
.get(), res
, "picture_pile");
53 res
->SetDouble("contents_scale", contents_scale_
);
55 MathUtil::AddToTracedValue("content_rect", content_rect_
, res
);
57 res
->SetInteger("layer_id", layer_id_
);
59 // TODO(vmpstr): Remove active and pending priority once tracing is using
60 // combined priority or at least can support both.
61 res
->BeginDictionary("active_priority");
62 priority_
.AsValueInto(res
);
65 res
->BeginDictionary("pending_priority");
66 priority_
.AsValueInto(res
);
69 res
->BeginDictionary("combined_priority");
70 priority
.AsValueInto(res
);
73 res
->BeginDictionary("draw_info");
74 draw_info_
.AsValueInto(res
);
77 res
->SetBoolean("has_resource", HasResource());
78 res
->SetBoolean("is_using_gpu_memory", HasResource() || HasRasterTask());
79 res
->SetString("resolution", TileResolutionToString(priority_
.resolution
));
81 res
->SetInteger("scheduled_priority", scheduled_priority_
);
83 res
->SetBoolean("use_picture_analysis", use_picture_analysis());
85 res
->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
88 size_t Tile::GPUMemoryUsageInBytes() const {
89 if (draw_info_
.resource_
)
90 return draw_info_
.resource_
->bytes();