Matt Sarett | cdc651d | 2017-03-30 12:41:48 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkColorSpaceXformer_DEFINED |
| 9 | #define SkColorSpaceXformer_DEFINED |
| 10 | |
| 11 | #include "SkColorSpaceXform.h" |
| 12 | #include "SkImage.h" |
| 13 | #include "SkShader.h" |
| 14 | |
| 15 | class SkColorSpaceXformer : public SkNoncopyable { |
| 16 | public: |
| 17 | static std::unique_ptr<SkColorSpaceXformer> Make(sk_sp<SkColorSpace> dst); |
| 18 | |
| 19 | sk_sp<SkImage> apply(const SkImage* src); |
Matt Sarett | e684483 | 2017-04-03 10:35:42 -0400 | [diff] [blame] | 20 | sk_sp<SkImage> apply(const SkBitmap& bitmap); |
Matt Sarett | 6d72ed9 | 2017-04-10 16:35:33 -0400 | [diff] [blame] | 21 | sk_sp<SkColorFilter> apply(const SkColorFilter* shader); |
Matt Sarett | cdc651d | 2017-03-30 12:41:48 -0400 | [diff] [blame] | 22 | const SkPaint* apply(const SkPaint* src); |
| 23 | const SkPaint& apply(const SkPaint& src); |
| 24 | void apply(SkColor dst[], const SkColor src[], int n); |
Matt Sarett | 6d72ed9 | 2017-04-10 16:35:33 -0400 | [diff] [blame] | 25 | SkColor apply(SkColor srgb); |
Matt Sarett | cdc651d | 2017-03-30 12:41:48 -0400 | [diff] [blame] | 26 | |
Matt Sarett | e22a6a2 | 2017-04-12 16:26:21 -0400 | [diff] [blame^] | 27 | sk_sp<SkColorSpace> dst() const { return fDst; } |
| 28 | |
Matt Sarett | cdc651d | 2017-03-30 12:41:48 -0400 | [diff] [blame] | 29 | private: |
Matt Sarett | cdc651d | 2017-03-30 12:41:48 -0400 | [diff] [blame] | 30 | sk_sp<SkShader> apply(const SkShader* shader); |
| 31 | |
| 32 | SkColorSpaceXformer() {} |
| 33 | |
| 34 | sk_sp<SkColorSpace> fDst; |
| 35 | std::unique_ptr<SkColorSpaceXform> fFromSRGB; |
| 36 | SkPaint fDstPaint; |
| 37 | }; |
| 38 | |
| 39 | #endif |