Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / cc / tiles / tile.cc
blob7d91552eb0980e87416b796e2ff4d61d490dff08
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"
7 #include <algorithm>
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"
14 namespace cc {
16 Tile::Id Tile::s_next_id_ = 1;
18 Tile::Tile(TileManager* tile_manager,
19 const gfx::Size& desired_texture_size,
20 const gfx::Rect& content_rect,
21 float contents_scale,
22 int layer_id,
23 int source_frame_number,
24 int flags)
25 : tile_manager_(tile_manager),
26 desired_texture_size_(desired_texture_size),
27 content_rect_(content_rect),
28 contents_scale_(contents_scale),
29 layer_id_(layer_id),
30 source_frame_number_(source_frame_number),
31 flags_(flags),
32 tiling_i_index_(-1),
33 tiling_j_index_(-1),
34 required_for_activation_(false),
35 required_for_draw_(false),
36 id_(s_next_id_++),
37 invalidated_id_(0),
38 scheduled_priority_(0) {
41 Tile::~Tile() {
42 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
43 TRACE_DISABLED_BY_DEFAULT("cc.debug"),
44 "cc::Tile", this);
47 void Tile::AsValueInto(base::trace_event::TracedValue* value) const {
48 TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
49 TRACE_DISABLED_BY_DEFAULT("cc.debug"), value, "cc::Tile", this);
50 value->SetDouble("contents_scale", contents_scale_);
52 MathUtil::AddToTracedValue("content_rect", content_rect_, value);
54 value->SetInteger("layer_id", layer_id_);
56 value->BeginDictionary("draw_info");
57 draw_info_.AsValueInto(value);
58 value->EndDictionary();
60 value->SetBoolean("has_resource", draw_info().has_resource());
61 value->SetBoolean("is_using_gpu_memory",
62 draw_info().has_resource() || HasRasterTask());
63 value->SetInteger("scheduled_priority", scheduled_priority_);
64 value->SetBoolean("use_picture_analysis", use_picture_analysis());
65 value->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
68 size_t Tile::GPUMemoryUsageInBytes() const {
69 if (draw_info_.resource_)
70 return draw_info_.resource_->bytes();
71 return 0;
74 void Tile::Deleter::operator()(Tile* tile) const {
75 TileManager* tile_manager = tile->tile_manager_;
76 tile_manager->Release(tile);
79 } // namespace cc