Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
TiledTextureUtils.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef skgpu_TiledTextureUtils_DEFINED
9#define skgpu_TiledTextureUtils_DEFINED
10
13
14#include <tuple>
15
16class GrClip;
18class SkBitmap;
19struct SkIRect;
20struct SkISize;
21class SkMatrix;
22class SkPaint;
23struct SkRect;
25
26namespace skgpu {
27
29public:
30 static bool ShouldTileImage(SkIRect conservativeClipBounds,
31 const SkISize& imageSize,
32 const SkMatrix& ctm,
33 const SkMatrix& srcToDst,
34 const SkRect* src,
35 int maxTileSize,
36 size_t cacheSize,
37 int* tileSize,
38 SkIRect* clippedSubset);
39
40 enum class ImageDrawMode {
41 // Src and dst have been restricted to the image content. May need to clamp, no need to
42 // decal.
44 // Src and dst are their original sizes, requires use of a decal instead of plain clamping.
45 // This is used when a dst clip is provided and extends outside of the optimized dst rect.
46 kDecal,
47 // Src or dst are empty, or do not intersect the image content so don't draw anything.
48 kSkip
49 };
50
51 static ImageDrawMode OptimizeSampleArea(const SkISize& imageSize,
52 const SkRect& origSrcRect,
53 const SkRect& origDstRect,
54 const SkPoint dstClip[4],
55 SkRect* outSrcRect,
56 SkRect* outDstRect,
57 SkMatrix* outSrcToDst);
58
59 static bool CanDisableMipmap(const SkMatrix& viewM, const SkMatrix& localM);
60
61 static void ClampedOutsetWithOffset(SkIRect* iRect, int outset, SkPoint* offset,
62 const SkIRect& clamp);
63
64 static std::tuple<bool, size_t> DrawAsTiledImageRect(SkCanvas*,
65 const SkImage*,
66 const SkRect& srcRect,
67 const SkRect& dstRect,
69 const SkSamplingOptions&,
70 const SkPaint*,
72 size_t cacheSize,
73 size_t maxTextureSize);
74};
75
76} // namespace skgpu
77
78#endif // skgpu_TiledTextureUtils_DEFINED
static const int outset
Definition BlurTest.cpp:58
static unsigned clamp(SkFixed fx, int max)
SrcRectConstraint
Definition SkCanvas.h:1541
static void ClampedOutsetWithOffset(SkIRect *iRect, int outset, SkPoint *offset, const SkIRect &clamp)
static ImageDrawMode OptimizeSampleArea(const SkISize &imageSize, const SkRect &origSrcRect, const SkRect &origDstRect, const SkPoint dstClip[4], SkRect *outSrcRect, SkRect *outDstRect, SkMatrix *outSrcToDst)
static bool ShouldTileImage(SkIRect conservativeClipBounds, const SkISize &imageSize, const SkMatrix &ctm, const SkMatrix &srcToDst, const SkRect *src, int maxTileSize, size_t cacheSize, int *tileSize, SkIRect *clippedSubset)
static std::tuple< bool, size_t > DrawAsTiledImageRect(SkCanvas *, const SkImage *, const SkRect &srcRect, const SkRect &dstRect, SkCanvas::QuadAAFlags, const SkSamplingOptions &, const SkPaint *, SkCanvas::SrcRectConstraint, size_t cacheSize, size_t maxTextureSize)
static bool CanDisableMipmap(const SkMatrix &viewM, const SkMatrix &localM)
Point offset