Move MakeDivByTextureWHMatrix to GrCoordTransform
R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/522873005
This commit is contained in:
parent
413191419d
commit
6267f81f3d
@ -64,7 +64,7 @@ public:
|
||||
void reset(GrCoordSet sourceCoords, const GrTexture* texture) {
|
||||
SkASSERT(!fInEffect);
|
||||
SkASSERT(NULL != texture);
|
||||
this->reset(sourceCoords, GrEffect::MakeDivByTextureWHMatrix(texture), texture);
|
||||
this->reset(sourceCoords, MakeDivByTextureWHMatrix(texture), texture);
|
||||
}
|
||||
|
||||
void reset(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture* texture = NULL) {
|
||||
@ -101,6 +101,15 @@ public:
|
||||
const SkMatrix& getMatrix() const { return fMatrix; }
|
||||
bool reverseY() const { return fReverseY; }
|
||||
|
||||
/** Useful for effects that want to insert a texture matrix that is implied by the texture
|
||||
dimensions */
|
||||
static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) {
|
||||
SkASSERT(NULL != texture);
|
||||
SkMatrix mat;
|
||||
mat.setIDiv(texture->width(), texture->height());
|
||||
return mat;
|
||||
}
|
||||
|
||||
private:
|
||||
GrCoordSet fSourceCoords;
|
||||
SkMatrix fMatrix;
|
||||
|
@ -125,15 +125,6 @@ public:
|
||||
|
||||
static const int kMaxVertexAttribs = 2;
|
||||
|
||||
/** Useful for effects that want to insert a texture matrix that is implied by the texture
|
||||
dimensions */
|
||||
static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) {
|
||||
SkASSERT(NULL != texture);
|
||||
SkMatrix mat;
|
||||
mat.setIDiv(texture->width(), texture->height());
|
||||
return mat;
|
||||
}
|
||||
|
||||
void* operator new(size_t size);
|
||||
void operator delete(void* target);
|
||||
|
||||
|
@ -90,9 +90,11 @@ private:
|
||||
float outerThreshold)
|
||||
: fInnerThreshold(innerThreshold)
|
||||
, fOuterThreshold(outerThreshold)
|
||||
, fImageCoordTransform(kLocal_GrCoordSet, MakeDivByTextureWHMatrix(texture), texture)
|
||||
, fImageCoordTransform(kLocal_GrCoordSet,
|
||||
GrCoordTransform::MakeDivByTextureWHMatrix(texture), texture)
|
||||
, fImageTextureAccess(texture)
|
||||
, fMaskCoordTransform(kLocal_GrCoordSet, MakeDivByTextureWHMatrix(maskTexture), maskTexture)
|
||||
, fMaskCoordTransform(kLocal_GrCoordSet,
|
||||
GrCoordTransform::MakeDivByTextureWHMatrix(maskTexture), maskTexture)
|
||||
, fMaskTextureAccess(maskTexture) {
|
||||
this->addCoordTransform(&fImageCoordTransform);
|
||||
this->addTextureAccess(&fImageTextureAccess);
|
||||
|
@ -427,7 +427,7 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
|
||||
ctx.ctm().mapVectors(&scale, 1);
|
||||
|
||||
GrPaint paint;
|
||||
SkMatrix offsetMatrix = GrEffect::MakeDivByTextureWHMatrix(displacement);
|
||||
SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacement);
|
||||
offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset.fX),
|
||||
SkIntToScalar(colorOffset.fY - displacementOffset.fY));
|
||||
|
||||
|
@ -1272,7 +1272,7 @@ GrLightingEffect::GrLightingEffect(GrTexture* texture,
|
||||
const SkLight* light,
|
||||
SkScalar surfaceScale,
|
||||
const SkMatrix& matrix)
|
||||
: INHERITED(texture, MakeDivByTextureWHMatrix(texture))
|
||||
: INHERITED(texture, GrCoordTransform::MakeDivByTextureWHMatrix(texture))
|
||||
, fLight(light)
|
||||
, fSurfaceScale(surfaceScale)
|
||||
, fFilterMatrix(matrix) {
|
||||
|
@ -66,7 +66,7 @@ private:
|
||||
float yInvZoom,
|
||||
float xInvInset,
|
||||
float yInvInset)
|
||||
: GrSingleTextureEffect(texture, MakeDivByTextureWHMatrix(texture))
|
||||
: GrSingleTextureEffect(texture, GrCoordTransform::MakeDivByTextureWHMatrix(texture))
|
||||
, fXOffset(xOffset)
|
||||
, fYOffset(yOffset)
|
||||
, fXInvZoom(xInvZoom)
|
||||
|
@ -154,7 +154,7 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
|
||||
return false;
|
||||
}
|
||||
|
||||
SkMatrix foregroundMatrix = GrEffect::MakeDivByTextureWHMatrix(foregroundTex);
|
||||
SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foregroundTex);
|
||||
foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOffset.fX),
|
||||
SkIntToScalar(backgroundOffset.fY-foregroundOffset.fY));
|
||||
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
Gr1DKernelEffect(GrTexture* texture,
|
||||
Direction direction,
|
||||
int radius)
|
||||
: GrSingleTextureEffect(texture, MakeDivByTextureWHMatrix(texture))
|
||||
: GrSingleTextureEffect(texture, GrCoordTransform::MakeDivByTextureWHMatrix(texture))
|
||||
, fDirection(direction)
|
||||
, fRadius(radius) {}
|
||||
|
||||
|
@ -42,10 +42,12 @@ public:
|
||||
if (NULL == domain) {
|
||||
static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode,
|
||||
SkShader::kClamp_TileMode };
|
||||
return Create(tex, coefficients, MakeDivByTextureWHMatrix(tex), kTileModes);
|
||||
return Create(tex, coefficients, GrCoordTransform::MakeDivByTextureWHMatrix(tex),
|
||||
kTileModes);
|
||||
} else {
|
||||
return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients,
|
||||
MakeDivByTextureWHMatrix(tex), *domain));
|
||||
GrCoordTransform::MakeDivByTextureWHMatrix(tex),
|
||||
*domain));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture,
|
||||
const SkIPoint& kernelOffset,
|
||||
GrTextureDomain::Mode tileMode,
|
||||
bool convolveAlpha)
|
||||
: INHERITED(texture, MakeDivByTextureWHMatrix(texture)),
|
||||
: INHERITED(texture, GrCoordTransform::MakeDivByTextureWHMatrix(texture)),
|
||||
fKernelSize(kernelSize),
|
||||
fGain(SkScalarToFloat(gain)),
|
||||
fBias(SkScalarToFloat(bias) / 255.0f),
|
||||
|
@ -72,7 +72,8 @@ public:
|
||||
|
||||
private:
|
||||
YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture)
|
||||
: fCoordTransform(kLocal_GrCoordSet, MakeDivByTextureWHMatrix(yTexture), yTexture)
|
||||
: fCoordTransform(kLocal_GrCoordSet, GrCoordTransform::MakeDivByTextureWHMatrix(yTexture),
|
||||
yTexture)
|
||||
, fYAccess(yTexture)
|
||||
, fUAccess(uTexture)
|
||||
, fVAccess(vTexture) {
|
||||
|
Loading…
Reference in New Issue
Block a user