Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: include/gpu/effects/GrAdvancedEquationXferProcessor.h

Issue 1037123003: Implement support for KHR_blend_equation_advanced (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_zzz2_barriers
Patch Set: Addressed comments Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/gpu/effects/GrAdvancedEquationXferProcessor.h
diff --git a/include/gpu/effects/GrAdvancedEquationXferProcessor.h b/include/gpu/effects/GrAdvancedEquationXferProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..dd5f063f858d8bd6f49b0b4952cc638ec1d90c58
--- /dev/null
+++ b/include/gpu/effects/GrAdvancedEquationXferProcessor.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrAdvancedEquationXferProcessor_DEFINED
+#define GrAdvancedEquationXferProcessor_DEFINED
+
+#include "GrTypes.h"
+#include "GrXferProcessor.h"
+
+/**
+ * Provides Xfer processors that implement advanced SVG/PDF blend modes in hardware, without the
+ * need for a dst texture. Can only be used if supported by the GPU.
+ */
+class GrAdvancedEquationXPFactory : public GrXPFactory {
+public:
+ static bool IsSupported(const GrContext*, SkXfermode::Mode);
+ static GrXPFactory* Create(SkXfermode::Mode);
+
+ bool canTweakAlphaForCoverage() const override;
+ bool supportsRGBCoverage(GrColor, uint32_t) const override;
+
+ void getInvariantOutput(const GrProcOptInfo&, const GrProcOptInfo&,
+ GrXPFactory::InvariantOutput* output) const override {
+ // Advanced blend modes all use the dst color, even when src alpha is 1, so we can't make
+ // any conclusions about the output without knowing something about the dst.
+ output->fWillBlendWithDst = true;
+ output->fBlendedColorFlags = 0;
+ }
+
+private:
+ template<GrBlendEquation> static GrXPFactory* RefFactory();
+
+ GrAdvancedEquationXPFactory(GrBlendEquation equation) : fEquation(equation) {}
+
+ GrXferProcessor* onCreateXferProcessor(const GrDrawTargetCaps& caps,
+ const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ const GrDeviceCoordTexture* dstCopy) const override;
+
+ bool willReadDstColor(const GrDrawTargetCaps&, const GrProcOptInfo&,
+ const GrProcOptInfo&) const override {
+ return false;
+ }
+
+ bool onIsEqual(const GrXPFactory& xpfBase) const override {
+ const GrAdvancedEquationXPFactory& xpf = xpfBase.cast<GrAdvancedEquationXPFactory>();
+ return fEquation == xpf.fEquation;
+ }
+
+ const GrBlendEquation fEquation;
+
+ GR_DECLARE_XP_FACTORY_TEST;
+
+ typedef GrXPFactory INHERITED;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698