1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60

cc / test / fake_tile_manager.cc [blame]

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/test/fake_tile_manager.h"

#include <stddef.h>
#include <stdint.h>

#include <limits>
#include <memory>

#include "base/containers/contains.h"
#include "base/task/single_thread_task_runner.h"
#include "cc/raster/raster_buffer.h"
#include "cc/raster/synchronous_task_graph_runner.h"
#include "cc/test/fake_raster_buffer_provider.h"
#include "cc/test/fake_tile_task_manager.h"
#include "cc/trees/layer_tree_settings.h"

namespace cc {

namespace {

SynchronousTaskGraphRunner* GetGlobalTaskGraphRunner() {
  static auto* task_graph_runner = new SynchronousTaskGraphRunner;
  return task_graph_runner;
}

FakeRasterBufferProviderImpl* GetGlobalRasterBufferProvider() {
  static auto* buffer_provider = new FakeRasterBufferProviderImpl;
  return buffer_provider;
}

}  // namespace

FakeTileManager::FakeTileManager(TileManagerClient* client,
                                 ResourcePool* resource_pool)
    : TileManager(client,
                  base::SingleThreadTaskRunner::GetCurrentDefault().get(),
                  nullptr,
                  std::numeric_limits<size_t>::max(),
                  false,
                  TileManagerSettings()),
      image_decode_cache_(
          kN32_SkColorType,
          LayerTreeSettings().decoded_image_working_set_budget_bytes) {
  SetResources(resource_pool, &image_decode_cache_, GetGlobalTaskGraphRunner(),
               GetGlobalRasterBufferProvider(),
               /*use_gpu_rasterization=*/false, nullptr);
  SetTileTaskManagerForTesting(std::make_unique<FakeTileTaskManagerImpl>());
}

FakeTileManager::~FakeTileManager() = default;

bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) {
  return base::Contains(tiles_for_raster, tile);
}

}  // namespace cc