aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@google.com>2017-03-18 15:36:52 +0000
committerGravatar Mike Klein <mtklein@google.com>2017-03-18 15:55:38 +0000
commit919cc4562cc615c7f4b4325def1f7454bc8dd724 (patch)
treedbf70b84856146df503b3102932ab51f077ee7c7 /dm
parentc09e88ca95a53d77eea95ea916283c724e44791c (diff)
Revert "Revert "Add color spin test for SkColorSpaceXformCanvas""
This reverts commit 73e21af21390c2806eb1350253233903808edd6b. Reason for revert: I will fix the broken bot next week. Original change's description: > Revert "Add color spin test for SkColorSpaceXformCanvas" > > This reverts commit cb01aec63bcb3dee52afcf3605bcd64166b873c0. > > Reason for revert: Breaks Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE > > Original change's description: > > Add color spin test for SkColorSpaceXformCanvas > > > > Also changes behavior to treat nullptr srcs as sRGB. > > > > Testing locally, it looks like 353 gms have no diffs from 8888. > > There are 269 diffs - some are fine (gms that do color space stuff) > > and some are bugs. > > > > BUG=skia: > > > > Change-Id: I55c2825f4f4b857e0b0a0ec050c6db82ac881492 > > Reviewed-on: https://skia-review.googlesource.com/9738 > > Reviewed-by: Brian Osman <brianosman@google.com> > > Commit-Queue: Matt Sarett <msarett@google.com> > > > > TBR=mtklein@google.com,msarett@google.com,brianosman@google.com,reviews@skia.org > # Not skipping CQ checks because original CL landed > 1 day ago. > BUG=skia: > > Change-Id: I70bb69f747b863d267494e37a60888a51ab0184c > Reviewed-on: https://skia-review.googlesource.com/9823 > Reviewed-by: Eric Boren <borenet@google.com> > Commit-Queue: Eric Boren <borenet@google.com> > TBR=borenet@google.com,mtklein@google.com,msarett@google.com,reviews@skia.org,brianosman@google.com # Not skipping CQ checks because original CL landed > 1 day ago. BUG=skia: Change-Id: I766382e6655f614042cded84f547f9fd5b109fca Reviewed-on: https://skia-review.googlesource.com/9879 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
Diffstat (limited to 'dm')
-rw-r--r--dm/DM.cpp20
-rw-r--r--dm/DMSrcSink.cpp32
-rw-r--r--dm/DMSrcSink.h3
3 files changed, 51 insertions, 4 deletions
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 4b51030557..d3d12393a6 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -14,6 +14,7 @@
#include "SkCodec.h"
#include "SkColorPriv.h"
#include "SkColorSpace.h"
+#include "SkColorSpacePriv.h"
#include "SkCommonFlags.h"
#include "SkCommonFlagsConfig.h"
#include "SkCommonFlagsPathRenderer.h"
@@ -895,9 +896,26 @@ static sk_sp<SkColorSpace> adobe_rgb() {
SkColorSpace::kAdobeRGB_Gamut);
}
+static sk_sp<SkColorSpace> rgb_to_gbr() {
+ float gbr[9];
+ gbr[0] = gSRGB_toXYZD50[1];
+ gbr[1] = gSRGB_toXYZD50[2];
+ gbr[2] = gSRGB_toXYZD50[0];
+ gbr[3] = gSRGB_toXYZD50[4];
+ gbr[4] = gSRGB_toXYZD50[5];
+ gbr[5] = gSRGB_toXYZD50[3];
+ gbr[6] = gSRGB_toXYZD50[7];
+ gbr[7] = gSRGB_toXYZD50[8];
+ gbr[8] = gSRGB_toXYZD50[6];
+ SkMatrix44 toXYZD50(SkMatrix44::kUninitialized_Constructor);
+ toXYZD50.set3x3RowMajorf(gbr);
+ return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, toXYZD50);
+}
+
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("adobe", ViaCSXform, wrapped, adobe_rgb(), false);
+ VIA("gbr", ViaCSXform, wrapped, rgb_to_gbr(), true);
VIA("lite", ViaLite, wrapped);
VIA("pipe", ViaPipe, wrapped);
VIA("twice", ViaTwice, wrapped);
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 "";
});
}
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index c973e3b393..b6e1b5955c 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -496,10 +496,11 @@ public:
class ViaCSXform : public Via {
public:
- explicit ViaCSXform(Sink*, sk_sp<SkColorSpace>);
+ explicit ViaCSXform(Sink*, sk_sp<SkColorSpace>, bool colorSpin);
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
private:
sk_sp<SkColorSpace> fCS;
+ bool fColorSpin;
};
} // namespace DM