Plumb dst color space in many places, rather than "mode"

This is less to type in most cases, and gives us more information
(for things like picture-backed images, where we need to know all
about the destination surface).

Additionally, strip out the plumbing entirely for bitmap sources,
where we don't need to know anything.

BUG=skia:

Change-Id: I4deff6c7c345fcf62eb08b2aff0560adae4313da
Reviewed-on: https://skia-review.googlesource.com/5748
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2016-12-09 14:51:59 -05:00 committed by Skia Commit-Bot
parent 073285c059
commit 61624f0c71
49 changed files with 195 additions and 262 deletions

View File

@ -146,7 +146,8 @@ protected:
if (!fPixmap.addr()) {
sk_sp<SkImage> image = GetResourceAsImage(fFileName.c_str());
SkBitmap bm;
if (!as_IB(image)->getROPixels(&bm, SkDestinationSurfaceColorMode::kLegacy)) {
SkColorSpace* legacyColorSpace = nullptr;
if (!as_IB(image)->getROPixels(&bm, legacyColorSpace)) {
SkFAIL("Could not read resource");
}
bm.peekPixels(&fPixmap);

View File

@ -1323,10 +1323,10 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(const AsFPA
GrSamplerParams::FilterMode::kNone_FilterMode);
sk_sp<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getImprovedPermutationsBitmap(),
textureParams, args.fColorMode));
textureParams));
sk_sp<GrTexture> gradientTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getGradientBitmap(),
textureParams, args.fColorMode));
textureParams));
return GrImprovedPerlinNoiseEffect::Make(fNumOctaves, fSeed, paintingData,
permutationsTexture.get(),
gradientTexture.get(), m);
@ -1350,10 +1350,10 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(const AsFPA
sk_sp<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
GrSamplerParams::ClampNoFilter(), args.fColorMode));
GrSamplerParams::ClampNoFilter()));
sk_sp<GrTexture> noiseTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
GrSamplerParams::ClampNoFilter(), args.fColorMode));
GrSamplerParams::ClampNoFilter()));
if ((permutationsTexture) && (noiseTexture)) {
sk_sp<GrFragmentProcessor> inner(

View File

@ -308,8 +308,7 @@ protected:
static void draw_as_bitmap(SkCanvas* canvas, SkImageCacherator* cache, SkScalar x, SkScalar y) {
SkBitmap bitmap;
cache->lockAsBitmap(&bitmap, nullptr,
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware);
cache->lockAsBitmap(&bitmap, nullptr, canvas->imageInfo().colorSpace());
canvas->drawBitmap(bitmap, x, y);
}
@ -318,8 +317,7 @@ protected:
sk_sp<SkColorSpace> texColorSpace;
sk_sp<GrTexture> texture(
cache->lockAsTexture(canvas->getGrContext(), GrSamplerParams::ClampBilerp(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware,
&texColorSpace, nullptr));
canvas->imageInfo().colorSpace(), &texColorSpace, nullptr));
if (!texture) {
// show placeholder if we have no texture
SkPaint paint;

View File

@ -83,8 +83,7 @@ protected:
}
sk_sp<GrTexture> texture(
GrRefCachedBitmapTexture(context, fBmp, GrSamplerParams::ClampNoFilter(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(context, fBmp, GrSamplerParams::ClampNoFilter()));
if (!texture) {
return;
}

View File

@ -82,14 +82,11 @@ protected:
sk_sp<GrTexture> texture[3];
texture[0].reset(
GrRefCachedBitmapTexture(context, fBmp[0], GrSamplerParams::ClampBilerp(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(context, fBmp[0], GrSamplerParams::ClampBilerp()));
texture[1].reset(
GrRefCachedBitmapTexture(context, fBmp[1], GrSamplerParams::ClampBilerp(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(context, fBmp[1], GrSamplerParams::ClampBilerp()));
texture[2].reset(
GrRefCachedBitmapTexture(context, fBmp[2], GrSamplerParams::ClampBilerp(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(context, fBmp[2], GrSamplerParams::ClampBilerp()));
if (!texture[0] || !texture[1] || !texture[2]) {
return;
@ -207,14 +204,11 @@ protected:
sk_sp<GrTexture> texture[3];
texture[0].reset(
GrRefCachedBitmapTexture(context, fBmp[0], GrSamplerParams::ClampBilerp(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(context, fBmp[0], GrSamplerParams::ClampBilerp()));
texture[1].reset(
GrRefCachedBitmapTexture(context, fBmp[1], GrSamplerParams::ClampBilerp(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(context, fBmp[1], GrSamplerParams::ClampBilerp()));
texture[2].reset(
GrRefCachedBitmapTexture(context, fBmp[1], GrSamplerParams::ClampBilerp(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(context, fBmp[1], GrSamplerParams::ClampBilerp()));
if (!texture[0] || !texture[1] || !texture[2]) {
return;

View File

@ -342,21 +342,18 @@ public:
const SkMatrix* viewMatrix,
const SkMatrix* localMatrix,
SkFilterQuality filterQuality,
SkColorSpace* dstColorSpace,
SkDestinationSurfaceColorMode colorMode)
SkColorSpace* dstColorSpace)
: fContext(context)
, fViewMatrix(viewMatrix)
, fLocalMatrix(localMatrix)
, fFilterQuality(filterQuality)
, fDstColorSpace(dstColorSpace)
, fColorMode(colorMode) {}
, fDstColorSpace(dstColorSpace) {}
GrContext* fContext;
const SkMatrix* fViewMatrix;
const SkMatrix* fLocalMatrix;
SkFilterQuality fFilterQuality;
SkColorSpace* fDstColorSpace;
SkDestinationSurfaceColorMode fColorMode;
};
/**

View File

@ -344,10 +344,6 @@ public:
GrPixelConfig config() const { return fRenderTargetProxy->config(); }
int numColorSamples() const { return fRenderTargetProxy->numColorSamples(); }
bool isGammaCorrect() const { return SkToBool(fColorSpace.get()); }
SkDestinationSurfaceColorMode colorMode() const {
return this->isGammaCorrect() ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
}
const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
GrColorSpaceXform* getColorXformFromSRGB() const { return fColorXformFromSRGB.get(); }

View File

@ -79,11 +79,9 @@ static inline GrColor SkPMColorToGrColor(SkPMColor c) {
/** Returns a texture representing the bitmap that is compatible with the GrSamplerParams. The
texture is inserted into the cache (unless the bitmap is marked volatile) and can be
retrieved again via this function. */
GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrSamplerParams&,
SkDestinationSurfaceColorMode);
GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrSamplerParams&);
sk_sp<GrTexture> GrMakeCachedBitmapTexture(GrContext*, const SkBitmap&, const GrSamplerParams&,
SkDestinationSurfaceColorMode);
sk_sp<GrTexture> GrMakeCachedBitmapTexture(GrContext*, const SkBitmap&, const GrSamplerParams&);
// TODO: Move SkImageInfo2GrPixelConfig to SkGrPriv.h (requires cleanup to SkWindow its subclasses).
GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, const SkColorSpace*,

View File

@ -182,14 +182,17 @@ bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmapProvider
return false;
}
SkDestinationSurfaceColorMode colorMode = provider.dstColorSpace()
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
if (invScaleSize.width() > SK_Scalar1 || invScaleSize.height() > SK_Scalar1) {
fCurrMip.reset(SkMipMapCache::FindAndRef(provider.makeCacheDesc(), provider.colorMode()));
fCurrMip.reset(SkMipMapCache::FindAndRef(provider.makeCacheDesc(), colorMode));
if (nullptr == fCurrMip.get()) {
SkBitmap orig;
if (!provider.asBitmap(&orig)) {
return false;
}
fCurrMip.reset(SkMipMapCache::AddAndRef(orig, provider.colorMode()));
fCurrMip.reset(SkMipMapCache::AddAndRef(orig, colorMode));
if (nullptr == fCurrMip.get()) {
return false;
}

View File

@ -417,13 +417,8 @@ sk_sp<SkSpecialImage> SkBitmapDevice::makeSpecial(const SkBitmap& bitmap) {
}
sk_sp<SkSpecialImage> SkBitmapDevice::makeSpecial(const SkImage* image) {
// This is called when we're about to draw the special-ized version of image to *this* device,
// so we can use our own presense/absence of a color space to decide how to decode the image.
SkDestinationSurfaceColorMode decodeColorMode = fBitmap.colorSpace()
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->height()),
image->makeNonTextureImage(), decodeColorMode);
image->makeNonTextureImage(), fBitmap.colorSpace());
}
sk_sp<SkSpecialImage> SkBitmapDevice::snapSpecial() {

View File

@ -45,7 +45,7 @@ void SkBitmapProvider::notifyAddedToCache() const {
}
bool SkBitmapProvider::asBitmap(SkBitmap* bm) const {
return as_IB(fImage)->getROPixels(bm, fColorMode, SkImage::kAllow_CachingHint);
return as_IB(fImage)->getROPixels(bm, fDstColorSpace, SkImage::kAllow_CachingHint);
}
bool SkBitmapProvider::accessScaledImage(const SkRect& srcRect,

View File

@ -13,20 +13,20 @@
class SkBitmapProvider {
public:
explicit SkBitmapProvider(const SkImage* img, SkDestinationSurfaceColorMode colorMode)
explicit SkBitmapProvider(const SkImage* img, SkColorSpace* dstColorSpace)
: fImage(img)
, fColorMode(colorMode) {
, fDstColorSpace(dstColorSpace) {
SkASSERT(img);
}
SkBitmapProvider(const SkBitmapProvider& other)
: fImage(other.fImage)
, fColorMode(other.fColorMode)
, fDstColorSpace(other.fDstColorSpace)
{}
int width() const;
int height() const;
uint32_t getID() const;
SkDestinationSurfaceColorMode colorMode() const { return fColorMode; }
SkColorSpace* dstColorSpace() const { return fDstColorSpace; }
SkImageInfo info() const;
bool isVolatile() const;
@ -48,10 +48,10 @@ private:
void* operator new(size_t) = delete;
void* operator new(size_t, void*) = delete;
// SkBitmapProvider is always short-lived/stack allocated, and the source image is guaranteed
// to outlive its scope => we can store a raw ptr to avoid ref churn.
const SkImage* fImage;
SkDestinationSurfaceColorMode fColorMode;
// SkBitmapProvider is always short-lived/stack allocated, and the source image and destination
// color space are guaranteed to outlive its scope => we can store raw ptrs to avoid ref churn.
const SkImage* fImage;
SkColorSpace* fDstColorSpace;
};
#endif

View File

@ -234,11 +234,8 @@ void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar
return;
}
SkDestinationSurfaceColorMode colorMode = this->imageInfo().colorSpace()
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
SkBitmap bm;
if (as_IB(image)->getROPixels(&bm, colorMode)) {
if (as_IB(image)->getROPixels(&bm, this->imageInfo().colorSpace())) {
this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
}
}
@ -251,11 +248,8 @@ void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
return;
}
SkDestinationSurfaceColorMode colorMode = this->imageInfo().colorSpace()
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
SkBitmap bm;
if (as_IB(image)->getROPixels(&bm, colorMode)) {
if (as_IB(image)->getROPixels(&bm, this->imageInfo().colorSpace())) {
this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
}
}

View File

@ -214,9 +214,9 @@ bool SkImageCacherator::tryLockAsBitmap(SkBitmap* bitmap, const SkImage* client,
}
bool SkImageCacherator::lockAsBitmap(SkBitmap* bitmap, const SkImage* client,
SkDestinationSurfaceColorMode colorMode,
SkColorSpace* dstColorSpace,
SkImage::CachingHint chint) {
CachedFormat format = this->chooseCacheFormat(colorMode);
CachedFormat format = this->chooseCacheFormat(dstColorSpace);
SkImageInfo cacheInfo = this->buildCacheInfo(format);
if (kNeedNewImageUniqueID == fUniqueIDs[format]) {
@ -302,11 +302,10 @@ struct CacheCaps {
const GrCaps* fCaps;
};
SkImageCacherator::CachedFormat SkImageCacherator::chooseCacheFormat(
SkDestinationSurfaceColorMode colorMode,
const GrCaps* grCaps) {
SkImageCacherator::CachedFormat SkImageCacherator::chooseCacheFormat(SkColorSpace* dstColorSpace,
const GrCaps* grCaps) {
SkColorSpace* cs = fInfo.colorSpace();
if (!cs || SkDestinationSurfaceColorMode::kLegacy == colorMode) {
if (!cs || !dstColorSpace) {
return kLegacy_CachedFormat;
}
@ -491,12 +490,11 @@ static GrTexture* set_key_and_return(GrTexture* tex, const GrUniqueKey& key) {
return tex;
}
sk_sp<SkColorSpace> SkImageCacherator::getColorSpace(GrContext* ctx,
SkDestinationSurfaceColorMode colorMode) {
sk_sp<SkColorSpace> SkImageCacherator::getColorSpace(GrContext* ctx, SkColorSpace* dstColorSpace) {
// TODO: This isn't always correct. Picture generator currently produces textures in N32,
// and will (soon) emit them in an arbitrary (destination) space. We will need to stash that
// information in/on the key so we can return the correct space in case #1 of lockTexture.
CachedFormat format = this->chooseCacheFormat(colorMode, ctx->caps());
CachedFormat format = this->chooseCacheFormat(dstColorSpace, ctx->caps());
SkImageInfo cacheInfo = this->buildCacheInfo(format);
return sk_ref_sp(cacheInfo.colorSpace());
}
@ -512,8 +510,7 @@ sk_sp<SkColorSpace> SkImageCacherator::getColorSpace(GrContext* ctx,
*/
GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& origKey,
const SkImage* client, SkImage::CachingHint chint,
bool willBeMipped,
SkDestinationSurfaceColorMode colorMode) {
bool willBeMipped, SkColorSpace* dstColorSpace) {
// Values representing the various texture lock paths we can take. Used for logging the path
// taken to a histogram.
enum LockTexturePath {
@ -529,7 +526,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori
// Determine which cached format we're going to use (which may involve decoding to a different
// info than the generator provides).
CachedFormat format = this->chooseCacheFormat(colorMode, ctx->caps());
CachedFormat format = this->chooseCacheFormat(dstColorSpace, ctx->caps());
// Fold the cache format into our texture key
GrUniqueKey key;
@ -592,7 +589,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori
if (this->tryLockAsBitmap(&bitmap, client, chint, format, cacheInfo)) {
GrTexture* tex = nullptr;
if (willBeMipped) {
tex = GrGenerateMipMapsAndUploadToTexture(ctx, bitmap, colorMode);
tex = GrGenerateMipMapsAndUploadToTexture(ctx, bitmap, dstColorSpace);
}
if (!tex) {
tex = GrUploadBitmapToTexture(ctx, bitmap);
@ -611,21 +608,21 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori
///////////////////////////////////////////////////////////////////////////////////////////////////
GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrSamplerParams& params,
SkDestinationSurfaceColorMode colorMode,
SkColorSpace* dstColorSpace,
sk_sp<SkColorSpace>* texColorSpace,
const SkImage* client, SkImage::CachingHint chint) {
if (!ctx) {
return nullptr;
}
return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(params, colorMode,
return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(params, dstColorSpace,
texColorSpace);
}
#else
GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrSamplerParams&,
SkDestinationSurfaceColorMode colorMode,
SkColorSpace* dstColorSpace,
sk_sp<SkColorSpace>* texColorSpace,
const SkImage* client, SkImage::CachingHint) {
return nullptr;

View File

@ -48,7 +48,7 @@ public:
* If not NULL, the client will be notified (->notifyAddedToCache()) when resources are
* added to the cache on its behalf.
*/
bool lockAsBitmap(SkBitmap*, const SkImage* client, SkDestinationSurfaceColorMode colorMode,
bool lockAsBitmap(SkBitmap*, const SkImage* client, SkColorSpace* dstColorSpace,
SkImage::CachingHint = SkImage::kAllow_CachingHint);
/**
@ -60,8 +60,7 @@ public:
*
* The caller is responsible for calling texture->unref() when they are done.
*/
GrTexture* lockAsTexture(GrContext*, const GrSamplerParams&,
SkDestinationSurfaceColorMode colorMode,
GrTexture* lockAsTexture(GrContext*, const GrSamplerParams&, SkColorSpace* dstColorSpace,
sk_sp<SkColorSpace>* texColorSpace, const SkImage* client,
SkImage::CachingHint = SkImage::kAllow_CachingHint);
@ -116,7 +115,7 @@ private:
SkImageCacherator(Validator*);
CachedFormat chooseCacheFormat(SkDestinationSurfaceColorMode, const GrCaps* = nullptr);
CachedFormat chooseCacheFormat(SkColorSpace* dstColorSpace, const GrCaps* = nullptr);
SkImageInfo buildCacheInfo(CachedFormat);
bool generateBitmap(SkBitmap*, const SkImageInfo&);
@ -126,11 +125,11 @@ private:
// Returns the texture. If the cacherator is generating the texture and wants to cache it,
// it should use the passed in key (if the key is valid).
GrTexture* lockTexture(GrContext*, const GrUniqueKey& key, const SkImage* client,
SkImage::CachingHint, bool willBeMipped, SkDestinationSurfaceColorMode);
SkImage::CachingHint, bool willBeMipped, SkColorSpace* dstColorSpace);
// Returns the color space of the texture that would be returned if you called lockTexture.
// Separate code path to allow querying of the color space for textures that cached (even
// externally).
sk_sp<SkColorSpace> getColorSpace(GrContext*, SkDestinationSurfaceColorMode);
sk_sp<SkColorSpace> getColorSpace(GrContext*, SkColorSpace* dstColorSpace);
void makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, CachedFormat, GrUniqueKey* cacheKey);
#endif

View File

@ -18,8 +18,7 @@ sk_sp<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(const AsFPAr
tmp.preConcat(*args.fLocalMatrix);
}
return fProxyShader->asFragmentProcessor(AsFPArgs(
args.fContext, args.fViewMatrix, &tmp, args.fFilterQuality, args.fDstColorSpace,
args.fColorMode));
args.fContext, args.fViewMatrix, &tmp, args.fFilterQuality, args.fDstColorSpace));
}
#endif

View File

@ -328,7 +328,6 @@ sk_sp<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(const AsFPArgs&
return nullptr;
}
return bitmapShader->asFragmentProcessor(SkShader::AsFPArgs(
args.fContext, args.fViewMatrix, nullptr, args.fFilterQuality, args.fDstColorSpace,
args.fColorMode));
args.fContext, args.fViewMatrix, nullptr, args.fFilterQuality, args.fDstColorSpace));
}
#endif

View File

@ -102,8 +102,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(GrContext* context) {
}
sk_sp<GrTexture> resultTex(
GrRefCachedBitmapTexture(context, bmp, GrSamplerParams::ClampNoFilter(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(context, bmp, GrSamplerParams::ClampNoFilter()));
if (!resultTex) {
return nullptr;
}
@ -181,7 +180,7 @@ static bool rect_fits(const SkIRect& rect, int width, int height) {
sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset,
sk_sp<SkImage> image,
SkDestinationSurfaceColorMode colorMode,
SkColorSpace* dstColorSpace,
const SkSurfaceProps* props) {
SkASSERT(rect_fits(subset, image->width(), image->height()));
@ -193,7 +192,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset,
#endif
{
SkBitmap bm;
if (as_IB(image)->getROPixels(&bm, colorMode)) {
if (as_IB(image)->getROPixels(&bm, dstColorSpace)) {
return MakeFromRaster(subset, bm, props);
}
}
@ -242,8 +241,7 @@ public:
sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override {
if (context) {
return sk_ref_sp(
GrRefCachedBitmapTexture(context, fBitmap, GrSamplerParams::ClampNoFilter(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(context, fBitmap, GrSamplerParams::ClampNoFilter()));
}
return nullptr;
@ -252,10 +250,7 @@ public:
sk_sp<GrTextureProxy> onAsTextureProxy(GrContext* context) const override {
if (context) {
sk_sp<GrTexture> tex(sk_ref_sp(GrRefCachedBitmapTexture(
context,
fBitmap,
GrSamplerParams::ClampNoFilter(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware)));
context, fBitmap, GrSamplerParams::ClampNoFilter())));
sk_sp<GrSurfaceProxy> sProxy = GrSurfaceProxy::MakeWrapped(std::move(tex));
return sk_ref_sp(sProxy->asTextureProxy());
}

View File

@ -73,7 +73,7 @@ public:
static sk_sp<SkSpecialImage> MakeFromImage(const SkIRect& subset,
sk_sp<SkImage>,
SkDestinationSurfaceColorMode,
SkColorSpace* dstColorSpace,
const SkSurfaceProps* = nullptr);
static sk_sp<SkSpecialImage> MakeFromRaster(const SkIRect& subset,
const SkBitmap&,

View File

@ -86,12 +86,8 @@ sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const
if (fSrcRect == bounds && dstRect == bounds) {
// No regions cropped out or resized; return entire image.
offset->fX = offset->fY = 0;
SkDestinationSurfaceColorMode decodeColorMode = ctx.outputProperties().colorSpace()
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(fImage->width(), fImage->height()),
fImage,
decodeColorMode,
fImage, ctx.outputProperties().colorSpace(),
&source->props());
}

View File

@ -926,10 +926,10 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(const AsFPAr
new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
sk_sp<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
GrSamplerParams::ClampNoFilter(), args.fColorMode));
GrSamplerParams::ClampNoFilter()));
sk_sp<GrTexture> noiseTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
GrSamplerParams::ClampNoFilter(), args.fColorMode));
GrSamplerParams::ClampNoFilter()));
SkMatrix m = *args.fViewMatrix;
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);

View File

@ -474,8 +474,7 @@ sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, SkBitmap b
if (-1 == row) {
atlas = nullptr;
texture.reset(
GrRefCachedBitmapTexture(context, bitmap, GrSamplerParams::ClampNoFilter(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(context, bitmap, GrSamplerParams::ClampNoFilter()));
} else {
texture.reset(SkRef(atlas->getTexture()));
}

View File

@ -1662,9 +1662,7 @@ GrGradientEffect::GrGradientEffect(const CreateArgs& args) {
fCoordTransform.reset(*args.fMatrix, fAtlas->getTexture(), params.filterMode());
fTextureSampler.reset(fAtlas->getTexture(), params);
} else {
sk_sp<GrTexture> texture(GrRefCachedBitmapTexture(
args.fContext, bitmap, params,
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
sk_sp<GrTexture> texture(GrRefCachedBitmapTexture(args.fContext, bitmap, params));
if (!texture) {
return;
}

View File

@ -27,7 +27,7 @@ GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b
}
GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped,
SkDestinationSurfaceColorMode colorMode) {
SkColorSpace* dstColorSpace) {
GrTexture* tex = nullptr;
if (fOriginalKey.isValid()) {
@ -37,7 +37,7 @@ GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped,
}
}
if (willBeMipped) {
tex = GrGenerateMipMapsAndUploadToTexture(this->context(), fBitmap, colorMode);
tex = GrGenerateMipMapsAndUploadToTexture(this->context(), fBitmap, dstColorSpace);
}
if (!tex) {
tex = GrUploadBitmapToTexture(this->context(), fBitmap);
@ -50,8 +50,8 @@ GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped,
}
void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey,
SkDestinationSurfaceColorMode colorMode) {
// Color mode is irrelevant in this case - we always upload the bitmap's contents as-is
SkColorSpace* dstColorSpace) {
// Destination color space is irrelevant - we always upload the bitmap's contents as-is
if (fOriginalKey.isValid()) {
MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey);
}
@ -65,7 +65,7 @@ SkAlphaType GrBitmapTextureMaker::alphaType() const {
return fBitmap.alphaType();
}
sk_sp<SkColorSpace> GrBitmapTextureMaker::getColorSpace(SkDestinationSurfaceColorMode colorMode) {
// Color space doesn't depend on mode - it's just whatever is in the bitmap
sk_sp<SkColorSpace> GrBitmapTextureMaker::getColorSpace(SkColorSpace* dstColorSpace) {
// Color space doesn't depend on destination color space - it's just whatever is in the bitmap
return sk_ref_sp(fBitmap.colorSpace());
}

View File

@ -18,15 +18,15 @@ public:
GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap);
protected:
GrTexture* refOriginalTexture(bool willBeMipped, SkDestinationSurfaceColorMode) override;
GrTexture* refOriginalTexture(bool willBeMipped, SkColorSpace* dstColorSpace) override;
void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey,
SkDestinationSurfaceColorMode colorMode) override;
SkColorSpace* dstColorSpace) override;
void didCacheCopy(const GrUniqueKey& copyKey) override;
SkAlphaType alphaType() const override;
sk_sp<SkColorSpace> getColorSpace(SkDestinationSurfaceColorMode) override;
sk_sp<SkColorSpace> getColorSpace(SkColorSpace* dstColorSpace) override;
private:
const SkBitmap fBitmap;

View File

@ -31,17 +31,16 @@ GrImageTextureMaker::GrImageTextureMaker(GrContext* context, SkImageCacherator*
}
}
GrTexture* GrImageTextureMaker::refOriginalTexture(bool willBeMipped,
SkDestinationSurfaceColorMode colorMode) {
GrTexture* GrImageTextureMaker::refOriginalTexture(bool willBeMipped, SkColorSpace* dstColorSpace) {
return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCachingHint, willBeMipped,
colorMode);
dstColorSpace);
}
void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey,
SkDestinationSurfaceColorMode colorMode) {
SkColorSpace* dstColorSpace) {
if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) {
SkImageCacherator::CachedFormat cacheFormat =
fCacher->chooseCacheFormat(colorMode, this->context()->caps());
fCacher->chooseCacheFormat(dstColorSpace, this->context()->caps());
GrUniqueKey cacheKey;
fCacher->makeCacheKeyFromOrigKey(fOriginalKey, cacheFormat, &cacheKey);
MakeCopyKeyFromOrigKey(cacheKey, stretch, paramsCopyKey);
@ -57,6 +56,6 @@ void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) {
SkAlphaType GrImageTextureMaker::alphaType() const {
return fCacher->info().alphaType();
}
sk_sp<SkColorSpace> GrImageTextureMaker::getColorSpace(SkDestinationSurfaceColorMode colorMode) {
return fCacher->getColorSpace(this->context(), colorMode);
sk_sp<SkColorSpace> GrImageTextureMaker::getColorSpace(SkColorSpace* dstColorSpace) {
return fCacher->getColorSpace(this->context(), dstColorSpace);
}

View File

@ -25,13 +25,13 @@ protected:
// able to efficiently produce a "stretched" texture natively (e.g. picture-backed)
// GrTexture* generateTextureForParams(const CopyParams&) override;
GrTexture* refOriginalTexture(bool willBeMipped, SkDestinationSurfaceColorMode) override;
GrTexture* refOriginalTexture(bool willBeMipped, SkColorSpace* dstColorSpace) override;
void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey,
SkDestinationSurfaceColorMode colorMode) override;
SkColorSpace* dstColorSpace) override;
void didCacheCopy(const GrUniqueKey& copyKey) override;
SkAlphaType alphaType() const override;
sk_sp<SkColorSpace> getColorSpace(SkDestinationSurfaceColorMode) override;
sk_sp<SkColorSpace> getColorSpace(SkColorSpace* dstColorSpace) override;
private:
SkImageCacherator* fCacher;

View File

@ -331,9 +331,6 @@ TestAsFPArgs::TestAsFPArgs(GrProcessorTestData* d) {
fArgs.fLocalMatrix = nullptr;
fArgs.fFilterQuality = kNone_SkFilterQuality;
fArgs.fDstColorSpace = fColorSpaceStorage.get();
fArgs.fColorMode = SkToBool(fArgs.fDstColorSpace)
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
}
} // namespace GrTest

View File

@ -30,8 +30,8 @@ GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, SkAlphaType alphaType,
}
void GrTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey,
SkDestinationSurfaceColorMode) {
// Color mode is irrelevant in this case - we already have a texture so we're just sub-setting
SkColorSpace* dstColorSpace) {
// Destination color space is irrelevant - we already have a texture so we're just sub-setting
GrUniqueKey baseKey;
GrMakeKeyFromImageID(&baseKey, fUniqueID, SkIRect::MakeWH(this->width(), this->height()));
MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
@ -46,7 +46,7 @@ GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) {
GrContext* context = texture->getContext();
const SkIRect* contentArea = this->contentAreaOrNull();
GrUniqueKey key;
this->makeCopyKey(copyParams, &key, SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware);
this->makeCopyKey(copyParams, &key, nullptr);
if (key.isValid()) {
GrTexture* cachedCopy = context->textureProvider()->findAndRefTextureByUniqueKey(key);
if (cachedCopy) {
@ -64,7 +64,6 @@ GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) {
}
GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrSamplerParams& params,
SkDestinationSurfaceColorMode colorMode,
SkIPoint* outOffset) {
GrTexture* texture = this->originalTexture();
GrContext* context = texture->getContext();
@ -106,8 +105,7 @@ sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
const GrSamplerParams::FilterMode* filterOrNullForBicubic,
SkColorSpace* dstColorSpace,
SkDestinationSurfaceColorMode colorMode) {
SkColorSpace* dstColorSpace) {
SkMatrix textureMatrix = origTextureMatrix;
const SkIRect* contentArea = this->contentAreaOrNull();
@ -126,7 +124,7 @@ sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
if (filterOrNullForBicubic) {
params.setFilterMode(*filterOrNullForBicubic);
}
sk_sp<GrTexture> texture(this->refTextureSafeForParams(params, colorMode, nullptr));
sk_sp<GrTexture> texture(this->refTextureSafeForParams(params, nullptr));
if (!texture) {
return nullptr;
}

View File

@ -23,8 +23,7 @@ public:
outOffset will be the top-left corner of the subset if a copy is not made. Otherwise,
the copy will be tight to the contents and outOffset will be (0, 0). If the copy's size
does not match subset's dimensions then the contents are scaled to fit the copy.*/
GrTexture* refTextureSafeForParams(const GrSamplerParams&, SkDestinationSurfaceColorMode,
SkIPoint* outOffset);
GrTexture* refTextureSafeForParams(const GrSamplerParams&, SkIPoint* outOffset);
sk_sp<GrFragmentProcessor> createFragmentProcessor(
const SkMatrix& textureMatrix,
@ -32,8 +31,7 @@ public:
FilterConstraint,
bool coordsLimitedToConstraintRect,
const GrSamplerParams::FilterMode* filterOrNullForBicubic,
SkColorSpace* dstColorSpace,
SkDestinationSurfaceColorMode) override;
SkColorSpace* dstColorSpace) override;
// We do not ref the texture nor the colorspace, so the caller must keep them in scope while
// this Adjuster is alive.
@ -43,7 +41,7 @@ public:
protected:
SkAlphaType alphaType() const override { return fAlphaType; }
void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey,
SkDestinationSurfaceColorMode colorMode) override;
SkColorSpace* dstColorSpace) override;
void didCacheCopy(const GrUniqueKey& copyKey) override;
GrTexture* originalTexture() const { return fOriginal; }

View File

@ -11,7 +11,7 @@
#include "GrGpu.h"
GrTexture* GrTextureMaker::refTextureForParams(const GrSamplerParams& params,
SkDestinationSurfaceColorMode colorMode,
SkColorSpace* dstColorSpace,
sk_sp<SkColorSpace>* texColorSpace) {
CopyParams copyParams;
bool willBeMipped = params.filterMode() == GrSamplerParams::kMipMap_FilterMode;
@ -21,15 +21,15 @@ GrTexture* GrTextureMaker::refTextureForParams(const GrSamplerParams& params,
}
if (texColorSpace) {
*texColorSpace = this->getColorSpace(colorMode);
*texColorSpace = this->getColorSpace(dstColorSpace);
}
if (!fContext->getGpu()->makeCopyForTextureParams(this->width(), this->height(), params,
&copyParams)) {
return this->refOriginalTexture(willBeMipped, colorMode);
return this->refOriginalTexture(willBeMipped, dstColorSpace);
}
GrUniqueKey copyKey;
this->makeCopyKey(copyParams, &copyKey, colorMode);
this->makeCopyKey(copyParams, &copyKey, dstColorSpace);
if (copyKey.isValid()) {
GrTexture* result = fContext->textureProvider()->findAndRefTextureByUniqueKey(copyKey);
if (result) {
@ -37,7 +37,7 @@ GrTexture* GrTextureMaker::refTextureForParams(const GrSamplerParams& params,
}
}
GrTexture* result = this->generateTextureForParams(copyParams, willBeMipped, colorMode);
GrTexture* result = this->generateTextureForParams(copyParams, willBeMipped, dstColorSpace);
if (!result) {
return nullptr;
}
@ -55,8 +55,7 @@ sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
const GrSamplerParams::FilterMode* filterOrNullForBicubic,
SkColorSpace* dstColorSpace,
SkDestinationSurfaceColorMode colorMode) {
SkColorSpace* dstColorSpace) {
const GrSamplerParams::FilterMode* fmForDetermineDomain = filterOrNullForBicubic;
if (filterOrNullForBicubic && GrSamplerParams::kMipMap_FilterMode == *filterOrNullForBicubic &&
@ -78,7 +77,7 @@ sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
params.reset(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode);
}
sk_sp<SkColorSpace> texColorSpace;
sk_sp<GrTexture> texture(this->refTextureForParams(params, colorMode, &texColorSpace));
sk_sp<GrTexture> texture(this->refTextureForParams(params, dstColorSpace, &texColorSpace));
if (!texture) {
return nullptr;
}
@ -98,8 +97,8 @@ sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
}
GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams, bool willBeMipped,
SkDestinationSurfaceColorMode colorMode) {
sk_sp<GrTexture> original(this->refOriginalTexture(willBeMipped, colorMode));
SkColorSpace* dstColorSpace) {
sk_sp<GrTexture> original(this->refOriginalTexture(willBeMipped, dstColorSpace));
if (!original) {
return nullptr;
}

View File

@ -21,7 +21,7 @@ public:
* does not match width()/height() then the contents of the original must be scaled to fit
* the texture. Places the color space of the texture in (*texColorSpace).
*/
GrTexture* refTextureForParams(const GrSamplerParams&, SkDestinationSurfaceColorMode,
GrTexture* refTextureForParams(const GrSamplerParams&, SkColorSpace* dstColorSpace,
sk_sp<SkColorSpace>* texColorSpace);
sk_sp<GrFragmentProcessor> createFragmentProcessor(
@ -30,8 +30,7 @@ public:
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
const GrSamplerParams::FilterMode* filterOrNullForBicubic,
SkColorSpace* dstColorSpace,
SkDestinationSurfaceColorMode) override;
SkColorSpace* dstColorSpace) override;
protected:
GrTextureMaker(GrContext* context, int width, int height, bool isAlphaOnly)
@ -42,13 +41,13 @@ protected:
* Return the maker's "original" texture. It is the responsibility of the maker to handle any
* caching of the original if desired.
*/
virtual GrTexture* refOriginalTexture(bool willBeMipped, SkDestinationSurfaceColorMode) = 0;
virtual GrTexture* refOriginalTexture(bool willBeMipped, SkColorSpace* dstColorSpace) = 0;
/**
* Returns the color space of the maker's "original" texture, assuming it was retrieved with
* the same destination color mode.
* the same destination color space.
*/
virtual sk_sp<SkColorSpace> getColorSpace(SkDestinationSurfaceColorMode) = 0;
virtual sk_sp<SkColorSpace> getColorSpace(SkColorSpace* dstColorSpace) = 0;
/**
* Return a new (uncached) texture that is the stretch of the maker's original.
@ -61,7 +60,7 @@ protected:
* by copying.
*/
virtual GrTexture* generateTextureForParams(const CopyParams&, bool willBeMipped,
SkDestinationSurfaceColorMode);
SkColorSpace* dstColorSpace);
GrContext* context() const { return fContext; }

View File

@ -61,8 +61,7 @@ public:
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
const GrSamplerParams::FilterMode* filterOrNullForBicubic,
SkColorSpace* dstColorSpace,
SkDestinationSurfaceColorMode) = 0;
SkColorSpace* dstColorSpace) = 0;
virtual ~GrTextureProducer() {}
@ -96,10 +95,11 @@ protected:
* return a key that identifies its original content + the CopyParms parameter. If the producer
* does not want to cache the stretched version (e.g. the producer is volatile), this should
* simply return without initializing the copyKey. If the texture generated by this producer
* depends on colorMode, then that information should also be incorporated in the key.
* depends on the destination color space, then that information should also be incorporated
* in the key.
*/
virtual void makeCopyKey(const CopyParams&, GrUniqueKey* copyKey,
SkDestinationSurfaceColorMode colorMode) = 0;
SkColorSpace* dstColorSpace) = 0;
/**
* If a stretched version of the texture is generated, it may be cached (assuming that

View File

@ -1039,8 +1039,7 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
SkASSERT(bitmap.width() <= fContext->caps()->maxTileSize() &&
bitmap.height() <= fContext->caps()->maxTileSize());
sk_sp<GrTexture> texture = GrMakeCachedBitmapTexture(
fContext.get(), bitmap, params, fRenderTargetContext->colorMode());
sk_sp<GrTexture> texture = GrMakeCachedBitmapTexture(fContext.get(), bitmap, params);
if (nullptr == texture) {
return;
}
@ -1119,8 +1118,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
// draw sprite neither filters nor tiles.
texture.reset(
GrRefCachedBitmapTexture(fContext.get(), bitmap, GrSamplerParams::ClampNoFilter(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(fContext.get(), bitmap, GrSamplerParams::ClampNoFilter()));
if (!texture) {
return;
}
@ -1290,8 +1288,7 @@ sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
}
sk_sp<GrTexture> texture =
GrMakeCachedBitmapTexture(fContext.get(), bitmap, GrSamplerParams::ClampNoFilter(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware);
GrMakeCachedBitmapTexture(fContext.get(), bitmap, GrSamplerParams::ClampNoFilter());
if (!texture) {
return nullptr;
}
@ -1389,7 +1386,7 @@ void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x
if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstraint,
paint.getFilterQuality(), *draw.fMatrix, SkMatrix::I())) {
// only support tiling as bitmap at the moment, so force raster-version
if (!as_IB(image)->getROPixels(&bm, fRenderTargetContext->colorMode())) {
if (!as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) {
return;
}
this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
@ -1398,7 +1395,7 @@ void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x
GrImageTextureMaker maker(fContext.get(), cacher, image, SkImage::kAllow_CachingHint);
this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kFast_SrcRectConstraint,
viewMatrix, fClip, paint);
} else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->colorMode())) {
} else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) {
this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
}
}
@ -1423,7 +1420,7 @@ void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), *draw.fMatrix,
srcToDstRect)) {
// only support tiling as bitmap at the moment, so force raster-version
if (!as_IB(image)->getROPixels(&bm, fRenderTargetContext->colorMode())) {
if (!as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) {
return;
}
this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
@ -1431,7 +1428,7 @@ void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
CHECK_SHOULD_DRAW(draw);
GrImageTextureMaker maker(fContext.get(), cacher, image, SkImage::kAllow_CachingHint);
this->drawTextureProducer(&maker, src, &dst, constraint, *draw.fMatrix, fClip, paint);
} else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->colorMode())) {
} else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) {
this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
}
}
@ -1464,8 +1461,7 @@ void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc
producer->createFragmentProcessor(SkMatrix::I(),
SkRect::MakeIWH(producer->width(), producer->height()),
GrTextureProducer::kNo_FilterConstraint, true,
&kMode, fRenderTargetContext->getColorSpace(),
fRenderTargetContext->colorMode()));
&kMode, fRenderTargetContext->getColorSpace()));
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext.get(), paint,
*draw.fMatrix, std::move(fp), producer->isAlphaOnly(),
@ -1493,7 +1489,7 @@ void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image,
if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) {
GrImageTextureMaker maker(fContext.get(), cacher, image, SkImage::kAllow_CachingHint);
this->drawProducerNine(draw, &maker, center, dst, paint);
} else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->colorMode())) {
} else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) {
this->drawBitmapNine(draw, bm, center, dst, paint);
}
}
@ -1518,8 +1514,7 @@ void SkGpuDevice::drawProducerLattice(const SkDraw& draw, GrTextureProducer* pro
producer->createFragmentProcessor(SkMatrix::I(),
SkRect::MakeIWH(producer->width(), producer->height()),
GrTextureProducer::kNo_FilterConstraint, true,
&kMode, fRenderTargetContext->getColorSpace(),
fRenderTargetContext->colorMode()));
&kMode, fRenderTargetContext->getColorSpace()));
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext.get(), paint,
*draw.fMatrix, std::move(fp), producer->isAlphaOnly(),
@ -1548,7 +1543,7 @@ void SkGpuDevice::drawImageLattice(const SkDraw& draw, const SkImage* image,
if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) {
GrImageTextureMaker maker(fContext.get(), cacher, image, SkImage::kAllow_CachingHint);
this->drawProducerLattice(draw, &maker, lattice, dst, paint);
} else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->colorMode())) {
} else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) {
this->drawBitmapLattice(draw, bm, lattice, dst, paint);
}
}

View File

@ -203,7 +203,7 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
}
sk_sp<GrFragmentProcessor> fp(producer->createFragmentProcessor(
*textureMatrix, clippedSrcRect, constraintMode, coordsAllInsideSrcRect, filterMode,
fRenderTargetContext->getColorSpace(), fRenderTargetContext->colorMode()));
fRenderTargetContext->getColorSpace()));
if (!fp) {
return;
}

View File

@ -319,8 +319,12 @@ void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pix
}
GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& bitmap,
SkDestinationSurfaceColorMode colorMode)
SkColorSpace* dstColorSpace)
{
SkDestinationSurfaceColorMode colorMode = dstColorSpace
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps());
sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc));
if (texture) {
@ -397,17 +401,15 @@ GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info,
}
GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
const GrSamplerParams& params,
SkDestinationSurfaceColorMode colorMode) {
const GrSamplerParams& params) {
// Caller doesn't care about the texture's color space (they can always get it from the bitmap)
return GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, colorMode, nullptr);
return GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, nullptr, nullptr);
}
sk_sp<GrTexture> GrMakeCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
const GrSamplerParams& params,
SkDestinationSurfaceColorMode colorMode) {
const GrSamplerParams& params) {
// Caller doesn't care about the texture's color space (they can always get it from the bitmap)
GrTexture* tex = GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, colorMode,
GrTexture* tex = GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, nullptr,
nullptr);
return sk_sp<GrTexture>(tex);
}
@ -574,8 +576,7 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
} else if (const SkShader* shader = skPaint.getShader()) {
shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context, &viewM, nullptr,
skPaint.getFilterQuality(),
rtc->getColorSpace(),
rtc->colorMode()));
rtc->getColorSpace()));
if (!shaderFP) {
return false;
}
@ -762,8 +763,7 @@ bool SkPaintToGrPaintWithTexture(GrContext* context,
&viewM,
nullptr,
paint.getFilterQuality(),
rtc->getColorSpace(),
rtc->colorMode()));
rtc->getColorSpace()));
if (!shaderFP) {
return false;
}

View File

@ -131,7 +131,7 @@ GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data,
GrTexture* GrUploadBitmapToTexture(GrContext*, const SkBitmap&);
GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext*, const SkBitmap&,
SkDestinationSurfaceColorMode);
SkColorSpace* dstColorSpace);
/**
* Creates a new texture for the pixmap.

View File

@ -66,11 +66,8 @@ bool SkImage::scalePixels(const SkPixmap& dst, SkFilterQuality quality, CachingH
// Idea: If/when SkImageGenerator supports a native-scaling API (where the generator itself
// can scale more efficiently) we should take advantage of it here.
//
SkDestinationSurfaceColorMode decodeColorMode = dst.info().colorSpace()
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
SkBitmap bm;
if (as_IB(this)->getROPixels(&bm, decodeColorMode, chint)) {
if (as_IB(this)->getROPixels(&bm, dst.info().colorSpace(), chint)) {
bm.lockPixels();
SkPixmap pmap;
// Note: By calling the pixmap scaler, we never cache the final result, so the chint
@ -87,7 +84,8 @@ void SkImage::preroll(GrContext* ctx) const {
// to produce a cached raster-bitmap form, so that drawing to a raster canvas should be fast.
//
SkBitmap bm;
if (as_IB(this)->getROPixels(&bm, SkDestinationSurfaceColorMode::kLegacy)) {
SkColorSpace* legacyColorSpace = nullptr;
if (as_IB(this)->getROPixels(&bm, legacyColorSpace)) {
bm.lockPixels();
bm.unlockPixels();
}
@ -109,7 +107,8 @@ SkData* SkImage::encode(SkEncodedImageFormat type, int quality) const {
// TODO: Right now, the encoders don't handle F16 or linearly premultiplied data. Once they do,
// we should decode in "color space aware" mode, then re-encode that. For now, work around this
// by asking for a legacy decode (which gives us the raw data in N32).
if (as_IB(this)->getROPixels(&bm, SkDestinationSurfaceColorMode::kLegacy)) {
SkColorSpace* legacyColorSpace = nullptr;
if (as_IB(this)->getROPixels(&bm, legacyColorSpace)) {
SkDynamicMemoryWStream buf;
return SkEncodeImage(&buf, bm, type, quality) ? buf.detachAsData().release() : nullptr;
}
@ -128,7 +127,8 @@ SkData* SkImage::encode(SkPixelSerializer* serializer) const {
// TODO: Right now, the encoders don't handle F16 or linearly premultiplied data. Once they do,
// we should decode in "color space aware" mode, then re-encode that. For now, work around this
// by asking for a legacy decode (which gives us the raw data in N32).
if (as_IB(this)->getROPixels(&bm, SkDestinationSurfaceColorMode::kLegacy) &&
SkColorSpace* legacyColorSpace = nullptr;
if (as_IB(this)->getROPixels(&bm, legacyColorSpace) &&
bm.requestLock(&apu)) {
if (serializer) {
return serializer->encode(apu.pixmap());
@ -327,11 +327,8 @@ sk_sp<SkImage> SkImage::makeWithFilter(const SkImageFilter* filter, const SkIRec
return nullptr;
}
SkColorSpace* colorSpace = as_IB(this)->onImageInfo().colorSpace();
SkDestinationSurfaceColorMode decodeColorMode = colorSpace
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
sk_sp<SkSpecialImage> srcSpecialImage = SkSpecialImage::MakeFromImage(
subset, sk_ref_sp(const_cast<SkImage*>(this)), decodeColorMode);
subset, sk_ref_sp(const_cast<SkImage*>(this)), colorSpace);
if (!srcSpecialImage) {
return nullptr;
}

View File

@ -54,11 +54,8 @@ size_t SkImageShader::onContextSize(const ContextRec& rec) const {
}
SkShader::Context* SkImageShader::onCreateContext(const ContextRec& rec, void* storage) const {
// TODO: This is wrong. We should be plumbing destination color space to context creation,
// and use that to determine the decoding mode of the image.
SkDestinationSurfaceColorMode decodeColorMode = SkMipMap::DeduceColorMode(rec);
return SkBitmapProcLegacyShader::MakeContext(*this, fTileModeX, fTileModeY,
SkBitmapProvider(fImage.get(), decodeColorMode),
SkBitmapProvider(fImage.get(), rec.fDstColorSpace),
rec, storage);
}
@ -218,7 +215,7 @@ sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(const AsFPArgs& ar
&doBicubic);
GrSamplerParams params(tm, textureFilterMode);
sk_sp<SkColorSpace> texColorSpace;
sk_sp<GrTexture> texture(as_IB(fImage)->asTextureRef(args.fContext, params, args.fColorMode,
sk_sp<GrTexture> texture(as_IB(fImage)->asTextureRef(args.fContext, params, args.fDstColorSpace,
&texColorSpace));
if (!texture) {
return nullptr;
@ -281,9 +278,7 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkFal
}
auto quality = paint.getFilterQuality();
auto mode = (dst == nullptr) ? SkDestinationSurfaceColorMode::kLegacy
: SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware;
SkBitmapProvider provider(fImage.get(), mode);
SkBitmapProvider provider(fImage.get(), dst);
SkDefaultBitmapController controller;
std::unique_ptr<SkBitmapController::State> state {
controller.requestBitmap(provider, matrix, quality)

View File

@ -52,12 +52,12 @@ public:
// return a read-only copy of the pixels. We promise to not modify them,
// but only inspect them (or encode them).
virtual bool getROPixels(SkBitmap*, SkDestinationSurfaceColorMode,
virtual bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace,
CachingHint = kAllow_CachingHint) const = 0;
// Caller must call unref when they are done.
virtual GrTexture* asTextureRef(GrContext*, const GrSamplerParams&,
SkDestinationSurfaceColorMode, sk_sp<SkColorSpace>*) const = 0;
virtual GrTexture* asTextureRef(GrContext*, const GrSamplerParams&, SkColorSpace*,
sk_sp<SkColorSpace>*) const = 0;
virtual sk_sp<SkImage> onMakeSubset(const SkIRect&) const = 0;

View File

@ -30,9 +30,9 @@ public:
SkImageCacherator* peekCacherator() const override { return &fCache; }
SkData* onRefEncoded(GrContext*) const override;
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
bool getROPixels(SkBitmap*, SkDestinationSurfaceColorMode, CachingHint) const override;
GrTexture* asTextureRef(GrContext*, const GrSamplerParams&,
SkDestinationSurfaceColorMode, sk_sp<SkColorSpace>*) const override;
bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override;
GrTexture* asTextureRef(GrContext*, const GrSamplerParams&, SkColorSpace*,
sk_sp<SkColorSpace>*) const override;
bool onIsLazyGenerated() const override { return true; }
private:
@ -45,12 +45,10 @@ private:
bool SkImage_Generator::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
int srcX, int srcY, CachingHint chint) const {
SkDestinationSurfaceColorMode decodeColorMode = dstInfo.colorSpace()
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
SkColorSpace* dstColorSpace = dstInfo.colorSpace();
SkBitmap bm;
if (kDisallow_CachingHint == chint) {
SkImageCacherator::CachedFormat cacheFormat = fCache.chooseCacheFormat(decodeColorMode);
SkImageCacherator::CachedFormat cacheFormat = fCache.chooseCacheFormat(dstColorSpace);
if (fCache.lockAsBitmapOnlyIfAlreadyCached(&bm, cacheFormat)) {
return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY);
} else {
@ -64,7 +62,7 @@ bool SkImage_Generator::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels
}
}
if (this->getROPixels(&bm, decodeColorMode, chint)) {
if (this->getROPixels(&bm, dstColorSpace, chint)) {
return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY);
}
return false;
@ -74,15 +72,15 @@ SkData* SkImage_Generator::onRefEncoded(GrContext* ctx) const {
return fCache.refEncoded(ctx);
}
bool SkImage_Generator::getROPixels(SkBitmap* bitmap, SkDestinationSurfaceColorMode colorMode,
bool SkImage_Generator::getROPixels(SkBitmap* bitmap, SkColorSpace* dstColorSpace,
CachingHint chint) const {
return fCache.lockAsBitmap(bitmap, this, colorMode, chint);
return fCache.lockAsBitmap(bitmap, this, dstColorSpace, chint);
}
GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, const GrSamplerParams& params,
SkDestinationSurfaceColorMode colorMode,
SkColorSpace* dstColorSpace,
sk_sp<SkColorSpace>* texColorSpace) const {
return fCache.lockAsTexture(ctx, params, colorMode, texColorSpace, this);
return fCache.lockAsTexture(ctx, params, dstColorSpace, texColorSpace, this);
}
sk_sp<SkImage> SkImage_Generator::onMakeSubset(const SkIRect& subset) const {

View File

@ -63,7 +63,7 @@ static SkImageInfo make_info(int w, int h, SkAlphaType at, sk_sp<SkColorSpace> c
return SkImageInfo::MakeN32(w, h, at, std::move(colorSpace));
}
bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkDestinationSurfaceColorMode,
bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkColorSpace* dstColorSpace,
CachingHint chint) const {
if (SkBitmapCache::Find(this->uniqueID(), dst)) {
SkASSERT(dst->getGenerationID() == this->uniqueID());
@ -90,14 +90,14 @@ bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkDestinationSurfaceColorMode,
}
GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrSamplerParams& params,
SkDestinationSurfaceColorMode colorMode,
SkColorSpace* dstColorSpace,
sk_sp<SkColorSpace>* texColorSpace) const {
if (texColorSpace) {
*texColorSpace = this->fColorSpace;
}
GrTextureAdjuster adjuster(this->peekTexture(), this->alphaType(), this->bounds(),
this->uniqueID(), this->fColorSpace.get());
return adjuster.refTextureSafeForParams(params, colorMode, nullptr);
return adjuster.refTextureSafeForParams(params, nullptr);
}
static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) {
@ -463,11 +463,8 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
}
if (SkImageCacherator* cacher = as_IB(this)->peekCacherator()) {
// Generator backed image. Tweak info to trigger correct kind of decode.
SkDestinationSurfaceColorMode decodeColorMode = dstColorSpace
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
SkImageCacherator::CachedFormat cacheFormat = cacher->chooseCacheFormat(
decodeColorMode, proxy.fCaps.get());
dstColorSpace, proxy.fCaps.get());
info = cacher->buildCacheInfo(cacheFormat).makeWH(scaledSize.width(),
scaledSize.height());

View File

@ -38,9 +38,9 @@ public:
}
}
bool getROPixels(SkBitmap*, SkDestinationSurfaceColorMode, CachingHint) const override;
GrTexture* asTextureRef(GrContext* ctx, const GrSamplerParams& params,
SkDestinationSurfaceColorMode, sk_sp<SkColorSpace>*) const override;
bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override;
GrTexture* asTextureRef(GrContext* ctx, const GrSamplerParams& params, SkColorSpace*,
sk_sp<SkColorSpace>*) const override;
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
GrTexture* peekTexture() const override { return fTexture.get(); }

View File

@ -87,9 +87,9 @@ public:
bool onPeekPixels(SkPixmap*) const override;
const SkBitmap* onPeekBitmap() const override { return &fBitmap; }
bool getROPixels(SkBitmap*, SkDestinationSurfaceColorMode, CachingHint) const override;
GrTexture* asTextureRef(GrContext*, const GrSamplerParams&,
SkDestinationSurfaceColorMode, sk_sp<SkColorSpace>*) const override;
bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override;
GrTexture* asTextureRef(GrContext*, const GrSamplerParams&, SkColorSpace*,
sk_sp<SkColorSpace>*) const override;
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
// exposed for SkSurface_Raster via SkNewImageFromPixelRef
@ -179,13 +179,13 @@ bool SkImage_Raster::onPeekPixels(SkPixmap* pm) const {
return fBitmap.peekPixels(pm);
}
bool SkImage_Raster::getROPixels(SkBitmap* dst, SkDestinationSurfaceColorMode, CachingHint) const {
bool SkImage_Raster::getROPixels(SkBitmap* dst, SkColorSpace* dstColorSpace, CachingHint) const {
*dst = fBitmap;
return true;
}
GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrSamplerParams& params,
SkDestinationSurfaceColorMode colorMode,
SkColorSpace* dstColorSpace,
sk_sp<SkColorSpace>* texColorSpace) const {
#if SK_SUPPORT_GPU
if (!ctx) {
@ -201,10 +201,10 @@ GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrSamplerParams& p
if (tex) {
GrTextureAdjuster adjuster(fPinnedTexture.get(), fBitmap.alphaType(), fBitmap.bounds(),
fPinnedUniqueID, fBitmap.colorSpace());
return adjuster.refTextureSafeForParams(params, colorMode, nullptr);
return adjuster.refTextureSafeForParams(params, nullptr);
}
return GrRefCachedBitmapTexture(ctx, fBitmap, params, colorMode);
return GrRefCachedBitmapTexture(ctx, fBitmap, params);
#endif
return nullptr;
@ -231,8 +231,7 @@ bool SkImage_Raster::onPinAsTexture(GrContext* ctx) const {
SkASSERT(fPinnedCount == 0);
SkASSERT(fPinnedUniqueID == 0);
fPinnedTexture.reset(
GrRefCachedBitmapTexture(ctx, fBitmap, GrSamplerParams::ClampNoFilter(),
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
GrRefCachedBitmapTexture(ctx, fBitmap, GrSamplerParams::ClampNoFilter()));
if (!fPinnedTexture) {
return false;
}

View File

@ -17,7 +17,8 @@
#include "SkUnPreMultiply.h"
void image_get_ro_pixels(const SkImage* image, SkBitmap* dst) {
if(as_IB(image)->getROPixels(dst, SkDestinationSurfaceColorMode::kLegacy)
SkColorSpace* legacyColorSpace = nullptr;
if(as_IB(image)->getROPixels(dst, legacyColorSpace)
&& dst->dimensions() == image->dimensions()) {
if (dst->colorType() != kIndex_8_SkColorType) {
return;
@ -502,7 +503,8 @@ sk_sp<SkPDFObject> SkPDFCreateBitmapObject(sk_sp<SkImage> image,
if (pixelSerializer) {
SkBitmap bm;
SkAutoPixmapUnlock apu;
if (as_IB(image.get())->getROPixels(&bm, SkDestinationSurfaceColorMode::kLegacy) &&
SkColorSpace* legacyColorSpace = nullptr;
if (as_IB(image.get())->getROPixels(&bm, legacyColorSpace) &&
bm.requestLock(&apu)) {
data.reset(pixelSerializer->encode(apu.pixmap()));
if (data && SkIsJFIF(data.get(), &info)) {

View File

@ -2318,9 +2318,9 @@ sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) {
// TODO: See comment above in drawSpecial. The color mode we use for decode should be driven
// by the destination where we're going to draw thing thing (ie this device). But we don't have
// a color space, so we always decode in legacy mode for now.
SkColorSpace* legacyColorSpace = nullptr;
return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->height()),
image->makeNonTextureImage(),
SkDestinationSurfaceColorMode::kLegacy);
image->makeNonTextureImage(), legacyColorSpace);
}
sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() {

View File

@ -154,14 +154,14 @@ DEF_TEST(ImageFilterCache_RasterBacked, reporter) {
// Shared test code for both the raster and gpu-backed image cases
static void test_image_backed(skiatest::Reporter* reporter, const sk_sp<SkImage>& srcImage) {
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
SkColorSpace* legacyColorSpace = nullptr;
sk_sp<SkSpecialImage> fullImg(
SkSpecialImage::MakeFromImage(full, srcImage, SkDestinationSurfaceColorMode::kLegacy));
sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromImage(full, srcImage, legacyColorSpace));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
sk_sp<SkSpecialImage> subsetImg(
SkSpecialImage::MakeFromImage(subset, srcImage, SkDestinationSurfaceColorMode::kLegacy));
sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromImage(subset, srcImage,
legacyColorSpace));
test_find_existing(reporter, fullImg, subsetImg);
test_dont_find_if_diff_key(reporter, fullImg, subsetImg);

View File

@ -52,7 +52,8 @@ static void test_blender(std::string resourceName, skiatest::Reporter* reporter)
return;
}
SkBitmap bm;
if (!as_IB(image)->getROPixels(&bm, SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware)) {
sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
if (!as_IB(image)->getROPixels(&bm, srgbColorSpace.get())) {
ERRORF(reporter, "Could not read resource");
return;
}

View File

@ -155,20 +155,20 @@ DEF_TEST(SpecialImage_Raster, reporter) {
}
}
static void test_specialimage_image(skiatest::Reporter* reporter,
SkDestinationSurfaceColorMode colorMode) {
static void test_specialimage_image(skiatest::Reporter* reporter, SkColorSpace* dstColorSpace) {
SkBitmap bm = create_bm();
sk_sp<SkImage> fullImage(SkImage::MakeFromBitmap(bm));
sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromImage(
SkIRect::MakeWH(kFullSize, kFullSize),
fullImage, colorMode));
fullImage, dstColorSpace));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
{
sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(subset, fullImage, colorMode));
sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(subset, fullImage,
dstColorSpace));
test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize);
}
@ -179,11 +179,13 @@ static void test_specialimage_image(skiatest::Reporter* reporter,
}
DEF_TEST(SpecialImage_Image_Legacy, reporter) {
test_specialimage_image(reporter, SkDestinationSurfaceColorMode::kLegacy);
SkColorSpace* legacyColorSpace = nullptr;
test_specialimage_image(reporter, legacyColorSpace);
}
DEF_TEST(SpecialImage_Image_ColorSpaceAware, reporter) {
test_specialimage_image(reporter, SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware);
sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
test_specialimage_image(reporter, srgbColorSpace.get());
}
#if SK_SUPPORT_GPU