Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 1 | /* |
| 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 Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkMatrix.h" |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 12 | |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 13 | class GrColorInfo; |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 14 | class GrRecordingContext; |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame] | 15 | class SkMatrixProvider; |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 16 | |
| 17 | struct GrFPArgs { |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 18 | GrFPArgs(GrRecordingContext* context, |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame] | 19 | const SkMatrixProvider& matrixProvider, |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 20 | const GrColorInfo* dstColorInfo) |
| 21 | : fContext(context) |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame] | 22 | , fMatrixProvider(matrixProvider) |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 23 | , fDstColorInfo(dstColorInfo) { |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 24 | SkASSERT(fContext); |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | class WithPreLocalMatrix; |
Michael Ludwig | 4e221bd | 2020-06-05 11:29:36 -0400 | [diff] [blame] | 28 | |
| 29 | GrFPArgs withNewMatrixProvider(const SkMatrixProvider& provider) const { |
Mike Reed | 12a7558 | 2021-03-20 10:49:02 -0400 | [diff] [blame] | 30 | GrFPArgs newArgs(fContext, provider, fDstColorInfo); |
Michael Ludwig | 4e221bd | 2020-06-05 11:29:36 -0400 | [diff] [blame] | 31 | newArgs.fInputColorIsOpaque = fInputColorIsOpaque; |
| 32 | newArgs.fPreLocalMatrix = fPreLocalMatrix; |
| 33 | return newArgs; |
| 34 | } |
Mike Reed | 3bc266b | 2018-01-20 22:24:41 +0000 | [diff] [blame] | 35 | |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 36 | GrRecordingContext* fContext; |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame] | 37 | const SkMatrixProvider& fMatrixProvider; |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 38 | |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 39 | const SkMatrix* fPreLocalMatrix = nullptr; |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 40 | |
Brian Salomon | c0d79e5 | 2019-04-10 15:02:11 -0400 | [diff] [blame] | 41 | // Make this SkAlphaType? |
| 42 | bool fInputColorIsOpaque = false; |
| 43 | |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 44 | const GrColorInfo* fDstColorInfo; |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 45 | }; |
| 46 | |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 47 | class GrFPArgs::WithPreLocalMatrix final : public GrFPArgs { |
| 48 | public: |
| 49 | WithPreLocalMatrix(const GrFPArgs& args, const SkMatrix& lm) : INHERITED(args) { |
| 50 | if (!lm.isIdentity()) { |
| 51 | if (fPreLocalMatrix) { |
| 52 | fStorage.setConcat(lm, *fPreLocalMatrix); |
| 53 | fPreLocalMatrix = fStorage.isIdentity() ? nullptr : &fStorage; |
| 54 | } else { |
| 55 | fPreLocalMatrix = &lm; |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | private: |
| 61 | WithPreLocalMatrix(const WithPreLocalMatrix&) = delete; |
| 62 | WithPreLocalMatrix& operator=(const WithPreLocalMatrix&) = delete; |
| 63 | |
| 64 | SkMatrix fStorage; |
| 65 | |
| 66 | using INHERITED = GrFPArgs; |
| 67 | }; |
| 68 | |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 69 | #endif |