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.
7 #include "cc/tile_manager.h"
8 #include "third_party/khronos/GLES2/gl2.h"
12 Tile::Tile(TileManager
* tile_manager
,
13 PicturePileImpl
* picture_pile
,
16 gfx::Rect content_rect
,
18 : tile_manager_(tile_manager
),
19 picture_pile_(picture_pile
),
20 tile_size_(tile_size
),
22 content_rect_(content_rect
),
23 contents_scale_(contents_scale
) {
24 tile_manager_
->RegisterTile(this);
28 tile_manager_
->UnregisterTile(this);
31 void Tile::set_priority(WhichTree tree
, const TilePriority
& priority
) {
32 tile_manager_
->WillModifyTilePriority(this, tree
, priority
);
33 priority_
[tree
] = priority
;
36 ResourceProvider::ResourceId
Tile::GetResourceId() const {
37 if (!managed_state_
.resource
)
39 if (managed_state_
.resource_is_being_initialized
)
42 return managed_state_
.resource
->id();
45 size_t Tile::bytes_consumed_if_allocated() const {
46 DCHECK(format_
== GL_RGBA
);
47 return 4 * tile_size_
.width() * tile_size_
.height();