aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-07-21 08:44:46 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-21 14:05:33 +0000
commit467022b1861033d968195687da15270c208279ff (patch)
tree34de5b201fb4dc64090c292cdc7bf924d073cae6 /src/effects
parent594838a44dd1253e71c1b0330018d2b5180ccc32 (diff)
Reduce dependence on GrSurface's origin field
Unfortunately, GrGPU and its ilk are still using the GrSurface's origin a lot. I will clean that up in a second CL. Change-Id: Iba729440ce8ea8d24bb7f4e5de55ed576a0f176d Reviewed-on: https://skia-review.googlesource.com/24700 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/GrCircleBlurFragmentProcessor.cpp5
-rw-r--r--src/effects/SkBlurMaskFilter.cpp22
-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
6 files changed, 32 insertions, 21 deletions
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index 135b00e4d9..a30bc4be35 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -174,10 +174,12 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrResourceProvider* resource
builder[0] = sigmaToCircleRRatioFixed;
builder.finish();
- sk_sp<GrTextureProxy> blurProfile = resourceProvider->findProxyByUniqueKey(key);
+ sk_sp<GrTextureProxy> blurProfile = resourceProvider->findProxyByUniqueKey(
+ key, kTopLeft_GrSurfaceOrigin);
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 +199,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..28b5870560 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -942,23 +942,24 @@ 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);
builder[0] = profileSize;
builder.finish();
- sk_sp<GrTextureProxy> blurProfile(resourceProvider->findProxyByUniqueKey(key));
+ sk_sp<GrTextureProxy> blurProfile(resourceProvider->findProxyByUniqueKey(
+ key, kTopLeft_GrSurfaceOrigin));
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 +968,7 @@ sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(
return nullptr;
}
+ SkASSERT(blurProfile->origin() == kTopLeft_GrSurfaceOrigin);
resourceProvider->assignUniqueKeyToProxy(key, blurProfile.get());
}
@@ -1117,7 +1119,8 @@ static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrContext* context,
}
builder.finish();
- sk_sp<GrTextureProxy> mask(context->resourceProvider()->findProxyByUniqueKey(key));
+ sk_sp<GrTextureProxy> mask(context->resourceProvider()->findProxyByUniqueKey(
+ key, kBottomLeft_GrSurfaceOrigin));
if (!mask) {
// TODO: this could be approx but the texture coords will need to be updated
sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContextWithFallback(
@@ -1154,6 +1157,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);