blob: 3058f8681de17fb755a69a3287237c666f72e24d [file] [log] [blame]
Mike Reede3429e62018-01-19 11:43:34 -05001/*
2 * Copyright 2018 Google Inc.
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 GrFPArgs_DEFINED
9#define GrFPArgs_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkFilterQuality.h"
12#include "include/core/SkMatrix.h"
Mike Reede3429e62018-01-19 11:43:34 -050013
Brian Salomon4bc0c1f2019-09-30 15:12:27 -040014class GrColorInfo;
Robert Phillips9338c602019-02-19 12:52:29 -050015class GrRecordingContext;
Brian Osman449b1152020-04-15 16:43:00 -040016class SkMatrixProvider;
Mike Reede3429e62018-01-19 11:43:34 -050017
18struct GrFPArgs {
Robert Phillips9338c602019-02-19 12:52:29 -050019 GrFPArgs(GrRecordingContext* context,
Brian Osman449b1152020-04-15 16:43:00 -040020 const SkMatrixProvider& matrixProvider,
Mike Reed3bc266b2018-01-20 22:24:41 +000021 SkFilterQuality filterQuality,
Brian Salomon4bc0c1f2019-09-30 15:12:27 -040022 const GrColorInfo* dstColorInfo)
23 : fContext(context)
Brian Osman449b1152020-04-15 16:43:00 -040024 , fMatrixProvider(matrixProvider)
Brian Salomon4bc0c1f2019-09-30 15:12:27 -040025 , fFilterQuality(filterQuality)
26 , fDstColorInfo(dstColorInfo) {
Florin Malitac6c5ead2018-04-11 15:33:40 -040027 SkASSERT(fContext);
Florin Malitac6c5ead2018-04-11 15:33:40 -040028 }
29
30 class WithPreLocalMatrix;
31 class WithPostLocalMatrix;
Mike Reed3bc266b2018-01-20 22:24:41 +000032
Robert Phillips9338c602019-02-19 12:52:29 -050033 GrRecordingContext* fContext;
Brian Osman449b1152020-04-15 16:43:00 -040034 const SkMatrixProvider& fMatrixProvider;
Florin Malitac6c5ead2018-04-11 15:33:40 -040035
Florin Malitac6c5ead2018-04-11 15:33:40 -040036 const SkMatrix* fPreLocalMatrix = nullptr;
Florin Malitac6c5ead2018-04-11 15:33:40 -040037
Brian Salomonc0d79e52019-04-10 15:02:11 -040038 // Make this SkAlphaType?
39 bool fInputColorIsOpaque = false;
40
Mike Reede3429e62018-01-19 11:43:34 -050041 SkFilterQuality fFilterQuality;
Brian Salomon4bc0c1f2019-09-30 15:12:27 -040042 const GrColorInfo* fDstColorInfo;
Mike Reede3429e62018-01-19 11:43:34 -050043};
44
Florin Malitac6c5ead2018-04-11 15:33:40 -040045class GrFPArgs::WithPreLocalMatrix final : public GrFPArgs {
46public:
47 WithPreLocalMatrix(const GrFPArgs& args, const SkMatrix& lm) : INHERITED(args) {
48 if (!lm.isIdentity()) {
49 if (fPreLocalMatrix) {
50 fStorage.setConcat(lm, *fPreLocalMatrix);
51 fPreLocalMatrix = fStorage.isIdentity() ? nullptr : &fStorage;
52 } else {
53 fPreLocalMatrix = &lm;
54 }
55 }
56 }
57
58private:
59 WithPreLocalMatrix(const WithPreLocalMatrix&) = delete;
60 WithPreLocalMatrix& operator=(const WithPreLocalMatrix&) = delete;
61
62 SkMatrix fStorage;
63
64 using INHERITED = GrFPArgs;
65};
66
Mike Reede3429e62018-01-19 11:43:34 -050067#endif
68