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/test/fake_picture_layer_tiling_client.h"
9 #include "cc/test/fake_picture_pile_impl.h"
10 #include "cc/test/fake_tile_manager.h"
14 FakePictureLayerTilingClient::FakePictureLayerTilingClient()
15 : tile_manager_(new FakeTileManager(&tile_manager_client_
)),
16 pile_(FakePicturePileImpl::CreateInfiniteFilledPile()),
18 twin_tiling_(nullptr),
19 recycled_twin_tiling_(nullptr),
20 max_tile_priority_bin_(TilePriority::NOW
) {
23 FakePictureLayerTilingClient::FakePictureLayerTilingClient(
24 ResourceProvider
* resource_provider
)
26 ResourcePool::Create(resource_provider
, GL_TEXTURE_2D
)),
27 tile_manager_(new FakeTileManager(
28 &tile_manager_client_
, resource_pool_
.get())),
29 pile_(FakePicturePileImpl::CreateInfiniteFilledPile()),
31 twin_tiling_(nullptr),
32 recycled_twin_tiling_(nullptr),
33 max_tile_priority_bin_(TilePriority::NOW
) {
36 FakePictureLayerTilingClient::~FakePictureLayerTilingClient() {
39 scoped_refptr
<Tile
> FakePictureLayerTilingClient::CreateTile(
41 const gfx::Rect
& rect
) {
42 return tile_manager_
->CreateTile(pile_
.get(), tile_size_
, rect
, 1, 0, 0, 0);
45 void FakePictureLayerTilingClient::SetTileSize(const gfx::Size
& tile_size
) {
46 tile_size_
= tile_size
;
49 gfx::Size
FakePictureLayerTilingClient::CalculateTileSize(
50 const gfx::Size
& /* content_bounds */) const {
54 TilePriority::PriorityBin
FakePictureLayerTilingClient::GetMaxTilePriorityBin()
56 return max_tile_priority_bin_
;
59 const Region
* FakePictureLayerTilingClient::GetPendingInvalidation() {
60 return &invalidation_
;
63 const PictureLayerTiling
*
64 FakePictureLayerTilingClient::GetPendingOrActiveTwinTiling(
65 const PictureLayerTiling
* tiling
) const {
68 for (size_t i
= 0; i
< twin_set_
->num_tilings(); ++i
) {
69 if (twin_set_
->tiling_at(i
)->contents_scale() == tiling
->contents_scale())
70 return twin_set_
->tiling_at(i
);
75 PictureLayerTiling
* FakePictureLayerTilingClient::GetRecycledTwinTiling(
76 const PictureLayerTiling
* tiling
) {
77 return recycled_twin_tiling_
;
80 WhichTree
FakePictureLayerTilingClient::GetTree() const {
84 bool FakePictureLayerTilingClient::RequiresHighResToDraw() const {