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/tiles/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/tiles/tile_manager.h"
16 Tile::Id
Tile::s_next_id_
= 0;
18 Tile::Tile(TileManager
* tile_manager
,
19 const gfx::Size
& desired_texture_size
,
20 const gfx::Rect
& content_rect
,
23 int source_frame_number
,
25 : tile_manager_(tile_manager
),
26 desired_texture_size_(desired_texture_size
),
27 content_rect_(content_rect
),
28 contents_scale_(contents_scale
),
30 source_frame_number_(source_frame_number
),
34 required_for_activation_(false),
35 required_for_draw_(false),
37 scheduled_priority_(0) {
41 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
42 TRACE_DISABLED_BY_DEFAULT("cc.debug"),
46 void Tile::AsValueInto(base::trace_event::TracedValue
* value
) const {
47 TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
48 TRACE_DISABLED_BY_DEFAULT("cc.debug"), value
, "cc::Tile", this);
49 value
->SetDouble("contents_scale", contents_scale_
);
51 MathUtil::AddToTracedValue("content_rect", content_rect_
, value
);
53 value
->SetInteger("layer_id", layer_id_
);
55 value
->BeginDictionary("draw_info");
56 draw_info_
.AsValueInto(value
);
57 value
->EndDictionary();
59 value
->SetBoolean("has_resource", draw_info().has_resource());
60 value
->SetBoolean("is_using_gpu_memory",
61 draw_info().has_resource() || HasRasterTask());
62 value
->SetInteger("scheduled_priority", scheduled_priority_
);
63 value
->SetBoolean("use_picture_analysis", use_picture_analysis());
64 value
->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
67 size_t Tile::GPUMemoryUsageInBytes() const {
68 if (draw_info_
.resource_
)
69 return draw_info_
.resource_
->bytes();
73 void Tile::Deleter::operator()(Tile
* tile
) const {
74 TileManager
* tile_manager
= tile
->tile_manager_
;
75 tile_manager
->Release(tile
);