| OLD | NEW |
| 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 #include "SkXfermode.h" | 9 #include "SkXfermode.h" |
| 10 #include "SkXfermode_opts_SSE2.h" | 10 #include "SkXfermode_opts_SSE2.h" |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 } | 803 } |
| 804 | 804 |
| 805 ////////////////////////////////////////////////////////////////////////////// | 805 ////////////////////////////////////////////////////////////////////////////// |
| 806 | 806 |
| 807 #if SK_SUPPORT_GPU | 807 #if SK_SUPPORT_GPU |
| 808 | 808 |
| 809 #include "GrFragmentProcessor.h" | 809 #include "GrFragmentProcessor.h" |
| 810 #include "GrCoordTransform.h" | 810 #include "GrCoordTransform.h" |
| 811 #include "GrInvariantOutput.h" | 811 #include "GrInvariantOutput.h" |
| 812 #include "GrProcessorUnitTest.h" | 812 #include "GrProcessorUnitTest.h" |
| 813 #include "GrTBackendProcessorFactory.h" | |
| 814 #include "gl/GrGLProcessor.h" | 813 #include "gl/GrGLProcessor.h" |
| 815 #include "gl/builders/GrGLProgramBuilder.h" | 814 #include "gl/builders/GrGLProgramBuilder.h" |
| 816 | 815 |
| 817 /** | 816 /** |
| 818 * GrProcessor that implements the all the separable xfer modes that cannot be e
xpressed as Coeffs. | 817 * GrProcessor that implements the all the separable xfer modes that cannot be e
xpressed as Coeffs. |
| 819 */ | 818 */ |
| 820 class XferEffect : public GrFragmentProcessor { | 819 class XferEffect : public GrFragmentProcessor { |
| 821 public: | 820 public: |
| 822 static bool IsSupportedMode(SkXfermode::Mode mode) { | 821 static bool IsSupportedMode(SkXfermode::Mode mode) { |
| 823 return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMod
e; | 822 return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMod
e; |
| 824 } | 823 } |
| 825 | 824 |
| 826 static GrFragmentProcessor* Create(SkXfermode::Mode mode, GrTexture* backgro
und) { | 825 static GrFragmentProcessor* Create(SkXfermode::Mode mode, GrTexture* backgro
und) { |
| 827 if (!IsSupportedMode(mode)) { | 826 if (!IsSupportedMode(mode)) { |
| 828 return NULL; | 827 return NULL; |
| 829 } else { | 828 } else { |
| 830 return SkNEW_ARGS(XferEffect, (mode, background)); | 829 return SkNEW_ARGS(XferEffect, (mode, background)); |
| 831 } | 830 } |
| 832 } | 831 } |
| 833 | 832 |
| 834 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE { | 833 virtual void getGLProcessorKey(const GrGLCaps& caps, |
| 835 return GrTBackendFragmentProcessorFactory<XferEffect>::getInstance(); | 834 GrProcessorKeyBuilder* b) const SK_OVERRIDE { |
| 835 GLProcessor::GenKey(*this, caps, b); |
| 836 } | 836 } |
| 837 | 837 |
| 838 static const char* Name() { return "XferEffect"; } | 838 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE { |
| 839 return SkNEW_ARGS(GLProcessor, (*this)); |
| 840 } |
| 841 |
| 842 virtual uint32_t classID() const { |
| 843 static uint32_t id = GenClassID(); |
| 844 return id; |
| 845 } |
| 846 |
| 847 virtual const char* name() const SK_OVERRIDE { return "XferEffect"; } |
| 839 | 848 |
| 840 SkXfermode::Mode mode() const { return fMode; } | 849 SkXfermode::Mode mode() const { return fMode; } |
| 841 const GrTextureAccess& backgroundAccess() const { return fBackgroundAccess;
} | 850 const GrTextureAccess& backgroundAccess() const { return fBackgroundAccess;
} |
| 842 | 851 |
| 843 class GLProcessor : public GrGLFragmentProcessor { | 852 class GLProcessor : public GrGLFragmentProcessor { |
| 844 public: | 853 public: |
| 845 GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&
) | 854 GLProcessor(const GrFragmentProcessor&) {} |
| 846 : INHERITED(factory) { | 855 |
| 847 } | |
| 848 virtual void emitCode(GrGLFPBuilder* builder, | 856 virtual void emitCode(GrGLFPBuilder* builder, |
| 849 const GrFragmentProcessor& fp, | 857 const GrFragmentProcessor& fp, |
| 850 const char* outputColor, | 858 const char* outputColor, |
| 851 const char* inputColor, | 859 const char* inputColor, |
| 852 const TransformedCoordsArray& coords, | 860 const TransformedCoordsArray& coords, |
| 853 const TextureSamplerArray& samplers) SK_OVERRIDE { | 861 const TextureSamplerArray& samplers) SK_OVERRIDE { |
| 854 SkXfermode::Mode mode = fp.cast<XferEffect>().mode(); | 862 SkXfermode::Mode mode = fp.cast<XferEffect>().mode(); |
| 855 const GrTexture* backgroundTex = | 863 const GrTexture* backgroundTex = |
| 856 fp.cast<XferEffect>().backgroundAccess().getTexture(); | 864 fp.cast<XferEffect>().backgroundAccess().getTexture(); |
| 857 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder
(); | 865 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder
(); |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1955 } else { | 1963 } else { |
| 1956 proc16 = rec.fProc16_General; | 1964 proc16 = rec.fProc16_General; |
| 1957 } | 1965 } |
| 1958 } | 1966 } |
| 1959 return proc16; | 1967 return proc16; |
| 1960 } | 1968 } |
| 1961 | 1969 |
| 1962 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1970 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
| 1963 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1971 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
| 1964 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1972 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |