diff options
author | 2017-02-28 16:20:03 -0500 | |
---|---|---|
committer | 2017-02-28 22:07:05 +0000 | |
commit | 32f2818c9d10090efeea62ccc211d48a33322dfb (patch) | |
tree | fd301bc81387a3c3e0cc767cba43ba214a314f86 /src/gpu | |
parent | dac5f6bcbec7130a209a6899444feb022719498d (diff) |
Clean up/remove unused GrFragmentProcessor-derived ctors
This is the simple (i.e., non-TextureAdjuster) portion of: https://skia-review.googlesource.com/c/8823/ (Remove GrFragmentProcessor-derived class' GrTexture-based ctors)
Change-Id: I8f673ebe922e03c69473c18c166bcf818507c662
Reviewed-on: https://skia-review.googlesource.com/8997
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrDrawOpAtlas.cpp | 65 | ||||
-rw-r--r-- | src/gpu/GrDrawOpAtlas.h | 16 | ||||
-rw-r--r-- | src/gpu/GrResourceProvider.cpp | 15 | ||||
-rw-r--r-- | src/gpu/GrResourceProvider.h | 7 | ||||
-rw-r--r-- | src/gpu/effects/Gr1DKernelEffect.h | 9 | ||||
-rw-r--r-- | src/gpu/effects/GrBitmapTextGeoProc.cpp | 22 | ||||
-rw-r--r-- | src/gpu/effects/GrBitmapTextGeoProc.h | 10 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.cpp | 74 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.h | 48 | ||||
-rw-r--r-- | src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp | 16 | ||||
-rw-r--r-- | src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h | 13 | ||||
-rw-r--r-- | src/gpu/effects/GrMatrixConvolutionEffect.cpp | 44 | ||||
-rw-r--r-- | src/gpu/effects/GrMatrixConvolutionEffect.h | 35 | ||||
-rw-r--r-- | src/gpu/ops/GrAADistanceFieldPathRenderer.cpp | 23 | ||||
-rw-r--r-- | src/gpu/ops/GrAtlasTextOp.cpp | 30 | ||||
-rw-r--r-- | src/gpu/ops/GrAtlasTextOp.h | 5 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasGlyphCache.cpp | 12 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasGlyphCache.h | 8 |
18 files changed, 110 insertions, 342 deletions
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp index feb6691439..6661b4855c 100644 --- a/src/gpu/GrDrawOpAtlas.cpp +++ b/src/gpu/GrDrawOpAtlas.cpp @@ -6,6 +6,8 @@ */ #include "GrDrawOpAtlas.h" + +#include "GrContext.h" #include "GrOpFlushState.h" #include "GrRectanizer.h" #include "GrTracing.h" @@ -119,18 +121,21 @@ void GrDrawOpAtlas::Plot::resetRects() { /////////////////////////////////////////////////////////////////////////////// -GrDrawOpAtlas::GrDrawOpAtlas(sk_sp<GrTexture> texture, int numPlotsX, int numPlotsY) - : fTexture(std::move(texture)), fAtlasGeneration(kInvalidAtlasGeneration + 1) { - fPlotWidth = fTexture->width() / numPlotsX; - fPlotHeight = fTexture->height() / numPlotsY; +GrDrawOpAtlas::GrDrawOpAtlas(GrContext* context, sk_sp<GrTextureProxy> proxy, + int numPlotsX, int numPlotsY) + : fContext(context) + , fProxy(std::move(proxy)) + , fAtlasGeneration(kInvalidAtlasGeneration + 1) { + fPlotWidth = fProxy->width() / numPlotsX; + fPlotHeight = fProxy->height() / numPlotsY; SkASSERT(numPlotsX * numPlotsY <= BulkUseTokenUpdater::kMaxPlots); - SkASSERT(fPlotWidth * numPlotsX == fTexture->width()); - SkASSERT(fPlotHeight * numPlotsY == fTexture->height()); + SkASSERT(fPlotWidth * numPlotsX == fProxy->width()); + SkASSERT(fPlotHeight * numPlotsY == fProxy->height()); SkDEBUGCODE(fNumPlots = numPlotsX * numPlotsY;) // We currently do not support compressed atlases... - SkASSERT(!GrPixelConfigIsCompressed(fTexture->desc().fConfig)); + SkASSERT(!GrPixelConfigIsCompressed(fProxy->desc().fConfig)); // set up allocated plots fPlotArray.reset(new sk_sp<Plot>[ numPlotsX * numPlotsY ]); @@ -140,7 +145,7 @@ GrDrawOpAtlas::GrDrawOpAtlas(sk_sp<GrTexture> texture, int numPlotsX, int numPlo for (int x = numPlotsX - 1, c = 0; x >= 0; --x, ++c) { uint32_t index = r * numPlotsX + c; currPlot->reset( - new Plot(index, 1, x, y, fPlotWidth, fPlotHeight, fTexture->desc().fConfig)); + new Plot(index, 1, x, y, fPlotWidth, fPlotHeight, fProxy->desc().fConfig)); // build LRU list fPlotList.addToHead(currPlot->get()); @@ -164,13 +169,17 @@ inline void GrDrawOpAtlas::updatePlot(GrDrawOp::Target* target, AtlasID* id, Plo if (target->hasDrawBeenFlushed(plot->lastUploadToken())) { // With c+14 we could move sk_sp into lamba to only ref once. sk_sp<Plot> plotsp(SkRef(plot)); - GrTexture* texture = fTexture.get(); - GrDrawOpUploadToken lastUploadToken = target->addAsapUpload( - [plotsp, texture] (GrDrawOp::WritePixelsFn& writePixels) { - plotsp->uploadToTexture(writePixels, texture); - } - ); - plot->setLastUploadToken(lastUploadToken); + // MDB TODO: this is currently fine since the atlas' proxy is always pre-instantiated. + // Once it is deferred more care must be taken upon instantiation failure. + GrTexture* texture = fProxy->instantiate(fContext->textureProvider()); + if (texture) { + GrDrawOpUploadToken lastUploadToken = target->addAsapUpload( + [plotsp, texture] (GrDrawOp::WritePixelsFn& writePixels) { + plotsp->uploadToTexture(writePixels, texture); + } + ); + plot->setLastUploadToken(lastUploadToken); + } } *id = plot->id(); } @@ -178,7 +187,7 @@ inline void GrDrawOpAtlas::updatePlot(GrDrawOp::Target* target, AtlasID* id, Plo bool GrDrawOpAtlas::addToAtlas(AtlasID* id, GrDrawOp::Target* target, int width, int height, const void* image, SkIPoint16* loc) { // We should already have a texture, TODO clean this up - SkASSERT(fTexture); + SkASSERT(fProxy); if (width > fPlotWidth || height > fPlotHeight) { return false; } @@ -188,7 +197,7 @@ bool GrDrawOpAtlas::addToAtlas(AtlasID* id, GrDrawOp::Target* target, int width, plotIter.init(fPlotList, PlotList::Iter::kHead_IterStart); Plot* plot; while ((plot = plotIter.get())) { - SkASSERT(GrBytesPerPixel(fTexture->desc().fConfig) == plot->bpp()); + SkASSERT(GrBytesPerPixel(fProxy->desc().fConfig) == plot->bpp()); if (plot->addSubImage(width, height, image, loc)) { this->updatePlot(target, id, plot); return true; @@ -203,7 +212,7 @@ bool GrDrawOpAtlas::addToAtlas(AtlasID* id, GrDrawOp::Target* target, int width, if (target->hasDrawBeenFlushed(plot->lastUseToken())) { this->processEviction(plot->id()); plot->resetRects(); - SkASSERT(GrBytesPerPixel(fTexture->desc().fConfig) == plot->bpp()); + SkASSERT(GrBytesPerPixel(fProxy->desc().fConfig) == plot->bpp()); SkDEBUGCODE(bool verify = )plot->addSubImage(width, height, image, loc); SkASSERT(verify); this->updatePlot(target, id, plot); @@ -226,7 +235,7 @@ bool GrDrawOpAtlas::addToAtlas(AtlasID* id, GrDrawOp::Target* target, int width, newPlot.reset(plot->clone()); fPlotList.addToHead(newPlot.get()); - SkASSERT(GrBytesPerPixel(fTexture->desc().fConfig) == newPlot->bpp()); + SkASSERT(GrBytesPerPixel(fProxy->desc().fConfig) == newPlot->bpp()); SkDEBUGCODE(bool verify = )newPlot->addSubImage(width, height, image, loc); SkASSERT(verify); @@ -234,13 +243,17 @@ bool GrDrawOpAtlas::addToAtlas(AtlasID* id, GrDrawOp::Target* target, int width, // one it displaced most likely was uploaded asap. // With c+14 we could move sk_sp into lambda to only ref once. sk_sp<Plot> plotsp(SkRef(newPlot.get())); - GrTexture* texture = fTexture.get(); - GrDrawOpUploadToken lastUploadToken = target->addInlineUpload( - [plotsp, texture] (GrDrawOp::WritePixelsFn& writePixels) { - plotsp->uploadToTexture(writePixels, texture); - } - ); - newPlot->setLastUploadToken(lastUploadToken); + // MDB TODO: this is currently fine since the atlas' proxy is always pre-instantiated. + // Once it is deferred more care must be taken upon instantiation failure. + GrTexture* texture = fProxy->instantiate(fContext->textureProvider()); + if (texture) { + GrDrawOpUploadToken lastUploadToken = target->addInlineUpload( + [plotsp, texture] (GrDrawOp::WritePixelsFn& writePixels) { + plotsp->uploadToTexture(writePixels, texture); + } + ); + newPlot->setLastUploadToken(lastUploadToken); + } *id = newPlot->id(); diff --git a/src/gpu/GrDrawOpAtlas.h b/src/gpu/GrDrawOpAtlas.h index 7a7da6c9be..917d4ecab6 100644 --- a/src/gpu/GrDrawOpAtlas.h +++ b/src/gpu/GrDrawOpAtlas.h @@ -55,7 +55,7 @@ public: */ typedef void (*EvictionFunc)(GrDrawOpAtlas::AtlasID, void*); - GrDrawOpAtlas(sk_sp<GrTexture>, int numPlotsX, int numPlotsY); + GrDrawOpAtlas(GrContext*, sk_sp<GrTextureProxy>, int numPlotsX, int numPlotsY); /** * Adds a width x height subimage to the atlas. Upon success it returns an ID and the subimage's @@ -72,7 +72,8 @@ public: bool addToAtlas(AtlasID*, GrDrawOp::Target*, int width, int height, const void* image, SkIPoint16* loc); - GrTexture* getTexture() const { return fTexture.get(); } + GrContext* context() const { return fContext; } + sk_sp<GrTextureProxy> getProxy() const { return fProxy; } uint64_t atlasGeneration() const { return fAtlasGeneration; } @@ -265,12 +266,13 @@ private: inline void processEviction(AtlasID); - sk_sp<GrTexture> fTexture; - int fPlotWidth; - int fPlotHeight; - SkDEBUGCODE(uint32_t fNumPlots;) + GrContext* fContext; + sk_sp<GrTextureProxy> fProxy; + int fPlotWidth; + int fPlotHeight; + SkDEBUGCODE(uint32_t fNumPlots;) - uint64_t fAtlasGeneration; + uint64_t fAtlasGeneration; struct EvictionData { EvictionFunc fFunc; diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp index d74807a7e7..2dd17b7569 100644 --- a/src/gpu/GrResourceProvider.cpp +++ b/src/gpu/GrResourceProvider.cpp @@ -135,7 +135,8 @@ GrBuffer* GrResourceProvider::createBuffer(size_t size, GrBufferType intendedTyp return buffer; } -std::unique_ptr<GrDrawOpAtlas> GrResourceProvider::makeAtlas(GrPixelConfig config, int width, +std::unique_ptr<GrDrawOpAtlas> GrResourceProvider::makeAtlas(GrContext* context, + GrPixelConfig config, int width, int height, int numPlotsX, int numPlotsY, GrDrawOpAtlas::EvictionFunc func, @@ -154,8 +155,18 @@ std::unique_ptr<GrDrawOpAtlas> GrResourceProvider::makeAtlas(GrPixelConfig confi if (!texture) { return nullptr; } + // MDB TODO: for now, wrap an instantiated texture. Having the deferred instantiation + // possess the correct properties (e.g., no pendingIO) should fall out of the system but + // should receive special attention. + // Note: When switching over to the deferred proxy, use the kExact flag to create + // the atlas. + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(texture)); + if (!proxy) { + return nullptr; + } + std::unique_ptr<GrDrawOpAtlas> atlas( - new GrDrawOpAtlas(std::move(texture), numPlotsX, numPlotsY)); + new GrDrawOpAtlas(context, std::move(proxy), numPlotsX, numPlotsY)); atlas->registerEvictionCallback(func, data); return atlas; } diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h index 47490e14de..091d2dbf16 100644 --- a/src/gpu/GrResourceProvider.h +++ b/src/gpu/GrResourceProvider.h @@ -146,9 +146,9 @@ public: * eviction occurs * @return An initialized GrDrawOpAtlas, or nullptr if creation fails */ - std::unique_ptr<GrDrawOpAtlas> makeAtlas(GrPixelConfig, int width, int height, int numPlotsX, - int numPlotsY, GrDrawOpAtlas::EvictionFunc func, - void* data); + std::unique_ptr<GrDrawOpAtlas> makeAtlas(GrContext*, GrPixelConfig, int width, int height, + int numPlotsX, int numPlotsY, + GrDrawOpAtlas::EvictionFunc func, void* data); /** * If passed in render target already has a stencil buffer, return it. Otherwise attempt to @@ -156,6 +156,7 @@ public: */ GrStencilAttachment* attachStencilAttachment(GrRenderTarget* rt); + GrContext* context() { return this->gpu()->getContext(); } const GrCaps* caps() { return this->gpu()->caps(); } /** diff --git a/src/gpu/effects/Gr1DKernelEffect.h b/src/gpu/effects/Gr1DKernelEffect.h index 24c94fcce2..a960eeec3a 100644 --- a/src/gpu/effects/Gr1DKernelEffect.h +++ b/src/gpu/effects/Gr1DKernelEffect.h @@ -28,15 +28,6 @@ public: kY_Direction, }; - Gr1DKernelEffect(GrTexture* texture, - Direction direction, - int radius, - OptimizationFlags optFlags) - : INHERITED(texture, nullptr, SkMatrix::I(), optFlags) - , fDirection(direction) - , fRadius(radius) { - } - Gr1DKernelEffect(GrContext* ctx, OptimizationFlags optFlags, sk_sp<GrTextureProxy> proxy, Direction direction, int radius) : INHERITED(ctx, optFlags, std::move(proxy), nullptr, SkMatrix::I()) diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index b1aa1d4723..bbce742c36 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -120,28 +120,6 @@ private: /////////////////////////////////////////////////////////////////////////////// -GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, - const GrSamplerParams& params, GrMaskFormat format, - const SkMatrix& localMatrix, bool usesLocalCoords) - : fColor(color) - , fLocalMatrix(localMatrix) - , fUsesLocalCoords(usesLocalCoords) - , fTextureSampler(texture, params) - , fInColor(nullptr) - , fMaskFormat(format) { - this->initClassID<GrBitmapTextGeoProc>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType); - - bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat || - kA565_GrMaskFormat == fMaskFormat; - if (hasVertexColor) { - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - } - fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kVec2us_GrVertexAttribType, - kHigh_GrSLPrecision); - this->addTextureSampler(&fTextureSampler); -} - GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrContext* context, GrColor color, sk_sp<GrTextureProxy> proxy, const GrSamplerParams& params, GrMaskFormat format, diff --git a/src/gpu/effects/GrBitmapTextGeoProc.h b/src/gpu/effects/GrBitmapTextGeoProc.h index 0f30ddc0a0..17a5e9da2f 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.h +++ b/src/gpu/effects/GrBitmapTextGeoProc.h @@ -21,13 +21,6 @@ class GrInvariantOutput; */ class GrBitmapTextGeoProc : public GrGeometryProcessor { public: - static sk_sp<GrGeometryProcessor> Make(GrColor color, GrTexture* tex, const GrSamplerParams& p, - GrMaskFormat format, const SkMatrix& localMatrix, - bool usesLocalCoords) { - return sk_sp<GrGeometryProcessor>( - new GrBitmapTextGeoProc(color, tex, p, format, localMatrix, usesLocalCoords)); - } - static sk_sp<GrGeometryProcessor> Make(GrContext* context, GrColor color, sk_sp<GrTextureProxy> proxy, const GrSamplerParams& p, GrMaskFormat format, const SkMatrix& localMatrix, @@ -55,9 +48,6 @@ public: GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override; private: - GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrSamplerParams& params, - GrMaskFormat format, const SkMatrix& localMatrix, bool usesLocalCoords); - GrBitmapTextGeoProc(GrContext*, GrColor, sk_sp<GrTextureProxy>, const GrSamplerParams& params, GrMaskFormat format, const SkMatrix& localMatrix, bool usesLocalCoords); diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 1c2ef6494a..19f5e2acbd 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -222,34 +222,6 @@ private: /////////////////////////////////////////////////////////////////////////////// -GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrColor color, - const SkMatrix& viewMatrix, - GrTexture* texture, - const GrSamplerParams& params, -#ifdef SK_GAMMA_APPLY_TO_A8 - float distanceAdjust, -#endif - uint32_t flags, - bool usesLocalCoords) - : fColor(color) - , fViewMatrix(viewMatrix) - , fTextureSampler(texture, params) -#ifdef SK_GAMMA_APPLY_TO_A8 - , fDistanceAdjust(distanceAdjust) -#endif - , fFlags(flags & kNonLCD_DistanceFieldEffectMask) - , fInColor(nullptr) - , fUsesLocalCoords(usesLocalCoords) { - SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); - this->initClassID<GrDistanceFieldA8TextGeoProc>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kVec2us_GrVertexAttribType, - kHigh_GrSLPrecision); - this->addTextureSampler(&fTextureSampler); -} - GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrContext* context, GrColor color, const SkMatrix& viewMatrix, @@ -499,30 +471,6 @@ private: }; /////////////////////////////////////////////////////////////////////////////// - -GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( - GrColor color, - const SkMatrix& viewMatrix, - GrTexture* texture, - const GrSamplerParams& params, - uint32_t flags, - bool usesLocalCoords) - : fColor(color) - , fViewMatrix(viewMatrix) - , fTextureSampler(texture, params) - , fFlags(flags & kNonLCD_DistanceFieldEffectMask) - , fInColor(nullptr) - , fUsesLocalCoords(usesLocalCoords) { - SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); - this->initClassID<GrDistanceFieldPathGeoProc>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kVec2us_GrVertexAttribType); - this->addTextureSampler(&fTextureSampler); -} - - GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( GrContext* context, GrColor color, @@ -828,28 +776,6 @@ private: }; /////////////////////////////////////////////////////////////////////////////// - -GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc( - GrColor color, const SkMatrix& viewMatrix, - GrTexture* texture, const GrSamplerParams& params, - DistanceAdjust distanceAdjust, - uint32_t flags, bool usesLocalCoords) - : fColor(color) - , fViewMatrix(viewMatrix) - , fTextureSampler(texture, params) - , fDistanceAdjust(distanceAdjust) - , fFlags(flags & kLCD_DistanceFieldEffectMask) - , fUsesLocalCoords(usesLocalCoords) { - SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag)); - this->initClassID<GrDistanceFieldLCDTextGeoProc>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kVec2us_GrVertexAttribType, - kHigh_GrSLPrecision); - this->addTextureSampler(&fTextureSampler); -} - GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc( GrContext* context, GrColor color, const SkMatrix& viewMatrix, diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.h b/src/gpu/effects/GrDistanceFieldGeoProc.h index 1852c13984..fc08790a46 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.h +++ b/src/gpu/effects/GrDistanceFieldGeoProc.h @@ -49,14 +49,6 @@ enum GrDistanceFieldEffectFlags { class GrDistanceFieldA8TextGeoProc : public GrGeometryProcessor { public: #ifdef SK_GAMMA_APPLY_TO_A8 - static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix, - GrTexture* tex, const GrSamplerParams& params, - float lum, uint32_t flags, bool usesLocalCoords) { - return sk_sp<GrGeometryProcessor>( - new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, lum, flags, - usesLocalCoords)); - } - static sk_sp<GrGeometryProcessor> Make(GrContext* context, GrColor color, const SkMatrix& viewMatrix, sk_sp<GrTextureProxy> proxy, @@ -67,14 +59,6 @@ public: params, lum, flags, usesLocalCoords)); } #else - static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix, - GrTexture* tex, const GrSamplerParams& params, - uint32_t flags, bool usesLocalCoords) { - return sk_sp<GrGeometryProcessor>( - new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, flags, - usesLocalCoords)); - } - static sk_sp<GrGeometryProcessor> Make(GrContext* context, GrColor color, const SkMatrix& viewMatrix, sk_sp<GrTextureProxy> proxy, @@ -106,13 +90,6 @@ public: GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override; private: - GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix, - GrTexture* texture, const GrSamplerParams& params, -#ifdef SK_GAMMA_APPLY_TO_A8 - float distanceAdjust, -#endif - uint32_t flags, bool usesLocalCoords); - GrDistanceFieldA8TextGeoProc(GrContext*, GrColor, const SkMatrix& viewMatrix, sk_sp<GrTextureProxy> proxy, const GrSamplerParams& params, #ifdef SK_GAMMA_APPLY_TO_A8 @@ -146,13 +123,6 @@ private: */ class GrDistanceFieldPathGeoProc : public GrGeometryProcessor { public: - static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix, - GrTexture* tex, const GrSamplerParams& params, - uint32_t flags, bool usesLocalCoords) { - return sk_sp<GrGeometryProcessor>( - new GrDistanceFieldPathGeoProc(color, viewMatrix, tex, params, flags, usesLocalCoords)); - } - static sk_sp<GrGeometryProcessor> Make(GrContext* context, GrColor color, const SkMatrix& viewMatrix, sk_sp<GrTextureProxy> proxy, const GrSamplerParams& params, @@ -179,10 +149,6 @@ public: GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override; private: - GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix, GrTexture* texture, - const GrSamplerParams& params, uint32_t flags, - bool usesLocalCoords); - GrDistanceFieldPathGeoProc(GrContext*, GrColor, const SkMatrix& viewMatrix, sk_sp<GrTextureProxy>, const GrSamplerParams&, uint32_t flags, bool usesLocalCoords); @@ -224,15 +190,6 @@ public: } }; - static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix, - GrTexture* tex, const GrSamplerParams& params, - DistanceAdjust distanceAdjust, uint32_t flags, - bool usesLocalCoords) { - return sk_sp<GrGeometryProcessor>( - new GrDistanceFieldLCDTextGeoProc(color, viewMatrix, tex, params, distanceAdjust, - flags, usesLocalCoords)); - } - static sk_sp<GrGeometryProcessor> Make(GrContext* context, GrColor color, const SkMatrix& viewMatrix, sk_sp<GrTextureProxy> proxy, @@ -263,11 +220,6 @@ public: GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override; private: - GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix, - GrTexture* texture, const GrSamplerParams& params, - DistanceAdjust wa, uint32_t flags, - bool usesLocalCoords); - GrDistanceFieldLCDTextGeoProc(GrContext*, GrColor, const SkMatrix& viewMatrix, sk_sp<GrTextureProxy> proxy, const GrSamplerParams& params, DistanceAdjust wa, uint32_t flags, diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp index 2d485e634e..ecfd25cb08 100644 --- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp +++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp @@ -168,22 +168,6 @@ static void fill_in_1D_guassian_kernel(float* kernel, int width, float gaussianS } } -GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor(GrTexture* texture, - Direction direction, - int radius, - float gaussianSigma, - bool useBounds, - int bounds[2]) - : INHERITED(texture, direction, radius, ModulationFlags(texture->config())) - , fUseBounds(useBounds) { - this->initClassID<GrGaussianConvolutionFragmentProcessor>(); - SkASSERT(radius <= kMaxKernelRadius); - - fill_in_1D_guassian_kernel(fKernel, this->width(), gaussianSigma, this->radius()); - - memcpy(fBounds, bounds, sizeof(fBounds)); -} - GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor( GrContext* context, sk_sp<GrTextureProxy> proxy, diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h index 6d6e5b0ebd..0a2b3cd550 100644 --- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h +++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h @@ -18,16 +18,6 @@ class GrGaussianConvolutionFragmentProcessor : public Gr1DKernelEffect { public: /// Convolve with a Gaussian kernel - static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, - Direction dir, - int halfWidth, - float gaussianSigma, - bool useBounds, - int* bounds) { - return sk_sp<GrFragmentProcessor>(new GrGaussianConvolutionFragmentProcessor( - tex, dir, halfWidth, gaussianSigma, useBounds, bounds)); - } - static sk_sp<GrFragmentProcessor> Make(GrContext* context, sk_sp<GrTextureProxy> proxy, Direction dir, @@ -59,9 +49,6 @@ public: private: /// Convolve with a Gaussian kernel - GrGaussianConvolutionFragmentProcessor(GrTexture*, Direction, int halfWidth, - float gaussianSigma, bool useBounds, int bounds[2]); - GrGaussianConvolutionFragmentProcessor(GrContext*, sk_sp<GrTextureProxy>, Direction, int halfWidth, float gaussianSigma, bool useBounds, int bounds[2]); diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index fd90c72800..01c4cd37d6 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -149,31 +149,6 @@ void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdma fDomain.setData(pdman, conv.domain(), texture); } -GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture, - const SkIRect& bounds, - const SkISize& kernelSize, - const SkScalar* kernel, - SkScalar gain, - SkScalar bias, - const SkIPoint& kernelOffset, - GrTextureDomain::Mode tileMode, - bool convolveAlpha) - // To advertise the preserves opaqueness optimization we'd have to examine the parameters. - : INHERITED(texture, nullptr, SkMatrix::I(), - kCompatibleWithCoverageAsAlpha_OptimizationFlag) - , fKernelSize(kernelSize) - , fGain(SkScalarToFloat(gain)) - , fBias(SkScalarToFloat(bias) / 255.0f) - , fConvolveAlpha(convolveAlpha) - , fDomain(texture, GrTextureDomain::MakeTexelDomainForMode(bounds, tileMode), tileMode) { - this->initClassID<GrMatrixConvolutionEffect>(); - for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) { - fKernel[i] = SkScalarToFloat(kernel[i]); - } - fKernelOffset[0] = static_cast<float>(kernelOffset.x()); - fKernelOffset[1] = static_cast<float>(kernelOffset.y()); -} - GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrContext* context, sk_sp<GrTextureProxy> proxy, const SkIRect& bounds, @@ -251,25 +226,6 @@ static void fill_in_2D_gaussian_kernel(float* kernel, int width, int height, // Static function to create a 2D convolution -sk_sp<GrFragmentProcessor> GrMatrixConvolutionEffect::MakeGaussian(GrTexture* texture, - const SkIRect& bounds, - const SkISize& kernelSize, - SkScalar gain, - SkScalar bias, - const SkIPoint& kernelOffset, - GrTextureDomain::Mode tileMode, - bool convolveAlpha, - SkScalar sigmaX, - SkScalar sigmaY) { - float kernel[MAX_KERNEL_SIZE]; - - fill_in_2D_gaussian_kernel(kernel, kernelSize.width(), kernelSize.height(), sigmaX, sigmaY); - - return sk_sp<GrFragmentProcessor>( - new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel, gain, bias, - kernelOffset, tileMode, convolveAlpha)); -} - sk_sp<GrFragmentProcessor> GrMatrixConvolutionEffect::MakeGaussian(GrContext* context, sk_sp<GrTextureProxy> proxy, const SkIRect& bounds, diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h index 581323b3cc..a8bdd6f552 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.h +++ b/src/gpu/effects/GrMatrixConvolutionEffect.h @@ -17,31 +17,6 @@ class GrMatrixConvolutionEffect : public GrSingleTextureEffect { public: - static sk_sp<GrFragmentProcessor> Make(GrTexture* texture, - const SkIRect& bounds, - const SkISize& kernelSize, - const SkScalar* kernel, - SkScalar gain, - SkScalar bias, - const SkIPoint& kernelOffset, - GrTextureDomain::Mode tileMode, - bool convolveAlpha) { - return sk_sp<GrFragmentProcessor>( - new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel, gain, bias, - kernelOffset, tileMode, convolveAlpha)); - } - - static sk_sp<GrFragmentProcessor> MakeGaussian(GrTexture* texture, - const SkIRect& bounds, - const SkISize& kernelSize, - SkScalar gain, - SkScalar bias, - const SkIPoint& kernelOffset, - GrTextureDomain::Mode tileMode, - bool convolveAlpha, - SkScalar sigmaX, - SkScalar sigmaY); - static sk_sp<GrFragmentProcessor> Make(GrContext* context, sk_sp<GrTextureProxy> proxy, const SkIRect& bounds, @@ -81,16 +56,6 @@ public: const char* name() const override { return "MatrixConvolution"; } private: - GrMatrixConvolutionEffect(GrTexture*, - const SkIRect& bounds, - const SkISize& kernelSize, - const SkScalar* kernel, - SkScalar gain, - SkScalar bias, - const SkIPoint& kernelOffset, - GrTextureDomain::Mode tileMode, - bool convolveAlpha); - GrMatrixConvolutionEffect(GrContext*, sk_sp<GrTextureProxy> proxy, const SkIRect& bounds, diff --git a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp index 2db3e3687c..b4c0c526fb 100644 --- a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp @@ -17,6 +17,7 @@ #include "GrResourceProvider.h" #include "GrSWMaskHelper.h" #include "GrSurfacePriv.h" +#include "GrSurfaceProxyPriv.h" #include "GrTexturePriv.h" #include "effects/GrBitmapTextGeoProc.h" #include "effects/GrDistanceFieldGeoProc.h" @@ -233,8 +234,8 @@ private: flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; flags |= fGammaCorrect ? kGammaCorrect_DistanceFieldEffectFlag : 0; - flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make( - this->color(), this->viewMatrix(), atlas->getTexture(), params, flags, + flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make(atlas->context(), + this->color(), this->viewMatrix(), atlas->getProxy(), params, flags, this->usesLocalCoords()); } else { GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode); @@ -250,8 +251,8 @@ private: invert.preTranslate(-fShapes[0].fTranslate.fX, -fShapes[0].fTranslate.fY); } - flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make( - this->color(), atlas->getTexture(), params, kA8_GrMaskFormat, invert, + flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(atlas->context(), + this->color(), atlas->getProxy(), params, kA8_GrMaskFormat, invert, this->usesLocalCoords()); } @@ -643,9 +644,12 @@ private: texBottom += translate.fY; // convert texcoords to unsigned short format - GrTexture* texture = atlas->getTexture(); - SkScalar uFactor = 65535.f / texture->width(); - SkScalar vFactor = 65535.f / texture->height(); + sk_sp<GrTextureProxy> proxy = atlas->getProxy(); + + // The proxy must be exact for this normalization to work correctly + SkASSERT(proxy->priv().isExact()); + SkScalar uFactor = 65535.f / proxy->width(); + SkScalar vFactor = 65535.f / proxy->height(); uint16_t l = (uint16_t)(texLeft*uFactor); uint16_t t = (uint16_t)(texTop*vFactor); uint16_t r = (uint16_t)(texRight*uFactor); @@ -742,7 +746,8 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) { SkASSERT(!args.fShape->isEmpty()); SkASSERT(args.fShape->hasUnstyledKey()); if (!fAtlas) { - fAtlas = args.fResourceProvider->makeAtlas(kAlpha_8_GrPixelConfig, + fAtlas = args.fResourceProvider->makeAtlas(args.fResourceProvider->context(), + kAlpha_8_GrPixelConfig, ATLAS_TEXTURE_WIDTH, ATLAS_TEXTURE_HEIGHT, NUM_PLOTS_X, NUM_PLOTS_Y, &GrAADistanceFieldPathRenderer::HandleEviction, @@ -816,7 +821,7 @@ DRAW_OP_TEST_DEFINE(AADistanceFieldPathOp) { gTestStruct.fContextID = context->uniqueID(); gTestStruct.reset(); gTestStruct.fAtlas = - context->resourceProvider()->makeAtlas(kAlpha_8_GrPixelConfig, + context->resourceProvider()->makeAtlas(context, kAlpha_8_GrPixelConfig, ATLAS_TEXTURE_WIDTH, ATLAS_TEXTURE_HEIGHT, NUM_PLOTS_X, NUM_PLOTS_Y, &PathTestStruct::HandleEviction, diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp index be320ce545..89329b5433 100644 --- a/src/gpu/ops/GrAtlasTextOp.cpp +++ b/src/gpu/ops/GrAtlasTextOp.cpp @@ -82,8 +82,8 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) const { return; } - GrTexture* texture = fFontCache->getTexture(this->maskFormat()); - if (!texture) { + sk_sp<GrTextureProxy> proxy = fFontCache->getProxy(this->maskFormat()); + if (!proxy) { SkDebugf("Could not allocate backing texture for atlas\n"); return; } @@ -93,11 +93,14 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) const { FlushInfo flushInfo; if (this->usesDistanceFields()) { flushInfo.fGeometryProcessor = - this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), texture); + this->setupDfProcessor(fFontCache->context(), this->viewMatrix(), + fFilteredColor, this->color(), std::move(proxy)); } else { GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode); flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make( - this->color(), texture, params, maskFormat, localMatrix, this->usesLocalCoords()); + fFontCache->context(), + this->color(), std::move(proxy), params, + maskFormat, localMatrix, this->usesLocalCoords()); } flushInfo.fGlyphsToFlush = 0; @@ -230,10 +233,11 @@ bool GrAtlasTextOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) { // TODO just use class params // TODO trying to figure out why lcd is so whack -sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const SkMatrix& viewMatrix, +sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(GrContext* context, + const SkMatrix& viewMatrix, SkColor filteredColor, GrColor color, - GrTexture* texture) const { + sk_sp<GrTextureProxy> proxy) const { GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kBilerp_FilterMode); bool isLCD = this->isLCD(); // set up any flags @@ -261,18 +265,20 @@ sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const SkMatrix& viewM GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make( redCorrection, greenCorrection, blueCorrection); - return GrDistanceFieldLCDTextGeoProc::Make( - color, viewMatrix, texture, params, widthAdjust, flags, this->usesLocalCoords()); + return GrDistanceFieldLCDTextGeoProc::Make(context, color, viewMatrix, std::move(proxy), + params, widthAdjust, flags, + this->usesLocalCoords()); } else { #ifdef SK_GAMMA_APPLY_TO_A8 U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, filteredColor); float correction = fDistanceAdjustTable->getAdjustment(lum >> kDistanceAdjustLumShift, fUseGammaCorrectDistanceTable); - return GrDistanceFieldA8TextGeoProc::Make( - color, viewMatrix, texture, params, correction, flags, this->usesLocalCoords()); + return GrDistanceFieldA8TextGeoProc::Make(context, color, viewMatrix, std::move(proxy), + params, correction, flags, + this->usesLocalCoords()); #else - return GrDistanceFieldA8TextGeoProc::Make( - color, viewMatrix, texture, params, flags, this->usesLocalCoords()); + return GrDistanceFieldA8TextGeoProc::Make(context, color, viewMatrix, std::move(proxy), + params, flags, this->usesLocalCoords()); #endif } } diff --git a/src/gpu/ops/GrAtlasTextOp.h b/src/gpu/ops/GrAtlasTextOp.h index 01736fc687..a52be6cf2b 100644 --- a/src/gpu/ops/GrAtlasTextOp.h +++ b/src/gpu/ops/GrAtlasTextOp.h @@ -148,8 +148,9 @@ private: // TODO just use class params // TODO trying to figure out why lcd is so whack - sk_sp<GrGeometryProcessor> setupDfProcessor(const SkMatrix& viewMatrix, SkColor filteredColor, - GrColor color, GrTexture* texture) const; + sk_sp<GrGeometryProcessor> setupDfProcessor(GrContext*, const + SkMatrix& viewMatrix, SkColor filteredColor, + GrColor color, sk_sp<GrTextureProxy> proxy) const; GrColor fColor; bool fUsesLocalCoords; diff --git a/src/gpu/text/GrAtlasGlyphCache.cpp b/src/gpu/text/GrAtlasGlyphCache.cpp index 95cadd86df..cf56c897d6 100644 --- a/src/gpu/text/GrAtlasGlyphCache.cpp +++ b/src/gpu/text/GrAtlasGlyphCache.cpp @@ -27,8 +27,8 @@ bool GrAtlasGlyphCache::initAtlas(GrMaskFormat format) { int numPlotsY = fAtlasConfigs[index].numPlotsY(); fAtlases[index] = fContext->resourceProvider()->makeAtlas( - config, width, height, numPlotsX, numPlotsY, &GrAtlasGlyphCache::HandleEviction, - (void*)this); + fContext, config, width, height, numPlotsX, numPlotsY, + &GrAtlasGlyphCache::HandleEviction, (void*)this); if (!fAtlases[index]) { return false; } @@ -166,8 +166,8 @@ void GrAtlasGlyphCache::dump() const { static int gDumpCount = 0; for (int i = 0; i < kMaskFormatCount; ++i) { if (fAtlases[i]) { - GrTexture* texture = fAtlases[i]->getTexture(); - if (texture) { + sk_sp<GrTextureProxy> proxy = fAtlases[i]->getProxy(); + if (proxy) { SkString filename; #ifdef SK_BUILD_FOR_ANDROID filename.printf("/sdcard/fontcache_%d%d.png", gDumpCount, i); @@ -175,9 +175,7 @@ void GrAtlasGlyphCache::dump() const { filename.printf("fontcache_%d%d.png", gDumpCount, i); #endif - sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(sk_ref_sp(texture))); - - save_pixels(fContext, sProxy.get(), filename.c_str()); + save_pixels(fContext, proxy.get(), filename.c_str()); } } } diff --git a/src/gpu/text/GrAtlasGlyphCache.h b/src/gpu/text/GrAtlasGlyphCache.h index 57b65baba2..9e97966952 100644 --- a/src/gpu/text/GrAtlasGlyphCache.h +++ b/src/gpu/text/GrAtlasGlyphCache.h @@ -126,12 +126,12 @@ public: void freeAll(); - // if texture returns nullptr, the client must not try to use other functions on the + // if getProxy returns nullptr, the client must not try to use other functions on the // GrAtlasGlyphCache which use the atlas. This function *must* be called first, before other // functions which use the atlas. - GrTexture* getTexture(GrMaskFormat format) { + sk_sp<GrTextureProxy> getProxy(GrMaskFormat format) { if (this->initAtlas(format)) { - return this->getAtlas(format)->getTexture(); + return this->getAtlas(format)->getProxy(); } return nullptr; } @@ -185,6 +185,8 @@ public: void setAtlasSizes_ForTesting(const GrDrawOpAtlasConfig configs[3]); + GrContext* context() const { return fContext; } + private: static GrPixelConfig MaskFormatToPixelConfig(GrMaskFormat format, const GrCaps& caps) { switch (format) { |