diff options
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DM.cpp | 6 | ||||
-rw-r--r-- | dm/DMSrcSink.cpp | 13 | ||||
-rw-r--r-- | dm/DMSrcSink.h | 10 |
3 files changed, 28 insertions, 1 deletions
@@ -890,8 +890,14 @@ static Sink* create_sink(const GrContextOptions& grCtxOptions, const SkCommandLi return nullptr; } +static sk_sp<SkColorSpace> adobe_rgb() { + return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, + SkColorSpace::kAdobeRGB_Gamut); +} + static Sink* create_via(const SkString& tag, Sink* wrapped) { #define VIA(t, via, ...) if (tag.equals(t)) { return new via(__VA_ARGS__); } + VIA("adobe", ViaCSXform, wrapped, adobe_rgb()); VIA("lite", ViaLite, wrapped); VIA("pipe", ViaPipe, wrapped); VIA("twice", ViaTwice, wrapped); diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 6561ad9da3..4f5cd43af8 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -13,6 +13,7 @@ #include "SkCodecImageGenerator.h" #include "SkColorSpace.h" #include "SkColorSpaceXform.h" +#include "SkColorSpaceXformCanvas.h" #include "SkColorSpace_XYZ.h" #include "SkCommonFlags.h" #include "SkData.h" @@ -1839,4 +1840,16 @@ Error ViaLite::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStrin }); } +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + +ViaCSXform::ViaCSXform(Sink* sink, sk_sp<SkColorSpace> cs) : Via(sink), fCS(std::move(cs)) {} + +Error ViaCSXform::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const { + return draw_to_canvas(fSink.get(), bitmap, stream, log, src.size(), + [&](SkCanvas* canvas) -> Error { + auto proxy = SkCreateColorSpaceXformCanvas(canvas, fCS); + return src.draw(proxy.get()); + }); +} + } // namespace DM diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h index d4fe29de4e..c973e3b393 100644 --- a/dm/DMSrcSink.h +++ b/dm/DMSrcSink.h @@ -349,7 +349,7 @@ public: class PipeSink : public Sink { public: PipeSink(); - + Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; const char* fileExtension() const override { return "skpipe"; } SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } @@ -494,6 +494,14 @@ public: Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; }; +class ViaCSXform : public Via { +public: + explicit ViaCSXform(Sink*, sk_sp<SkColorSpace>); + Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; +private: + sk_sp<SkColorSpace> fCS; +}; + } // namespace DM #endif//DMSrcSink_DEFINED |