aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/effects/SkLumaColorFilter.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-07 18:00:17 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-07 18:00:17 +0000
commit6c1ee2d4e727357451c8a6fcf4a08e75890b5d6d (patch)
tree144de7ce27c8400a39866d0f53f7be49aa935cda /include/effects/SkLumaColorFilter.h
parentdd6cde5235d5d36607f4f1df66057d807b432b99 (diff)
Luminance-to-alpha color filter (SkLumaColorFilter).
Adding a color filter luma implementation. The plan is to convert existing clients and then deprecate SkLumaXfermode. R=bsalomon@google.com, reed@google.com, robertphillips@google.com Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/25453004 git-svn-id: http://skia.googlecode.com/svn/trunk@11636 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/effects/SkLumaColorFilter.h')
-rw-r--r--include/effects/SkLumaColorFilter.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/effects/SkLumaColorFilter.h b/include/effects/SkLumaColorFilter.h
new file mode 100644
index 0000000000..fef06ab12a
--- /dev/null
+++ b/include/effects/SkLumaColorFilter.h
@@ -0,0 +1,46 @@
+/*
+ * 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 SkLumaColorFilter_DEFINED
+#define SkLumaColorFilter_DEFINED
+
+#include "SkColorFilter.h"
+
+/**
+ * Luminance-to-alpha color filter, as defined in
+ * http://www.w3.org/TR/SVG/masking.html#Masking
+ * http://www.w3.org/TR/css-masking/#MaskValues
+ *
+ * Each color is scaled by the (unpremultiplied) luminance value:
+ *
+ * C' = [Lum * a, Lum * r, Lum * g, Lum * b]
+ *
+ */
+class SK_API SkLumaColorFilter : public SkColorFilter {
+public:
+ static SkColorFilter* Create();
+
+ virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const SK_OVERRIDE;
+
+#if SK_SUPPORT_GPU
+ virtual GrEffectRef* asNewEffect(GrContext*) const SK_OVERRIDE;
+#endif
+
+ SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter)
+
+protected:
+ SkLumaColorFilter(SkFlattenableReadBuffer& buffer);
+ virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
+
+private:
+ SkLumaColorFilter();
+
+ typedef SkColorFilter INHERITED;
+};
+
+#endif