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

Unified Diff: include/effects/SkLumaXfermode.h

Issue 22918012: Add luminance mask transfer modes. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix VS builds (no named variadic macro params support) Created 7 years, 4 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/effects/SkLumaXfermode.h
diff --git a/include/effects/SkLumaXfermode.h b/include/effects/SkLumaXfermode.h
new file mode 100644
index 0000000000000000000000000000000000000000..b64c94d63fe1ba0d0b2f54f1195a971c54976021
--- /dev/null
+++ b/include/effects/SkLumaXfermode.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkLumaXfermode_DEFINED
+#define SkLumaXfermode_DEFINED
+
+#include "SkXfermode.h"
+
+/**
+ * Luminance mask transfer, as defined in
+ * http://www.w3.org/TR/SVG/masking.html#Masking
+ * http://www.w3.org/TR/css-masking/#MaskValues
+ *
+ * The luminance-to-alpha function is applied before performing a standard
+ * SrcIn or DstIn xfer:
reed1 2013/08/22 18:35:51 Is this list (srcin, dstin) complete, or just e.g.
f(malita) 2013/08/22 19:25:52 It is complete with regard to SVG/CSS masking supp
+ *
+ * luma(C) = (0.2125 * C.r + 0.7154 * C.g + 0.0721 * C.b) * C.a
reed1 2013/08/22 18:35:51 Can you document what happens to the resulting r,g
f(malita) 2013/08/22 19:25:52 Will do.
+ *
+ * The only supported submodes are SrcIn and DstIn.
+ */
+class SK_API SkLumaMaskXfermode : public SkXfermode {
+public:
+ static SkXfermode* Create(SkXfermode::Mode);
reed1 2013/08/22 18:35:51 Should you support another Create that takes SkXfe
f(malita) 2013/08/22 19:25:52 This ties into the decision to support arbitrary t
+
+ virtual SkPMColor xferColor(SkPMColor, SkPMColor) const SK_OVERRIDE;
+ virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
+ const SkAlpha aa[]) const SK_OVERRIDE;
+
+ SK_DEVELOPER_TO_STRING()
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaMaskXfermode)
+
+#if SK_SUPPORT_GPU
+ virtual bool asNewEffectOrCoeff(GrContext*, GrEffectRef**, Coeff*, Coeff*,
+ GrTexture*) const SK_OVERRIDE;
+#endif
+
+protected:
+ SkLumaMaskXfermode(SkFlattenableReadBuffer&);
+ virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
+
+private:
+ SkLumaMaskXfermode(SkXfermode::Mode);
+
+ const SkXfermode::Mode fMode;
+
+ typedef SkXfermode INHERITED;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698