Remove SkPaint::getHash
This was a particularly bad hash (A == B didn't imply hash(A) == hash(B)). It was also entirely unused. Change-Id: Id923bf1035effce04e12b1cc01d1c6aa4d11fdb6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419336 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
b2cb817d23
commit
cc2d073020
@ -6,7 +6,8 @@ This file includes a list of high level updates for each milestone release.
|
||||
|
||||
Milestone 93
|
||||
------------
|
||||
*
|
||||
* Removed SkPaint::getHash
|
||||
https://review.skia.org/419336
|
||||
|
||||
* * *
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
// Copyright 2019 Google LLC.
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
#include "tools/fiddle/examples.h"
|
||||
// HASH=7f7e1b701361912b344f90ae6b530393
|
||||
REG_FIDDLE(Paint_getHash, 256, 256, true, 0) {
|
||||
void draw(SkCanvas* canvas) {
|
||||
SkPaint paint1, paint2;
|
||||
paint1.setColor(SK_ColorRED);
|
||||
paint2.setColor(0xFFFF0000);
|
||||
SkDebugf("paint1 %c= paint2\n", paint1 == paint2 ? '=' : '!');
|
||||
SkDebugf("paint1.getHash() %c= paint2.getHash()\n",
|
||||
paint1.getHash() == paint2.getHash() ? '=' : '!');
|
||||
}
|
||||
} // END FIDDLE
|
@ -144,22 +144,6 @@ public:
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
/** Returns a hash generated from SkPaint values and pointers.
|
||||
Identical hashes guarantee that the paints are
|
||||
equivalent, but differing hashes do not guarantee that the paints have differing
|
||||
contents.
|
||||
|
||||
If operator==(const SkPaint& a, const SkPaint& b) returns true for two paints,
|
||||
their hashes are also equal.
|
||||
|
||||
The hash returned is platform and implementation specific.
|
||||
|
||||
@return a shallow hash
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_getHash
|
||||
*/
|
||||
uint32_t getHash() const;
|
||||
|
||||
/** Sets all SkPaint contents to their initial values. This is equivalent to replacing
|
||||
SkPaint with the result of SkPaint().
|
||||
|
||||
|
@ -439,12 +439,3 @@ bool SkPaint::nothingToDraw() const {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t SkPaint::getHash() const {
|
||||
// We're going to hash 5 pointers and 6 floats, finishing up with fBitfields,
|
||||
// so fBitfields should be 5 pointers and 6 floats from the start.
|
||||
static_assert(offsetof(SkPaint, fBitfieldsUInt) == 5 * sizeof(void*) + 6 * sizeof(float),
|
||||
"SkPaint_notPackedTightly");
|
||||
return SkOpts::hash(reinterpret_cast<const uint32_t*>(this),
|
||||
offsetof(SkPaint, fBitfieldsUInt) + sizeof(fBitfieldsUInt));
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ DEF_TEST(Paint_copy, reporter) {
|
||||
|
||||
// copy the paint using the copy constructor and check they are the same
|
||||
SkPaint copiedPaint = paint;
|
||||
REPORTER_ASSERT(reporter, paint.getHash() == copiedPaint.getHash());
|
||||
REPORTER_ASSERT(reporter, paint == copiedPaint);
|
||||
|
||||
// copy the paint using the equal operator and check they are the same
|
||||
@ -163,26 +162,6 @@ DEF_TEST(Paint_MoreFlattening, r) {
|
||||
ASSERT(other.getBlendMode() == paint.getBlendMode());
|
||||
}
|
||||
|
||||
DEF_TEST(Paint_getHash, r) {
|
||||
// Try not to inspect the actual hash values in here.
|
||||
// We might want to change the hash function.
|
||||
|
||||
SkPaint paint;
|
||||
const uint32_t defaultHash = paint.getHash();
|
||||
|
||||
// Check that some arbitrary field affects the hash.
|
||||
paint.setColor(0xFF00FF00);
|
||||
REPORTER_ASSERT(r, paint.getHash() != defaultHash);
|
||||
paint.setColor(SK_ColorBLACK); // Reset to default value.
|
||||
REPORTER_ASSERT(r, paint.getHash() == defaultHash);
|
||||
|
||||
// This is part of fBitfields, the last field we hash.
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
REPORTER_ASSERT(r, paint.getHash() != defaultHash);
|
||||
paint.setBlendMode(SkBlendMode::kSrcOver);
|
||||
REPORTER_ASSERT(r, paint.getHash() == defaultHash);
|
||||
}
|
||||
|
||||
#include "include/effects/SkColorMatrixFilter.h"
|
||||
|
||||
DEF_TEST(Paint_nothingToDraw, r) {
|
||||
|
@ -530,7 +530,6 @@
|
||||
#include "../../docs/examples/Paint_getFlags.cpp"
|
||||
#include "../../docs/examples/Paint_getFontMetrics.cpp"
|
||||
#include "../../docs/examples/Paint_getFontSpacing.cpp"
|
||||
#include "../../docs/examples/Paint_getHash.cpp"
|
||||
#include "../../docs/examples/Paint_getHinting.cpp"
|
||||
#include "../../docs/examples/Paint_getImageFilter.cpp"
|
||||
#include "../../docs/examples/Paint_getMaskFilter.cpp"
|
||||
|
@ -2044,10 +2044,6 @@ SkScalar getFontMetrics(SkFontMetrics* metrics) const;
|
||||
SkPaint
|
||||
SkScalar getFontSpacing() const;
|
||||
|
||||
[Paint_getHash]
|
||||
SkPaint
|
||||
uint32_t getHash() const;
|
||||
|
||||
[Paint_getHinting]
|
||||
SkPaint
|
||||
SkFontHinting getHinting() const;
|
||||
|
Loading…
Reference in New Issue
Block a user