aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/effects
diff options
context:
space:
mode:
authorGravatar Sadrul Habib Chowdhury <sadrul@chromium.org>2017-08-18 10:20:02 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-18 16:53:49 +0000
commit4189d1b8b7dfa62f10845b0afcadba3a956ec939 (patch)
tree34085badc5c840d2b92da7fff1a6aad35ff6df91 /include/effects
parent8009488d7f322dd43601b0ba273e3db62a2aaadd (diff)
Add SK_API to SkOverdrawCanvas and SkOverdrawColorFilter.
The SkiaRenderer in chromium is going to use the overdraw canvas and filter for measuring overdraw. Move these headers out of src/ into include/. Bug: chromium:704285 Change-Id: I2abb1671b73e3d26552462cf700340a7e3b874f0 Reviewed-on: https://skia-review.googlesource.com/36160 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include/effects')
-rw-r--r--include/effects/SkOverdrawColorFilter.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/include/effects/SkOverdrawColorFilter.h b/include/effects/SkOverdrawColorFilter.h
new file mode 100644
index 0000000000..ac97821269
--- /dev/null
+++ b/include/effects/SkOverdrawColorFilter.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkColorFilter.h"
+#include "SkFlattenable.h"
+
+#ifndef SkOverdrawColorFilter_DEFINED
+#define SkOverdrawColorFilter_DEFINED
+
+/**
+ * Uses the value in the src alpha channel to set the dst pixel.
+ * 0 -> fColors[0]
+ * 1 -> fColors[1]
+ * ...
+ * 5 (or larger) -> fColors[5]
+ *
+ */
+class SK_API SkOverdrawColorFilter : public SkColorFilter {
+public:
+ static constexpr int kNumColors = 6;
+
+ static sk_sp<SkOverdrawColorFilter> Make(const SkPMColor colors[kNumColors]) {
+ return sk_sp<SkOverdrawColorFilter>(new SkOverdrawColorFilter(colors));
+ }
+
+#if SK_SUPPORT_GPU
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrContext*,
+ SkColorSpace*) const override;
+#endif
+
+ void toString(SkString* str) const override;
+
+ static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer);
+ Factory getFactory() const override { return CreateProc; }
+ SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
+
+protected:
+ void flatten(SkWriteBuffer& buffer) const override;
+
+private:
+ SkOverdrawColorFilter(const SkPMColor colors[kNumColors]) {
+ memcpy(fColors, colors, kNumColors * sizeof(SkPMColor));
+ }
+
+ void onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, bool) const override;
+
+ SkPMColor fColors[kNumColors];
+
+ typedef SkColorFilter INHERITED;
+};
+
+#endif // SkOverdrawColorFilter_DEFINED