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

Unified Diff: src/core/SkColorSpaceXform.h

Issue 1952063002: Create SkColorSpaceXform to handle color conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Comments Created 4 years, 7 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: src/core/SkColorSpaceXform.h
diff --git a/src/core/SkColorSpaceXform.h b/src/core/SkColorSpaceXform.h
new file mode 100644
index 0000000000000000000000000000000000000000..8e58f0f42e40f5b10958602553411d0b22dd6364
--- /dev/null
+++ b/src/core/SkColorSpaceXform.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkColorSpaceXform_DEFINED
+#define SkColorSpaceXform_DEFINED
+
+#include "SkColorSpace.h"
+
+class SkColorSpaceXform {
+public:
+
+ enum Op {
+ kSrcToLinear_Op, // Apply src gamma
+ kSrcToLinearDstGamut_Op, // Apply src gamma and matrix
+ kSrcToDst_Op, // Apply src gamma, matrix, and dst gamma
+ };
+
+ /**
+ * Create an object to handle color space conversions.
+ *
+ * @param srcSpace The encoded color space. This is required if the conversion op
+ * will begin in the encoded gamut. Otherwise it may be nullptr.
+ * @param dstSpace The destination color space. This is required if the conversion op
+ * will finish in the destination gamut. Otherwise it may be nullptr.
+ * @param op Indicates the start and end point of the conversion.
+ *
+ */
+ static SkColorSpaceXform* New(sk_sp<SkColorSpace> srcSpace, sk_sp<SkColorSpace> dstSpace,
+ Op op);
+
+ /**
+ * Apply the color conversion to a src buffer, storing the output in the dst buffer.
Brian Osman 2016/05/05 13:29:44 Should probably document that this assumes (requir
msarett 2016/05/05 15:49:05 Yes you're right! I think it makes sense to start
+ */
+ virtual void apply(void* dst, const void* src, const SkISize& size, size_t dstRowBytes,
+ size_t srcRowBytes) const = 0;
+
+ virtual ~SkColorSpaceXform() {}
+};
+
+class SkGammaByValueXform : public SkColorSpaceXform {
+public:
+
+ void apply(void* dst, const void* src, const SkISize& size, size_t dstRowBytes,
+ size_t srcRowBytes) const override;
+
+private:
+ SkGammaByValueXform(const SkFloat3& gammas);
+
+ const SkFloat3 fGammas;
+
+ friend class SkColorSpaceXform;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698