Flutter Engine
mock_raster_cache.cc
Go to the documentation of this file.
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 
9 namespace flutter {
10 namespace testing {
11 
13  : RasterCacheResult(nullptr, SkRect::MakeEmpty()),
14  device_rect_(device_rect) {}
15 
16 std::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 
28 std::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
static SkIRect GetDeviceBounds(const SkRect &rect, const SkMatrix &ctm)
Definition: raster_cache.h:98
std::unique_ptr< RasterCacheResult > RasterizeLayer(PrerollContext *context, Layer *layer, const SkMatrix &ctm, bool checkerboard) const override
Rasterize an engine Layer and produce a RasterCacheResult to be stored in the cache.
const SkRect & paint_bounds() const
Definition: layer.h:166
std::unique_ptr< RasterCacheResult > RasterizePicture(SkPicture *picture, GrDirectContext *context, const SkMatrix &ctm, SkColorSpace *dst_color_space, bool checkerboard) const override
Rasterize a picture object and produce a RasterCacheResult to be stored in the cache.