diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrBitmapTextureMaker.cpp | 3 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 39 | ||||
-rw-r--r-- | src/gpu/SkGr.h | 7 |
3 files changed, 26 insertions, 23 deletions
diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp index 6c771675ee..bde827658a 100644 --- a/src/gpu/GrBitmapTextureMaker.cpp +++ b/src/gpu/GrBitmapTextureMaker.cpp @@ -41,7 +41,8 @@ sk_sp<GrTextureProxy> GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM proxy = GrGenerateMipMapsAndUploadToTextureProxy(this->context(), fBitmap, dstColorSpace); } if (!proxy) { - proxy = GrUploadBitmapToTextureProxy(this->context()->resourceProvider(), fBitmap); + proxy = GrUploadBitmapToTextureProxy(this->context()->resourceProvider(), fBitmap, + dstColorSpace); } if (proxy && fOriginalKey.isValid()) { this->context()->resourceProvider()->assignUniqueKeyToProxy(fOriginalKey, proxy.get()); diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index d331278448..81fde3579d 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -62,7 +62,8 @@ void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima ////////////////////////////////////////////////////////////////////////////// sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrResourceProvider* resourceProvider, - const SkBitmap& bitmap) { + const SkBitmap& bitmap, + SkColorSpace* dstColorSpace) { if (!bitmap.readyToDraw()) { return nullptr; } @@ -70,7 +71,7 @@ sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrResourceProvider* resourceP if (!bitmap.peekPixels(&pixmap)) { return nullptr; } - return GrUploadPixmapToTextureProxy(resourceProvider, pixmap, SkBudgeted::kYes); + return GrUploadPixmapToTextureProxy(resourceProvider, pixmap, SkBudgeted::kYes, dstColorSpace); } static const SkPixmap* compute_desc(const GrCaps& caps, const SkPixmap& pixmap, @@ -127,9 +128,18 @@ static const SkPixmap* compute_desc(const GrCaps& caps, const SkPixmap& pixmap, return pmap; } -sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxyNoCheck(GrResourceProvider* resourceProvider, - const SkPixmap& pixmap, - SkBudgeted budgeted) { +sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrResourceProvider* resourceProvider, + const SkPixmap& pixmap, + SkBudgeted budgeted, + SkColorSpace* dstColorSpace) { + SkDestinationSurfaceColorMode colorMode = dstColorSpace + ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware + : SkDestinationSurfaceColorMode::kLegacy; + + if (!SkImageInfoIsValid(pixmap.info(), colorMode)) { + return nullptr; + } + SkBitmap tmpBitmap; SkPixmap tmpPixmap; GrSurfaceDesc desc; @@ -143,16 +153,6 @@ sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxyNoCheck(GrResourceProvider* re return nullptr; } -sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrResourceProvider* resourceProvider, - const SkPixmap& pixmap, - SkBudgeted budgeted) { - if (!SkImageInfoIsValidRenderingCS(pixmap.info())) { - return nullptr; - } - - return GrUploadPixmapToTextureProxyNoCheck(resourceProvider, pixmap, budgeted); -} - //////////////////////////////////////////////////////////////////////////////// void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pixelRef) { @@ -175,7 +175,7 @@ sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext* ctx, ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware : SkDestinationSurfaceColorMode::kLegacy; - if (!SkImageInfoIsValidRenderingCS(bitmap.info())) { + if (!SkImageInfoIsValid(bitmap.info(), colorMode)) { return nullptr; } @@ -222,7 +222,7 @@ sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrContext* ctx, const SkImage const GrMipLevel* texels, int mipLevelCount, SkDestinationSurfaceColorMode colorMode) { - if (!SkImageInfoIsValidRenderingCS(info)) { + if (!SkImageInfoIsValid(info, colorMode)) { return nullptr; } @@ -257,7 +257,10 @@ sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrResourceProvider* resourceProvid proxy = resourceProvider->findProxyByUniqueKey(originalKey); } if (!proxy) { - proxy = GrUploadBitmapToTextureProxy(resourceProvider, bitmap); + // Pass nullptr for |dstColorSpace|. This is lenient - we allow a wider range of + // color spaces in legacy mode. Unfortunately, we have to be lenient here, since + // we can't necessarily know the |dstColorSpace| at this time. + proxy = GrUploadBitmapToTextureProxy(resourceProvider, bitmap, nullptr); if (proxy && originalKey.isValid()) { resourceProvider->assignUniqueKeyToProxy(originalKey, proxy.get()); // MDB TODO (caching): this has to play nice with the GrSurfaceProxy's caching diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h index cefcc4858d..7784c53845 100644 --- a/src/gpu/SkGr.h +++ b/src/gpu/SkGr.h @@ -211,7 +211,8 @@ sk_sp<GrTextureProxy> GrRefCachedBitmapTextureProxy(GrContext*, * The bitmap must have CPU-accessible pixels. Attempts to take advantage of faster paths for * compressed textures and yuv planes. */ -sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrResourceProvider*, const SkBitmap&); +sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrResourceProvider*, const SkBitmap&, + SkColorSpace* dstColorSpace); sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext*, const SkBitmap&, SkColorSpace* dstColorSpace); @@ -220,9 +221,7 @@ sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext*, const * Creates a new texture for the pixmap. */ sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrResourceProvider*, - const SkPixmap&, SkBudgeted); -sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxyNoCheck(GrResourceProvider*, - const SkPixmap&, SkBudgeted); + const SkPixmap&, SkBudgeted, SkColorSpace*); /** * Creates a new texture populated with the mipmap levels. |