aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmapDevice.cpp2
-rw-r--r--src/core/SkImageFilter.cpp2
-rw-r--r--src/core/SkSpecialImage.cpp3
-rw-r--r--src/effects/imagefilters/SkArithmeticImageFilter.cpp2
-rw-r--r--src/effects/imagefilters/SkDisplacementMapEffect.cpp7
-rw-r--r--src/effects/imagefilters/SkLightingImageFilter.cpp2
-rw-r--r--src/effects/imagefilters/SkMorphologyImageFilter.cpp2
-rw-r--r--src/effects/imagefilters/SkXfermodeImageFilter.cpp2
-rw-r--r--src/gpu/SkGpuDevice.cpp6
-rw-r--r--src/gpu/SkGr.cpp14
-rw-r--r--src/gpu/SkGr.h8
-rw-r--r--src/image/SkImage.cpp3
-rw-r--r--src/pdf/SkPDFDevice.cpp4
13 files changed, 20 insertions, 37 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 0d1ec8ddc5..08c36d3980 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -643,7 +643,7 @@ void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPain
SkMatrix::MakeTrans(SkIntToScalar(-x), SkIntToScalar(-y)), this->ctm());
const SkIRect clipBounds = fRCStack.rc().getBounds().makeOffset(-x, -y);
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
- SkImageFilter::OutputProperties outputProperties(fBitmap.colorSpace());
+ SkImageFilter::OutputProperties outputProperties(fBitmap.colorType(), fBitmap.colorSpace());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), outputProperties);
filteredImage = filter->filterImage(src, ctx, &offset);
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index f6d2c63547..e6ea213146 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -247,7 +247,7 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
- GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get());
+ GrPixelConfig config = SkColorType2GrPixelConfig(outputProperties.colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, bounds.width(), bounds.height(),
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 0d229a1530..240b8dd6a7 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -432,10 +432,9 @@ public:
return nullptr;
}
- SkColorSpace* colorSpace = outProps.colorSpace();
return SkSpecialSurface::MakeRenderTarget(
fContext, size.width(), size.height(),
- GrRenderableConfigForColorSpace(colorSpace), sk_ref_sp(colorSpace));
+ SkColorType2GrPixelConfig(outProps.colorType()), sk_ref_sp(outProps.colorSpace()));
}
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
index 3fc065536b..e392d55581 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -350,7 +350,7 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, bounds.width(), bounds.height(),
- GrRenderableConfigForColorSpace(outputProperties.colorSpace()),
+ SkColorType2GrPixelConfig(outputProperties.colorType()),
sk_ref_sp(outputProperties.colorSpace())));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
index 8983fcacbd..026c03ea07 100644
--- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp
+++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
@@ -243,7 +243,8 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
// With a more complex DAG attached to this input, it's not clear that working in ANY specific
// color space makes sense, so we ignore color spaces (and gamma) entirely. This may not be
// ideal, but it's at least consistent and predictable.
- Context displContext(ctx.ctm(), ctx.clipBounds(), ctx.cache(), OutputProperties(nullptr));
+ Context displContext(ctx.ctm(), ctx.clipBounds(), ctx.cache(),
+ OutputProperties(kN32_SkColorType, nullptr));
sk_sp<SkSpecialImage> displ(this->filterInput(0, source, displContext, &displOffset));
if (!displ) {
return nullptr;
@@ -308,12 +309,12 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
+ GrPixelConfig config = SkColorType2GrPixelConfig(ctx.outputProperties().colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
bounds.width(), bounds.height(),
- GrRenderableConfigForColorSpace(colorSpace),
- sk_ref_sp(colorSpace)));
+ config, sk_ref_sp(colorSpace)));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp
index 659dbbca27..9a560b4ceb 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -469,7 +469,7 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, offsetBounds.width(), offsetBounds.height(),
- GrRenderableConfigForColorSpace(outputProperties.colorSpace()),
+ SkColorType2GrPixelConfig(outputProperties.colorType()),
sk_ref_sp(outputProperties.colorSpace())));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
index 6fe4e09949..899c5a1d57 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -466,7 +466,7 @@ static sk_sp<SkSpecialImage> apply_morphology(
sk_sp<GrTextureProxy> srcTexture(input->asTextureProxyRef(context));
SkASSERT(srcTexture);
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
- GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get());
+ GrPixelConfig config = SkColorType2GrPixelConfig(outputProperties.colorType());
// setup new clip
const GrFixedClip clip(SkIRect::MakeWH(srcTexture->width(), srcTexture->height()));
diff --git a/src/effects/imagefilters/SkXfermodeImageFilter.cpp b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
index 7393ab9485..fef28f1d57 100644
--- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp
+++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
@@ -319,7 +319,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter_Base::filterImageGPU(
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, bounds.width(), bounds.height(),
- GrRenderableConfigForColorSpace(outputProperties.colorSpace()),
+ SkColorType2GrPixelConfig(outputProperties.colorType()),
sk_ref_sp(outputProperties.colorSpace())));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index a665517d4f..ffe237f803 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -183,8 +183,12 @@ sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(SkSpecialImage* srcImg,
matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
const SkIRect clipBounds = this->devClipBounds().makeOffset(-left, -top);
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
+ SkColorType colorType;
+ if (!GrPixelConfigToColorType(fRenderTargetContext->colorSpaceInfo().config(), &colorType)) {
+ colorType = kN32_SkColorType;
+ }
SkImageFilter::OutputProperties outputProperties(
- fRenderTargetContext->colorSpaceInfo().colorSpace());
+ colorType, fRenderTargetContext->colorSpaceInfo().colorSpace());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), outputProperties);
return filter->filterImage(srcImg, ctx, offset);
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index cc2b8fda9e..ff2b9843e8 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -274,20 +274,6 @@ bool GrPixelConfigToColorType(GrPixelConfig config, SkColorType* ctOut) {
return false;
}
-GrPixelConfig GrRenderableConfigForColorSpace(const SkColorSpace* colorSpace) {
- if (!colorSpace) {
- return kRGBA_8888_GrPixelConfig;
- } else if (colorSpace->gammaIsLinear()) {
- // TODO
- return kRGBA_half_GrPixelConfig;
- } else if (colorSpace->gammaCloseToSRGB()) {
- return kSRGBA_8888_GrPixelConfig;
- } else {
- SkDEBUGFAIL("No renderable config exists for color space with strange gamma");
- return kUnknown_GrPixelConfig;
- }
-}
-
////////////////////////////////////////////////////////////////////////////////////////////////
static inline bool blend_requires_shader(const SkBlendMode mode) {
diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h
index b766105613..a2ac670712 100644
--- a/src/gpu/SkGr.h
+++ b/src/gpu/SkGr.h
@@ -245,12 +245,4 @@ void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima
removed should the bitmap's contents change or be destroyed. */
void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pixelRef);
-//////////////////////////////////////////////////////////////////////////////
-
-/** When image filter code needs to construct a render target context to do intermediate rendering,
- we need a renderable pixel config. The source (SkSpecialImage) may not be in a renderable
- format, but we want to preserve the color space of that source. This picks an appropriate format
- to use. */
-GrPixelConfig GrRenderableConfigForColorSpace(const SkColorSpace*);
-
#endif
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 43c4cbaa39..128e693ad2 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -256,6 +256,7 @@ sk_sp<SkImage> SkImage::makeWithFilter(const SkImageFilter* filter, const SkIRec
if (!filter || !outSubset || !offset || !this->bounds().contains(subset)) {
return nullptr;
}
+ SkColorType colorType = as_IB(this)->onImageInfo().colorType();
SkColorSpace* colorSpace = as_IB(this)->onImageInfo().colorSpace();
sk_sp<SkSpecialImage> srcSpecialImage = SkSpecialImage::MakeFromImage(
subset, sk_ref_sp(const_cast<SkImage*>(this)), colorSpace);
@@ -265,7 +266,7 @@ sk_sp<SkImage> SkImage::makeWithFilter(const SkImageFilter* filter, const SkIRec
sk_sp<SkImageFilterCache> cache(
SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize));
- SkImageFilter::OutputProperties outputProperties(colorSpace);
+ SkImageFilter::OutputProperties outputProperties(colorType, colorSpace);
SkImageFilter::Context context(SkMatrix::I(), clipBounds, cache.get(), outputProperties);
sk_sp<SkSpecialImage> result = filter->filterImage(srcSpecialImage.get(), context, offset);
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 2d2e27bf1f..6868aefe5c 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -2342,9 +2342,9 @@ void SkPDFDevice::drawSpecial(SkSpecialImage* srcImg, int x, int y, const SkPain
const SkIRect clipBounds =
this->cs().bounds(this->bounds()).roundOut().makeOffset(-x, -y);
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
- // TODO: Should PDF be operating in a specified color space? For now, run the filter
+ // TODO: Should PDF be operating in a specified color type/space? For now, run the filter
// in the same color space as the source (this is different from all other backends).
- SkImageFilter::OutputProperties outputProperties(srcImg->getColorSpace());
+ SkImageFilter::OutputProperties outputProperties(kN32_SkColorType, srcImg->getColorSpace());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), outputProperties);
sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset));