aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrSimpleTextureEffect.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-01-26 17:35:06 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-27 14:56:48 +0000
commit85eb4226a4cd8c10a0e3f3ba2f3a60efbb2dd61b (patch)
tree0f740e811d6360b4c5ae059e6a80431e8567ee43 /src/gpu/effects/GrSimpleTextureEffect.h
parentbcda1f07d5e1b8d080e0134a24c5bc1707ef3985 (diff)
Start of rewrite of GrFragmentProcessor optimizations.
This adds a replacement for computeInvariantOutput buts does not use it yet. The replacement allows for three types of optimizations: * known input color -> known output color for GrFP elimination * tracking of whether all color processors modulate their input for the "tweak alpha" optimziation * opaqueness tracking This loses some of the generality of computInvariantOutput. It does not track the known output status of individual color components (other than opaque alpha). It does not track whether GrFragmentProcessors read their input color. It doesn't allow a processor that will receive non-constant output to advertise that it produces a constant output. These could probably be added back in the unlikely case that they prove valuable. Unlike computeInvariantOutput the optimizations are decided at instantiation time and constant colors are expressed as GrColor4f rather than GrColor. Change-Id: I684d3f9050693dde2d28154fa695e049ed8cf61a Reviewed-on: https://skia-review.googlesource.com/7481 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/effects/GrSimpleTextureEffect.h')
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.h54
1 files changed, 44 insertions, 10 deletions
diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h
index bf013e9c83..c44ce44121 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/GrSimpleTextureEffect.h
@@ -13,6 +13,29 @@
class GrInvariantOutput;
+// In a few places below we rely on braced initialization order being defined by the C++ spec (left
+// to right). We use operator-> on a sk_sp and then in a later argument std::move() the sk_sp. GCC
+// 4.9.0 and earlier has a bug where the left to right order evaluation isn't implemented correctly.
+#if defined(__GNUC__) && !defined(__clang__)
+# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+# if (GCC_VERSION > 40900)
+# define GCC_EVAL_ORDER_BUG 0
+# else
+# define GCC_EVAL_ORDER_BUG 1
+# endif
+# undef GCC_VERSION
+#else
+# define GCC_EVAL_ORDER_BUG 0
+#endif
+
+#if GCC_EVAL_ORDER_BUG
+# define PROXY_MOVE(X) (X)
+#else
+# define PROXY_MOVE(X) (std::move(X))
+#endif
+
+#undef GCC_EVAL_ORDER_BUG
+
/**
* The output color of this effect is a modulation of the input color and a sample from a texture.
* It allows explicit specification of the filtering and wrap modes (GrSamplerParams) and accepts
@@ -81,32 +104,41 @@ private:
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
GrSamplerParams::FilterMode filterMode)
- : GrSingleTextureEffect(texture, std::move(colorSpaceXform), matrix, filterMode) {
+ : INHERITED(texture, std::move(colorSpaceXform), matrix, filterMode,
+ ModulationFlags(texture->config())) {
this->initClassID<GrSimpleTextureEffect>();
}
GrSimpleTextureEffect(GrContext* ctx, sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix,
+ sk_sp<GrColorSpaceXform> colorSpaceXform, const SkMatrix& matrix,
GrSamplerParams::FilterMode filterMode)
- : GrSingleTextureEffect(ctx, std::move(proxy), std::move(colorSpaceXform),
- matrix, filterMode) {
+ : INHERITED{ctx,
+ ModulationFlags(proxy->config()),
+ PROXY_MOVE(proxy),
+ std::move(colorSpaceXform),
+ matrix,
+ filterMode} {
this->initClassID<GrSimpleTextureEffect>();
}
GrSimpleTextureEffect(GrTexture* texture,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
+ sk_sp<GrColorSpaceXform>colorSpaceXform,
const SkMatrix& matrix,
const GrSamplerParams& params)
- : GrSingleTextureEffect(texture, std::move(colorSpaceXform), matrix, params) {
+ : INHERITED(texture, std::move(colorSpaceXform), matrix, params,
+ ModulationFlags(texture->config())) {
this->initClassID<GrSimpleTextureEffect>();
}
GrSimpleTextureEffect(GrContext* ctx, sk_sp<GrTextureProxy> proxy,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix,
+ sk_sp<GrColorSpaceXform> colorSpaceXform, const SkMatrix& matrix,
const GrSamplerParams& params)
- : GrSingleTextureEffect(ctx, std::move(proxy), std::move(colorSpaceXform), matrix, params) {
+ : INHERITED{ctx,
+ ModulationFlags(proxy->config()),
+ PROXY_MOVE(proxy),
+ std::move(colorSpaceXform),
+ matrix,
+ params} {
this->initClassID<GrSimpleTextureEffect>();
}
@@ -123,4 +155,6 @@ private:
typedef GrSingleTextureEffect INHERITED;
};
+#undef PROXY_MOVE
+
#endif