| 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 | |
| 11 | #include "include/core/SkFilterQuality.h" |
| 12 | #include "include/core/SkMatrix.h" |
| 13 | |
| 14 | class GrColorInfo; |
| 15 | class GrRecordingContext; |
| 16 | class SkMatrixProvider; |
| 17 | |
| 18 | struct GrFPArgs { |
| 19 | GrFPArgs(GrRecordingContext* context, |
| 20 | const SkMatrixProvider& matrixProvider, |
| 21 | SkFilterQuality filterQuality, |
| 22 | const GrColorInfo* dstColorInfo) |
| 23 | : fContext(context) |
| 24 | , fMatrixProvider(matrixProvider) |
| 25 | , fFilterQuality(filterQuality) |
| 26 | , fDstColorInfo(dstColorInfo) { |
| 27 | SkASSERT(fContext); |
| 28 | } |
| 29 | |
| 30 | class WithPreLocalMatrix; |
| 31 | |
| 32 | GrFPArgs withNewMatrixProvider(const SkMatrixProvider& provider) const { |
| 33 | GrFPArgs newArgs(fContext, provider, fFilterQuality, fDstColorInfo); |
| 34 | newArgs.fInputColorIsOpaque = fInputColorIsOpaque; |
| 35 | newArgs.fPreLocalMatrix = fPreLocalMatrix; |
| 36 | return newArgs; |
| 37 | } |
| 38 | |
| 39 | GrRecordingContext* fContext; |
| 40 | const SkMatrixProvider& fMatrixProvider; |
| 41 | |
| 42 | const SkMatrix* fPreLocalMatrix = nullptr; |
| 43 | |
| 44 | // Make this SkAlphaType? |
| 45 | bool fInputColorIsOpaque = false; |
| 46 | |
| 47 | SkFilterQuality fFilterQuality; |
| 48 | const GrColorInfo* fDstColorInfo; |
| 49 | }; |
| 50 | |
| 51 | class GrFPArgs::WithPreLocalMatrix final : public GrFPArgs { |
| 52 | public: |
| 53 | WithPreLocalMatrix(const GrFPArgs& args, const SkMatrix& lm) : INHERITED(args) { |
| 54 | if (!lm.isIdentity()) { |
| 55 | if (fPreLocalMatrix) { |
| 56 | fStorage.setConcat(lm, *fPreLocalMatrix); |
| 57 | fPreLocalMatrix = fStorage.isIdentity() ? nullptr : &fStorage; |
| 58 | } else { |
| 59 | fPreLocalMatrix = &lm; |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | private: |
| 65 | WithPreLocalMatrix(const WithPreLocalMatrix&) = delete; |
| 66 | WithPreLocalMatrix& operator=(const WithPreLocalMatrix&) = delete; |
| 67 | |
| 68 | SkMatrix fStorage; |
| 69 | |
| 70 | using INHERITED = GrFPArgs; |
| 71 | }; |
| 72 | |
| 73 | #endif |
| 74 | |