}
static sk_sp<SkImage> make_image(SkCanvas* canvas) {
- const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
+ const SkImageInfo info = SkImageInfo::MakeS32(100, 100, kPremul_SkAlphaType);
auto surface(canvas->makeSurface(info));
if (!surface) {
surface = SkSurface::MakeRaster(info);
#if SK_SUPPORT_GPU
if (source->isTextureBacked()) {
GrContext* context = source->getContext();
+
+ // Ensure the input is in the destination's gamut. This saves us from having to do the
+ // xform during the filter itself.
+ input = ImageToColorSpace(input.get(), ctx.outputProperties());
+
sk_sp<GrTexture> inputTexture(input->asTextureRef(context));
if (!inputTexture) {
return nullptr;
offset->fY = dstBounds.fTop;
inputBounds.offset(-inputOffset);
dstBounds.offset(-inputOffset);
- // We intentionally use the source's color space, not the destination's (from ctx). We
- // always blur in the source's config, so we need a compatible color space. We also want to
- // avoid doing gamut conversion on every fetch of the texture.
+ // Typically, we would create the RTC with the output's color space (from ctx), but we
+ // always blur in the PixelConfig of the *input*. Those might not be compatible (if they
+ // have different transfer functions). We've already guaranteed that those color spaces
+ // have the same gamut, so in this case, we do everything in the input's color space.
sk_sp<GrRenderTargetContext> renderTargetContext(SkGpuBlurUtils::GaussianBlur(
context,
inputTexture.get(),
- sk_ref_sp(source->getColorSpace()),
+ sk_ref_sp(input->getColorSpace()),
dstBounds,
&inputBounds,
sigma.x(),
return nullptr;
}
- // TODO: Get the colorSpace from the renderTargetContext (once it has one)
return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(dstBounds.width(), dstBounds.height()),
kNeedNewImageUniqueID_SpecialImage,
renderTargetContext->asTexture(),
- sk_ref_sp(input->getColorSpace()), &source->props());
+ sk_ref_sp(renderTargetContext->getColorSpace()),
+ &source->props());
}
#endif
SkCanvas* canvas = surf->getCanvas();
SkASSERT(canvas);
- src->draw(canvas, 0, 0, nullptr);
+ SkPaint p;
+ p.setBlendMode(SkBlendMode::kSrc);
+ src->draw(canvas, 0, 0, &p);
return surf->makeImageSnapshot();
}
#endif