Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/ColorBehavior.h |
| diff --git a/third_party/WebKit/Source/platform/graphics/ColorBehavior.h b/third_party/WebKit/Source/platform/graphics/ColorBehavior.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..80fd4854e4ba913ace4f28c023185619aec07ae2 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/graphics/ColorBehavior.h |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ColorBehavior_h |
| +#define ColorBehavior_h |
| + |
| +#include "platform/PlatformExport.h" |
| +#include "public/platform/WebVector.h" |
| +#include "third_party/skia/include/core/SkRefCnt.h" |
| + |
| +class SkColorSpace; |
| + |
| +namespace blink { |
| + |
| +class PLATFORM_EXPORT ColorBehavior { |
| + public: |
| + // This specifies to ignore color profiles embedded in images entirely. No |
| + // transformations will be applied to any pixel data, and no SkImages will be |
| + // tagged with an SkColorSpace. |
| + static inline ColorBehavior ignore() { |
| + return ColorBehavior(Type::Ignore, nullptr); |
| + } |
| + |
| + // This specifies that images will not be transformed (to the extent |
| + // possible), but that SkImages will be tagged with the embedded SkColorSpace |
| + // (or sRGB if there was no embedded color profile). |
| + static inline ColorBehavior tag() { |
| + return ColorBehavior(Type::Tag, nullptr); |
| + } |
| + |
| + // This specifies that images will be transformed to the specified target |
| + // color space, and that SkImages will not be tagged with any SkColorSpace. |
| + static inline ColorBehavior transformTo(sk_sp<SkColorSpace> target) { |
| + return ColorBehavior(Type::TransformTo, std::move(target)); |
| + } |
| + |
| + // Set the target color profile into which all images with embedded color |
| + // profiles should be converted. Note that only the first call to this |
| + // function in this process has any effect. |
| + static void setGlobalTargetColorProfile(const WebVector<char>&); |
| + static sk_sp<SkColorSpace> globalTargetColorSpace(); |
| + |
| + // Return the behavior of transforming to the color space specified above, or |
| + // sRGB, if the above has not yet been called. |
| + static ColorBehavior transformToGlobalTarget(); |
| + |
| + // Transform to a target color space to be used by tests. |
| + static ColorBehavior transformToTargetForTesting(); |
| + |
| + enum class Type { |
| + Ignore, |
|
pdr.
2016/12/07 19:29:37
These are referenced outside this class but it's h
ccameron
2016/12/07 20:31:38
Added isIgnore/isTransformToTargetColorSpace metho
|
| + Tag, |
| + TransformTo, |
| + }; |
| + Type type() const { return m_type; } |
| + sk_sp<SkColorSpace> targetColorSpace() const { return m_target; } |
| + |
| + private: |
| + ColorBehavior(Type type, sk_sp<SkColorSpace> target) |
| + : m_type(type), m_target(std::move(target)) {} |
| + Type m_type; |
| + sk_sp<SkColorSpace> m_target; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // ColorBehavior_h |