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 "base/thread_task_runner_handle.h"
10 #include "cc/test/fake_picture_pile_impl.h"
11 #include "cc/test/fake_tile_manager.h"
15 FakePictureLayerTilingClient::FakePictureLayerTilingClient()
16 : tile_manager_(new FakeTileManager(&tile_manager_client_
)),
17 pile_(FakePicturePileImpl::CreateInfiniteFilledPile()),
19 twin_tiling_(nullptr),
20 has_valid_tile_priorities_(true) {
23 FakePictureLayerTilingClient::FakePictureLayerTilingClient(
24 ResourceProvider
* resource_provider
)
26 ResourcePool::Create(resource_provider
,
27 base::ThreadTaskRunnerHandle::Get().get(),
30 new FakeTileManager(&tile_manager_client_
, resource_pool_
.get())),
31 pile_(FakePicturePileImpl::CreateInfiniteFilledPile()),
33 twin_tiling_(nullptr),
34 has_valid_tile_priorities_(true) {}
36 FakePictureLayerTilingClient::~FakePictureLayerTilingClient() {
39 ScopedTilePtr
FakePictureLayerTilingClient::CreateTile(
40 const Tile::CreateInfo
& info
) {
41 return tile_manager_
->CreateTile(info
, 0, 0, 0);
44 void FakePictureLayerTilingClient::SetTileSize(const gfx::Size
& tile_size
) {
45 tile_size_
= tile_size
;
48 gfx::Size
FakePictureLayerTilingClient::CalculateTileSize(
49 const gfx::Size
& /* content_bounds */) const {
53 bool FakePictureLayerTilingClient::HasValidTilePriorities() const {
54 return has_valid_tile_priorities_
;
57 const Region
* FakePictureLayerTilingClient::GetPendingInvalidation() {
58 return &invalidation_
;
61 const PictureLayerTiling
*
62 FakePictureLayerTilingClient::GetPendingOrActiveTwinTiling(
63 const PictureLayerTiling
* tiling
) const {
66 for (size_t i
= 0; i
< twin_set_
->num_tilings(); ++i
) {
67 if (twin_set_
->tiling_at(i
)->contents_scale() == tiling
->contents_scale())
68 return twin_set_
->tiling_at(i
);
73 bool FakePictureLayerTilingClient::RequiresHighResToDraw() const {