Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / cc / test / fake_picture_layer_tiling_client.cc
blob41f27c509ccb860fb85050686587bcc6bd7bd95f
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 "cc/test/fake_picture_pile_impl.h"
10 #include "cc/test/fake_tile_manager.h"
12 namespace cc {
14 FakePictureLayerTilingClient::FakePictureLayerTilingClient()
15 : tile_manager_(new FakeTileManager(&tile_manager_client_)),
16 pile_(FakePicturePileImpl::CreateInfiniteFilledPile()),
17 twin_set_(nullptr),
18 twin_tiling_(nullptr),
19 recycled_twin_tiling_(nullptr),
20 max_tile_priority_bin_(TilePriority::NOW),
21 tree_(ACTIVE_TREE) {
24 FakePictureLayerTilingClient::FakePictureLayerTilingClient(
25 ResourceProvider* resource_provider)
26 : resource_pool_(ResourcePool::Create(resource_provider, GL_TEXTURE_2D)),
27 tile_manager_(
28 new FakeTileManager(&tile_manager_client_, resource_pool_.get())),
29 pile_(FakePicturePileImpl::CreateInfiniteFilledPile()),
30 twin_set_(nullptr),
31 twin_tiling_(nullptr),
32 recycled_twin_tiling_(nullptr),
33 max_tile_priority_bin_(TilePriority::NOW),
34 tree_(ACTIVE_TREE) {
37 FakePictureLayerTilingClient::~FakePictureLayerTilingClient() {
40 scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile(
41 float content_scale,
42 const gfx::Rect& rect) {
43 return tile_manager_->CreateTile(pile_.get(), tile_size_, rect, 1, 0, 0, 0);
46 void FakePictureLayerTilingClient::SetTileSize(const gfx::Size& tile_size) {
47 tile_size_ = tile_size;
50 gfx::Size FakePictureLayerTilingClient::CalculateTileSize(
51 const gfx::Size& /* content_bounds */) const {
52 return tile_size_;
55 TilePriority::PriorityBin FakePictureLayerTilingClient::GetMaxTilePriorityBin()
56 const {
57 return max_tile_priority_bin_;
60 const Region* FakePictureLayerTilingClient::GetPendingInvalidation() {
61 return &invalidation_;
64 const PictureLayerTiling*
65 FakePictureLayerTilingClient::GetPendingOrActiveTwinTiling(
66 const PictureLayerTiling* tiling) const {
67 if (!twin_set_)
68 return twin_tiling_;
69 for (size_t i = 0; i < twin_set_->num_tilings(); ++i) {
70 if (twin_set_->tiling_at(i)->contents_scale() == tiling->contents_scale())
71 return twin_set_->tiling_at(i);
73 return nullptr;
76 PictureLayerTiling* FakePictureLayerTilingClient::GetRecycledTwinTiling(
77 const PictureLayerTiling* tiling) {
78 return recycled_twin_tiling_;
81 WhichTree FakePictureLayerTilingClient::GetTree() const {
82 return tree_;
85 bool FakePictureLayerTilingClient::RequiresHighResToDraw() const {
86 return false;
89 } // namespace cc