diff --git a/gn/gpu.gni b/gn/gpu.gni index c7535b06a1..8a1904d6c2 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -44,7 +44,6 @@ skia_gpu_sources = [ "$_include/private/GrResourceKey.h", "$_include/private/GrSingleOwner.h", "$_include/private/GrSurfaceProxy.h", - "$_include/private/GrSwizzle.h", "$_include/private/GrTextureProxy.h", "$_include/private/GrTypesPriv.h", @@ -195,6 +194,7 @@ skia_gpu_sources = [ "$_src/gpu/GrSurfaceContextPriv.h", "$_src/gpu/GrSurfaceProxyPriv.h", "$_src/gpu/GrSwizzle.cpp", + "$_src/gpu/GrSwizzle.h", "$_src/gpu/GrTessellator.cpp", "$_src/gpu/GrTessellator.h", "$_src/gpu/GrTextureOpList.cpp", diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h index f038db6033..040acead00 100644 --- a/include/private/GrRenderTargetProxy.h +++ b/include/private/GrRenderTargetProxy.h @@ -9,7 +9,6 @@ #define GrRenderTargetProxy_DEFINED #include "include/private/GrSurfaceProxy.h" -#include "include/private/GrSwizzle.h" #include "include/private/GrTypesPriv.h" class GrResourceProvider; @@ -55,8 +54,6 @@ public: int maxWindowRectangles(const GrCaps& caps) const; - const GrSwizzle& outputSwizzle() const { return fOutputSwizzle; } - bool wrapsVkSecondaryCB() const { return fWrapsVkSecondaryCB == WrapsVkSecondaryCB::kYes; } // TODO: move this to a priv class! @@ -72,9 +69,7 @@ protected: // Deferred version GrRenderTargetProxy(const GrCaps&, const GrBackendFormat&, const GrSurfaceDesc&, - GrSurfaceOrigin, const GrSwizzle& textureSwizzle, - const GrSwizzle& outputSwizzle, SkBackingFit, SkBudgeted, - GrInternalSurfaceFlags); + GrSurfaceOrigin, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags); enum class WrapsVkSecondaryCB : bool { kNo = false, kYes = true }; @@ -90,13 +85,11 @@ protected: // know the final size until flush time. GrRenderTargetProxy(LazyInstantiateCallback&&, LazyInstantiationType lazyType, const GrBackendFormat&, const GrSurfaceDesc&, GrSurfaceOrigin, - const GrSwizzle& textureSwizzle, const GrSwizzle& outputSwizzle, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags, WrapsVkSecondaryCB wrapsVkSecondaryCB); // Wrapped version - GrRenderTargetProxy(sk_sp, GrSurfaceOrigin, const GrSwizzle& textureSwizzle, - const GrSwizzle& outputSwizzle, + GrRenderTargetProxy(sk_sp, GrSurfaceOrigin, WrapsVkSecondaryCB wrapsVkSecondaryCB = WrapsVkSecondaryCB::kNo); sk_sp createSurface(GrResourceProvider*) const override; @@ -127,15 +120,8 @@ private: // address of other types, leading to this problem. int fSampleCnt; - GrSwizzle fOutputSwizzle; bool fNeedsStencil; WrapsVkSecondaryCB fWrapsVkSecondaryCB; - // This is to fix issue in large comment above. Without the padding we end 6 bytes into a 16 - // byte range, so the GrTextureProxy ends up starting 8 byte aligned by not 16. We add the - // padding here to get us right up to the 16 byte alignment (technically any padding of 3-10 - // bytes would work since it always goes up to 8 byte alignment, but we use 10 to more explicit - // about what we're doing). - char fDummyPadding[10]; // For wrapped render targets the actual GrRenderTarget is stored in the GrIORefProxy class. // For deferred proxies that pointer is filled in when we need to instantiate the diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index 414b84bcbc..7b938b1a07 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -13,7 +13,6 @@ #include "include/gpu/GrGpuResource.h" #include "include/gpu/GrSurface.h" #include "include/gpu/GrTexture.h" -#include "include/private/GrSwizzle.h" #include "include/private/SkNoncopyable.h" class GrCaps; @@ -250,8 +249,6 @@ public: return fOrigin; } - const GrSwizzle& textureSwizzle() const { return fTextureSwizzle; } - const GrBackendFormat& backendFormat() const { return fFormat; } class UniqueID { @@ -417,22 +414,20 @@ public: protected: // Deferred version GrSurfaceProxy(const GrBackendFormat& format, const GrSurfaceDesc& desc, - GrSurfaceOrigin origin, const GrSwizzle& textureSwizzle, SkBackingFit fit, + GrSurfaceOrigin origin, SkBackingFit fit, SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags) - : GrSurfaceProxy(nullptr, LazyInstantiationType::kSingleUse, format, desc, origin, - textureSwizzle, fit, budgeted, surfaceFlags) { + : GrSurfaceProxy(nullptr, LazyInstantiationType::kSingleUse, format, desc, origin, fit, + budgeted, surfaceFlags) { // Note: this ctor pulls a new uniqueID from the same pool at the GrGpuResources } // Lazy-callback version GrSurfaceProxy(LazyInstantiateCallback&&, LazyInstantiationType, const GrBackendFormat& format, const GrSurfaceDesc&, GrSurfaceOrigin, - const GrSwizzle& textureSwizzle, SkBackingFit, SkBudgeted, - GrInternalSurfaceFlags); + SkBackingFit, SkBudgeted, GrInternalSurfaceFlags); // Wrapped version. - GrSurfaceProxy(sk_sp, GrSurfaceOrigin, const GrSwizzle& textureSwizzle, - SkBackingFit); + GrSurfaceProxy(sk_sp, GrSurfaceOrigin, SkBackingFit); virtual ~GrSurfaceProxy(); @@ -483,8 +478,6 @@ private: int fWidth; int fHeight; GrSurfaceOrigin fOrigin; - GrSwizzle fTextureSwizzle; - SkBackingFit fFit; // always kApprox for lazy-callback resources // always kExact for wrapped resources mutable SkBudgeted fBudgeted; // always kYes for lazy-callback resources diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h index 7bc7528526..5d136e3cdd 100644 --- a/include/private/GrTextureProxy.h +++ b/include/private/GrTextureProxy.h @@ -88,10 +88,13 @@ protected: friend class GrTextureProxyPriv; friend class GrSurfaceProxyPriv; // ability to change key sync state after lazy instantiation. + // Deferred version - when constructed with data the origin is always kTopLeft. + GrTextureProxy(const GrBackendFormat&, const GrSurfaceDesc& srcDesc, GrMipMapped, SkBackingFit, + SkBudgeted, const void* srcData, size_t srcRowBytes, GrInternalSurfaceFlags); + // Deferred version - no data. GrTextureProxy(const GrBackendFormat&, const GrSurfaceDesc& srcDesc, GrSurfaceOrigin, - GrMipMapped, const GrSwizzle& textureSwizzle, SkBackingFit, SkBudgeted, - GrInternalSurfaceFlags); + GrMipMapped, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags); // Lazy-callback version // There are two main use cases for lazily-instantiated proxies: @@ -104,11 +107,11 @@ protected: // The minimal knowledge version is used for CCPR where we are generating an atlas but we do not // know the final size until flush time. GrTextureProxy(LazyInstantiateCallback&&, LazyInstantiationType, const GrBackendFormat&, - const GrSurfaceDesc& desc, GrSurfaceOrigin, GrMipMapped, const GrSwizzle&, - SkBackingFit, SkBudgeted, GrInternalSurfaceFlags); + const GrSurfaceDesc& desc, GrSurfaceOrigin, GrMipMapped, SkBackingFit, + SkBudgeted, GrInternalSurfaceFlags); // Wrapped version - GrTextureProxy(sk_sp, GrSurfaceOrigin, const GrSwizzle&); + GrTextureProxy(sk_sp, GrSurfaceOrigin); ~GrTextureProxy() override; diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 1a6962cf2d..025273d747 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -11,13 +11,13 @@ #include "include/core/SkPath.h" #include "include/core/SkSurface.h" #include "include/gpu/GrTypes.h" -#include "include/private/GrSwizzle.h" #include "include/private/SkTArray.h" #include "src/gpu/GrAllocator.h" #include "src/gpu/GrCaps.h" #include "src/gpu/GrGpuCommandBuffer.h" #include "src/gpu/GrProgramDesc.h" #include "src/gpu/GrSamplePatternDictionary.h" +#include "src/gpu/GrSwizzle.h" #include "src/gpu/GrTextureProducer.h" #include "src/gpu/GrXferProcessor.h" #include diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index 8551983ad5..bb9ca00c68 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -154,15 +154,11 @@ sk_sp GrProxyProvider::createWrapped(sk_sp tex, GrSur SkASSERT(!this->findProxyByUniqueKey(tex->getUniqueKey(), origin)); } #endif - GrColorType colorType = GrPixelConfigToColorType(tex->config()); - GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(tex->backendFormat(), colorType); if (tex->asRenderTarget()) { - GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(tex->backendFormat(), colorType); - return sk_sp(new GrTextureRenderTargetProxy(std::move(tex), origin, - texSwizzle, outSwizzle)); + return sk_sp(new GrTextureRenderTargetProxy(std::move(tex), origin)); } else { - return sk_sp(new GrTextureProxy(std::move(tex), origin, texSwizzle)); + return sk_sp(new GrTextureProxy(std::move(tex), origin)); } } @@ -452,20 +448,15 @@ sk_sp GrProxyProvider::createProxy(const GrBackendFormat& format this->caps()->getRenderTargetSampleCount(desc.fSampleCnt, desc.fConfig); } - GrColorType colorType = GrPixelConfigToColorType(desc.fConfig); - GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(format, colorType); - if (copyDesc.fFlags & kRenderTarget_GrSurfaceFlag) { // We know anything we instantiate later from this deferred path will be // both texturable and renderable - GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(format, colorType); return sk_sp(new GrTextureRenderTargetProxy(*this->caps(), format, copyDesc, - origin, mipMapped, texSwizzle, - outSwizzle, fit, budgeted, - surfaceFlags)); + origin, mipMapped, + fit, budgeted, surfaceFlags)); } - return sk_sp(new GrTextureProxy(format, copyDesc, origin, mipMapped, texSwizzle, + return sk_sp(new GrTextureProxy(format, copyDesc, origin, mipMapped, fit, budgeted, surfaceFlags)); } @@ -544,10 +535,7 @@ sk_sp GrProxyProvider::wrapBackendTexture(const GrBackendTexture // Make sure we match how we created the proxy with SkBudgeted::kNo SkASSERT(GrBudgetedType::kBudgeted != tex->resourcePriv().budgetedType()); - GrColorType colorType = GrPixelConfigToColorType(tex->config()); - GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(tex->backendFormat(), colorType); - - return sk_sp(new GrTextureProxy(std::move(tex), origin, texSwizzle)); + return sk_sp(new GrTextureProxy(std::move(tex), origin)); } sk_sp GrProxyProvider::wrapRenderableBackendTexture( @@ -588,12 +576,7 @@ sk_sp GrProxyProvider::wrapRenderableBackendTexture( // Make sure we match how we created the proxy with SkBudgeted::kNo SkASSERT(GrBudgetedType::kBudgeted != tex->resourcePriv().budgetedType()); - GrColorType colorType = GrPixelConfigToColorType(tex->config()); - GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(tex->backendFormat(), colorType); - GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(tex->backendFormat(), colorType); - - return sk_sp(new GrTextureRenderTargetProxy(std::move(tex), origin, texSwizzle, - outSwizzle)); + return sk_sp(new GrTextureRenderTargetProxy(std::move(tex), origin)); } sk_sp GrProxyProvider::wrapBackendRenderTarget( @@ -609,8 +592,8 @@ sk_sp GrProxyProvider::wrapBackendRenderTarget( return nullptr; } - GrColorType colorType = GrPixelConfigToColorType(backendRT.config()); #ifdef SK_DEBUG + GrColorType colorType = GrPixelConfigToColorType(backendRT.config()); GrPixelConfig testConfig = this->caps()->validateBackendRenderTarget(backendRT, GrColorTypeToSkColorType(colorType)); @@ -633,11 +616,7 @@ sk_sp GrProxyProvider::wrapBackendRenderTarget( // Make sure we match how we created the proxy with SkBudgeted::kNo SkASSERT(GrBudgetedType::kBudgeted != rt->resourcePriv().budgetedType()); - GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(rt->backendFormat(), colorType); - GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(rt->backendFormat(), colorType); - - return sk_sp(new GrRenderTargetProxy(std::move(rt), origin, texSwizzle, - outSwizzle)); + return sk_sp(new GrRenderTargetProxy(std::move(rt), origin)); } sk_sp GrProxyProvider::wrapBackendTextureAsRenderTarget( @@ -667,12 +646,7 @@ sk_sp GrProxyProvider::wrapBackendTextureAsRenderTarget( // This proxy should be unbudgeted because we're just wrapping an external resource SkASSERT(GrBudgetedType::kBudgeted != rt->resourcePriv().budgetedType()); - GrColorType colorType = GrPixelConfigToColorType(rt->config()); - GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(rt->backendFormat(), colorType); - GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(rt->backendFormat(), colorType); - - return sk_sp(new GrRenderTargetProxy(std::move(rt), origin, texSwizzle, - outSwizzle)); + return sk_sp(new GrRenderTargetProxy(std::move(rt), origin)); } sk_sp GrProxyProvider::wrapVulkanSecondaryCBAsRenderTarget( @@ -700,14 +674,10 @@ sk_sp GrProxyProvider::wrapVulkanSecondaryCBAsRenderTarget( // This proxy should be unbudgeted because we're just wrapping an external resource SkASSERT(GrBudgetedType::kBudgeted != rt->resourcePriv().budgetedType()); - GrColorType colorType = GrPixelConfigToColorType(rt->config()); - GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(rt->backendFormat(), colorType); - GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(rt->backendFormat(), colorType); - // All Vulkan surfaces uses top left origins. return sk_sp( new GrRenderTargetProxy(std::move(rt), - kTopLeft_GrSurfaceOrigin, texSwizzle, outSwizzle, + kTopLeft_GrSurfaceOrigin, GrRenderTargetProxy::WrapsVkSecondaryCB::kYes)); } @@ -764,17 +734,12 @@ sk_sp GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& } #endif - GrColorType colorType = GrPixelConfigToColorType(desc.fConfig); - GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(format, colorType); - GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(format, colorType); - return sk_sp( SkToBool(kRenderTarget_GrSurfaceFlag & desc.fFlags) ? new GrTextureRenderTargetProxy(std::move(callback), lazyType, format, desc, - origin, mipMapped, texSwizzle, outSwizzle, fit, - budgeted, surfaceFlags) + origin, mipMapped, fit, budgeted, surfaceFlags) : new GrTextureProxy(std::move(callback), lazyType, format, desc, origin, - mipMapped, texSwizzle, fit, budgeted, surfaceFlags)); + mipMapped, fit, budgeted, surfaceFlags)); } sk_sp GrProxyProvider::createLazyRenderTargetProxy( @@ -804,17 +769,13 @@ sk_sp GrProxyProvider::createLazyRenderTargetProxy( LazyInstantiationType lazyType = this->renderingDirectly() ? LazyInstantiationType::kSingleUse : LazyInstantiationType::kMultipleUse; - GrColorType colorType = GrPixelConfigToColorType(desc.fConfig); - GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(format, colorType); - GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(format, colorType); - if (textureInfo) { // Wrapped vulkan secondary command buffers don't support texturing since we won't have an // actual VkImage to texture from. SkASSERT(!wrapsVkSecondaryCB); return sk_sp(new GrTextureRenderTargetProxy( std::move(callback), lazyType, format, desc, origin, textureInfo->fMipMapped, - texSwizzle, outSwizzle, fit, budgeted, surfaceFlags)); + fit, budgeted, surfaceFlags)); } GrRenderTargetProxy::WrapsVkSecondaryCB vkSCB = @@ -822,8 +783,8 @@ sk_sp GrProxyProvider::createLazyRenderTargetProxy( : GrRenderTargetProxy::WrapsVkSecondaryCB::kNo; return sk_sp(new GrRenderTargetProxy( - std::move(callback), lazyType, format, desc, origin, texSwizzle, outSwizzle, fit, - budgeted, surfaceFlags, vkSCB)); + std::move(callback), lazyType, format, desc, origin, fit, budgeted, surfaceFlags, + vkSCB)); } sk_sp GrProxyProvider::MakeFullyLazyProxy( @@ -843,18 +804,14 @@ sk_sp GrProxyProvider::MakeFullyLazyProxy( desc.fConfig = config; desc.fSampleCnt = sampleCnt; - GrColorType colorType = GrPixelConfigToColorType(desc.fConfig); - GrSwizzle texSwizzle = caps.getTextureSwizzle(format, colorType); - GrSwizzle outSwizzle = caps.getOutputSwizzle(format, colorType); - return sk_sp( (Renderable::kYes == renderable) ? new GrTextureRenderTargetProxy( std::move(callback), LazyInstantiationType::kSingleUse, format, desc, - origin, GrMipMapped::kNo, texSwizzle, outSwizzle, - SkBackingFit::kApprox, SkBudgeted::kYes, surfaceFlags) + origin, GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, + surfaceFlags) : new GrTextureProxy(std::move(callback), LazyInstantiationType::kSingleUse, - format, desc, origin, GrMipMapped::kNo, texSwizzle, + format, desc, origin, GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, surfaceFlags)); } diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp index c90ff98f35..bd453c87e8 100644 --- a/src/gpu/GrRenderTargetProxy.cpp +++ b/src/gpu/GrRenderTargetProxy.cpp @@ -21,12 +21,10 @@ // cases to make the sampleConfig/numSamples stuff more rational. GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrBackendFormat& format, const GrSurfaceDesc& desc, GrSurfaceOrigin origin, - const GrSwizzle& textureSwizzle, - const GrSwizzle& outputSwizzle, SkBackingFit fit, - SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags) - : INHERITED(format, desc, origin, textureSwizzle, fit, budgeted, surfaceFlags) + SkBackingFit fit, SkBudgeted budgeted, + GrInternalSurfaceFlags surfaceFlags) + : INHERITED(format, desc, origin, fit, budgeted, surfaceFlags) , fSampleCnt(desc.fSampleCnt) - , fOutputSwizzle(outputSwizzle) , fNeedsStencil(false) , fWrapsVkSecondaryCB(WrapsVkSecondaryCB::kNo) { // Since we know the newly created render target will be internal, we are able to precompute @@ -40,14 +38,12 @@ GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrBackendForm GrRenderTargetProxy::GrRenderTargetProxy(LazyInstantiateCallback&& callback, LazyInstantiationType lazyType, const GrBackendFormat& format, const GrSurfaceDesc& desc, - GrSurfaceOrigin origin, const GrSwizzle& textureSwizzle, - const GrSwizzle& outputSwizzle, SkBackingFit fit, + GrSurfaceOrigin origin, SkBackingFit fit, SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags, WrapsVkSecondaryCB wrapsVkSecondaryCB) - : INHERITED(std::move(callback), lazyType, format, desc, origin, textureSwizzle, fit, - budgeted, surfaceFlags) + : INHERITED(std::move(callback), lazyType, format, desc, origin, fit, budgeted, + surfaceFlags) , fSampleCnt(desc.fSampleCnt) - , fOutputSwizzle(outputSwizzle) , fNeedsStencil(false) , fWrapsVkSecondaryCB(wrapsVkSecondaryCB) { SkASSERT(SkToBool(kRenderTarget_GrSurfaceFlag & desc.fFlags)); @@ -55,12 +51,9 @@ GrRenderTargetProxy::GrRenderTargetProxy(LazyInstantiateCallback&& callback, // Wrapped version GrRenderTargetProxy::GrRenderTargetProxy(sk_sp surf, GrSurfaceOrigin origin, - const GrSwizzle& textureSwizzle, - const GrSwizzle& outputSwizzle, WrapsVkSecondaryCB wrapsVkSecondaryCB) - : INHERITED(std::move(surf), origin, textureSwizzle, SkBackingFit::kExact) + : INHERITED(std::move(surf), origin, SkBackingFit::kExact) , fSampleCnt(fTarget->asRenderTarget()->numStencilSamples()) - , fOutputSwizzle(outputSwizzle) , fNeedsStencil(false) , fWrapsVkSecondaryCB(wrapsVkSecondaryCB) { } diff --git a/src/gpu/GrShaderCaps.h b/src/gpu/GrShaderCaps.h index cf9005ace4..53af67d67e 100644 --- a/src/gpu/GrShaderCaps.h +++ b/src/gpu/GrShaderCaps.h @@ -9,8 +9,8 @@ #define GrShaderCaps_DEFINED #include "include/core/SkRefCnt.h" -#include "include/private/GrSwizzle.h" #include "include/private/GrTypesPriv.h" +#include "src/gpu/GrSwizzle.h" #include "src/gpu/glsl/GrGLSL.h" namespace SkSL { diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index a2408e581d..ccf2e55e48 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -54,16 +54,14 @@ static bool is_valid_non_lazy(const GrSurfaceDesc& desc) { // Lazy-callback version GrSurfaceProxy::GrSurfaceProxy(LazyInstantiateCallback&& callback, LazyInstantiationType lazyType, const GrBackendFormat& format, const GrSurfaceDesc& desc, - GrSurfaceOrigin origin, const GrSwizzle& textureSwizzle, - SkBackingFit fit, SkBudgeted budgeted, - GrInternalSurfaceFlags surfaceFlags) + GrSurfaceOrigin origin, SkBackingFit fit, + SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags) : fSurfaceFlags(surfaceFlags) , fFormat(format) , fConfig(desc.fConfig) , fWidth(desc.fWidth) , fHeight(desc.fHeight) , fOrigin(origin) - , fTextureSwizzle(textureSwizzle) , fFit(fit) , fBudgeted(budgeted) , fLazyInstantiateCallback(std::move(callback)) @@ -86,8 +84,7 @@ GrSurfaceProxy::GrSurfaceProxy(LazyInstantiateCallback&& callback, LazyInstantia } // Wrapped version -GrSurfaceProxy::GrSurfaceProxy(sk_sp surface, GrSurfaceOrigin origin, - const GrSwizzle& textureSwizzle, SkBackingFit fit) +GrSurfaceProxy::GrSurfaceProxy(sk_sp surface, GrSurfaceOrigin origin, SkBackingFit fit) : INHERITED(std::move(surface)) , fSurfaceFlags(fTarget->surfacePriv().flags()) , fFormat(fTarget->backendFormat()) @@ -95,7 +92,6 @@ GrSurfaceProxy::GrSurfaceProxy(sk_sp surface, GrSurfaceOrigin origin, , fWidth(fTarget->width()) , fHeight(fTarget->height()) , fOrigin(origin) - , fTextureSwizzle(textureSwizzle) , fFit(fit) , fBudgeted(fTarget->resourcePriv().budgetedType() == GrBudgetedType::kBudgeted ? SkBudgeted::kYes diff --git a/src/gpu/GrSwizzle.cpp b/src/gpu/GrSwizzle.cpp index b72040954c..21fe8343af 100644 --- a/src/gpu/GrSwizzle.cpp +++ b/src/gpu/GrSwizzle.cpp @@ -5,7 +5,7 @@ * found in the LICENSE file. */ -#include "include/private/GrSwizzle.h" +#include "src/gpu/GrSwizzle.h" #include "src/core/SkRasterPipeline.h" void GrSwizzle::apply(SkRasterPipeline* pipeline) const { diff --git a/include/private/GrSwizzle.h b/src/gpu/GrSwizzle.h similarity index 100% rename from include/private/GrSwizzle.h rename to src/gpu/GrSwizzle.h diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp index 3a39481e0e..e0c0b47e6a 100644 --- a/src/gpu/GrTextureProxy.cpp +++ b/src/gpu/GrTextureProxy.cpp @@ -15,12 +15,24 @@ #include "src/gpu/GrSurfacePriv.h" #include "src/gpu/GrTexturePriv.h" +// Deferred version - with data +GrTextureProxy::GrTextureProxy(const GrBackendFormat& format, const GrSurfaceDesc& srcDesc, + GrMipMapped mipMapped, SkBackingFit fit, SkBudgeted budgeted, + const void* srcData, size_t /*rowBytes*/, + GrInternalSurfaceFlags surfaceFlags) + : INHERITED(format, srcDesc, kTopLeft_GrSurfaceOrigin, fit, budgeted, surfaceFlags) + , fMipMapped(mipMapped) + , fProxyProvider(nullptr) + , fDeferredUploader(nullptr) { + SkASSERT(!srcData); // currently handled in Make() +} + // Deferred version - no data GrTextureProxy::GrTextureProxy(const GrBackendFormat& format, const GrSurfaceDesc& srcDesc, GrSurfaceOrigin origin, GrMipMapped mipMapped, - const GrSwizzle& textureSwizzle, SkBackingFit fit, - SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags) - : INHERITED(format, srcDesc, origin, textureSwizzle, fit, budgeted, surfaceFlags) + SkBackingFit fit, SkBudgeted budgeted, + GrInternalSurfaceFlags surfaceFlags) + : INHERITED(format, srcDesc, origin, fit, budgeted, surfaceFlags) , fMipMapped(mipMapped) , fProxyProvider(nullptr) , fDeferredUploader(nullptr) {} @@ -28,19 +40,17 @@ GrTextureProxy::GrTextureProxy(const GrBackendFormat& format, const GrSurfaceDes // Lazy-callback version GrTextureProxy::GrTextureProxy(LazyInstantiateCallback&& callback, LazyInstantiationType lazyType, const GrBackendFormat& format, const GrSurfaceDesc& desc, - GrSurfaceOrigin origin, GrMipMapped mipMapped, - const GrSwizzle& texSwizzle, SkBackingFit fit, SkBudgeted budgeted, - GrInternalSurfaceFlags surfaceFlags) - : INHERITED(std::move(callback), lazyType, format, desc, origin, texSwizzle, fit, budgeted, + GrSurfaceOrigin origin, GrMipMapped mipMapped, SkBackingFit fit, + SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags) + : INHERITED(std::move(callback), lazyType, format, desc, origin, fit, budgeted, surfaceFlags) , fMipMapped(mipMapped) , fProxyProvider(nullptr) , fDeferredUploader(nullptr) {} // Wrapped version -GrTextureProxy::GrTextureProxy(sk_sp surf, GrSurfaceOrigin origin, - const GrSwizzle& textureSwizzle) - : INHERITED(std::move(surf), origin, textureSwizzle, SkBackingFit::kExact) +GrTextureProxy::GrTextureProxy(sk_sp surf, GrSurfaceOrigin origin) + : INHERITED(std::move(surf), origin, SkBackingFit::kExact) , fMipMapped(fTarget->asTexture()->texturePriv().mipMapped()) , fProxyProvider(nullptr) , fDeferredUploader(nullptr) { diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp index 8366e75031..7bf9002d4a 100644 --- a/src/gpu/GrTextureRenderTargetProxy.cpp +++ b/src/gpu/GrTextureRenderTargetProxy.cpp @@ -23,17 +23,13 @@ GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc& desc, GrSurfaceOrigin origin, GrMipMapped mipMapped, - const GrSwizzle& texSwizzle, - const GrSwizzle& outSwizzle, SkBackingFit fit, SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags) - : GrSurfaceProxy(format, desc, origin, texSwizzle, fit, budgeted, surfaceFlags) + : GrSurfaceProxy(format, desc, origin, fit, budgeted, surfaceFlags) // for now textures w/ data are always wrapped - , GrRenderTargetProxy(caps, format, desc, origin, texSwizzle, outSwizzle, fit, budgeted, - surfaceFlags) - , GrTextureProxy(format, desc, origin, mipMapped, texSwizzle, fit, budgeted, surfaceFlags) { -} + , GrRenderTargetProxy(caps, format, desc, origin, fit, budgeted, surfaceFlags) + , GrTextureProxy(format, desc, origin, mipMapped, fit, budgeted, surfaceFlags) {} // Lazy-callback version GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(LazyInstantiateCallback&& callback, @@ -42,30 +38,26 @@ GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(LazyInstantiateCallback&& const GrSurfaceDesc& desc, GrSurfaceOrigin origin, GrMipMapped mipMapped, - const GrSwizzle& texSwizzle, - const GrSwizzle& outSwizzle, SkBackingFit fit, SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags) - : GrSurfaceProxy(std::move(callback), lazyType, format, desc, origin, texSwizzle, fit, - budgeted, surfaceFlags) + : GrSurfaceProxy(std::move(callback), lazyType, format, desc, origin, fit, budgeted, + surfaceFlags) // Since we have virtual inheritance, we initialize GrSurfaceProxy directly. Send null // callbacks to the texture and RT proxies simply to route to the appropriate constructors. - , GrRenderTargetProxy(LazyInstantiateCallback(), lazyType, format, desc, origin, texSwizzle, - outSwizzle, fit, budgeted, surfaceFlags, WrapsVkSecondaryCB::kNo) + , GrRenderTargetProxy(LazyInstantiateCallback(), lazyType, format, desc, origin, fit, + budgeted, surfaceFlags, WrapsVkSecondaryCB::kNo) , GrTextureProxy(LazyInstantiateCallback(), lazyType, format, desc, origin, mipMapped, - texSwizzle, fit, budgeted, surfaceFlags) {} + fit, budgeted, surfaceFlags) {} // Wrapped version // This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and // GrRenderTargetProxy) so its constructor must be explicitly called. GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp surf, - GrSurfaceOrigin origin, - const GrSwizzle& texSwizzle, - const GrSwizzle& outSwizzle) - : GrSurfaceProxy(surf, origin, texSwizzle, SkBackingFit::kExact) - , GrRenderTargetProxy(surf, origin, texSwizzle, outSwizzle) - , GrTextureProxy(surf, origin, texSwizzle) { + GrSurfaceOrigin origin) + : GrSurfaceProxy(surf, origin, SkBackingFit::kExact) + , GrRenderTargetProxy(surf, origin) + , GrTextureProxy(surf, origin) { SkASSERT(surf->asTexture()); SkASSERT(surf->asRenderTarget()); } diff --git a/src/gpu/GrTextureRenderTargetProxy.h b/src/gpu/GrTextureRenderTargetProxy.h index 1afd4566cb..852309b44e 100644 --- a/src/gpu/GrTextureRenderTargetProxy.h +++ b/src/gpu/GrTextureRenderTargetProxy.h @@ -29,20 +29,16 @@ private: // Deferred version GrTextureRenderTargetProxy(const GrCaps&, const GrBackendFormat&, const GrSurfaceDesc&, - GrSurfaceOrigin, GrMipMapped, const GrSwizzle& textureSwizzle, - const GrSwizzle& outputSwizzle, SkBackingFit, SkBudgeted, + GrSurfaceOrigin, GrMipMapped, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags); // Lazy-callback version GrTextureRenderTargetProxy(LazyInstantiateCallback&&, LazyInstantiationType, const GrBackendFormat&, const GrSurfaceDesc& desc, GrSurfaceOrigin, - GrMipMapped, const GrSwizzle& textureSwizzle, - const GrSwizzle& outputSwizzle, SkBackingFit, SkBudgeted, - GrInternalSurfaceFlags); + GrMipMapped, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags); // Wrapped version - GrTextureRenderTargetProxy(sk_sp, GrSurfaceOrigin, const GrSwizzle& textureSwizzle, - const GrSwizzle& outputSwizzle); + GrTextureRenderTargetProxy(sk_sp, GrSurfaceOrigin); bool instantiate(GrResourceProvider*) override; sk_sp createSurface(GrResourceProvider*) const override; diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 87d904353a..fe1a9f2596 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -10,11 +10,11 @@ #define GrGLCaps_DEFINED #include -#include "include/private/GrSwizzle.h" #include "include/private/SkChecksum.h" #include "include/private/SkTArray.h" #include "include/private/SkTHash.h" #include "src/gpu/GrCaps.h" +#include "src/gpu/GrSwizzle.h" #include "src/gpu/gl/GrGLStencilAttachment.h" class GrGLContextInfo; diff --git a/src/gpu/gl/GrGLTypesPriv.cpp b/src/gpu/gl/GrGLTypesPriv.cpp index 65a760852c..8c66fa558a 100644 --- a/src/gpu/gl/GrGLTypesPriv.cpp +++ b/src/gpu/gl/GrGLTypesPriv.cpp @@ -7,7 +7,7 @@ #include "include/core/SkScalar.h" #include "include/private/GrGLTypesPriv.h" -#include "include/private/GrSwizzle.h" +#include "src/gpu/GrSwizzle.h" #include "src/gpu/gl/GrGLDefines.h" GrGLTextureParameters::SamplerOverriddenState::SamplerOverriddenState() diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index dc2afe7e80..bed69a3916 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -8,7 +8,6 @@ #include "src/gpu/gl/builders/GrGLProgramBuilder.h" #include "include/gpu/GrContext.h" -#include "include/private/GrSwizzle.h" #include "src/core/SkATrace.h" #include "src/core/SkAutoMalloc.h" #include "src/core/SkReader32.h" @@ -21,6 +20,7 @@ #include "src/gpu/GrProgramDesc.h" #include "src/gpu/GrShaderCaps.h" #include "src/gpu/GrShaderUtils.h" +#include "src/gpu/GrSwizzle.h" #include "src/gpu/gl/GrGLGpu.h" #include "src/gpu/gl/GrGLProgram.h" #include "src/gpu/gl/builders/GrGLProgramBuilder.h" diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.cpp b/src/gpu/glsl/GrGLSLShaderBuilder.cpp index 5a820581f6..bd30080df9 100644 --- a/src/gpu/glsl/GrGLSLShaderBuilder.cpp +++ b/src/gpu/glsl/GrGLSLShaderBuilder.cpp @@ -5,13 +5,12 @@ * found in the LICENSE file. */ -#include "src/gpu/glsl/GrGLSLShaderBuilder.h" - -#include "include/private/GrSwizzle.h" #include "src/gpu/GrShaderCaps.h" #include "src/gpu/GrShaderVar.h" +#include "src/gpu/GrSwizzle.h" #include "src/gpu/glsl/GrGLSLColorSpaceXformHelper.h" #include "src/gpu/glsl/GrGLSLProgramBuilder.h" +#include "src/gpu/glsl/GrGLSLShaderBuilder.h" GrGLSLShaderBuilder::GrGLSLShaderBuilder(GrGLSLProgramBuilder* program) : fProgramBuilder(program) diff --git a/src/gpu/glsl/GrGLSLUniformHandler.h b/src/gpu/glsl/GrGLSLUniformHandler.h index cee6a5a771..1a5c9519b7 100644 --- a/src/gpu/glsl/GrGLSLUniformHandler.h +++ b/src/gpu/glsl/GrGLSLUniformHandler.h @@ -8,8 +8,8 @@ #ifndef GrGLSLUniformHandler_DEFINED #define GrGLSLUniformHandler_DEFINED -#include "include/private/GrSwizzle.h" #include "src/gpu/GrShaderVar.h" +#include "src/gpu/GrSwizzle.h" #include "src/gpu/glsl/GrGLSLProgramDataManager.h" // variable names beginning with this prefix will not be mangled diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm index bdebe19110..da2e374891 100644 --- a/src/gpu/mtl/GrMtlCaps.mm +++ b/src/gpu/mtl/GrMtlCaps.mm @@ -657,7 +657,7 @@ static bool format_color_type_valid_pair(MTLPixelFormat format, GrColorType colo static GrSwizzle get_swizzle(const GrBackendFormat& format, GrColorType colorType, bool forOutput) { SkASSERT(format.getMtlFormat()); - MTLPixelFormat mtlFormat = static_cast(*format.getMtlFormat()); + MTLPixelFormat mtlFormat = static_cast(*format.getVkFormat()); SkASSERT(format_color_type_valid_pair(mtlFormat, colorType)); diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp index 3798eb9f64..5db4d45eda 100644 --- a/src/gpu/vk/GrVkCaps.cpp +++ b/src/gpu/vk/GrVkCaps.cpp @@ -682,7 +682,7 @@ static bool format_is_srgb(VkFormat format) { } } -// These are all the valid VkFormats that we support in Skia. They are roughly ordered from most +// These are all the valid VkFormats that we support in Skia. They are roughly order from most // frequently used to least to improve look up times in arrays. static constexpr VkFormat kVkFormats[] = { VK_FORMAT_R8G8B8A8_UNORM, diff --git a/tests/SkRasterPipelineTest.cpp b/tests/SkRasterPipelineTest.cpp index 01244658e5..ce4fcf4315 100644 --- a/tests/SkRasterPipelineTest.cpp +++ b/tests/SkRasterPipelineTest.cpp @@ -5,10 +5,10 @@ * found in the LICENSE file. */ -#include "include/private/GrSwizzle.h" #include "include/private/SkHalf.h" #include "include/private/SkTo.h" #include "src/core/SkRasterPipeline.h" +#include "src/gpu/GrSwizzle.h" #include "tests/Test.h" DEF_TEST(SkRasterPipeline, r) {