diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-21 17:52:29 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-21 17:52:29 +0000 |
commit | e5280893f8f9f6b6149572a4c8fe513f9c2b3888 (patch) | |
tree | 7b455fc2cde11c8018c83cc0545bca2c33b87bea /src/gpu/effects | |
parent | 5b92499f8ff96760ba54fdd76f48a8af2088b3f5 (diff) |
Hide GrRRectEffect class from header
R=robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/175233002
git-svn-id: http://skia.googlecode.com/svn/trunk@13535 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/effects')
-rw-r--r-- | src/gpu/effects/GrRRectEffect.cpp | 150 | ||||
-rw-r--r-- | src/gpu/effects/GrRRectEffect.h | 43 |
2 files changed, 101 insertions, 92 deletions
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp index 3923a6f36b..3b7cecaff0 100644 --- a/src/gpu/effects/GrRRectEffect.cpp +++ b/src/gpu/effects/GrRRectEffect.cpp @@ -11,16 +11,87 @@ #include "gl/GrGLSL.h" #include "GrTBackendEffectFactory.h" -#include "SkPath.h" +#include "SkRRect.h" -// This effect only supports circular corner rrects where all corners have the same radius -// which must be <= kRadiusMin. -static const SkScalar kRadiusMin = 0.5f; +class GLRRectEffect; + +class RRectEffect : public GrEffect { +public: + // This effect only supports circular corner rrects where all corners have the same radius + // which must be <= kRadiusMin. + static const SkScalar kRadiusMin; + + static GrEffectRef* Create(const SkRRect&); + + virtual ~RRectEffect() {}; + static const char* Name() { return "RRect"; } + + const SkRRect& getRRect() const { return fRRect; } + + typedef GLRRectEffect GLEffect; + + virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; + + virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; + +private: + RRectEffect(const SkRRect&); + + virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; + + SkRRect fRRect; + + GR_DECLARE_EFFECT_TEST; + + typedef GrEffect INHERITED; +}; + +const SkScalar RRectEffect::kRadiusMin = 0.5f; + +GrEffectRef* RRectEffect::Create(const SkRRect& rrect) { + return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(RRectEffect, (rrect)))); +} + +void RRectEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { + *validFlags = 0; +} + +const GrBackendEffectFactory& RRectEffect::getFactory() const { + return GrTBackendEffectFactory<RRectEffect>::getInstance(); +} + +RRectEffect::RRectEffect(const SkRRect& rrect) + : fRRect(rrect) { + this->setWillReadFragmentPosition(); +} + +bool RRectEffect::onIsEqual(const GrEffect& other) const { + const RRectEffect& rre = CastEffect<RRectEffect>(other); + return fRRect == rre.fRRect; +} + +////////////////////////////////////////////////////////////////////////////// + +GR_DEFINE_EFFECT_TEST(RRectEffect); + +GrEffectRef* RRectEffect::TestCreate(SkRandom* random, + GrContext*, + const GrDrawTargetCaps& caps, + GrTexture*[]) { + SkScalar w = random->nextRangeScalar(20.f, 1000.f); + SkScalar h = random->nextRangeScalar(20.f, 1000.f); + SkScalar r = random->nextRangeF(kRadiusMin, 9.f); + SkRRect rrect; + rrect.setRectXY(SkRect::MakeWH(w, h), r, r); + + return GrRRectEffect::Create(rrect); +} ////////////////////////////////////////////////////////////////////////////// -class GrGLRRectEffect : public GrGLEffect { + +class GLRRectEffect : public GrGLEffect { public: - GrGLRRectEffect(const GrBackendEffectFactory&, const GrDrawEffect&); + GLRRectEffect(const GrBackendEffectFactory&, const GrDrawEffect&); virtual void emitCode(GrGLShaderBuilder* builder, const GrDrawEffect& drawEffect, @@ -41,19 +112,19 @@ private: typedef GrGLEffect INHERITED; }; -GrGLRRectEffect::GrGLRRectEffect(const GrBackendEffectFactory& factory, - const GrDrawEffect& drawEffect) +GLRRectEffect::GLRRectEffect(const GrBackendEffectFactory& factory, + const GrDrawEffect& drawEffect) : INHERITED (factory) { fPrevRRect.setEmpty(); } -void GrGLRRectEffect::emitCode(GrGLShaderBuilder* builder, - const GrDrawEffect& drawEffect, - EffectKey key, - const char* outputColor, - const char* inputColor, - const TransformedCoordsArray&, - const TextureSamplerArray& samplers) { +void GLRRectEffect::emitCode(GrGLShaderBuilder* builder, + const GrDrawEffect& drawEffect, + EffectKey key, + const char* outputColor, + const char* inputColor, + const TransformedCoordsArray&, + const TextureSamplerArray& samplers) { const char *rectName; const char *radiusPlusHalfName; // The inner rect is the rrect bounds inset by the radius. Its top, left, right, and bottom @@ -88,14 +159,14 @@ void GrGLRRectEffect::emitCode(GrGLShaderBuilder* builder, (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str()); } -void GrGLRRectEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) { - const GrRRectEffect& rre = drawEffect.castEffect<GrRRectEffect>(); +void GLRRectEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) { + const RRectEffect& rre = drawEffect.castEffect<RRectEffect>(); const SkRRect& rrect = rre.getRRect(); if (rrect != fPrevRRect) { SkASSERT(rrect.isSimpleCircular()); SkRect rect = rrect.getBounds(); SkScalar radius = rrect.getSimpleRadii().fX; - SkASSERT(radius >= kRadiusMin); + SkASSERT(radius >= RRectEffect::kRadiusMin); rect.inset(radius, radius); uman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); uman.set1f(fRadiusPlusHalfUniform, radius + 0.5f); @@ -109,47 +180,10 @@ GrEffectRef* GrRRectEffect::Create(const SkRRect& rrect) { if (!rrect.isSimpleCircular()) { return NULL; } - if (rrect.getSimpleRadii().fX < kRadiusMin) { + + if (rrect.getSimpleRadii().fX < RRectEffect::kRadiusMin) { return NULL; } - return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrRRectEffect, (rrect)))); -} - -GrRRectEffect::~GrRRectEffect() {} - -void GrRRectEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { - *validFlags = 0; -} - -const GrBackendEffectFactory& GrRRectEffect::getFactory() const { - return GrTBackendEffectFactory<GrRRectEffect>::getInstance(); -} -GrRRectEffect::GrRRectEffect(const SkRRect& rrect) - : fRRect(rrect) { - SkASSERT(rrect.isSimpleCircular()); - SkASSERT(rrect.getSimpleRadii().fX >= kRadiusMin); - this->setWillReadFragmentPosition(); -} - -bool GrRRectEffect::onIsEqual(const GrEffect& other) const { - const GrRRectEffect& rre = CastEffect<GrRRectEffect>(other); - return fRRect == rre.fRRect; -} - -////////////////////////////////////////////////////////////////////////////// - -GR_DEFINE_EFFECT_TEST(GrRRectEffect); - -GrEffectRef* GrRRectEffect::TestCreate(SkRandom* random, - GrContext*, - const GrDrawTargetCaps& caps, - GrTexture*[]) { - SkScalar w = random->nextRangeScalar(20.f, 1000.f); - SkScalar h = random->nextRangeScalar(20.f, 1000.f); - SkScalar r = random->nextRangeF(kRadiusMin, 9.f); - SkRRect rrect; - rrect.setRectXY(SkRect::MakeWH(w, h), r, r); - - return GrRRectEffect::Create(rrect); + return RRectEffect::Create(rrect); } diff --git a/src/gpu/effects/GrRRectEffect.h b/src/gpu/effects/GrRRectEffect.h index 3d899e2a09..45dac0154f 100644 --- a/src/gpu/effects/GrRRectEffect.h +++ b/src/gpu/effects/GrRRectEffect.h @@ -8,42 +8,17 @@ #ifndef GrRRectEffect_DEFINED #define GrRRectEffect_DEFINED -#include "GrEffect.h" +#include "GrTypes.h" -#include "SkRRect.h" +class GrEffectRef; +class SkRRect; -class GrGLRRectEffect; - -/** - * An effect that performs anti-aliasing for an SkRRect. It doesn't support all varieties of SkRRect - * so the caller must check for a NULL return from the Create() method. - */ -class GrRRectEffect : public GrEffect { -public: - static GrEffectRef* Create(const SkRRect&); - - virtual ~GrRRectEffect(); - static const char* Name() { return "RRect"; } - - const SkRRect& getRRect() const { return fRRect; } - - typedef GrGLRRectEffect GLEffect; - - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; - - virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; - -private: - GrRRectEffect(const SkRRect&); - - virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; - - SkRRect fRRect; - - GR_DECLARE_EFFECT_TEST; - - typedef GrEffect INHERITED; +namespace GrRRectEffect { + /** + * Creates an effect that performs anti-aliased clipping against a SkRRect. It doesn't support + * all varieties of SkRRect so the caller must check for a NULL return. + */ + GrEffectRef* Create(const SkRRect&); }; - #endif |