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

Side by Side Diff: src/core/SkXfermode.cpp

Issue 571163002: removing GrDrawEffect (Closed) Base URL: https://skia.googlesource.com/skia.git@gp3
Patch Set: rebase after revert Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « include/gpu/GrTBackendEffectFactory.h ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkXfermode.h" 10 #include "SkXfermode.h"
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 return GrTBackendEffectFactory<XferEffect>::getInstance(); 811 return GrTBackendEffectFactory<XferEffect>::getInstance();
812 } 812 }
813 813
814 static const char* Name() { return "XferEffect"; } 814 static const char* Name() { return "XferEffect"; }
815 815
816 SkXfermode::Mode mode() const { return fMode; } 816 SkXfermode::Mode mode() const { return fMode; }
817 const GrTextureAccess& backgroundAccess() const { return fBackgroundAccess; } 817 const GrTextureAccess& backgroundAccess() const { return fBackgroundAccess; }
818 818
819 class GLEffect : public GrGLEffect { 819 class GLEffect : public GrGLEffect {
820 public: 820 public:
821 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) 821 GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
822 : GrGLEffect(factory) { 822 : GrGLEffect(factory) {
823 } 823 }
824 virtual void emitCode(GrGLProgramBuilder* builder, 824 virtual void emitCode(GrGLProgramBuilder* builder,
825 const GrDrawEffect& drawEffect, 825 const GrEffect& effect,
826 const GrEffectKey& key, 826 const GrEffectKey& key,
827 const char* outputColor, 827 const char* outputColor,
828 const char* inputColor, 828 const char* inputColor,
829 const TransformedCoordsArray& coords, 829 const TransformedCoordsArray& coords,
830 const TextureSamplerArray& samplers) SK_OVERRIDE { 830 const TextureSamplerArray& samplers) SK_OVERRIDE {
831 SkXfermode::Mode mode = drawEffect.castEffect<XferEffect>().mode(); 831 SkXfermode::Mode mode = effect.cast<XferEffect>().mode();
832 const GrTexture* backgroundTex = drawEffect.castEffect<XferEffect>() .backgroundAccess().getTexture(); 832 const GrTexture* backgroundTex =
833 effect.cast<XferEffect>().backgroundAccess().getTexture();
833 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui lder(); 834 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui lder();
834 const char* dstColor; 835 const char* dstColor;
835 if (backgroundTex) { 836 if (backgroundTex) {
836 dstColor = "bgColor"; 837 dstColor = "bgColor";
837 fsBuilder->codeAppendf("\t\tvec4 %s = ", dstColor); 838 fsBuilder->codeAppendf("\t\tvec4 %s = ", dstColor);
838 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), c oords[0].type()); 839 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), c oords[0].type());
839 fsBuilder->codeAppendf(";\n"); 840 fsBuilder->codeAppendf(";\n");
840 } else { 841 } else {
841 dstColor = fsBuilder->dstColor(); 842 dstColor = fsBuilder->dstColor();
842 } 843 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 fsBuilder->codeAppendf("\t\t%s.rgb += (1.0 - %s.a) * %s.rgb + (1.0 - %s.a) * %s.rgb;\n", 964 fsBuilder->codeAppendf("\t\t%s.rgb += (1.0 - %s.a) * %s.rgb + (1.0 - %s.a) * %s.rgb;\n",
964 outputColor, inputColor, dstColor, ds tColor, inputColor); 965 outputColor, inputColor, dstColor, ds tColor, inputColor);
965 break; 966 break;
966 } 967 }
967 default: 968 default:
968 SkFAIL("Unknown XferEffect mode."); 969 SkFAIL("Unknown XferEffect mode.");
969 break; 970 break;
970 } 971 }
971 } 972 }
972 973
973 static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps &, 974 static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
974 GrEffectKeyBuilder* b) { 975 GrEffectKeyBuilder* b) {
975 // The background may come from the dst or from a texture. 976 // The background may come from the dst or from a texture.
976 uint32_t key = drawEffect.effect()->numTextures(); 977 uint32_t key = effect.numTextures();
977 SkASSERT(key <= 1); 978 SkASSERT(key <= 1);
978 key |= drawEffect.castEffect<XferEffect>().mode() << 1; 979 key |= effect.cast<XferEffect>().mode() << 1;
979 b->add32(key); 980 b->add32(key);
980 } 981 }
981 982
982 private: 983 private:
983 static void HardLight(GrGLFragmentShaderBuilder* fsBuilder, 984 static void HardLight(GrGLFragmentShaderBuilder* fsBuilder,
984 const char* final, 985 const char* final,
985 const char* src, 986 const char* src,
986 const char* dst) { 987 const char* dst) {
987 static const char kComponents[] = {'r', 'g', 'b'}; 988 static const char kComponents[] = {'r', 'g', 'b'};
988 for (size_t i = 0; i < SK_ARRAY_COUNT(kComponents); ++i) { 989 for (size_t i = 0; i < SK_ARRAY_COUNT(kComponents); ++i) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 if (background) { 1208 if (background) {
1208 fBackgroundTransform.reset(kLocal_GrCoordSet, background); 1209 fBackgroundTransform.reset(kLocal_GrCoordSet, background);
1209 this->addCoordTransform(&fBackgroundTransform); 1210 this->addCoordTransform(&fBackgroundTransform);
1210 fBackgroundAccess.reset(background); 1211 fBackgroundAccess.reset(background);
1211 this->addTextureAccess(&fBackgroundAccess); 1212 this->addTextureAccess(&fBackgroundAccess);
1212 } else { 1213 } else {
1213 this->setWillReadDstColor(); 1214 this->setWillReadDstColor();
1214 } 1215 }
1215 } 1216 }
1216 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE { 1217 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
1217 const XferEffect& s = CastEffect<XferEffect>(other); 1218 const XferEffect& s = other.cast<XferEffect>();
1218 return fMode == s.fMode && 1219 return fMode == s.fMode &&
1219 fBackgroundAccess.getTexture() == s.fBackgroundAccess.getTexture( ); 1220 fBackgroundAccess.getTexture() == s.fBackgroundAccess.getTexture( );
1220 } 1221 }
1221 1222
1222 SkXfermode::Mode fMode; 1223 SkXfermode::Mode fMode;
1223 GrCoordTransform fBackgroundTransform; 1224 GrCoordTransform fBackgroundTransform;
1224 GrTextureAccess fBackgroundAccess; 1225 GrTextureAccess fBackgroundAccess;
1225 1226
1226 typedef GrEffect INHERITED; 1227 typedef GrEffect INHERITED;
1227 }; 1228 };
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 } else { 1957 } else {
1957 proc16 = rec.fProc16_General; 1958 proc16 = rec.fProc16_General;
1958 } 1959 }
1959 } 1960 }
1960 return proc16; 1961 return proc16;
1961 } 1962 }
1962 1963
1963 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1964 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1964 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1965 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1965 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1966 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « include/gpu/GrTBackendEffectFactory.h ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698