aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-07-21 14:12:29 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-21 19:05:25 +0000
commitc686ce39f06d556d55befd290e0eb82851c7d33b (patch)
treed2d9cd464240a5a037ece559748ecedbb4293d0b
parent219f3622ba32a1cb6380212a2ec1947513fbfeb9 (diff)
Smaller fragment from "Reduce dependence on GrSurface's origin field"
TBR=bsalomon@google.com Change-Id: I996226ffaf84ca357740a6da9bb80a3b8febb379 Reviewed-on: https://skia-review.googlesource.com/25745 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r--src/effects/GrCircleBlurFragmentProcessor.cpp2
-rw-r--r--src/effects/SkBlurMaskFilter.cpp16
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp7
-rw-r--r--src/effects/SkLightingImageFilter.cpp7
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp7
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp5
-rw-r--r--src/gpu/effects/GrBicubicEffect.cpp5
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp1
-rw-r--r--src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp7
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.cpp7
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp16
-rw-r--r--src/gpu/effects/GrTextureDomain.h3
12 files changed, 48 insertions, 35 deletions
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index 135b00e4d9..fb12afbaeb 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -178,6 +178,7 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrResourceProvider* resource
if (!blurProfile) {
static constexpr int kProfileTextureWidth = 512;
GrSurfaceDesc texDesc;
+ texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
texDesc.fWidth = kProfileTextureWidth;
texDesc.fHeight = 1;
texDesc.fConfig = kAlpha_8_GrPixelConfig;
@@ -197,6 +198,7 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrResourceProvider* resource
return nullptr;
}
+ SkASSERT(blurProfile->origin() == kTopLeft_GrSurfaceOrigin);
resourceProvider->assignUniqueKeyToProxy(key, blurProfile.get());
}
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index d85160e651..eac70c93c7 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -942,15 +942,8 @@ void GrGLRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman,
sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(
GrResourceProvider* resourceProvider,
float sigma) {
- GrSurfaceDesc texDesc;
-
unsigned int profileSize = SkScalarCeilToInt(6*sigma);
- texDesc.fWidth = profileSize;
- texDesc.fHeight = 1;
- texDesc.fConfig = kAlpha_8_GrPixelConfig;
- texDesc.fIsMipMapped = false;
-
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey key;
GrUniqueKey::Builder builder(&key, kDomain, 1);
@@ -959,6 +952,13 @@ sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(
sk_sp<GrTextureProxy> blurProfile(resourceProvider->findProxyByUniqueKey(key));
if (!blurProfile) {
+ GrSurfaceDesc texDesc;
+ texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
+ texDesc.fWidth = profileSize;
+ texDesc.fHeight = 1;
+ texDesc.fConfig = kAlpha_8_GrPixelConfig;
+ texDesc.fIsMipMapped = false;
+
std::unique_ptr<uint8_t[]> profile(SkBlurMask::ComputeBlurProfile(sigma));
blurProfile = GrSurfaceProxy::MakeDeferred(resourceProvider,
@@ -967,6 +967,7 @@ sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(
return nullptr;
}
+ SkASSERT(blurProfile->origin() == kTopLeft_GrSurfaceOrigin);
resourceProvider->assignUniqueKeyToProxy(key, blurProfile.get());
}
@@ -1154,6 +1155,7 @@ static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrContext* context,
if (!mask) {
return nullptr;
}
+ SkASSERT(mask->origin() == kBottomLeft_GrSurfaceOrigin);
context->resourceProvider()->assignUniqueKeyToProxy(key, mask.get());
}
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 90756a7265..06e7e687ab 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -597,14 +597,15 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
void GrGLDisplacementMapEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& proc) {
const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
- GrTexture* colorTex = displacementMap.textureSampler(1).peekTexture();
+ GrSurfaceProxy* proxy = displacementMap.textureSampler(1).proxy();
+ GrTexture* colorTex = proxy->priv().peekTexture();
SkScalar scaleX = displacementMap.scale().fX / colorTex->width();
SkScalar scaleY = displacementMap.scale().fY / colorTex->height();
pdman.set2f(fScaleUni, SkScalarToFloat(scaleX),
- colorTex->origin() == kTopLeft_GrSurfaceOrigin ?
+ proxy->origin() == kTopLeft_GrSurfaceOrigin ?
SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));
- fGLDomain.setData(pdman, displacementMap.domain(), colorTex);
+ fGLDomain.setData(pdman, displacementMap.domain(), proxy);
if (SkToBool(displacementMap.colorSpaceXform())) {
fColorSpaceHelper.setData(pdman, displacementMap.colorSpaceXform());
}
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 7b72fcd5aa..58064ceea9 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -1899,14 +1899,15 @@ void GrGLLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman,
fLight = lighting.light()->createGLLight();
}
- GrTexture* texture = lighting.textureSampler(0).peekTexture();
+ GrTextureProxy* proxy = lighting.textureSampler(0).proxy();
+ GrTexture* texture = proxy->priv().peekTexture();
- float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
+ float ySign = proxy->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
pdman.set2f(fImageIncrementUni, 1.0f / texture->width(), ySign / texture->height());
pdman.set1f(fSurfaceScaleUni, lighting.surfaceScale());
sk_sp<SkImageFilterLight> transformedLight(
lighting.light()->transform(lighting.filterMatrix()));
- fDomain.setData(pdman, lighting.domain(), texture);
+ fDomain.setData(pdman, lighting.domain(), proxy);
fLight->setData(pdman, transformedLight.get());
}
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 90e0a5c879..b2c6714828 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -202,14 +202,15 @@ void GrGLMagnifierEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& effect) {
const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>();
- GrTexture* tex = zoom.textureSampler(0).peekTexture();
+ GrSurfaceProxy* proxy = zoom.textureSampler(0).proxy();
+ GrTexture* tex = proxy->priv().peekTexture();
SkScalar invW = 1.0f / tex->width();
SkScalar invH = 1.0f / tex->height();
{
SkScalar y = zoom.srcRect().y() * invH;
- if (tex->origin() != kTopLeft_GrSurfaceOrigin) {
+ if (proxy->origin() != kTopLeft_GrSurfaceOrigin) {
y = 1.0f - (zoom.srcRect().height() / zoom.bounds().height()) - y;
}
@@ -221,7 +222,7 @@ void GrGLMagnifierEffect::onSetData(const GrGLSLProgramDataManager& pdman,
{
SkScalar y = zoom.bounds().y() * invH;
- if (tex->origin() != kTopLeft_GrSurfaceOrigin) {
+ if (proxy->origin() != kTopLeft_GrSurfaceOrigin) {
y = 1.0f - zoom.bounds().height() * invH;
}
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index a148bb3bcd..2cc224da99 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -293,7 +293,8 @@ void GrGLMorphologyEffect::GenKey(const GrProcessor& proc,
void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& proc) {
const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
- GrTexture& texture = *m.textureSampler(0).peekTexture();
+ GrSurfaceProxy* proxy = m.textureSampler(0).proxy();
+ GrTexture& texture = *proxy->priv().peekTexture();
float pixelSize = 0.0f;
switch (m.direction()) {
@@ -311,7 +312,7 @@ void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
if (m.useRange()) {
const float* range = m.range();
if (Gr1DKernelEffect::kY_Direction == m.direction() &&
- texture.origin() == kBottomLeft_GrSurfaceOrigin) {
+ proxy->origin() == kBottomLeft_GrSurfaceOrigin) {
pdman.set2f(fRangeUni, 1.0f - (range[1]*pixelSize), 1.0f - (range[0]*pixelSize));
} else {
pdman.set2f(fRangeUni, range[0] * pixelSize, range[1] * pixelSize);
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 6d8072f231..f7441bc043 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -120,13 +120,14 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& processor) {
const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>();
- GrTexture* texture = processor.textureSampler(0).peekTexture();
+ GrSurfaceProxy* proxy = processor.textureSampler(0).proxy();
+ GrTexture* texture = proxy->priv().peekTexture();
float imageIncrement[2];
imageIncrement[0] = 1.0f / texture->width();
imageIncrement[1] = 1.0f / texture->height();
pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
- fDomain.setData(pdman, bicubicEffect.domain(), texture);
+ fDomain.setData(pdman, bicubicEffect.domain(), proxy);
if (SkToBool(bicubicEffect.colorSpaceXform())) {
fColorSpaceHelper.setData(pdman, bicubicEffect.colorSpaceXform());
}
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index e4989de507..e8d04771f5 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -133,6 +133,7 @@ bool GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
return false;
}
GrSurfaceDesc desc;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fWidth = kSize;
desc.fHeight = kSize;
desc.fConfig = kConfig;
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index 4d1a99d83e..1ab9b78cfc 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -121,10 +121,11 @@ void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& processor) {
const GrGaussianConvolutionFragmentProcessor& conv =
processor.cast<GrGaussianConvolutionFragmentProcessor>();
- GrTexture& texture = *conv.textureSampler(0).peekTexture();
+ GrSurfaceProxy* proxy = conv.textureSampler(0).proxy();
+ GrTexture& texture = *proxy->priv().peekTexture();
float imageIncrement[2] = {0};
- float ySign = texture.origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
+ float ySign = proxy->origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
switch (conv.direction()) {
case Gr1DKernelEffect::kX_Direction:
imageIncrement[0] = 1.0f / texture.width();
@@ -149,7 +150,7 @@ void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
pdman.set2f(fBoundsUni, inv * bounds[0], inv * bounds[1]);
} else {
SkScalar inv = SkScalarInvert(SkIntToScalar(texture.height()));
- if (texture.origin() != kTopLeft_GrSurfaceOrigin) {
+ if (proxy->origin() != kTopLeft_GrSurfaceOrigin) {
pdman.set2f(fBoundsUni, 1.0f - (inv * bounds[1]), 1.0f - (inv * bounds[0]));
} else {
pdman.set2f(fBoundsUni, inv * bounds[1], inv * bounds[0]);
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index bc1537c8b4..abfe5b3774 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -131,10 +131,11 @@ void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor,
void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& processor) {
const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>();
- GrTexture* texture = conv.textureSampler(0).peekTexture();
+ GrSurfaceProxy* proxy = conv.textureSampler(0).proxy();
+ GrTexture* texture = proxy->priv().peekTexture();
float imageIncrement[2];
- float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
+ float ySign = proxy->origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
imageIncrement[0] = 1.0f / texture->width();
imageIncrement[1] = ySign / texture->height();
pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
@@ -145,7 +146,7 @@ void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdma
pdman.set4fv(fKernelUni, arrayCount, conv.kernel());
pdman.set1f(fGainUni, conv.gain());
pdman.set1f(fBiasUni, conv.bias());
- fDomain.setData(pdman, conv.domain(), texture);
+ fDomain.setData(pdman, conv.domain(), proxy);
}
GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy,
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index a8ce0ab6c5..f2b78586d7 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -161,7 +161,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
const GrTextureDomain& textureDomain,
- GrTexture* tex) {
+ GrSurfaceProxy* proxy) {
+ GrTexture* tex = proxy->priv().peekTexture();
SkASSERT(textureDomain.mode() == fMode);
if (kIgnore_Mode != textureDomain.mode()) {
SkScalar wInv = SK_Scalar1 / tex->width();
@@ -180,7 +181,7 @@ void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
SkASSERT(values[3] >= 0.0f && values[3] <= 1.0f);
// vertical flip if necessary
- if (kBottomLeft_GrSurfaceOrigin == tex->origin()) {
+ if (kBottomLeft_GrSurfaceOrigin == proxy->origin()) {
values[1] = 1.0f - values[1];
values[3] = 1.0f - values[3];
// The top and bottom were just flipped, so correct the ordering
@@ -270,9 +271,9 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const {
const GrFragmentProcessor& fp) override {
const GrTextureDomainEffect& tde = fp.cast<GrTextureDomainEffect>();
const GrTextureDomain& domain = tde.fTextureDomain;
- GrTexture* texture = tde.textureSampler(0).peekTexture();
+ GrSurfaceProxy* proxy = tde.textureSampler(0).proxy();
- fGLDomain.setData(pdman, domain, texture);
+ fGLDomain.setData(pdman, domain, proxy);
if (SkToBool(tde.colorSpaceXform())) {
fColorSpaceHelper.setData(pdman, tde.colorSpaceXform());
}
@@ -372,16 +373,17 @@ GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLS
const GrFragmentProcessor& fp) override {
const GrDeviceSpaceTextureDecalFragmentProcessor& dstdfp =
fp.cast<GrDeviceSpaceTextureDecalFragmentProcessor>();
- GrTexture* texture = dstdfp.textureSampler(0).peekTexture();
+ GrSurfaceProxy* proxy = dstdfp.textureSampler(0).proxy();
+ GrTexture* texture = proxy->priv().peekTexture();
- fGLDomain.setData(pdman, dstdfp.fTextureDomain, texture);
+ fGLDomain.setData(pdman, dstdfp.fTextureDomain, proxy);
float iw = 1.f / texture->width();
float ih = 1.f / texture->height();
float scaleAndTransData[4] = {
iw, ih,
-dstdfp.fDeviceSpaceOffset.fX * iw, -dstdfp.fDeviceSpaceOffset.fY * ih
};
- if (texture->origin() == kBottomLeft_GrSurfaceOrigin) {
+ if (proxy->origin() == kBottomLeft_GrSurfaceOrigin) {
scaleAndTransData[1] = -scaleAndTransData[1];
scaleAndTransData[3] = 1 - scaleAndTransData[3];
}
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index cbc55ecdba..8be1a2bc66 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -115,8 +115,7 @@ public:
* texture domain. The rectangle is automatically adjusted to account for the texture's
* origin.
*/
- void setData(const GrGLSLProgramDataManager& pdman, const GrTextureDomain& textureDomain,
- GrTexture* texure);
+ void setData(const GrGLSLProgramDataManager&, const GrTextureDomain&, GrSurfaceProxy*);
enum {
kDomainKeyBits = 2, // See DomainKey().