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); |
| 20 | const SkPaint* apply(const SkPaint* src); |
| 21 | const SkPaint& apply(const SkPaint& src); |
| 22 | void apply(SkColor dst[], const SkColor src[], int n); |
| 23 | |
| 24 | private: |
| 25 | SkColor apply(SkColor srgb); |
| 26 | sk_sp<SkShader> apply(const SkShader* shader); |
| 27 | |
| 28 | SkColorSpaceXformer() {} |
| 29 | |
| 30 | sk_sp<SkColorSpace> fDst; |
| 31 | std::unique_ptr<SkColorSpaceXform> fFromSRGB; |
| 32 | SkPaint fDstPaint; |
| 33 | }; |
| 34 | |
| 35 | #endif |