I am currently working with Skia and need to implement a blending shader that modifies the color at a given (x, y) coordinate based on the original color at that location. Ideally, I would like to use GL_EXT_shader_framebuffer_fetch to access the existing framebuffer color directly within the fragment shader.
I am aware that an alternative approach would be to use surface->makeImageSnapshot() to create a sampler, but this method is significantly slow and introduces high overhead. Therefore, I am looking for a more efficient way to achieve this within Skia.
Does Skia support GL_EXT_shader_framebuffer_fetch, or is there an alternative method that can efficiently provide access to the previous framebuffer color?
This is my code below:
```
float rectPos[2] = {float(rect.fLeft), float(rect.fTop)};
// 创建 shader,并应用在 canvas 上
SkSamplingOptions linear(SkFilterMode::kLinear, SkMipmapMode::kNone);
SkRuntimeShaderBuilder TmuaBuild(mTmuaEffect);
TmuaBuild.child("blurBackground") = downSampleBlurImage->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, linear, nullptr);
TmuaBuild.child("number") = number->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, linear, nullptr);
TmuaBuild.uniform("rectPos").set(rectPos, 2);
// TmuaBuild.uniform("scaleArg") = SkV4{1.0f / scale, 1.0f, 1.0f, 0.0f};
// 绘制 shader 到 canvas
paint.setShader(TmuaBuild.makeShader());
canvas->drawRect(rect, paint);
sk_sp<SkImage> background = surface->makeImageSnapshot();
SkRuntimeShaderBuilder TvcmEffectBuild(mTvcmEffect);
TvcmEffectBuild.child("background") = background->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, linear, nullptr);
TvcmEffectBuild.child("number") = number->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, linear, nullptr);
TvcmEffectBuild.uniform("rectPos").set(rectPos, 2);
// 绘制 shader 到 canvas
paint.setShader(TvcmEffectBuild.makeShader());
canvas->drawRect(rect, paint);
```
On Feb 7, 2025, at 10:02 PM, 程洋 <d171...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/skia-discuss/bbad895b-c5c9-42c4-baa1-6ed76fed1b3en%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/skia-discuss/36736b36-2518-49b3-b7b0-6d7b0859184cn%40googlegroups.com.