aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrFPArgs.h77
-rw-r--r--src/gpu/GrTestUtils.cpp3
-rw-r--r--src/gpu/SkGpuDevice.cpp2
-rw-r--r--src/gpu/SkGr.cpp2
4 files changed, 65 insertions, 19 deletions
diff --git a/src/gpu/GrFPArgs.h b/src/gpu/GrFPArgs.h
index cdb2e5de50..e67c638226 100644
--- a/src/gpu/GrFPArgs.h
+++ b/src/gpu/GrFPArgs.h
@@ -9,39 +9,86 @@
#define GrFPArgs_DEFINED
#include "SkFilterQuality.h"
+#include "SkMatrix.h"
-class SkMatrix;
class GrContext;
class GrColorSpaceInfo;
struct GrFPArgs {
GrFPArgs(GrContext* context,
const SkMatrix* viewMatrix,
- const SkMatrix* localMatrix,
- SkFilterQuality filterQuality,
- const GrColorSpaceInfo* dstColorSpaceInfo)
- : fContext(context)
- , fViewMatrix(viewMatrix)
- , fLocalMatrix(localMatrix)
- , fFilterQuality(filterQuality)
- , fDstColorSpaceInfo(dstColorSpaceInfo) {}
-
- GrFPArgs(GrContext* context,
- const SkMatrix* viewMatrix,
SkFilterQuality filterQuality,
const GrColorSpaceInfo* dstColorSpaceInfo)
: fContext(context)
, fViewMatrix(viewMatrix)
- , fLocalMatrix(nullptr)
, fFilterQuality(filterQuality)
- , fDstColorSpaceInfo(dstColorSpaceInfo) {}
+ , fDstColorSpaceInfo(dstColorSpaceInfo) {
+ SkASSERT(fContext);
+ SkASSERT(fViewMatrix);
+ }
+
+ class WithPreLocalMatrix;
+ class WithPostLocalMatrix;
GrContext* fContext;
const SkMatrix* fViewMatrix;
- const SkMatrix* fLocalMatrix;
+
+ // We track both pre and post local matrix adjustments. For a given FP:
+ //
+ // total_local_matrix = postLocalMatrix x FP_localMatrix x preLocalMatrix
+ //
+ // Use the helpers above to create pre/post GrFPArgs wrappers.
+ //
+ const SkMatrix* fPreLocalMatrix = nullptr;
+ const SkMatrix* fPostLocalMatrix = nullptr;
+
SkFilterQuality fFilterQuality;
const GrColorSpaceInfo* fDstColorSpaceInfo;
};
+class GrFPArgs::WithPreLocalMatrix final : public GrFPArgs {
+public:
+ WithPreLocalMatrix(const GrFPArgs& args, const SkMatrix& lm) : INHERITED(args) {
+ if (!lm.isIdentity()) {
+ if (fPreLocalMatrix) {
+ fStorage.setConcat(lm, *fPreLocalMatrix);
+ fPreLocalMatrix = fStorage.isIdentity() ? nullptr : &fStorage;
+ } else {
+ fPreLocalMatrix = &lm;
+ }
+ }
+ }
+
+private:
+ WithPreLocalMatrix(const WithPreLocalMatrix&) = delete;
+ WithPreLocalMatrix& operator=(const WithPreLocalMatrix&) = delete;
+
+ SkMatrix fStorage;
+
+ using INHERITED = GrFPArgs;
+};
+
+class GrFPArgs::WithPostLocalMatrix final : public GrFPArgs {
+public:
+ WithPostLocalMatrix(const GrFPArgs& args, const SkMatrix& lm) : INHERITED(args) {
+ if (!lm.isIdentity()) {
+ if (fPostLocalMatrix) {
+ fStorage.setConcat(*fPostLocalMatrix, lm);
+ fPostLocalMatrix = fStorage.isIdentity() ? nullptr : &fStorage;
+ } else {
+ fPostLocalMatrix = &lm;
+ }
+ }
+ }
+
+private:
+ WithPostLocalMatrix(const WithPostLocalMatrix&) = delete;
+ WithPostLocalMatrix& operator=(const WithPostLocalMatrix&) = delete;
+
+ SkMatrix fStorage;
+
+ using INHERITED = GrFPArgs;
+};
+
#endif
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
index 8958f84704..2aff35dad2 100644
--- a/src/gpu/GrTestUtils.cpp
+++ b/src/gpu/GrTestUtils.cpp
@@ -337,8 +337,7 @@ TestAsFPArgs::TestAsFPArgs(GrProcessorTestData* d)
: fViewMatrixStorage(TestMatrix(d->fRandom))
, fColorSpaceInfoStorage(skstd::make_unique<GrColorSpaceInfo>(TestColorSpace(d->fRandom),
kRGBA_8888_GrPixelConfig))
- , fArgs(d->context(), &fViewMatrixStorage, nullptr, kNone_SkFilterQuality,
- fColorSpaceInfoStorage.get())
+ , fArgs(d->context(), &fViewMatrixStorage, kNone_SkFilterQuality, fColorSpaceInfoStorage.get())
{}
TestAsFPArgs::~TestAsFPArgs() {}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index eb26ba2f9b..fca372eabd 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1092,7 +1092,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special1, int left, int top, const
if (tmpUnfiltered.getMaskFilter()) {
SkMatrix ctm = this->ctm();
ctm.postTranslate(-SkIntToScalar(left + offset.fX), -SkIntToScalar(top + offset.fY));
- tmpUnfiltered.setMaskFilter(tmpUnfiltered.getMaskFilter()->makeWithLocalMatrix(ctm));
+ tmpUnfiltered.setMaskFilter(tmpUnfiltered.getMaskFilter()->makeWithMatrix(ctm));
}
tmpUnfiltered.setImageFilter(nullptr);
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index b4cb22bd10..99465f620b 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -514,7 +514,7 @@ bool SkPaintToGrPaintWithTexture(GrContext* context,
if (textureIsAlphaOnly) {
if (const auto* shader = as_SB(paint.getShader())) {
shaderFP = shader->asFragmentProcessor(GrFPArgs(
- context, &viewM, nullptr, paint.getFilterQuality(), &colorSpaceInfo));
+ context, &viewM, paint.getFilterQuality(), &colorSpaceInfo));
if (!shaderFP) {
return false;
}