| 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 | |
| 17 | struct GrFPArgs { | 
| 18 | GrFPArgs(GrRecordingContext* context, | 
| 19 | const SkMatrix* viewMatrix, | 
| 20 | SkFilterQuality filterQuality, | 
| 21 | const GrColorInfo* dstColorInfo) | 
| 22 | : fContext(context) | 
| 23 | , fViewMatrix(viewMatrix) | 
| 24 | , fFilterQuality(filterQuality) | 
| 25 | , fDstColorInfo(dstColorInfo) { | 
| 26 | SkASSERT(fContext); | 
| 27 | SkASSERT(fViewMatrix); | 
| 28 | } | 
| 29 | |
| 30 | class WithPreLocalMatrix; | 
| 31 | class WithPostLocalMatrix; | 
| 32 | |
| 33 | GrRecordingContext* fContext; | 
| 34 | const SkMatrix* fViewMatrix; | 
| 35 | |
| 36 | const SkMatrix* fPreLocalMatrix = nullptr; | 
| 37 | |
| 38 | // Make this SkAlphaType? | 
| 39 | bool fInputColorIsOpaque = false; | 
| 40 | |
| 41 | SkFilterQuality fFilterQuality; | 
| 42 | const GrColorInfo* fDstColorInfo; | 
| 43 | }; | 
| 44 | |
| 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 | |
| 67 | #endif | 
| 68 | |
| 69 | 
