Revert "Reland "Preserve colorType and alphaType in SkImage::makeColorSpace""
This reverts commit893052ea51
. Reason for revert: Chrome roll layout failures. Original change's description: > Reland "Preserve colorType and alphaType in SkImage::makeColorSpace" > > This reverts commit0d08b3e4b1
. > > Reason for revert: Fixed Chrome test. > > Original change's description: > > Revert "Preserve colorType and alphaType in SkImage::makeColorSpace" > > > > This reverts commitd842557c07
. > > > > Reason for revert: Chrome roll failing CanvasAsyncBlobCreatorTest.ColorManagedConvertToBlob test. > > > > Original change's description: > > > Preserve colorType and alphaType in SkImage::makeColorSpace > > > > > > Raster images were always converting to N32, and GPU images were > > > always converting to premul. These were unexpected and inconsistent. > > > > > > Bug: skia:8382 > > > Change-Id: I78fe6cff1208eef077a71d08e676cf8f8d5fed9a > > > Reviewed-on: https://skia-review.googlesource.com/156142 > > > Commit-Queue: Brian Osman <brianosman@google.com> > > > Reviewed-by: Mike Klein <mtklein@google.com> > > > > TBR=mtklein@google.com,brianosman@google.com > > > > Change-Id: I366b097644ac1fa920fc9addcad3e09c2a0a63cc > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: skia:8382 > > Reviewed-on: https://skia-review.googlesource.com/156184 > > Reviewed-by: Brian Osman <brianosman@google.com> > > Commit-Queue: Brian Osman <brianosman@google.com> > > TBR=mtklein@google.com,brianosman@google.com > > Change-Id: I860f33a1d57e0e77ce63b78d66d49a1082d2b4dd > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:8382 > Reviewed-on: https://skia-review.googlesource.com/156188 > Reviewed-by: Brian Osman <brianosman@google.com> > Commit-Queue: Brian Osman <brianosman@google.com> TBR=mtklein@google.com,brianosman@google.com Change-Id: Ib53912d014916374e5d0ee3d224ba69d41a5018c No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:8382 Reviewed-on: https://skia-review.googlesource.com/156360 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
f0b2393fde
commit
11f4994b84
@ -53,6 +53,6 @@ void SkToSRGBColorFilter::flatten(SkWriteBuffer& buffer) const {
|
|||||||
std::unique_ptr<GrFragmentProcessor> SkToSRGBColorFilter::asFragmentProcessor(
|
std::unique_ptr<GrFragmentProcessor> SkToSRGBColorFilter::asFragmentProcessor(
|
||||||
GrContext*, const GrColorSpaceInfo&) const {
|
GrContext*, const GrColorSpaceInfo&) const {
|
||||||
return GrColorSpaceXformEffect::Make(fSrcColorSpace.get(), kPremul_SkAlphaType,
|
return GrColorSpaceXformEffect::Make(fSrcColorSpace.get(), kPremul_SkAlphaType,
|
||||||
sk_srgb_singleton(), kPremul_SkAlphaType);
|
sk_srgb_singleton());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -144,10 +144,9 @@ GrFragmentProcessor::OptimizationFlags GrColorSpaceXformEffect::OptFlags(
|
|||||||
|
|
||||||
std::unique_ptr<GrFragmentProcessor> GrColorSpaceXformEffect::Make(SkColorSpace* src,
|
std::unique_ptr<GrFragmentProcessor> GrColorSpaceXformEffect::Make(SkColorSpace* src,
|
||||||
SkAlphaType srcAT,
|
SkAlphaType srcAT,
|
||||||
SkColorSpace* dst,
|
SkColorSpace* dst) {
|
||||||
SkAlphaType dstAT) {
|
|
||||||
auto xform = GrColorSpaceXform::Make(src, srcAT,
|
auto xform = GrColorSpaceXform::Make(src, srcAT,
|
||||||
dst, dstAT);
|
dst, kPremul_SkAlphaType);
|
||||||
if (!xform) {
|
if (!xform) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
* Returns a fragment processor that converts the input's color space from src to dst.
|
* Returns a fragment processor that converts the input's color space from src to dst.
|
||||||
*/
|
*/
|
||||||
static std::unique_ptr<GrFragmentProcessor> Make(SkColorSpace* src, SkAlphaType srcAT,
|
static std::unique_ptr<GrFragmentProcessor> Make(SkColorSpace* src, SkAlphaType srcAT,
|
||||||
SkColorSpace* dst, SkAlphaType dstAT);
|
SkColorSpace* dst);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a fragment processor that calls the passed in fragment processor, and then converts
|
* Returns a fragment processor that calls the passed in fragment processor, and then converts
|
||||||
|
@ -141,8 +141,7 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrS
|
|||||||
// If the caller expects the pixels in a different color space than the one from the image,
|
// If the caller expects the pixels in a different color space than the one from the image,
|
||||||
// apply a color conversion to do this.
|
// apply a color conversion to do this.
|
||||||
std::unique_ptr<GrFragmentProcessor> colorConversionProcessor =
|
std::unique_ptr<GrFragmentProcessor> colorConversionProcessor =
|
||||||
GrColorSpaceXformEffect::Make(srcColorSpace, kOpaque_SkAlphaType,
|
GrColorSpaceXformEffect::Make(srcColorSpace, kPremul_SkAlphaType, dstColorSpace);
|
||||||
dstColorSpace, kOpaque_SkAlphaType);
|
|
||||||
if (colorConversionProcessor) {
|
if (colorConversionProcessor) {
|
||||||
paint.addColorFragmentProcessor(std::move(colorConversionProcessor));
|
paint.addColorFragmentProcessor(std::move(colorConversionProcessor));
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,8 @@ bool SkImage::isAlphaOnly() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkImage> SkImage::makeColorSpace(sk_sp<SkColorSpace> target) const {
|
sk_sp<SkImage> SkImage::makeColorSpace(sk_sp<SkColorSpace> target) const {
|
||||||
if (!target) {
|
SkColorSpaceTransferFn fn;
|
||||||
|
if (!target || !target->isNumericalTransferFn(&fn)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,8 +313,11 @@ sk_sp<SkImage> SkImage::makeColorSpace(sk_sp<SkColorSpace> target) const {
|
|||||||
return sk_ref_sp(const_cast<SkImage*>(this));
|
return sk_ref_sp(const_cast<SkImage*>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Re-visit this! Keep existing color type?
|
||||||
|
SkColorType targetColorType = kN32_SkColorType;
|
||||||
|
|
||||||
// TODO: We might consider making this a deferred conversion?
|
// TODO: We might consider making this a deferred conversion?
|
||||||
return as_IB(this)->onMakeColorSpace(std::move(target));
|
return as_IB(this)->onMakeColorSpace(std::move(target), targetColorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkImage> SkImage::makeNonTextureImage() const {
|
sk_sp<SkImage> SkImage::makeNonTextureImage() const {
|
||||||
|
@ -93,7 +93,7 @@ public:
|
|||||||
virtual bool onPinAsTexture(GrContext*) const { return false; }
|
virtual bool onPinAsTexture(GrContext*) const { return false; }
|
||||||
virtual void onUnpinAsTexture(GrContext*) const {}
|
virtual void onUnpinAsTexture(GrContext*) const {}
|
||||||
|
|
||||||
virtual sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>) const = 0;
|
virtual sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType) const = 0;
|
||||||
protected:
|
protected:
|
||||||
SkImage_Base(int width, int height, uint32_t uniqueID);
|
SkImage_Base(int width, int height, uint32_t uniqueID);
|
||||||
|
|
||||||
|
@ -1012,9 +1012,17 @@ bool SkImage::MakeBackendTextureFromSkImage(GrContext* ctx,
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target) const {
|
sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target, SkColorType) const {
|
||||||
auto xform = GrColorSpaceXformEffect::Make(fColorSpace.get(), this->alphaType(),
|
sk_sp<SkColorSpace> srcSpace = fColorSpace;
|
||||||
target.get(), this->alphaType());
|
if (!fColorSpace) {
|
||||||
|
if (target->isSRGB()) {
|
||||||
|
return sk_ref_sp(const_cast<SkImage*>((SkImage*)this));
|
||||||
|
}
|
||||||
|
|
||||||
|
srcSpace = SkColorSpace::MakeSRGB();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto xform = GrColorSpaceXformEffect::Make(srcSpace.get(), this->alphaType(), target.get());
|
||||||
if (!xform) {
|
if (!xform) {
|
||||||
return sk_ref_sp(const_cast<SkImage_Gpu*>(this));
|
return sk_ref_sp(const_cast<SkImage_Gpu*>(this));
|
||||||
}
|
}
|
||||||
@ -1040,10 +1048,13 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target) const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkAlphaType newAlphaType = (kUnpremul_SkAlphaType == fAlphaType) ? kPremul_SkAlphaType
|
||||||
|
: fAlphaType;
|
||||||
// MDB: this call is okay bc we know 'renderTargetContext' was exact
|
// MDB: this call is okay bc we know 'renderTargetContext' was exact
|
||||||
return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID,
|
return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID,
|
||||||
fAlphaType, renderTargetContext->asTextureProxyRef(),
|
newAlphaType, renderTargetContext->asTextureProxyRef(),
|
||||||
std::move(target), fBudgeted);
|
std::move(target), fBudgeted);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkImage_Gpu::onIsValid(GrContext* context) const {
|
bool SkImage_Gpu::onIsValid(GrContext* context) const {
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
|
|
||||||
sk_sp<SkColorSpace> refColorSpace() { return fColorSpace; }
|
sk_sp<SkColorSpace> refColorSpace() { return fColorSpace; }
|
||||||
|
|
||||||
sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>) const override;
|
sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType) const override;
|
||||||
|
|
||||||
typedef ReleaseContext TextureContext;
|
typedef ReleaseContext TextureContext;
|
||||||
typedef void (*TextureFulfillProc)(TextureContext textureContext, GrBackendTexture* outTexture);
|
typedef void (*TextureFulfillProc)(TextureContext textureContext, GrBackendTexture* outTexture);
|
||||||
|
@ -311,7 +311,8 @@ sk_sp<SkImage> SkImage_Lazy::onMakeSubset(const SkIRect& subset) const {
|
|||||||
return validator ? sk_sp<SkImage>(new SkImage_Lazy(&validator)) : nullptr;
|
return validator ? sk_sp<SkImage>(new SkImage_Lazy(&validator)) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkImage> SkImage_Lazy::onMakeColorSpace(sk_sp<SkColorSpace> target) const {
|
sk_sp<SkImage> SkImage_Lazy::onMakeColorSpace(sk_sp<SkColorSpace> target,
|
||||||
|
SkColorType targetColorType) const {
|
||||||
SkAutoExclusive autoAquire(fOnMakeColorSpaceMutex);
|
SkAutoExclusive autoAquire(fOnMakeColorSpaceMutex);
|
||||||
if (target && fOnMakeColorSpaceTarget &&
|
if (target && fOnMakeColorSpaceTarget &&
|
||||||
SkColorSpace::Equals(target.get(), fOnMakeColorSpaceTarget.get())) {
|
SkColorSpace::Equals(target.get(), fOnMakeColorSpaceTarget.get())) {
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
|
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
|
||||||
bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override;
|
bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override;
|
||||||
bool onIsLazyGenerated() const override { return true; }
|
bool onIsLazyGenerated() const override { return true; }
|
||||||
sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>) const override;
|
sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType) const override;
|
||||||
|
|
||||||
bool onIsValid(GrContext*) const override;
|
bool onIsValid(GrContext*) const override;
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ public:
|
|||||||
SkASSERT(bitmapMayBeMutable || fBitmap.isImmutable());
|
SkASSERT(bitmapMayBeMutable || fBitmap.isImmutable());
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>) const override;
|
sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType) const override;
|
||||||
|
|
||||||
bool onIsValid(GrContext* context) const override { return true; }
|
bool onIsValid(GrContext* context) const override { return true; }
|
||||||
|
|
||||||
@ -341,7 +341,8 @@ bool SkImage_Raster::onAsLegacyBitmap(SkBitmap* bitmap) const {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
sk_sp<SkImage> SkImage_Raster::onMakeColorSpace(sk_sp<SkColorSpace> target) const {
|
sk_sp<SkImage> SkImage_Raster::onMakeColorSpace(sk_sp<SkColorSpace> target,
|
||||||
|
SkColorType targetColorType) const {
|
||||||
SkPixmap src;
|
SkPixmap src;
|
||||||
SkAssertResult(fBitmap.peekPixels(&src));
|
SkAssertResult(fBitmap.peekPixels(&src));
|
||||||
|
|
||||||
@ -354,7 +355,7 @@ sk_sp<SkImage> SkImage_Raster::onMakeColorSpace(sk_sp<SkColorSpace> target) cons
|
|||||||
src.setColorSpace(SkColorSpace::MakeSRGB());
|
src.setColorSpace(SkColorSpace::MakeSRGB());
|
||||||
}
|
}
|
||||||
|
|
||||||
SkImageInfo dstInfo = fBitmap.info().makeColorSpace(target);
|
SkImageInfo dstInfo = fBitmap.info().makeColorType(targetColorType).makeColorSpace(target);
|
||||||
SkBitmap dst;
|
SkBitmap dst;
|
||||||
dst.allocPixels(dstInfo);
|
dst.allocPixels(dstInfo);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user