Fix color space matrix hashing to avoid hashing the typemask
BUG=skia: Change-Id: I8d4594fcf0eeebf598871bfe9203ed52460c98ce Reviewed-on: https://skia-review.googlesource.com/6558 Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
This commit is contained in:
parent
8c852be264
commit
e151bdb357
@ -491,7 +491,10 @@ private:
|
||||
return 0 == fTypeMask;
|
||||
}
|
||||
|
||||
inline const SkMScalar* values() const { return &fMat[0][0]; }
|
||||
|
||||
friend class SkColorSpace;
|
||||
friend class SkColorSpace_XYZ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -5,17 +5,17 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkChecksum.h"
|
||||
#include "SkColorSpace_XYZ.h"
|
||||
#include "SkColorSpacePriv.h"
|
||||
#include "SkColorSpaceXform_Base.h"
|
||||
#include "SkOpts.h"
|
||||
|
||||
SkColorSpace_XYZ::SkColorSpace_XYZ(SkGammaNamed gammaNamed, const SkMatrix44& toXYZD50)
|
||||
: INHERITED(nullptr)
|
||||
, fGammaNamed(gammaNamed)
|
||||
, fGammas(nullptr)
|
||||
, fToXYZD50(toXYZD50)
|
||||
, fToXYZD50Hash(SkGoodHash()(toXYZD50))
|
||||
, fToXYZD50Hash(SkOpts::hash_fn(toXYZD50.values(), 16 * sizeof(SkMScalar), 0))
|
||||
, fFromXYZD50(SkMatrix44::kUninitialized_Constructor)
|
||||
{}
|
||||
|
||||
@ -25,7 +25,7 @@ SkColorSpace_XYZ::SkColorSpace_XYZ(SkGammaNamed gammaNamed, sk_sp<SkGammas> gamm
|
||||
, fGammaNamed(gammaNamed)
|
||||
, fGammas(std::move(gammas))
|
||||
, fToXYZD50(toXYZD50)
|
||||
, fToXYZD50Hash(SkGoodHash()(toXYZD50))
|
||||
, fToXYZD50Hash(SkOpts::hash_fn(toXYZD50.values(), 16 * sizeof(SkMScalar), 0))
|
||||
, fFromXYZD50(SkMatrix44::kUninitialized_Constructor) {
|
||||
SkASSERT(!fGammas || 3 == fGammas->channels());
|
||||
if (fGammas) {
|
||||
|
@ -419,3 +419,23 @@ DEF_TEST(ColorSpace_InvalidICC, r) {
|
||||
sk_sp<SkColorSpace> cs = SkColorSpace::MakeICC(data->data(), data->size());
|
||||
REPORTER_ASSERT(r, !cs);
|
||||
}
|
||||
|
||||
DEF_TEST(ColorSpace_MatrixHash, r) {
|
||||
sk_sp<SkColorSpace> srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
|
||||
|
||||
SkColorSpaceTransferFn fn;
|
||||
fn.fA = 1.0f;
|
||||
fn.fB = 0.0f;
|
||||
fn.fC = 0.0f;
|
||||
fn.fD = 0.0f;
|
||||
fn.fE = 0.0f;
|
||||
fn.fF = 0.0f;
|
||||
fn.fG = 3.0f;
|
||||
|
||||
SkMatrix44 srgbMat(SkMatrix44::kUninitialized_Constructor);
|
||||
srgbMat.set3x3RowMajorf(gSRGB_toXYZD50);
|
||||
sk_sp<SkColorSpace> strange = SkColorSpace::MakeRGB(fn, srgbMat);
|
||||
|
||||
REPORTER_ASSERT(r, *as_CSB(srgb)->toXYZD50() == *as_CSB(strange)->toXYZD50());
|
||||
REPORTER_ASSERT(r, as_CSB(srgb)->toXYZD50Hash() == as_CSB(strange)->toXYZD50Hash());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user