1// Copyright 2013 The Flutter 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.
4
5#include "flutter/flow/testing/mock_raster_cache.h"
6
7#include "flutter/flow/layers/layer.h"
8
9namespace flutter {
10namespace testing {
11
12MockRasterCacheResult::MockRasterCacheResult(SkIRect device_rect)
13 : RasterCacheResult(nullptr, SkRect::MakeEmpty()),
14 device_rect_(device_rect) {}
15
16std::unique_ptr<RasterCacheResult> MockRasterCache::RasterizePicture(
17 SkPicture* picture,
18 GrDirectContext* context,
19 const SkMatrix& ctm,
20 SkColorSpace* dst_color_space,
21 bool checkerboard) const {
22 SkRect logical_rect = picture->cullRect();
23 SkIRect cache_rect = RasterCache::GetDeviceBounds(logical_rect, ctm);
24
25 return std::make_unique<MockRasterCacheResult>(cache_rect);
26}
27
28std::unique_ptr<RasterCacheResult> MockRasterCache::RasterizeLayer(
29 PrerollContext* context,
30 Layer* layer,
31 const SkMatrix& ctm,
32 bool checkerboard) const {
33 SkRect logical_rect = layer->paint_bounds();
34 SkIRect cache_rect = RasterCache::GetDeviceBounds(logical_rect, ctm);
35
36 return std::make_unique<MockRasterCacheResult>(cache_rect);
37}
38
39} // namespace testing
40} // namespace flutter
41