diff options
Diffstat (limited to 'dm/DMSrcSink.cpp')
-rw-r--r-- | dm/DMSrcSink.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 4f5cd43af8..14d5552789 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -1842,13 +1842,41 @@ 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)) {} +ViaCSXform::ViaCSXform(Sink* sink, sk_sp<SkColorSpace> cs, bool colorSpin) + : Via(sink) + , fCS(std::move(cs)) + , fColorSpin(colorSpin) {} 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()); + Error err = src.draw(proxy.get()); + if (!err.isEmpty()) { + return err; + } + + // Undo the color spin, so we can look at the pixels in Gold. + if (fColorSpin) { + SkBitmap pixels; + pixels.allocPixels(canvas->imageInfo()); + canvas->readPixels(&pixels, 0, 0); + for (int y = 0; y < pixels.height(); y++) { + for (int x = 0; x < pixels.width(); x++) { + uint32_t pixel = *pixels.getAddr32(x, y); + uint8_t r = SkGetPackedR32(pixel); + uint8_t g = SkGetPackedG32(pixel); + uint8_t b = SkGetPackedB32(pixel); + uint8_t a = SkGetPackedA32(pixel); + *pixels.getAddr32(x, y) = + SkSwizzle_RGBA_to_PMColor(b << 0 | r << 8 | g << 16 | a << 24); + } + } + + canvas->writePixels(pixels, 0, 0); + } + + return ""; }); } |