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>
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index 3c2115e..bc40c38 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -372,12 +372,12 @@
paint.setGammaCorrect(dstRenderTargetContext->isGammaCorrect());
// FIXME: this should be mitchell, not bilinear.
GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kBilerp_FilterMode);
- sk_sp<GrTexture> tex(srcRenderTargetContext->asTexture());
- if (!tex) {
+ sk_sp<GrTextureProxy> proxy(srcRenderTargetContext->asTextureProxyRef());
+ if (!proxy) {
return nullptr;
}
- paint.addColorTextureProcessor(tex.get(), nullptr, SkMatrix::I(), params);
+ paint.addColorTextureProcessor(context, std::move(proxy), nullptr, SkMatrix::I(), params);
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
SkIRect dstRect(srcRect);
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
index 45430df..464dc5e 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
@@ -27,31 +27,6 @@
}
GrAlphaThresholdFragmentProcessor::GrAlphaThresholdFragmentProcessor(
- GrTexture* texture,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- GrTexture* maskTexture,
- float innerThreshold,
- float outerThreshold,
- const SkIRect& bounds)
- : INHERITED(OptFlags(outerThreshold))
- , fInnerThreshold(innerThreshold)
- , fOuterThreshold(outerThreshold)
- , fImageCoordTransform(SkMatrix::I(), texture, GrSamplerParams::kNone_FilterMode)
- , fImageTextureSampler(texture)
- , fColorSpaceXform(std::move(colorSpaceXform))
- , fMaskCoordTransform(
- SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())),
- maskTexture,
- GrSamplerParams::kNone_FilterMode)
- , fMaskTextureSampler(maskTexture) {
- this->initClassID<GrAlphaThresholdFragmentProcessor>();
- this->addCoordTransform(&fImageCoordTransform);
- this->addTextureSampler(&fImageTextureSampler);
- this->addCoordTransform(&fMaskCoordTransform);
- this->addTextureSampler(&fMaskTextureSampler);
-}
-
-GrAlphaThresholdFragmentProcessor::GrAlphaThresholdFragmentProcessor(
GrContext* context,
sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.h b/src/effects/GrAlphaThresholdFragmentProcessor.h
index fa7a760..315993d 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.h
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.h
@@ -20,20 +20,6 @@
class GrAlphaThresholdFragmentProcessor : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- GrTexture* maskTexture,
- float innerThreshold,
- float outerThreshold,
- const SkIRect& bounds) {
- return sk_sp<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor(
- texture,
- std::move(colorSpaceXform),
- maskTexture,
- innerThreshold, outerThreshold,
- bounds));
- }
-
static sk_sp<GrFragmentProcessor> Make(GrContext* context,
sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
@@ -60,13 +46,6 @@
private:
static OptimizationFlags OptFlags(float outerThreshold);
- GrAlphaThresholdFragmentProcessor(GrTexture* texture,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- GrTexture* maskTexture,
- float innerThreshold,
- float outerThreshold,
- const SkIRect& bounds);
-
GrAlphaThresholdFragmentProcessor(GrContext*,
sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 507b697..dcc3429 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -770,7 +770,7 @@
const char* name() const override { return "RectBlur"; }
- static sk_sp<GrFragmentProcessor> Make(GrTextureProvider *textureProvider,
+ static sk_sp<GrFragmentProcessor> Make(GrTextureProvider* textureProvider,
const SkRect& rect, float sigma) {
int doubleProfileSize = SkScalarCeilToInt(12*sigma);
@@ -959,7 +959,6 @@
builder.finish();
sk_sp<GrTexture> blurProfile(textureProvider->findAndRefTextureByUniqueKey(key));
-
if (!blurProfile) {
std::unique_ptr<uint8_t[]> profile(SkBlurMask::ComputeBlurProfile(sigma));
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 2e08180..3c0a2d5 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -214,17 +214,6 @@
#if SK_SUPPORT_GPU
class GrDisplacementMapEffect : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(
- SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
- SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVector scale,
- GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* color,
- sk_sp<GrColorSpaceXform> colorSpaceXform, const SkISize& colorDimensions) {
- return sk_sp<GrFragmentProcessor>(
- new GrDisplacementMapEffect(xChannelSelector, yChannelSelector, scale, displacement,
- offsetMatrix, color, std::move(colorSpaceXform),
- colorDimensions));
- }
-
static sk_sp<GrFragmentProcessor> Make(GrContext* context,
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVector scale,
@@ -259,13 +248,6 @@
bool onIsEqual(const GrFragmentProcessor&) const override;
- GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
- SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
- const SkVector& scale,
- GrTexture* displacement, const SkMatrix& offsetMatrix,
- GrTexture* color, sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkISize& colorDimensions);
-
GrDisplacementMapEffect(GrContext*,
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
@@ -503,34 +485,6 @@
}
GrDisplacementMapEffect::GrDisplacementMapEffect(
- SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
- SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
- const SkVector& scale,
- GrTexture* displacement,
- const SkMatrix& offsetMatrix,
- GrTexture* color,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkISize& colorDimensions)
- : INHERITED(GrPixelConfigIsOpaque(color->config()) ? kPreservesOpaqueInput_OptimizationFlag
- : kNone_OptimizationFlags)
- , fDisplacementTransform(offsetMatrix, displacement, GrSamplerParams::kNone_FilterMode)
- , fDisplacementSampler(displacement)
- , fColorTransform(color, GrSamplerParams::kNone_FilterMode)
- , fDomain(color, GrTextureDomain::MakeTexelDomain(SkIRect::MakeSize(colorDimensions)),
- GrTextureDomain::kDecal_Mode)
- , fColorSampler(color)
- , fColorSpaceXform(std::move(colorSpaceXform))
- , fXChannelSelector(xChannelSelector)
- , fYChannelSelector(yChannelSelector)
- , fScale(scale) {
- this->initClassID<GrDisplacementMapEffect>();
- this->addCoordTransform(&fDisplacementTransform);
- this->addTextureSampler(&fDisplacementSampler);
- this->addCoordTransform(&fColorTransform);
- this->addTextureSampler(&fColorSampler);
-}
-
-GrDisplacementMapEffect::GrDisplacementMapEffect(
GrContext* context,
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 8307e31..a78f223 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -48,19 +48,6 @@
#if SK_SUPPORT_GPU
class GrMagnifierEffect : public GrSingleTextureEffect {
public:
- static sk_sp<GrFragmentProcessor> Make(GrTexture* texture,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkIRect& bounds,
- const SkRect& srcRect,
- float xInvZoom,
- float yInvZoom,
- float xInvInset,
- float yInvInset) {
- return sk_sp<GrFragmentProcessor>(new GrMagnifierEffect(texture, std::move(colorSpaceXform),
- bounds, srcRect,
- xInvZoom, yInvZoom,
- xInvInset, yInvInset));
- }
static sk_sp<GrFragmentProcessor> Make(GrContext* context,
sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
@@ -94,25 +81,6 @@
float yInvInset() const { return fYInvInset; }
private:
- GrMagnifierEffect(GrTexture* texture,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkIRect& bounds,
- const SkRect& srcRect,
- float xInvZoom,
- float yInvZoom,
- float xInvInset,
- float yInvInset)
- : INHERITED(texture, std::move(colorSpaceXform), SkMatrix::I(),
- ModulationFlags(texture->config()))
- , fBounds(bounds)
- , fSrcRect(srcRect)
- , fXInvZoom(xInvZoom)
- , fYInvZoom(yInvZoom)
- , fXInvInset(xInvInset)
- , fYInvInset(yInvInset) {
- this->initClassID<GrMagnifierEffect>();
- }
-
GrMagnifierEffect(GrContext* context,
sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index a4a720d..81d9f8d 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -146,16 +146,6 @@
kDilate_MorphologyType,
};
- static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, Direction dir, int radius,
- MorphologyType type) {
- return sk_sp<GrFragmentProcessor>(new GrMorphologyEffect(tex, dir, radius, type));
- }
-
- static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, Direction dir, int radius,
- MorphologyType type, const float bounds[2]) {
- return sk_sp<GrFragmentProcessor>(new GrMorphologyEffect(tex, dir, radius, type, bounds));
- }
-
static sk_sp<GrFragmentProcessor> Make(GrContext* context, sk_sp<GrTextureProxy> proxy,
Direction dir, int radius, MorphologyType type) {
return sk_sp<GrFragmentProcessor>(new GrMorphologyEffect(context, std::move(proxy),
@@ -190,9 +180,6 @@
bool onIsEqual(const GrFragmentProcessor&) const override;
- GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType);
- GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType, const float bounds[2]);
-
GrMorphologyEffect(GrContext*, sk_sp<GrTextureProxy>, Direction, int radius, MorphologyType);
GrMorphologyEffect(GrContext*, sk_sp<GrTextureProxy>,
Direction, int radius, MorphologyType, const float bounds[2]);
@@ -336,29 +323,6 @@
///////////////////////////////////////////////////////////////////////////////
-GrMorphologyEffect::GrMorphologyEffect(GrTexture* texture,
- Direction direction,
- int radius,
- MorphologyType type)
- : INHERITED(texture, direction, radius, ModulationFlags(texture->config()))
- , fType(type)
- , fUseRange(false) {
- this->initClassID<GrMorphologyEffect>();
-}
-
-GrMorphologyEffect::GrMorphologyEffect(GrTexture* texture,
- Direction direction,
- int radius,
- MorphologyType type,
- const float range[2])
- : INHERITED(texture, direction, radius, ModulationFlags(texture->config()))
- , fType(type)
- , fUseRange(true) {
- this->initClassID<GrMorphologyEffect>();
- fRange[0] = range[0];
- fRange[1] = range[1];
-}
-
GrMorphologyEffect::GrMorphologyEffect(GrContext* context,
sk_sp<GrTextureProxy> proxy,
Direction direction,
@@ -430,10 +394,10 @@
#endif
-static void apply_morphology_rect(GrTextureProvider* provider,
+static void apply_morphology_rect(GrContext* context,
GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
- GrTextureProxy* textureProxy,
+ sk_sp<GrTextureProxy> proxy,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
@@ -442,21 +406,19 @@
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
paint.setGammaCorrect(renderTargetContext->isGammaCorrect());
- GrTexture* tex = textureProxy->instantiate(provider);
- if (!tex) {
- return;
- }
- paint.addColorFragmentProcessor(GrMorphologyEffect::Make(tex, direction, radius, morphType,
+
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(context, std::move(proxy),
+ direction, radius, morphType,
bounds));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
renderTargetContext->fillRectToRect(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(dstRect), SkRect::Make(srcRect));
}
-static void apply_morphology_rect_no_bounds(GrTextureProvider* provider,
+static void apply_morphology_rect_no_bounds(GrContext* context,
GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
- GrTextureProxy* textureProxy,
+ sk_sp<GrTextureProxy> proxy,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
@@ -464,20 +426,18 @@
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
paint.setGammaCorrect(renderTargetContext->isGammaCorrect());
- GrTexture* tex = textureProxy->instantiate(provider);
- if (!tex) {
- return;
- }
- paint.addColorFragmentProcessor(GrMorphologyEffect::Make(tex, direction, radius, morphType));
+
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(context, std::move(proxy),
+ direction, radius, morphType));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
renderTargetContext->fillRectToRect(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(dstRect), SkRect::Make(srcRect));
}
-static void apply_morphology_pass(GrTextureProvider* provider,
+static void apply_morphology_pass(GrContext* context,
GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
- GrTextureProxy* textureProxy,
+ sk_sp<GrTextureProxy> textureProxy,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
@@ -508,15 +468,15 @@
}
if (middleSrcRect.fLeft - middleSrcRect.fRight >= 0) {
// radius covers srcRect; use bounds over entire draw
- apply_morphology_rect(provider, renderTargetContext, clip, textureProxy,
+ apply_morphology_rect(context, renderTargetContext, clip, std::move(textureProxy),
srcRect, dstRect, radius, morphType, bounds, direction);
} else {
// Draw upper and lower margins with bounds; middle without.
- apply_morphology_rect(provider, renderTargetContext, clip, textureProxy,
+ apply_morphology_rect(context, renderTargetContext, clip, textureProxy,
lowerSrcRect, lowerDstRect, radius, morphType, bounds, direction);
- apply_morphology_rect(provider, renderTargetContext, clip, textureProxy,
+ apply_morphology_rect(context, renderTargetContext, clip, textureProxy,
upperSrcRect, upperDstRect, radius, morphType, bounds, direction);
- apply_morphology_rect_no_bounds(provider, renderTargetContext, clip, textureProxy,
+ apply_morphology_rect_no_bounds(context, renderTargetContext, clip, std::move(textureProxy),
middleSrcRect, middleDstRect, radius, morphType, direction);
}
}
@@ -548,8 +508,8 @@
return nullptr;
}
- apply_morphology_pass(context->textureProvider(),
- dstRTContext.get(), clip, srcTexture.get(),
+ apply_morphology_pass(context,
+ dstRTContext.get(), clip, std::move(srcTexture),
srcRect, dstRect, radius.fWidth, morphType,
Gr1DKernelEffect::kX_Direction);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
@@ -569,8 +529,8 @@
return nullptr;
}
- apply_morphology_pass(context->textureProvider(),
- dstRTContext.get(), clip, srcTexture.get(),
+ apply_morphology_pass(context,
+ dstRTContext.get(), clip, std::move(srcTexture),
srcRect, dstRect, radius.fHeight, morphType,
Gr1DKernelEffect::kY_Direction);
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index feb6691..6661b48 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 @@
///////////////////////////////////////////////////////////////////////////////
-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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 7a7da6c..917d4ec 100644
--- a/src/gpu/GrDrawOpAtlas.h
+++ b/src/gpu/GrDrawOpAtlas.h
@@ -55,7 +55,7 @@
*/
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 @@
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 @@
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 d74807a..2dd17b7 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -135,7 +135,8 @@
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 @@
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 47490e1..091d2db 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -146,9 +146,9 @@
* 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 @@
*/
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 24c94fc..a960eee 100644
--- a/src/gpu/effects/Gr1DKernelEffect.h
+++ b/src/gpu/effects/Gr1DKernelEffect.h
@@ -28,15 +28,6 @@
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 b1aa1d4..bbce742 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -120,28 +120,6 @@
///////////////////////////////////////////////////////////////////////////////
-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 0f30ddc..17a5e9d 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.h
+++ b/src/gpu/effects/GrBitmapTextGeoProc.h
@@ -21,13 +21,6 @@
*/
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 @@
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 1c2ef64..19f5e2a 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -222,34 +222,6 @@
///////////////////////////////////////////////////////////////////////////////
-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 @@
};
///////////////////////////////////////////////////////////////////////////////
-
-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 @@
};
///////////////////////////////////////////////////////////////////////////////
-
-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 1852c13..fc08790 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.h
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.h
@@ -49,14 +49,6 @@
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 @@
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 @@
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 @@
*/
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 @@
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 @@
}
};
- 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 @@
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 2d485e6..ecfd25c 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -168,22 +168,6 @@
}
}
-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 6d6e5b0..0a2b3cd 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 @@
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 fd90c72..01c4cd3 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -149,31 +149,6 @@
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 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 581323b..a8bdd6f 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 @@
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 2db3e36..b4c0c52 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 @@
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 @@
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 @@
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 @@
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 @@
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 be320ce..89329b5 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -82,8 +82,8 @@
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 @@
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 @@
// 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 @@
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 01736fc..a52be6c 100644
--- a/src/gpu/ops/GrAtlasTextOp.h
+++ b/src/gpu/ops/GrAtlasTextOp.h
@@ -148,8 +148,9 @@
// 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 95cadd8..cf56c89 100644
--- a/src/gpu/text/GrAtlasGlyphCache.cpp
+++ b/src/gpu/text/GrAtlasGlyphCache.cpp
@@ -27,8 +27,8 @@
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 @@
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 @@
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 57b65ba..9e97966 100644
--- a/src/gpu/text/GrAtlasGlyphCache.h
+++ b/src/gpu/text/GrAtlasGlyphCache.h
@@ -126,12 +126,12 @@
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 @@
void setAtlasSizes_ForTesting(const GrDrawOpAtlasConfig configs[3]);
+ GrContext* context() const { return fContext; }
+
private:
static GrPixelConfig MaskFormatToPixelConfig(GrMaskFormat format, const GrCaps& caps) {
switch (format) {
diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp
index dbdcaec..a25c868 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -118,7 +118,9 @@
desc.fHeight = texS;
GrTextureProvider* texProvider = context->textureProvider();
- sk_sp<GrTexture> texture(texProvider->createTexture(desc, SkBudgeted::kNo, texData, 0));
+ sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), texProvider,
+ desc, SkBudgeted::kNo,
+ texData, 0);
// Create two render target contexts (L32 and S32)
sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeSRGB();
@@ -132,7 +134,8 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
GrSamplerParams mipMapParams(SkShader::kRepeat_TileMode, GrSamplerParams::kMipMap_FilterMode);
- paint.addColorTextureProcessor(texture.get(), nullptr, SkMatrix::MakeScale(rtS), mipMapParams);
+ paint.addColorTextureProcessor(context, sk_ref_sp(proxy->asTextureProxy()),
+ nullptr, SkMatrix::MakeScale(rtS), mipMapParams);
// 1) Draw texture to S32 surface (should generate/use sRGB mips)
paint.setGammaCorrect(true);
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index da4f8eb..0e309bf 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -124,7 +124,17 @@
sk_sp<SkImage> GrContext::getFontAtlasImage_ForTesting(GrMaskFormat format) {
GrAtlasGlyphCache* cache = this->getAtlasGlyphCache();
- GrTexture* tex = cache->getTexture(format);
+ sk_sp<GrTextureProxy> proxy = cache->getProxy(format);
+ if (!proxy) {
+ return nullptr;
+ }
+
+ GrTexture* tex = proxy->instantiate(this->textureProvider());
+ if (!tex) {
+ return nullptr;
+ }
+
+ // MDB TODO: add proxy-backed SkImage_Gpu's
sk_sp<SkImage> image(new SkImage_Gpu(tex->width(), tex->height(),
kNeedNewImageUniqueID, kPremul_SkAlphaType,
sk_ref_sp(tex), nullptr, SkBudgeted::kNo));