Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Unified Diff: src/gpu/effects/GrCircleEdgeEffect.cpp

Issue 13344002: Move edge GrEffects to locally defined classes (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: rebase to head revision Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/effects/GrCircleEdgeEffect.h ('k') | src/gpu/effects/GrEdgeEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrCircleEdgeEffect.cpp
===================================================================
--- src/gpu/effects/GrCircleEdgeEffect.cpp (revision 8491)
+++ src/gpu/effects/GrCircleEdgeEffect.cpp (working copy)
@@ -1,81 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrCircleEdgeEffect.h"
-#include "gl/GrGLEffect.h"
-#include "gl/GrGLSL.h"
-#include "GrTBackendEffectFactory.h"
-
-class GrGLCircleEdgeEffect : public GrGLEffect {
-public:
- GrGLCircleEdgeEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
- : INHERITED (factory) {}
-
- virtual void emitCode(GrGLShaderBuilder* builder,
- const GrDrawEffect& drawEffect,
- EffectKey key,
- const char* outputColor,
- const char* inputColor,
- const TextureSamplerArray& samplers) SK_OVERRIDE {
- const GrCircleEdgeEffect& circleEffect = drawEffect.castEffect<GrCircleEdgeEffect>();
- const char *vsName, *fsName;
- builder->addVarying(kVec4f_GrSLType, "CircleEdge", &vsName, &fsName);
-
- const SkString* attrName =
- builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]);
- builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str());
-
- builder->fsCodeAppendf("\tfloat d = distance(%s.xy, %s.xy);\n",
- builder->fragmentPosition(), fsName);
- builder->fsCodeAppendf("\tfloat edgeAlpha = clamp(%s.z - d, 0.0, 1.0);\n", fsName);
- if (circleEffect.isStroked()) {
- builder->fsCodeAppendf("\tfloat innerAlpha = clamp(d - %s.w, 0.0, 1.0);\n", fsName);
- builder->fsCodeAppend("\tedgeAlpha *= innerAlpha;\n");
- }
- SkString modulate;
- GrGLSLModulate4f(&modulate, inputColor, "edgeAlpha");
- builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str());
- }
-
- static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
- const GrCircleEdgeEffect& circleEffect = drawEffect.castEffect<GrCircleEdgeEffect>();
-
- return circleEffect.isStroked() ? 0x1 : 0x0;
- }
-
- virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {
- }
-
-private:
- typedef GrGLEffect INHERITED;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-GrCircleEdgeEffect::GrCircleEdgeEffect(bool stroke) : GrEffect() {
- this->addVertexAttrib(kVec4f_GrSLType);
- fStroke = stroke;
-}
-
-void GrCircleEdgeEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
- *validFlags = 0;
-}
-
-const GrBackendEffectFactory& GrCircleEdgeEffect::getFactory() const {
- return GrTBackendEffectFactory<GrCircleEdgeEffect>::getInstance();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-GR_DEFINE_EFFECT_TEST(GrCircleEdgeEffect);
-
-GrEffectRef* GrCircleEdgeEffect::TestCreate(SkMWCRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
- return GrCircleEdgeEffect::Create(random->nextBool());
-}
« no previous file with comments | « src/gpu/effects/GrCircleEdgeEffect.h ('k') | src/gpu/effects/GrEdgeEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698