aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMSrcSink.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-10-31 16:41:29 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-31 21:03:14 +0000
commit5b7e470a5b622f5a9bdd81803a23540b3e4e4cf7 (patch)
tree7d8ff50d038e625bc2e286437a9496f0c7dca9ba /dm/DMSrcSink.cpp
parente26062a169e2ff15436b715ea237a0342a4abf55 (diff)
Use color filter to undo GBR (actually BRG)
This allows the via to work with GPU (where we don't render to N32). Change-Id: I42e8457731a5ee51d14f7092eebd6efe72decd84 Reviewed-on: https://skia-review.googlesource.com/65822 Commit-Queue: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'dm/DMSrcSink.cpp')
-rw-r--r--dm/DMSrcSink.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 8e36f0c669..6af90c3a47 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -2153,10 +2153,13 @@ ViaCSXform::ViaCSXform(Sink* sink, sk_sp<SkColorSpace> cs, bool 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);
- Error err = src.draw(proxy.get());
- if (!err.isEmpty()) {
- return err;
+ {
+ SkAutoCanvasRestore acr(canvas, true);
+ auto proxy = SkCreateColorSpaceXformCanvas(canvas, fCS);
+ Error err = src.draw(proxy.get());
+ if (!err.isEmpty()) {
+ return err;
+ }
}
// Undo the color spin, so we can look at the pixels in Gold.
@@ -2164,19 +2167,15 @@ Error ViaCSXform::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkSt
SkBitmap pixels;
pixels.allocPixels(canvas->imageInfo());
canvas->readPixels(pixels, 0, 0);
- for (int y = 0; y < pixels.height(); y++) {
- uint32_t* row = pixels.getAddr32(0,y);
- for (int x = 0; x < pixels.width(); x++) {
- uint32_t pixel = *row;
- uint8_t r = SkGetPackedR32(pixel);
- uint8_t g = SkGetPackedG32(pixel);
- uint8_t b = SkGetPackedB32(pixel);
- uint8_t a = SkGetPackedA32(pixel);
- *row++ = SkSwizzle_RGBA_to_PMColor(b << 0 | r << 8 | g << 16 | a << 24);
- }
- }
- canvas->writePixels(pixels, 0, 0);
+ SkPaint rotateColors;
+ SkScalar matrix[20] = { 0, 0, 1, 0, 0, // B -> R
+ 1, 0, 0, 0, 0, // R -> G
+ 0, 1, 0, 0, 0, // G -> B
+ 0, 0, 0, 1, 0 };
+ rotateColors.setBlendMode(SkBlendMode::kSrc);
+ rotateColors.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
+ canvas->drawBitmap(pixels, 0, 0, &rotateColors);
}
return "";