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"
13 #include "third_party/khronos/GLES2/gl2.h"
17 Tile::Id
Tile::s_next_id_
= 0;
19 Tile::Tile(TileManager
* tile_manager
,
20 RasterSource
* raster_source
,
21 const gfx::Size
& desired_texture_size
,
22 const gfx::Rect
& content_rect
,
25 int source_frame_number
,
27 : RefCountedManaged
<Tile
>(tile_manager
),
28 desired_texture_size_(desired_texture_size
),
29 content_rect_(content_rect
),
30 contents_scale_(contents_scale
),
32 source_frame_number_(source_frame_number
),
37 required_for_activation_(false),
38 required_for_draw_(false),
40 scheduled_priority_(0) {
41 set_raster_source(raster_source
);
42 for (int i
= 0; i
<= LAST_TREE
; i
++)
43 is_occluded_
[i
] = false;
47 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
48 TRACE_DISABLED_BY_DEFAULT("cc.debug"),
52 void Tile::AsValueInto(base::trace_event::TracedValue
* res
) const {
53 TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
54 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res
, "cc::Tile", this);
55 TracedValue::SetIDRef(raster_source_
.get(), res
, "picture_pile");
56 res
->SetDouble("contents_scale", contents_scale_
);
58 MathUtil::AddToTracedValue("content_rect", content_rect_
, res
);
60 res
->SetInteger("layer_id", layer_id_
);
62 res
->BeginDictionary("active_priority");
63 priority_
[ACTIVE_TREE
].AsValueInto(res
);
66 res
->BeginDictionary("pending_priority");
67 priority_
[PENDING_TREE
].AsValueInto(res
);
70 res
->BeginDictionary("draw_info");
71 draw_info_
.AsValueInto(res
);
74 res
->SetBoolean("has_resource", HasResource());
75 res
->SetBoolean("is_using_gpu_memory", HasResource() || HasRasterTask());
76 res
->SetString("resolution",
77 TileResolutionToString(combined_priority().resolution
));
79 res
->SetInteger("scheduled_priority", scheduled_priority_
);
81 res
->SetBoolean("use_picture_analysis", use_picture_analysis());
83 res
->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
86 size_t Tile::GPUMemoryUsageInBytes() const {
87 if (draw_info_
.resource_
)
88 return draw_info_
.resource_
->bytes();