#include "GrContext.h"
#include "GrCoordTransform.h"
#include "SkGr.h"
-#include "SkGrPriv.h"
#include "effects/GrConstColorProcessor.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
class GrPerlinNoise2Effect : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(GrTextureProvider* textureProvider,
- SkPerlinNoiseShader2::Type type,
+ static sk_sp<GrFragmentProcessor> Make(SkPerlinNoiseShader2::Type type,
int numOctaves, bool stitchTiles,
SkPerlinNoiseShader2::PaintingData* paintingData,
- sk_sp<GrTextureProxy> permutationsProxy,
- sk_sp<GrTextureProxy> noiseProxy,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
const SkMatrix& matrix) {
return sk_sp<GrFragmentProcessor>(
- new GrPerlinNoise2Effect(textureProvider, type, numOctaves, stitchTiles, paintingData,
- std::move(permutationsProxy), std::move(noiseProxy), matrix));
+ new GrPerlinNoise2Effect(type, numOctaves, stitchTiles, paintingData,
+ permutationsTexture, noiseTexture, matrix));
}
virtual ~GrPerlinNoise2Effect() { delete fPaintingData; }
fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit;
}
- GrPerlinNoise2Effect(GrTextureProvider* textureProvider,
- SkPerlinNoiseShader2::Type type, int numOctaves, bool stitchTiles,
+ GrPerlinNoise2Effect(SkPerlinNoiseShader2::Type type, int numOctaves, bool stitchTiles,
SkPerlinNoiseShader2::PaintingData* paintingData,
- sk_sp<GrTextureProxy> permutationsProxy,
- sk_sp<GrTextureProxy> noiseProxy,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
const SkMatrix& matrix)
: INHERITED(kNone_OptimizationFlags)
, fType(type)
, fNumOctaves(numOctaves)
, fStitchTiles(stitchTiles)
- , fPermutationsSampler(textureProvider, std::move(permutationsProxy))
- , fNoiseSampler(textureProvider, std::move(noiseProxy))
+ , fPermutationsSampler(permutationsTexture)
+ , fNoiseSampler(noiseTexture)
, fPaintingData(paintingData) {
this->initClassID<GrPerlinNoise2Effect>();
this->addTextureSampler(&fPermutationsSampler);
GrConstColorProcessor::kIgnore_InputMode);
}
- sk_sp<GrTextureProxy> permutationsProxy = GrMakeCachedBitmapProxy(
- args.fContext,
- paintingData->getPermutationsBitmap());
- sk_sp<GrTextureProxy> noiseProxy = GrMakeCachedBitmapProxy(args.fContext,
- paintingData->getNoiseBitmap());
+ sk_sp<GrTexture> permutationsTexture(
+ GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
+ GrSamplerParams::ClampNoFilter(), nullptr));
+ sk_sp<GrTexture> noiseTexture(
+ GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
+ GrSamplerParams::ClampNoFilter(), nullptr));
- if (permutationsProxy && noiseProxy) {
+ if ((permutationsTexture) && (noiseTexture)) {
sk_sp<GrFragmentProcessor> inner(
- GrPerlinNoise2Effect::Make(args.fContext->textureProvider(),
- fType,
+ GrPerlinNoise2Effect::Make(fType,
fNumOctaves,
fStitchTiles,
paintingData,
- std::move(permutationsProxy),
- std::move(noiseProxy),
+ permutationsTexture.get(), noiseTexture.get(),
m));
return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
sk_sp<GrTextureProxy> onAsTextureProxy(GrContext* context) const override {
if (context) {
- return GrMakeCachedBitmapProxy(context, fBitmap);
+ sk_sp<GrTexture> tex(sk_ref_sp(GrRefCachedBitmapTexture(
+ context, fBitmap, GrSamplerParams::ClampNoFilter(), nullptr)));
+ return GrSurfaceProxy::MakeWrapped(std::move(tex));
}
return nullptr;
#include "GrContext.h"
#include "GrCoordTransform.h"
#include "SkGr.h"
-#include "SkGrPriv.h"
#include "effects/GrConstColorProcessor.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
class GrPerlinNoiseEffect : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(GrTextureProvider* textureProvider,
- SkPerlinNoiseShader::Type type,
+ static sk_sp<GrFragmentProcessor> Make(SkPerlinNoiseShader::Type type,
int numOctaves, bool stitchTiles,
SkPerlinNoiseShader::PaintingData* paintingData,
- sk_sp<GrTextureProxy> permutationsProxy,
- sk_sp<GrTextureProxy> noiseProxy,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
const SkMatrix& matrix) {
return sk_sp<GrFragmentProcessor>(
- new GrPerlinNoiseEffect(textureProvider, type, numOctaves, stitchTiles, paintingData,
- std::move(permutationsProxy), std::move(noiseProxy), matrix));
+ new GrPerlinNoiseEffect(type, numOctaves, stitchTiles, paintingData,
+ permutationsTexture, noiseTexture, matrix));
}
virtual ~GrPerlinNoiseEffect() { delete fPaintingData; }
fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit;
}
- GrPerlinNoiseEffect(GrTextureProvider* textureProvider,
- SkPerlinNoiseShader::Type type, int numOctaves, bool stitchTiles,
+ GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type, int numOctaves, bool stitchTiles,
SkPerlinNoiseShader::PaintingData* paintingData,
- sk_sp<GrTextureProxy> permutationsProxy, sk_sp<GrTextureProxy> noiseProxy,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
const SkMatrix& matrix)
: INHERITED(kNone_OptimizationFlags)
, fType(type)
, fCoordTransform(matrix)
, fNumOctaves(numOctaves)
, fStitchTiles(stitchTiles)
- , fPermutationsSampler(textureProvider, std::move(permutationsProxy))
- , fNoiseSampler(textureProvider, std::move(noiseProxy))
+ , fPermutationsSampler(permutationsTexture)
+ , fNoiseSampler(noiseTexture)
, fPaintingData(paintingData) {
this->initClassID<GrPerlinNoiseEffect>();
this->addTextureSampler(&fPermutationsSampler);
SkPerlinNoiseShader::PaintingData* paintingData =
new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
- sk_sp<GrTextureProxy> permutationsProxy(GrMakeCachedBitmapProxy(
- args.fContext,
- paintingData->getPermutationsBitmap()));
- sk_sp<GrTextureProxy> noiseProxy(GrMakeCachedBitmapProxy(args.fContext,
- paintingData->getNoiseBitmap()));
+ sk_sp<GrTexture> permutationsTexture(
+ GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
+ GrSamplerParams::ClampNoFilter(), nullptr));
+ sk_sp<GrTexture> noiseTexture(
+ GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
+ GrSamplerParams::ClampNoFilter(), nullptr));
SkMatrix m = *args.fViewMatrix;
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
- if (permutationsProxy && noiseProxy) {
+ if ((permutationsTexture) && (noiseTexture)) {
sk_sp<GrFragmentProcessor> inner(
- GrPerlinNoiseEffect::Make(args.fContext->textureProvider(),
- fType,
+ GrPerlinNoiseEffect::Make(fType,
fNumOctaves,
fStitchTiles,
paintingData,
- std::move(permutationsProxy),
- std::move(noiseProxy),
+ permutationsTexture.get(), noiseTexture.get(),
m));
return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
#include "SkArenaAlloc.h"
#include "SkBitmap.h"
#include "SkColorPriv.h"
-#include "SkGrPriv.h"
#include "SkRasterPipeline.h"
#include "SkReadBuffer.h"
#include "SkString.h"
class ColorTableEffect : public GrFragmentProcessor {
public:
- static sk_sp<GrFragmentProcessor> Make(GrContext* context,
- const SkBitmap& bitmap,
- unsigned flags);
+ static sk_sp<GrFragmentProcessor> Make(GrContext* context, SkBitmap bitmap, unsigned flags);
virtual ~ColorTableEffect();
}
///////////////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, const SkBitmap& bitmap,
+sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, SkBitmap bitmap,
unsigned flags) {
GrTextureStripAtlas::Desc desc;
sk_sp<GrTexture> texture;
if (-1 == row) {
atlas = nullptr;
-
- sk_sp<GrTextureProxy> proxy = GrMakeCachedBitmapProxy(context, bitmap);
- if (proxy) {
- texture.reset(proxy->instantiate(context->textureProvider()));
- }
+ texture.reset(
+ GrRefCachedBitmapTexture(context, bitmap, GrSamplerParams::ClampNoFilter(), nullptr));
} else {
texture.reset(SkRef(atlas->getTexture()));
}
- if (!texture) {
- return nullptr;
- }
-
return sk_sp<GrFragmentProcessor>(new ColorTableEffect(texture.get(), atlas, row, flags));
}