| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
| 9 #include "GrDitherEffect.h" | 9 #include "GrDitherEffect.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 static GrFragmentProcessor* Create() { | 23 static GrFragmentProcessor* Create() { |
| 24 GR_CREATE_STATIC_FRAGMENT_PROCESSOR(gDitherEffect, DitherEffect, ()) | 24 GR_CREATE_STATIC_FRAGMENT_PROCESSOR(gDitherEffect, DitherEffect, ()) |
| 25 return SkRef(gDitherEffect); | 25 return SkRef(gDitherEffect); |
| 26 } | 26 } |
| 27 | 27 |
| 28 virtual ~DitherEffect() {}; | 28 virtual ~DitherEffect() {}; |
| 29 static const char* Name() { return "Dither"; } | 29 static const char* Name() { return "Dither"; } |
| 30 | 30 |
| 31 typedef GLDitherEffect GLProcessor; | 31 typedef GLDitherEffect GLProcessor; |
| 32 | 32 |
| 33 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | |
| 34 | |
| 35 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE { | 33 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE { |
| 36 return GrTBackendFragmentProcessorFactory<DitherEffect>::getInstance(); | 34 return GrTBackendFragmentProcessorFactory<DitherEffect>::getInstance(); |
| 37 } | 35 } |
| 38 | 36 |
| 39 private: | 37 private: |
| 40 DitherEffect() { | 38 DitherEffect() { |
| 41 this->setWillReadFragmentPosition(); | 39 this->setWillReadFragmentPosition(); |
| 42 } | 40 } |
| 43 | 41 |
| 44 // All dither effects are equal | 42 // All dither effects are equal |
| 45 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE { return true;
} | 43 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE { return true;
} |
| 46 | 44 |
| 45 virtual void onGetConstantColorComponents(GrColor* color, uint32_t* validFla
gs, |
| 46 bool* isSingleComponent) const SK_
OVERRIDE; |
| 47 |
| 47 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 48 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 48 | 49 |
| 49 typedef GrFragmentProcessor INHERITED; | 50 typedef GrFragmentProcessor INHERITED; |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 void DitherEffect::getConstantColorComponents(GrColor* color, uint32_t* validFla
gs) const { | 53 void DitherEffect::onGetConstantColorComponents(GrColor* color, uint32_t* validF
lags, |
| 54 bool* isSingleComponent) const { |
| 53 *validFlags = 0; | 55 *validFlags = 0; |
| 54 } | 56 } |
| 55 | 57 |
| 56 ////////////////////////////////////////////////////////////////////////////// | 58 ////////////////////////////////////////////////////////////////////////////// |
| 57 | 59 |
| 58 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect); | 60 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect); |
| 59 | 61 |
| 60 GrFragmentProcessor* DitherEffect::TestCreate(SkRandom*, | 62 GrFragmentProcessor* DitherEffect::TestCreate(SkRandom*, |
| 61 GrContext*, | 63 GrContext*, |
| 62 const GrDrawTargetCaps&, | 64 const GrDrawTargetCaps&, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 fsBuilder->codeAppendf("\t\tfloat r = " | 109 fsBuilder->codeAppendf("\t\tfloat r = " |
| 108 "fract(sin(dot(%s.xy ,vec2(12.9898,78.233))) * 43758.
5453);\n", | 110 "fract(sin(dot(%s.xy ,vec2(12.9898,78.233))) * 43758.
5453);\n", |
| 109 fsBuilder->fragmentPosition()); | 111 fsBuilder->fragmentPosition()); |
| 110 fsBuilder->codeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n", | 112 fsBuilder->codeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n", |
| 111 outputColor, GrGLSLExpr4(inputColor).c_str()); | 113 outputColor, GrGLSLExpr4(inputColor).c_str()); |
| 112 } | 114 } |
| 113 | 115 |
| 114 ////////////////////////////////////////////////////////////////////////////// | 116 ////////////////////////////////////////////////////////////////////////////// |
| 115 | 117 |
| 116 GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); } | 118 GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); } |
| OLD | NEW |