1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2018 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#ifndef GrFPArgs_DEFINED 9cb93a386Sopenharmony_ci#define GrFPArgs_DEFINED 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_ci#include "include/core/SkMatrix.h" 12cb93a386Sopenharmony_ci 13cb93a386Sopenharmony_ciclass GrColorInfo; 14cb93a386Sopenharmony_ciclass GrRecordingContext; 15cb93a386Sopenharmony_ciclass SkMatrixProvider; 16cb93a386Sopenharmony_ci 17cb93a386Sopenharmony_cistruct GrFPArgs { 18cb93a386Sopenharmony_ci GrFPArgs(GrRecordingContext* context, 19cb93a386Sopenharmony_ci const SkMatrixProvider& matrixProvider, 20cb93a386Sopenharmony_ci const GrColorInfo* dstColorInfo) 21cb93a386Sopenharmony_ci : fContext(context) 22cb93a386Sopenharmony_ci , fMatrixProvider(matrixProvider) 23cb93a386Sopenharmony_ci , fDstColorInfo(dstColorInfo) { 24cb93a386Sopenharmony_ci SkASSERT(fContext); 25cb93a386Sopenharmony_ci } 26cb93a386Sopenharmony_ci 27cb93a386Sopenharmony_ci class WithPreLocalMatrix; 28cb93a386Sopenharmony_ci 29cb93a386Sopenharmony_ci GrFPArgs withNewMatrixProvider(const SkMatrixProvider& provider) const { 30cb93a386Sopenharmony_ci GrFPArgs newArgs(fContext, provider, fDstColorInfo); 31cb93a386Sopenharmony_ci newArgs.fPreLocalMatrix = fPreLocalMatrix; 32cb93a386Sopenharmony_ci return newArgs; 33cb93a386Sopenharmony_ci } 34cb93a386Sopenharmony_ci 35cb93a386Sopenharmony_ci GrRecordingContext* fContext; 36cb93a386Sopenharmony_ci const SkMatrixProvider& fMatrixProvider; 37cb93a386Sopenharmony_ci 38cb93a386Sopenharmony_ci const SkMatrix* fPreLocalMatrix = nullptr; 39cb93a386Sopenharmony_ci 40cb93a386Sopenharmony_ci const GrColorInfo* fDstColorInfo; 41cb93a386Sopenharmony_ci}; 42cb93a386Sopenharmony_ci 43cb93a386Sopenharmony_ciclass GrFPArgs::WithPreLocalMatrix final : public GrFPArgs { 44cb93a386Sopenharmony_cipublic: 45cb93a386Sopenharmony_ci WithPreLocalMatrix(const GrFPArgs& args, const SkMatrix& lm) : INHERITED(args) { 46cb93a386Sopenharmony_ci if (!lm.isIdentity()) { 47cb93a386Sopenharmony_ci if (fPreLocalMatrix) { 48cb93a386Sopenharmony_ci fStorage.setConcat(lm, *fPreLocalMatrix); 49cb93a386Sopenharmony_ci fPreLocalMatrix = fStorage.isIdentity() ? nullptr : &fStorage; 50cb93a386Sopenharmony_ci } else { 51cb93a386Sopenharmony_ci fPreLocalMatrix = &lm; 52cb93a386Sopenharmony_ci } 53cb93a386Sopenharmony_ci } 54cb93a386Sopenharmony_ci } 55cb93a386Sopenharmony_ci 56cb93a386Sopenharmony_ciprivate: 57cb93a386Sopenharmony_ci WithPreLocalMatrix(const WithPreLocalMatrix&) = delete; 58cb93a386Sopenharmony_ci WithPreLocalMatrix& operator=(const WithPreLocalMatrix&) = delete; 59cb93a386Sopenharmony_ci 60cb93a386Sopenharmony_ci SkMatrix fStorage; 61cb93a386Sopenharmony_ci 62cb93a386Sopenharmony_ci using INHERITED = GrFPArgs; 63cb93a386Sopenharmony_ci}; 64cb93a386Sopenharmony_ci 65cb93a386Sopenharmony_ci#endif 66