diff options
author | Jim Van Verth <jvanverth@google.com> | 2018-11-02 13:36:42 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-11-05 17:42:03 +0000 |
commit | 30e0d7fb4fbad3a8535619ff7391c5c0f86cd66d (patch) | |
tree | 94488a4d0d6f615afc088b321ae0c3feca5b1cb4 /src/image | |
parent | 8b35379ae1f1b223385a1c566628eb9a33a5683c (diff) | |
download | skqp-30e0d7fb4fbad3a8535619ff7391c5c0f86cd66d.tar.gz |
Draw YUVA images with multitexture
Bug: skia:7901
Change-Id: I99cde1acc27c1cfb730671463a2c17537926cd99
Reviewed-on: https://skia-review.googlesource.com/c/164696
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/image')
-rw-r--r-- | src/image/SkImage_Base.h | 4 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 3 | ||||
-rw-r--r-- | src/image/SkImage_GpuYUVA.cpp | 25 | ||||
-rw-r--r-- | src/image/SkImage_GpuYUVA.h | 16 |
4 files changed, 45 insertions, 3 deletions
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index 8cb796faa9..c4c6fab23c 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -58,7 +58,9 @@ public: virtual sk_sp<GrTextureProxy> refPinnedTextureProxy(uint32_t* uniqueID) const { return nullptr; } - + virtual bool isYUVA() const { return false; } + virtual bool asYUVATextureProxiesRef(sk_sp<GrTextureProxy>[4], SkYUVAIndex[4], + SkYUVColorSpace*) const { return false; } virtual GrTexture* onGetTexture() const { return nullptr; } #endif virtual GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO, diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 8cf4edbcf0..f4098855c3 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -183,7 +183,8 @@ sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB( // TODO: Modify the fragment processor to sample from different channel instead of taking nv12 // bool. paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Make(tempTextureProxies, yuvaIndices, - yuvColorSpace)); + yuvColorSpace, + GrSamplerState::Filter::kNearest)); const SkRect rect = SkRect::MakeIWH(width, height); diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp index 9a54d23713..8a32d1ad67 100644 --- a/src/image/SkImage_GpuYUVA.cpp +++ b/src/image/SkImage_GpuYUVA.cpp @@ -12,10 +12,13 @@ #include "GrClip.h" #include "GrContext.h" #include "GrContextPriv.h" +#include "GrGpu.h" #include "GrRenderTargetContext.h" #include "GrTexture.h" +#include "GrTextureProducer.h" #include "SkImage_Gpu.h" #include "SkImage_GpuYUVA.h" +#include "SkMipMap.h" #include "SkYUVASizeInfo.h" #include "effects/GrYUVtoRGBEffect.h" @@ -52,6 +55,25 @@ SkImageInfo SkImage_GpuYUVA::onImageInfo() const { fAlphaType, fColorSpace); } +bool SkImage_GpuYUVA::canBeMipmapped(GrContext* context) const { + int numTextures; + if (!SkYUVAIndex::AreValidIndices(fYUVAIndices, &numTextures)) { + return false; + } + + for (int i = 0; i < numTextures; ++i) { + GrTextureProducer::CopyParams copyParams; + int mipCount = SkMipMap::ComputeLevelCount(fProxies[i]->width(), fProxies[i]->height()); + if (mipCount && GrGpu::IsACopyNeededForMips(fContext->contextPriv().caps(), + fProxies[i].get(), + GrSamplerState::Filter::kMipMap, + ©Params)) { + return false; + } + } + return true; +} + ////////////////////////////////////////////////////////////////////////////////////////////////// sk_sp<GrTextureProxy> SkImage_GpuYUVA::asTextureProxyRef() const { @@ -69,7 +91,8 @@ sk_sp<GrTextureProxy> SkImage_GpuYUVA::asTextureProxyRef() const { // TODO: modify the YUVtoRGBEffect to do premul if fImageAlphaType is kPremul_AlphaType paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Make(fProxies, fYUVAIndices, - fYUVColorSpace)); + fYUVColorSpace, + GrSamplerState::Filter::kNearest)); const SkRect rect = SkRect::MakeIWH(this->width(), this->height()); diff --git a/src/image/SkImage_GpuYUVA.h b/src/image/SkImage_GpuYUVA.h index 2b4a5dd31d..fea77005d5 100644 --- a/src/image/SkImage_GpuYUVA.h +++ b/src/image/SkImage_GpuYUVA.h @@ -23,6 +23,8 @@ struct SkYUVASizeInfo; // proxy will be stored and used for any future rendering. class SkImage_GpuYUVA : public SkImage_GpuBase { public: + friend class GrYUVAImageTextureMaker; + SkImage_GpuYUVA(sk_sp<GrContext>, int width, int height, uint32_t uniqueID, SkYUVColorSpace, sk_sp<GrTextureProxy> proxies[], const SkYUVAIndex yuvaIndices[4], GrSurfaceOrigin, sk_sp<SkColorSpace>, SkBudgeted); @@ -35,6 +37,20 @@ public: virtual bool onIsTextureBacked() const override { return SkToBool(fProxies[0].get()); } + virtual bool isYUVA() const override { return true; } + virtual bool asYUVATextureProxiesRef(sk_sp<GrTextureProxy> proxies[4], + SkYUVAIndex yuvaIndices[4], + SkYUVColorSpace* yuvColorSpace) const override { + for (int i = 0; i < 4; ++i) { + proxies[i] = fProxies[i]; + yuvaIndices[i] = fYUVAIndices[i]; + } + *yuvColorSpace = fYUVColorSpace; + return true; + } + + bool canBeMipmapped(GrContext* context) const; + /** Create a new SkImage_GpuYUVA that's very similar to SkImage created by MakeFromYUVATextures. The main difference is that the client doesn't have the backend textures on the gpu yet but |