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/SkFilterQuality.h" |
| 12 | #include "include/core/SkMatrix.h" |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 13 | |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 14 | class GrColorInfo; |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 15 | class GrRecordingContext; |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame^] | 16 | class SkMatrixProvider; |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 17 | |
| 18 | struct GrFPArgs { |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 19 | GrFPArgs(GrRecordingContext* context, |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame^] | 20 | const SkMatrixProvider& matrixProvider, |
Mike Reed | 3bc266b | 2018-01-20 22:24:41 +0000 | [diff] [blame] | 21 | SkFilterQuality filterQuality, |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 22 | const GrColorInfo* dstColorInfo) |
| 23 | : fContext(context) |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame^] | 24 | , fMatrixProvider(matrixProvider) |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 25 | , fFilterQuality(filterQuality) |
| 26 | , fDstColorInfo(dstColorInfo) { |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 27 | SkASSERT(fContext); |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | class WithPreLocalMatrix; |
| 31 | class WithPostLocalMatrix; |
Mike Reed | 3bc266b | 2018-01-20 22:24:41 +0000 | [diff] [blame] | 32 | |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 33 | GrRecordingContext* fContext; |
Brian Osman | 449b115 | 2020-04-15 16:43:00 -0400 | [diff] [blame^] | 34 | const SkMatrixProvider& fMatrixProvider; |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 35 | |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 36 | const SkMatrix* fPreLocalMatrix = nullptr; |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 37 | |
Brian Salomon | c0d79e5 | 2019-04-10 15:02:11 -0400 | [diff] [blame] | 38 | // Make this SkAlphaType? |
| 39 | bool fInputColorIsOpaque = false; |
| 40 | |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 41 | SkFilterQuality fFilterQuality; |
Brian Salomon | 4bc0c1f | 2019-09-30 15:12:27 -0400 | [diff] [blame] | 42 | const GrColorInfo* fDstColorInfo; |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 43 | }; |
| 44 | |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 45 | class GrFPArgs::WithPreLocalMatrix final : public GrFPArgs { |
| 46 | public: |
| 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 | |
| 58 | private: |
| 59 | WithPreLocalMatrix(const WithPreLocalMatrix&) = delete; |
| 60 | WithPreLocalMatrix& operator=(const WithPreLocalMatrix&) = delete; |
| 61 | |
| 62 | SkMatrix fStorage; |
| 63 | |
| 64 | using INHERITED = GrFPArgs; |
| 65 | }; |
| 66 | |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 67 | #endif |
| 68 | |