[graphite] Distribute key creation to SkShaders
Bug: skia:12701 Change-Id: I33d24fc319acbfbb3a218a8dd916c5a64f15f028 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/503342 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
9a7acd43c4
commit
433504300a
@ -43,18 +43,18 @@ sk_sp<SkShader> PaintParams::refShader() const { return fShader; }
|
||||
void PaintParams::toKey(SkShaderCodeDictionary* dict,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniforms) const {
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
|
||||
if (fShader) {
|
||||
as_SB(fShader)->addToKey(dict, backend, key, uniforms);
|
||||
as_SB(fShader)->addToKey(dict, backend, key, uniformBlock);
|
||||
} else {
|
||||
SolidColorShaderBlock::AddToKey(backend, key, uniforms, fColor);
|
||||
SolidColorShaderBlock::AddToKey(backend, key, uniformBlock, fColor);
|
||||
}
|
||||
|
||||
if (fBlender) {
|
||||
as_BB(fBlender)->addToKey(dict, backend, key, uniforms);
|
||||
as_BB(fBlender)->addToKey(dict, backend, key, uniformBlock);
|
||||
} else {
|
||||
BlendModeBlock::AddToKey(backend, key, uniforms, SkBlendMode::kSrcOver);
|
||||
BlendModeBlock::AddToKey(backend, key, uniformBlock, SkBlendMode::kSrcOver);
|
||||
}
|
||||
|
||||
SkASSERT(key->sizeInBytes() > 0);
|
||||
|
@ -63,12 +63,12 @@ sk_sp<SkBlender> SkBlender::Mode(SkBlendMode mode) {
|
||||
void SkBlenderBase::addToKey(SkShaderCodeDictionary* dict,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniforms) const {
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
|
||||
if (skstd::optional<SkBlendMode> bm = as_BB(this)->asBlendMode(); bm.has_value()) {
|
||||
BlendModeBlock::AddToKey(backend, key, uniforms, bm.value());
|
||||
BlendModeBlock::AddToKey(backend, key, uniformBlock, bm.value());
|
||||
} else {
|
||||
BlendModeBlock::AddToKey(backend, key, uniforms, SkBlendMode::kSrcOver);
|
||||
BlendModeBlock::AddToKey(backend, key, uniformBlock, SkBlendMode::kSrcOver);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ void validate_block_header(const SkPaintParamsKey& key, int headerOffset,
|
||||
SkPaintParamsKey::kBlockHeaderSizeInBytes + blockDataSize);
|
||||
}
|
||||
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
void add_blendmode_to_key(SkPaintParamsKey* key, SkBlendMode bm) {
|
||||
SkASSERT(static_cast<int>(bm) <= std::numeric_limits<uint8_t>::max());
|
||||
key->addByte(static_cast<uint8_t>(bm));
|
||||
@ -53,7 +54,9 @@ SkTileMode to_tilemode(uint8_t data) {
|
||||
SkASSERT(data <= static_cast<int>(SkTileMode::kLastTileMode));
|
||||
return static_cast<SkTileMode>(data);
|
||||
}
|
||||
#endif
|
||||
#endif // SK_DEBUG
|
||||
|
||||
#endif // SK_GRAPHITE_ENABLED
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
@ -128,6 +131,7 @@ void AddToKey(SkBackend backend,
|
||||
if (uniformBlock) {
|
||||
uniformBlock->add(make_solid_uniform_data(color));
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif // SK_GRAPHITE_ENABLED
|
||||
|
||||
@ -181,14 +185,13 @@ sk_sp<SkUniformData> make_linear_gradient_uniform_data(const GradientData& gradD
|
||||
SkSpan<const SkUniform> uniforms = skgpu::GetUniforms(CodeSnippetID::kLinearGradientShader);
|
||||
SkASSERT(uniforms.size() == kExpectedNumGradientUniforms);
|
||||
|
||||
float unusedRadius = 0.0f;
|
||||
const void* srcs[kExpectedNumGradientUniforms] = {
|
||||
gradData.fColor4fs,
|
||||
gradData.fOffsets,
|
||||
&gradData.fPoints[0],
|
||||
&gradData.fPoints[1],
|
||||
&unusedRadius,
|
||||
&unusedRadius,
|
||||
&gradData.fRadii[0], // unused
|
||||
&gradData.fRadii[1], // unused
|
||||
};
|
||||
|
||||
return make_gradient_uniform_data_common(uniforms, srcs);
|
||||
@ -199,16 +202,13 @@ sk_sp<SkUniformData> make_radial_gradient_uniform_data(const GradientData& gradD
|
||||
SkSpan<const SkUniform> uniforms = skgpu::GetUniforms(CodeSnippetID::kRadialGradientShader);
|
||||
SkASSERT(uniforms.size() == kExpectedNumGradientUniforms);
|
||||
|
||||
SkPoint unusedPoint = {0.0f, 0.0f};
|
||||
float unusedRadius = 0.0f;
|
||||
|
||||
const void* srcs[kExpectedNumGradientUniforms] = {
|
||||
gradData.fColor4fs,
|
||||
gradData.fOffsets,
|
||||
&gradData.fPoints[0],
|
||||
&unusedPoint,
|
||||
&gradData.fPoints[1], // unused
|
||||
&gradData.fRadii[0],
|
||||
&unusedRadius,
|
||||
&gradData.fRadii[1], // unused
|
||||
};
|
||||
|
||||
return make_gradient_uniform_data_common(uniforms, srcs);
|
||||
@ -219,16 +219,13 @@ sk_sp<SkUniformData> make_sweep_gradient_uniform_data(const GradientData& gradDa
|
||||
SkSpan<const SkUniform> uniforms = skgpu::GetUniforms(CodeSnippetID::kSweepGradientShader);
|
||||
SkASSERT(uniforms.size() == kExpectedNumGradientUniforms);
|
||||
|
||||
SkPoint unusedPoint = {0.0f, 0.0f};
|
||||
float unusedRadius = 0.0f;
|
||||
|
||||
const void* srcs[kExpectedNumGradientUniforms] = {
|
||||
gradData.fColor4fs,
|
||||
gradData.fOffsets,
|
||||
&gradData.fPoints[0],
|
||||
&unusedPoint,
|
||||
&unusedRadius,
|
||||
&unusedRadius,
|
||||
&gradData.fPoints[1], // unused
|
||||
&gradData.fRadii[0], // unused
|
||||
&gradData.fRadii[1], // unused
|
||||
};
|
||||
|
||||
return make_gradient_uniform_data_common(uniforms, srcs);
|
||||
@ -255,7 +252,6 @@ sk_sp<SkUniformData> make_conical_gradient_uniform_data(const GradientData& grad
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
GradientData::GradientData(SkShader::GradientType type,
|
||||
SkTileMode tm,
|
||||
int numStops)
|
||||
@ -311,6 +307,39 @@ void GradientData::toOffsets(int numStops, float inputOffsets[kMaxStops]) {
|
||||
}
|
||||
}
|
||||
|
||||
GradientData::GradientData(SkShader::GradientType type,
|
||||
SkPoint point0, SkPoint point1,
|
||||
float radius0, float radius1,
|
||||
SkTileMode tm,
|
||||
int numStops,
|
||||
SkColor4f* color4fs,
|
||||
float* offsets)
|
||||
: fType(type)
|
||||
, fTM(tm)
|
||||
, fNumStops(std::min(numStops, kMaxStops)) {
|
||||
SkASSERT(fNumStops >= 1);
|
||||
|
||||
fPoints[0] = point0;
|
||||
fPoints[1] = point1;
|
||||
fRadii[0] = radius0;
|
||||
fRadii[1] = radius1;
|
||||
memcpy(fColor4fs, color4fs, fNumStops * sizeof(SkColor4f));
|
||||
if (offsets) {
|
||||
memcpy(fOffsets, offsets, fNumStops * sizeof(float));
|
||||
} else {
|
||||
for (int i = 0; i < fNumStops; ++i) {
|
||||
fOffsets[i] = SkIntToFloat(i) / (fNumStops-1);
|
||||
}
|
||||
}
|
||||
|
||||
// Extend the colors and offset, if necessary, to fill out the arrays
|
||||
// TODO: this should be done later when the actual code snippet has been selected!!
|
||||
for (int i = fNumStops ; i < kMaxStops; ++i) {
|
||||
fColor4fs[i] = fColor4fs[fNumStops-1];
|
||||
fOffsets[i] = fOffsets[fNumStops-1];
|
||||
}
|
||||
}
|
||||
|
||||
void AddToKey(SkBackend backend,
|
||||
SkPaintParamsKey *key,
|
||||
SkUniformBlock* uniformBlock,
|
||||
@ -359,6 +388,7 @@ void AddToKey(SkBackend backend,
|
||||
key->endBlock(headerOffset, codeSnippetID);
|
||||
|
||||
validate_block_header(*key, headerOffset, codeSnippetID, kBlockDataSize);
|
||||
return;
|
||||
}
|
||||
#endif // SK_GRAPHITE_ENABLED
|
||||
|
||||
@ -423,6 +453,8 @@ void Dump(const SkPaintParamsKey& key, int headerOffset) {
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
namespace ImageShaderBlock {
|
||||
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
|
||||
inline static constexpr int kTileModeBits = 2;
|
||||
|
||||
static const int kXTileModeShift = 0;
|
||||
@ -444,13 +476,16 @@ ImageData ExtractFromKey(const SkPaintParamsKey& key, uint32_t headerOffset) {
|
||||
|
||||
return { tmX, tmY };
|
||||
}
|
||||
#endif
|
||||
#endif // SK_DEBUG
|
||||
|
||||
#endif // SK_GRAPHITE_ENABLED
|
||||
|
||||
void AddToKey(SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniformBlock,
|
||||
const ImageData& imgData) {
|
||||
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
if (backend == SkBackend::kGraphite) {
|
||||
|
||||
uint8_t data = (static_cast<uint8_t>(imgData.fTileModes[0]) << kXTileModeShift) |
|
||||
@ -463,7 +498,11 @@ void AddToKey(SkBackend backend,
|
||||
key->endBlock(headerOffset, CodeSnippetID::kImageShader);
|
||||
|
||||
SkASSERT(imgData == ExtractFromKey(*key, headerOffset));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
#endif // SK_GRAPHITE_ENABLED
|
||||
|
||||
if (backend == SkBackend::kSkVM || backend == SkBackend::kGanesh) {
|
||||
// TODO: add implementation for other backends
|
||||
SolidColorShaderBlock::AddToKey(backend, key, uniformBlock, SkColors::kRed);
|
||||
}
|
||||
@ -471,13 +510,17 @@ void AddToKey(SkBackend backend,
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void Dump(const SkPaintParamsKey& key, int headerOffset) {
|
||||
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
ImageData imgData = ExtractFromKey(key, headerOffset);
|
||||
|
||||
SkDebugf("kImageShader: tileModes(%s, %s) ",
|
||||
SkTileModeToStr(imgData.fTileModes[0]),
|
||||
SkTileModeToStr(imgData.fTileModes[1]));
|
||||
#endif // SK_GRAPHITE_ENABLED
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif // SK_DEBUG
|
||||
|
||||
} // namespace ImageShaderBlock
|
||||
|
||||
@ -489,6 +532,7 @@ void AddToKey(SkBackend backend,
|
||||
SkUniformBlock* uniformBlock,
|
||||
const BlendData& blendData) {
|
||||
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
if (backend == SkBackend::kGraphite) {
|
||||
int headerOffset = key->beginBlock(CodeSnippetID::kBlendShader);
|
||||
|
||||
@ -503,10 +547,13 @@ void AddToKey(SkBackend backend,
|
||||
|
||||
key->endBlock(headerOffset, CodeSnippetID::kBlendShader);
|
||||
|
||||
int expectedBlockSize = SkPaintParamsKey::kBlockHeaderSizeInBytes +
|
||||
1 + firstShaderSize + secondShaderSize;
|
||||
int expectedBlockSize = 1 + firstShaderSize + secondShaderSize;
|
||||
validate_block_header(*key, headerOffset, CodeSnippetID::kBlendShader, expectedBlockSize);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
#endif // SK_GRAPHITE_ENABLED
|
||||
|
||||
if (backend == SkBackend::kSkVM || backend == SkBackend::kGanesh) {
|
||||
// TODO: add implementation for other backends
|
||||
SolidColorShaderBlock::AddToKey(backend, key, uniformBlock, SkColors::kRed);
|
||||
}
|
||||
@ -514,6 +561,7 @@ void AddToKey(SkBackend backend,
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void Dump(const SkPaintParamsKey& key, int headerOffset) {
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
auto [id, storedBlockSize] = key.readCodeSnippetID(headerOffset);
|
||||
SkASSERT(id == CodeSnippetID::kBlendShader);
|
||||
|
||||
@ -535,6 +583,7 @@ void Dump(const SkPaintParamsKey& key, int headerOffset) {
|
||||
int calculatedBlockSize = SkPaintParamsKey::kBlockHeaderSizeInBytes +
|
||||
firstBlockSize + secondBlockSize + 1;
|
||||
SkASSERT(calculatedBlockSize == storedBlockSize);
|
||||
#endif// SK_GRAPHITE_ENABLED
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -543,34 +592,52 @@ void Dump(const SkPaintParamsKey& key, int headerOffset) {
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
namespace BlendModeBlock {
|
||||
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
static const int kBlockDataSize = 1;
|
||||
#endif
|
||||
|
||||
void AddToKey(SkBackend /* backend */,
|
||||
void AddToKey(SkBackend backend,
|
||||
SkPaintParamsKey *key,
|
||||
SkUniformBlock* uniformBlock,
|
||||
SkBlendMode bm) {
|
||||
|
||||
int headerOffset = key->beginBlock(CodeSnippetID::kSimpleBlendMode);
|
||||
add_blendmode_to_key(key, bm);
|
||||
key->endBlock(headerOffset, CodeSnippetID::kSimpleBlendMode);
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
if (backend == SkBackend::kGraphite) {
|
||||
int headerOffset = key->beginBlock(CodeSnippetID::kSimpleBlendMode);
|
||||
add_blendmode_to_key(key, bm);
|
||||
key->endBlock(headerOffset, CodeSnippetID::kSimpleBlendMode);
|
||||
|
||||
validate_block_header(*key, headerOffset,
|
||||
CodeSnippetID::kSimpleBlendMode, kBlockDataSize);
|
||||
validate_block_header(*key, headerOffset,
|
||||
CodeSnippetID::kSimpleBlendMode, kBlockDataSize);
|
||||
return;
|
||||
}
|
||||
#endif// SK_GRAPHITE_ENABLED
|
||||
|
||||
if (backend == SkBackend::kSkVM || backend == SkBackend::kGanesh) {
|
||||
// TODO: add implementation for other backends
|
||||
SolidColorShaderBlock::AddToKey(backend, key, uniformBlock, SkColors::kRed);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
SkBlendMode ExtractFromKey(const SkPaintParamsKey& key, uint32_t headerOffset) {
|
||||
validate_block_header(key, headerOffset,
|
||||
CodeSnippetID::kSimpleBlendMode, kBlockDataSize);
|
||||
validate_block_header(key, headerOffset, CodeSnippetID::kSimpleBlendMode, kBlockDataSize);
|
||||
|
||||
uint8_t data = key.byte(headerOffset + SkPaintParamsKey::kBlockHeaderSizeInBytes);
|
||||
return to_blendmode(data);
|
||||
}
|
||||
#endif // SK_GRAPHITE_ENABLED
|
||||
|
||||
void Dump(const SkPaintParamsKey& key, int headerOffset) {
|
||||
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
SkBlendMode bm = ExtractFromKey(key, headerOffset);
|
||||
|
||||
SkDebugf("kSimpleBlendMode: %s\n", SkBlendMode_Name(bm));
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -67,6 +67,14 @@ namespace GradientShaderBlocks {
|
||||
SkColor colors[kMaxStops],
|
||||
float offsets[kMaxStops]);
|
||||
|
||||
GradientData(SkShader::GradientType,
|
||||
SkPoint point0, SkPoint point1,
|
||||
float radius0, float radius1,
|
||||
SkTileMode,
|
||||
int numStops,
|
||||
SkColor4f* colors,
|
||||
float* offsets);
|
||||
|
||||
bool operator==(const GradientData& rhs) const {
|
||||
return fType == rhs.fType &&
|
||||
fPoints[0] == rhs.fPoints[0] &&
|
||||
|
@ -5,15 +5,17 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/shaders/SkColorShader.h"
|
||||
|
||||
#include "include/core/SkColorSpace.h"
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "src/core/SkColorSpacePriv.h"
|
||||
#include "src/core/SkColorSpaceXformSteps.h"
|
||||
#include "src/core/SkKeyHelpers.h"
|
||||
#include "src/core/SkRasterPipeline.h"
|
||||
#include "src/core/SkReadBuffer.h"
|
||||
#include "src/core/SkUtils.h"
|
||||
#include "src/core/SkVM.h"
|
||||
#include "src/shaders/SkColorShader.h"
|
||||
|
||||
SkColorShader::SkColorShader(SkColor c) : fColor(c) {}
|
||||
|
||||
@ -134,3 +136,17 @@ std::unique_ptr<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void SkColorShader::addToKey(SkShaderCodeDictionary* dict,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
SolidColorShaderBlock::AddToKey(backend, key, uniformBlock, SkColor4f::FromColor(fColor));
|
||||
}
|
||||
|
||||
void SkColor4Shader::addToKey(SkShaderCodeDictionary* dict,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
SolidColorShaderBlock::AddToKey(backend, key, uniformBlock, fColor);
|
||||
}
|
||||
|
@ -31,6 +31,10 @@ public:
|
||||
#if SK_SUPPORT_GPU
|
||||
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
|
||||
#endif
|
||||
void addToKey(SkShaderCodeDictionary*,
|
||||
SkBackend,
|
||||
SkPaintParamsKey*,
|
||||
SkUniformBlock*) const override;
|
||||
|
||||
private:
|
||||
SK_FLATTENABLE_HOOKS(SkColorShader)
|
||||
@ -61,6 +65,10 @@ public:
|
||||
#if SK_SUPPORT_GPU
|
||||
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
|
||||
#endif
|
||||
void addToKey(SkShaderCodeDictionary*,
|
||||
SkBackend,
|
||||
SkPaintParamsKey*,
|
||||
SkUniformBlock*) const override;
|
||||
|
||||
private:
|
||||
SK_FLATTENABLE_HOOKS(SkColor4Shader)
|
||||
|
@ -192,9 +192,9 @@ std::unique_ptr<GrFragmentProcessor> SkShader_Blend::asFragmentProcessor(
|
||||
void SkShader_Blend::addToKey(SkShaderCodeDictionary* dict,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniforms) const {
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
// TODO: add blender support
|
||||
SkASSERT(!fBlender);
|
||||
|
||||
BlendShaderBlock::AddToKey(backend, key, uniforms, { fDst.get(), fSrc.get(), fMode });
|
||||
BlendShaderBlock::AddToKey(backend, key, uniformBlock, { fDst.get(), fSrc.get(), fMode });
|
||||
}
|
||||
|
@ -376,8 +376,8 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
|
||||
void SkImageShader::addToKey(SkShaderCodeDictionary* dict,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniforms) const {
|
||||
ImageShaderBlock::AddToKey(backend, key, uniforms, { fTileModeX, fTileModeY });
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
ImageShaderBlock::AddToKey(backend, key, uniformBlock, { fTileModeX, fTileModeY });
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -153,8 +153,8 @@ SkUpdatableShader* SkShaderBase::onUpdatableShader(SkArenaAlloc* alloc) const {
|
||||
void SkShaderBase::addToKey(SkShaderCodeDictionary* dictionary,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniforms) const {
|
||||
SolidColorShaderBlock::AddToKey(backend, key, uniforms, SkColors::kRed);
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
SolidColorShaderBlock::AddToKey(backend, key, uniformBlock, SkColors::kRed);
|
||||
}
|
||||
|
||||
sk_sp<SkShader> SkShaders::Empty() { return sk_make_sp<SkEmptyShader>(); }
|
||||
|
@ -218,14 +218,15 @@ public:
|
||||
Add implementation details, for the specified backend, of this SkShader to the
|
||||
provided key.
|
||||
|
||||
@param dictionary dictionary of code fragments available to be used in the key
|
||||
@param backend the backend that would be carrying out the drawing
|
||||
@param key destination for implementation details of this SkShader
|
||||
@param dictionary dictionary of code fragments available to be used in the key
|
||||
@param backend the backend that would be carrying out the drawing
|
||||
@param key destination for implementation details of this SkShader
|
||||
@param uniformBlock if non-null, storage for this shader's uniform data
|
||||
*/
|
||||
virtual void addToKey(SkShaderCodeDictionary* dictionary,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock*) const;
|
||||
SkUniformBlock* uniformBlock) const;
|
||||
|
||||
protected:
|
||||
SkShaderBase(const SkMatrix* localMatrix = nullptr);
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "src/shaders/gradients/SkLinearGradient.h"
|
||||
|
||||
#include "src/core/SkKeyHelpers.h"
|
||||
#include "src/core/SkReadBuffer.h"
|
||||
#include "src/core/SkWriteBuffer.h"
|
||||
#include "src/shaders/gradients/Sk4fLinearGradient.h"
|
||||
@ -102,3 +103,18 @@ std::unique_ptr<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void SkLinearGradient::addToKey(SkShaderCodeDictionary* dict,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
GradientShaderBlocks::GradientData data(kLinear_GradientType,
|
||||
fStart, fEnd,
|
||||
0.0f, 0.0f,
|
||||
fTileMode,
|
||||
fColorCount,
|
||||
fOrigColors4f,
|
||||
fOrigPos);
|
||||
|
||||
GradientShaderBlocks::AddToKey(backend, key, uniformBlock, data);
|
||||
}
|
||||
|
@ -18,6 +18,10 @@ public:
|
||||
#if SK_SUPPORT_GPU
|
||||
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
|
||||
#endif
|
||||
void addToKey(SkShaderCodeDictionary*,
|
||||
SkBackend,
|
||||
SkPaintParamsKey*,
|
||||
SkUniformBlock*) const override;
|
||||
|
||||
protected:
|
||||
SkLinearGradient(SkReadBuffer& buffer);
|
||||
|
@ -5,10 +5,12 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/shaders/gradients/SkRadialGradient.h"
|
||||
|
||||
#include "src/core/SkKeyHelpers.h"
|
||||
#include "src/core/SkRasterPipeline.h"
|
||||
#include "src/core/SkReadBuffer.h"
|
||||
#include "src/core/SkWriteBuffer.h"
|
||||
#include "src/shaders/gradients/SkRadialGradient.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -80,3 +82,18 @@ std::unique_ptr<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void SkRadialGradient::addToKey(SkShaderCodeDictionary* dict,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
GradientShaderBlocks::GradientData data(kRadial_GradientType,
|
||||
fCenter, { 0.0f, 0.0f },
|
||||
fRadius, 0.0f,
|
||||
fTileMode,
|
||||
fColorCount,
|
||||
fOrigColors4f,
|
||||
fOrigPos);
|
||||
|
||||
GradientShaderBlocks::AddToKey(backend, key, uniformBlock, data);
|
||||
}
|
||||
|
@ -18,6 +18,10 @@ public:
|
||||
#if SK_SUPPORT_GPU
|
||||
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
|
||||
#endif
|
||||
void addToKey(SkShaderCodeDictionary*,
|
||||
SkBackend,
|
||||
SkPaintParamsKey*,
|
||||
SkUniformBlock*) const override;
|
||||
|
||||
protected:
|
||||
SkRadialGradient(SkReadBuffer& buffer);
|
||||
|
@ -5,11 +5,13 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/shaders/gradients/SkSweepGradient.h"
|
||||
|
||||
#include "include/private/SkFloatingPoint.h"
|
||||
#include "src/core/SkKeyHelpers.h"
|
||||
#include "src/core/SkRasterPipeline.h"
|
||||
#include "src/core/SkReadBuffer.h"
|
||||
#include "src/core/SkWriteBuffer.h"
|
||||
#include "src/shaders/gradients/SkSweepGradient.h"
|
||||
|
||||
SkSweepGradient::SkSweepGradient(const SkPoint& center, SkScalar t0, SkScalar t1,
|
||||
const Descriptor& desc)
|
||||
@ -104,3 +106,18 @@ std::unique_ptr<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void SkSweepGradient::addToKey(SkShaderCodeDictionary* dict,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
GradientShaderBlocks::GradientData data(kSweep_GradientType,
|
||||
fCenter, { 0.0f, 0.0f },
|
||||
0.0, 0.0f,
|
||||
fTileMode,
|
||||
fColorCount,
|
||||
fOrigColors4f,
|
||||
fOrigPos);
|
||||
|
||||
GradientShaderBlocks::AddToKey(backend, key, uniformBlock, data);
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ public:
|
||||
#if SK_SUPPORT_GPU
|
||||
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
|
||||
#endif
|
||||
void addToKey(SkShaderCodeDictionary*,
|
||||
SkBackend,
|
||||
SkPaintParamsKey*,
|
||||
SkUniformBlock*) const override;
|
||||
|
||||
SkScalar getTBias() const { return fTBias; }
|
||||
|
||||
|
@ -5,11 +5,13 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/shaders/gradients/SkTwoPointConicalGradient.h"
|
||||
|
||||
#include "include/private/SkFloatingPoint.h"
|
||||
#include "src/core/SkKeyHelpers.h"
|
||||
#include "src/core/SkRasterPipeline.h"
|
||||
#include "src/core/SkReadBuffer.h"
|
||||
#include "src/core/SkWriteBuffer.h"
|
||||
#include "src/shaders/gradients/SkTwoPointConicalGradient.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@ -274,3 +276,18 @@ std::unique_ptr<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProces
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void SkTwoPointConicalGradient::addToKey(SkShaderCodeDictionary* dict,
|
||||
SkBackend backend,
|
||||
SkPaintParamsKey* key,
|
||||
SkUniformBlock* uniformBlock) const {
|
||||
GradientShaderBlocks::GradientData data(kConical_GradientType,
|
||||
fCenter1, fCenter2,
|
||||
fRadius1, fRadius2,
|
||||
fTileMode,
|
||||
fColorCount,
|
||||
fOrigColors4f,
|
||||
fOrigPos);
|
||||
|
||||
GradientShaderBlocks::AddToKey(backend, key, uniformBlock, data);
|
||||
}
|
||||
|
@ -51,6 +51,11 @@ public:
|
||||
#if SK_SUPPORT_GPU
|
||||
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
|
||||
#endif
|
||||
void addToKey(SkShaderCodeDictionary*,
|
||||
SkBackend,
|
||||
SkPaintParamsKey*,
|
||||
SkUniformBlock*) const override;
|
||||
|
||||
bool isOpaque() const override;
|
||||
|
||||
SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
|
||||
|
@ -41,7 +41,7 @@ sk_sp<SkShader> make_blend_shader(sk_sp<SkShader> shaderA,
|
||||
|
||||
void dump_keys(SkShaderCodeDictionary *dict, const SkPaint &paint) {
|
||||
#ifdef SK_DEBUG
|
||||
auto keys = SkPaintPriv::ToKeys(paint, dict, SkBackend::kGanesh);
|
||||
auto keys = SkPaintPriv::ToKeys(paint, dict, SkBackend::kGraphite);
|
||||
|
||||
for (auto k: keys) {
|
||||
// TODO: we need a better way to assess that key creation succeeded
|
||||
|
Loading…
Reference in New Issue
Block a user