Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / cc / test / fake_picture_layer_tiling_client.cc
blob59ea9266ea24e478d6bb4fd381bb86af3d9956cd
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"
7 #include <limits>
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"
13 namespace cc {
15 FakePictureLayerTilingClient::FakePictureLayerTilingClient()
16 : tile_manager_(new FakeTileManager(&tile_manager_client_)),
17 pile_(FakePicturePileImpl::CreateInfiniteFilledPile()),
18 twin_set_(nullptr),
19 twin_tiling_(nullptr),
20 has_valid_tile_priorities_(true) {
23 FakePictureLayerTilingClient::FakePictureLayerTilingClient(
24 ResourceProvider* resource_provider)
25 : resource_pool_(
26 ResourcePool::Create(resource_provider,
27 base::ThreadTaskRunnerHandle::Get().get(),
28 GL_TEXTURE_2D)),
29 tile_manager_(
30 new FakeTileManager(&tile_manager_client_, resource_pool_.get())),
31 pile_(FakePicturePileImpl::CreateInfiniteFilledPile()),
32 twin_set_(nullptr),
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 {
50 return tile_size_;
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 {
64 if (!twin_set_)
65 return twin_tiling_;
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);
70 return nullptr;
73 bool FakePictureLayerTilingClient::RequiresHighResToDraw() const {
74 return false;
77 } // namespace cc