diff options
author | brianosman <brianosman@google.com> | 2016-08-18 06:43:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-18 06:43:03 -0700 |
commit | 5814b8a1dda25665810e05408895ed202d31d472 (patch) | |
tree | 45ff2796fe7393bd41f29fd203fa7bd8818d3c5a /src | |
parent | 2a43fe2723cbf70613f49abaa43a9e2ccd434b6b (diff) |
Add alpha type to texture producer
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2250403003
Review-Url: https://codereview.chromium.org/2250403003
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrImageIDTextureAdjuster.cpp | 8 | ||||
-rw-r--r-- | src/gpu/GrImageIDTextureAdjuster.h | 2 | ||||
-rw-r--r-- | src/gpu/GrTextureParamsAdjuster.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrTextureParamsAdjuster.h | 6 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 6 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 2 | ||||
-rw-r--r-- | src/image/SkImage_Raster.cpp | 2 |
7 files changed, 24 insertions, 8 deletions
diff --git a/src/gpu/GrImageIDTextureAdjuster.cpp b/src/gpu/GrImageIDTextureAdjuster.cpp index f9aaae1282..5a96b6d3e6 100644 --- a/src/gpu/GrImageIDTextureAdjuster.cpp +++ b/src/gpu/GrImageIDTextureAdjuster.cpp @@ -62,6 +62,10 @@ void GrBitmapTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { GrInstallBitmapUniqueKeyInvalidator(copyKey, fBitmap.pixelRef()); } +SkAlphaType GrBitmapTextureMaker::alphaType() const { + return fBitmap.alphaType(); +} + SkColorSpace* GrBitmapTextureMaker::getColorSpace() { return fBitmap.colorSpace(); } @@ -101,6 +105,10 @@ void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { } } +SkAlphaType GrImageTextureMaker::alphaType() const { + return fCacher->info().alphaType(); +} + SkColorSpace* GrImageTextureMaker::getColorSpace() { return fCacher->info().colorSpace(); } diff --git a/src/gpu/GrImageIDTextureAdjuster.h b/src/gpu/GrImageIDTextureAdjuster.h index 25b866bbc0..36ac0ad3e1 100644 --- a/src/gpu/GrImageIDTextureAdjuster.h +++ b/src/gpu/GrImageIDTextureAdjuster.h @@ -29,6 +29,7 @@ protected: void didCacheCopy(const GrUniqueKey& copyKey) override; + SkAlphaType alphaType() const override; SkColorSpace* getColorSpace() override; private: @@ -54,6 +55,7 @@ protected: void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) override; void didCacheCopy(const GrUniqueKey& copyKey) override; + SkAlphaType alphaType() const override; SkColorSpace* getColorSpace() override; private: diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp index 20b77cb844..68a6f99070 100644 --- a/src/gpu/GrTextureParamsAdjuster.cpp +++ b/src/gpu/GrTextureParamsAdjuster.cpp @@ -112,11 +112,13 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset, return copyDC->asTexture().release(); } -GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea, - uint32_t uniqueID, SkColorSpace* cs) +GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, SkAlphaType alphaType, + const SkIRect& contentArea, uint32_t uniqueID, + SkColorSpace* cs) : INHERITED(contentArea.width(), contentArea.height(), GrPixelConfigIsAlphaOnly(original->config())) , fOriginal(original) + , fAlphaType(alphaType) , fColorSpace(cs) , fUniqueID(uniqueID) { diff --git a/src/gpu/GrTextureParamsAdjuster.h b/src/gpu/GrTextureParamsAdjuster.h index 879c6605f8..3de4db7441 100644 --- a/src/gpu/GrTextureParamsAdjuster.h +++ b/src/gpu/GrTextureParamsAdjuster.h @@ -73,6 +73,7 @@ public: int width() const { return fWidth; } int height() const { return fHeight; } bool isAlphaOnly() const { return fIsAlphaOnly; } + virtual SkAlphaType alphaType() const = 0; virtual SkColorSpace* getColorSpace() = 0; protected: @@ -144,9 +145,11 @@ public: // We do not ref the texture nor the colorspace, so the caller must keep them in scope while // this Adjuster is alive. - GrTextureAdjuster(GrTexture*, const SkIRect& area, uint32_t uniqueID, SkColorSpace*); + GrTextureAdjuster(GrTexture*, SkAlphaType, const SkIRect& area, uint32_t uniqueID, + SkColorSpace*); protected: + SkAlphaType alphaType() const override { return fAlphaType; } SkColorSpace* getColorSpace() override; void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override; void didCacheCopy(const GrUniqueKey& copyKey) override; @@ -159,6 +162,7 @@ protected: private: SkTLazy<SkIRect> fContentArea; GrTexture* fOriginal; + SkAlphaType fAlphaType; SkColorSpace* fColorSpace; uint32_t fUniqueID; diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 864d124aea..376d5e1b57 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1316,7 +1316,7 @@ void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x uint32_t pinnedUniqueID; if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) { CHECK_SHOULD_DRAW(draw); - GrTextureAdjuster adjuster(tex.get(), image->bounds(), pinnedUniqueID, + GrTextureAdjuster adjuster(tex.get(), image->alphaType(), image->bounds(), pinnedUniqueID, as_IB(image)->onImageInfo().colorSpace()); this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_SrcRectConstraint, viewMatrix, fClip, paint); @@ -1348,7 +1348,7 @@ void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const uint32_t pinnedUniqueID; if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) { CHECK_SHOULD_DRAW(draw); - GrTextureAdjuster adjuster(tex.get(), image->bounds(), pinnedUniqueID, + GrTextureAdjuster adjuster(tex.get(), image->alphaType(), image->bounds(), pinnedUniqueID, as_IB(image)->onImageInfo().colorSpace()); this->drawTextureProducer(&adjuster, src, &dst, constraint, *draw.fMatrix, fClip, paint); return; @@ -1419,7 +1419,7 @@ void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, uint32_t pinnedUniqueID; if (sk_sp<GrTexture> tex = as_IB(image)->refPinnedTexture(&pinnedUniqueID)) { CHECK_SHOULD_DRAW(draw); - GrTextureAdjuster adjuster(tex.get(), image->bounds(), pinnedUniqueID, + GrTextureAdjuster adjuster(tex.get(), image->alphaType(), image->bounds(), pinnedUniqueID, as_IB(image)->onImageInfo().colorSpace()); this->drawProducerNine(draw, &adjuster, center, dst, paint); } else { diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index eba66f46ed..6b7416b26b 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -82,7 +82,7 @@ bool SkImage_Gpu::getROPixels(SkBitmap* dst, CachingHint chint) const { GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& params, SkSourceGammaTreatment gammaTreatment) const { - GrTextureAdjuster adjuster(this->peekTexture(), this->bounds(), this->uniqueID(), + GrTextureAdjuster adjuster(this->peekTexture(), this->alphaType(), this->bounds(), this->uniqueID(), this->onImageInfo().colorSpace()); return adjuster.refTextureSafeForParams(params, gammaTreatment, nullptr); } diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index d334dfb326..5799f0b3ef 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp @@ -207,7 +207,7 @@ GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p uint32_t uniqueID; sk_sp<GrTexture> tex = this->refPinnedTexture(&uniqueID); if (tex) { - GrTextureAdjuster adjuster(fPinnedTexture.get(), fBitmap.bounds(), + GrTextureAdjuster adjuster(fPinnedTexture.get(), fBitmap.alphaType(), fBitmap.bounds(), fPinnedUniqueID, fBitmap.colorSpace()); return adjuster.refTextureSafeForParams(params, gammaTreatment, nullptr); } |