[graphite] Reduce maintainance issues wrt SkPaintParamKey dumping
Bug: skia:12701 Change-Id: I75afb5115743f59b0626d43c6ada4f5a3813422f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/494137 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
4ec5259b90
commit
00f71133a8
@ -19,7 +19,7 @@ void AddToKey(SkPaintParamsKey* key) {
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void Dump(const SkPaintParamsKey& key, uint32_t headerOffset) {
|
||||
void Dump(const SkPaintParamsKey& key, int headerOffset) {
|
||||
SkASSERT(key.byte(headerOffset) == (uint8_t) CodeSnippetID::kDepthStencilOnlyDraw);
|
||||
SkASSERT(key.byte(headerOffset+1) == 2);
|
||||
|
||||
@ -38,7 +38,7 @@ void AddToKey(SkPaintParamsKey* key) {
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void Dump(const SkPaintParamsKey& key, uint32_t headerOffset) {
|
||||
void Dump(const SkPaintParamsKey& key, int headerOffset) {
|
||||
SkASSERT(key.byte(headerOffset) == (uint8_t) CodeSnippetID::kSolidColorShader);
|
||||
SkASSERT(key.byte(headerOffset+1) == 2);
|
||||
|
||||
@ -97,7 +97,7 @@ std::pair<CodeSnippetID, SkTileMode> ExtractFromKey(const SkPaintParamsKey& key,
|
||||
return { id, tm };
|
||||
}
|
||||
|
||||
void Dump(const SkPaintParamsKey& key, uint32_t headerOffset) {
|
||||
void Dump(const SkPaintParamsKey& key, int headerOffset) {
|
||||
auto [id, tm] = ExtractFromKey(key, headerOffset);
|
||||
|
||||
switch (id) {
|
||||
@ -140,7 +140,7 @@ SkBlendMode ExtractFromKey(const SkPaintParamsKey& key, uint32_t headerOffset) {
|
||||
return static_cast<SkBlendMode>(key.byte(headerOffset+2));
|
||||
}
|
||||
|
||||
void Dump(const SkPaintParamsKey& key, uint32_t headerOffset) {
|
||||
void Dump(const SkPaintParamsKey& key, int headerOffset) {
|
||||
SkBlendMode bm = ExtractFromKey(key, headerOffset);
|
||||
|
||||
SkDebugf("kSimpleBlendMode: %s\n", SkBlendMode_Name(bm));
|
||||
|
@ -24,7 +24,7 @@ namespace DepthStencilOnlyBlock {
|
||||
|
||||
void AddToKey(SkPaintParamsKey*);
|
||||
#ifdef SK_DEBUG
|
||||
void Dump(const SkPaintParamsKey&, uint32_t headerOffset);
|
||||
void Dump(const SkPaintParamsKey&, int headerOffset);
|
||||
#endif
|
||||
|
||||
} // namespace DepthStencilOnlyBlock
|
||||
@ -33,7 +33,7 @@ namespace SolidColorShaderBlock {
|
||||
|
||||
void AddToKey(SkPaintParamsKey*);
|
||||
#ifdef SK_DEBUG
|
||||
void Dump(const SkPaintParamsKey&, uint32_t headerOffset);
|
||||
void Dump(const SkPaintParamsKey&, int headerOffset);
|
||||
#endif
|
||||
|
||||
} // namespace SolidColorShaderBlock
|
||||
@ -43,7 +43,7 @@ namespace GradientShaderBlocks {
|
||||
|
||||
void AddToKey(SkPaintParamsKey*, SkShader::GradientType, SkTileMode);
|
||||
#ifdef SK_DEBUG
|
||||
void Dump(const SkPaintParamsKey&, uint32_t headerOffset);
|
||||
void Dump(const SkPaintParamsKey&, int headerOffset);
|
||||
#endif
|
||||
|
||||
} // namespace GradientShaderBlocks
|
||||
@ -52,7 +52,7 @@ namespace BlendModeBlock {
|
||||
|
||||
void AddToKey(SkPaintParamsKey*, SkBlendMode);
|
||||
#ifdef SK_DEBUG
|
||||
void Dump(const SkPaintParamsKey&, uint32_t headerOffset);
|
||||
void Dump(const SkPaintParamsKey&, int headerOffset);
|
||||
#endif
|
||||
|
||||
} // namespace BlendModeBlock
|
||||
|
@ -16,19 +16,38 @@ bool SkPaintParamsKey::operator==(const SkPaintParamsKey& that) const {
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
typedef void (*Dumper)(const SkPaintParamsKey&, uint32_t headerOffset);
|
||||
typedef void (*DumpMethod)(const SkPaintParamsKey&, int headerOffset);
|
||||
|
||||
static Dumper gDumpers[kCodeSnippetIDCount] = {
|
||||
DepthStencilOnlyBlock::Dump, // kDepthStencilOnlyDraw
|
||||
namespace {
|
||||
|
||||
SolidColorShaderBlock::Dump, // kSolidColorShader
|
||||
GradientShaderBlocks::Dump, // kLinearGradientShader
|
||||
GradientShaderBlocks::Dump, // kRadialGradientShader
|
||||
GradientShaderBlocks::Dump, // kSweepGradientShader
|
||||
GradientShaderBlocks::Dump, // kConicalGradientShader
|
||||
void dump_unknown_block(const SkPaintParamsKey& key, int headerOffset) {
|
||||
uint8_t id = key.byte(headerOffset);
|
||||
uint8_t blockSize = key.byte(headerOffset+1);
|
||||
SkASSERT(blockSize >= 2 && headerOffset+blockSize <= key.sizeInBytes());
|
||||
|
||||
BlendModeBlock::Dump, // kSimpleBlendMode
|
||||
};
|
||||
SkDebugf("Unknown block - id: %d size: %dB\n", id, blockSize);
|
||||
}
|
||||
|
||||
DumpMethod get_dump_method(CodeSnippetID id) {
|
||||
switch (id) {
|
||||
case CodeSnippetID::kDepthStencilOnlyDraw: return DepthStencilOnlyBlock::Dump;
|
||||
|
||||
// SkShader code snippets
|
||||
case CodeSnippetID::kSolidColorShader: return SolidColorShaderBlock::Dump;
|
||||
|
||||
case CodeSnippetID::kLinearGradientShader: [[fallthrough]];
|
||||
case CodeSnippetID::kRadialGradientShader: [[fallthrough]];
|
||||
case CodeSnippetID::kSweepGradientShader: [[fallthrough]];
|
||||
case CodeSnippetID::kConicalGradientShader: return GradientShaderBlocks::Dump;
|
||||
|
||||
// BlendMode code snippets
|
||||
case CodeSnippetID::kSimpleBlendMode: return BlendModeBlock::Dump;
|
||||
|
||||
default: return dump_unknown_block;
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// This just iterates over the top-level blocks calling block-specific dump methods.
|
||||
void SkPaintParamsKey::dump() const {
|
||||
@ -38,7 +57,7 @@ void SkPaintParamsKey::dump() const {
|
||||
while (curHeaderOffset < this->sizeInBytes()) {
|
||||
auto [codeSnippetID, blockSize] = this->readCodeSnippetID(curHeaderOffset);
|
||||
|
||||
(gDumpers[(int) codeSnippetID])(*this, curHeaderOffset);
|
||||
get_dump_method(codeSnippetID)(*this, curHeaderOffset);
|
||||
|
||||
curHeaderOffset += blockSize;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user