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

Side by Side Diff: src/gpu/effects/GrDitherEffect.cpp

Issue 1434313002: Make all GrFragmentProcessors GL independent. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 | « src/gpu/effects/GrDistanceFieldGeoProc.cpp ('k') | src/gpu/effects/GrMatrixConvolutionEffect.h » ('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 * 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 "GrDitherEffect.h" 8 #include "GrDitherEffect.h"
9 #include "GrFragmentProcessor.h" 9 #include "GrFragmentProcessor.h"
10 #include "GrInvariantOutput.h" 10 #include "GrInvariantOutput.h"
11 #include "SkRect.h" 11 #include "SkRect.h"
12 #include "gl/GrGLFragmentProcessor.h" 12 #include "glsl/GrGLSLFragmentProcessor.h"
13 #include "glsl/GrGLSLFragmentShaderBuilder.h" 13 #include "glsl/GrGLSLFragmentShaderBuilder.h"
14 #include "glsl/GrGLSLProgramBuilder.h" 14 #include "glsl/GrGLSLProgramBuilder.h"
15 15
16 ////////////////////////////////////////////////////////////////////////////// 16 //////////////////////////////////////////////////////////////////////////////
17 17
18 class DitherEffect : public GrFragmentProcessor { 18 class DitherEffect : public GrFragmentProcessor {
19 public: 19 public:
20 static GrFragmentProcessor* Create() { 20 static GrFragmentProcessor* Create() {
21 return new DitherEffect; 21 return new DitherEffect;
22 } 22 }
23 23
24 virtual ~DitherEffect() {}; 24 virtual ~DitherEffect() {};
25 25
26 const char* name() const override { return "Dither"; } 26 const char* name() const override { return "Dither"; }
27 27
28 private: 28 private:
29 DitherEffect() { 29 DitherEffect() {
30 this->initClassID<DitherEffect>(); 30 this->initClassID<DitherEffect>();
31 this->setWillReadFragmentPosition(); 31 this->setWillReadFragmentPosition();
32 } 32 }
33 33
34 GrGLFragmentProcessor* onCreateGLInstance() const override; 34 GrGLSLFragmentProcessor* onCreateGLInstance() const override;
35 35
36 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride; 36 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
37 37
38 // All dither effects are equal 38 // All dither effects are equal
39 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } 39 bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
40 40
41 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 41 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
42 42
43 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 43 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
44 44
45 typedef GrFragmentProcessor INHERITED; 45 typedef GrFragmentProcessor INHERITED;
46 }; 46 };
47 47
48 void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 48 void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
49 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); 49 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
50 } 50 }
51 51
52 ////////////////////////////////////////////////////////////////////////////// 52 //////////////////////////////////////////////////////////////////////////////
53 53
54 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect); 54 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect);
55 55
56 const GrFragmentProcessor* DitherEffect::TestCreate(GrProcessorTestData*) { 56 const GrFragmentProcessor* DitherEffect::TestCreate(GrProcessorTestData*) {
57 return DitherEffect::Create(); 57 return DitherEffect::Create();
58 } 58 }
59 59
60 ////////////////////////////////////////////////////////////////////////////// 60 //////////////////////////////////////////////////////////////////////////////
61 61
62 class GLDitherEffect : public GrGLFragmentProcessor { 62 class GLDitherEffect : public GrGLSLFragmentProcessor {
63 public: 63 public:
64 GLDitherEffect(const GrProcessor&); 64 GLDitherEffect(const GrProcessor&);
65 65
66 virtual void emitCode(EmitArgs& args) override; 66 virtual void emitCode(EmitArgs& args) override;
67 67
68 private: 68 private:
69 typedef GrGLFragmentProcessor INHERITED; 69 typedef GrGLSLFragmentProcessor INHERITED;
70 }; 70 };
71 71
72 GLDitherEffect::GLDitherEffect(const GrProcessor&) { 72 GLDitherEffect::GLDitherEffect(const GrProcessor&) {
73 } 73 }
74 74
75 void GLDitherEffect::emitCode(EmitArgs& args) { 75 void GLDitherEffect::emitCode(EmitArgs& args) {
76 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder() ; 76 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder() ;
77 // Generate a random number based on the fragment position. For this 77 // Generate a random number based on the fragment position. For this
78 // random number generator, we use the "GLSL rand" function 78 // random number generator, we use the "GLSL rand" function
79 // that seems to be floating around on the internet. It works under 79 // that seems to be floating around on the internet. It works under
(...skipping 10 matching lines...) Expand all
90 args.fOutputColor, GrGLSLExpr4(args.fInputColor).c_st r()); 90 args.fOutputColor, GrGLSLExpr4(args.fInputColor).c_st r());
91 } 91 }
92 92
93 ////////////////////////////////////////////////////////////////////////////// 93 //////////////////////////////////////////////////////////////////////////////
94 94
95 void DitherEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, 95 void DitherEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
96 GrProcessorKeyBuilder* b) const { 96 GrProcessorKeyBuilder* b) const {
97 GLDitherEffect::GenKey(*this, caps, b); 97 GLDitherEffect::GenKey(*this, caps, b);
98 } 98 }
99 99
100 GrGLFragmentProcessor* DitherEffect::onCreateGLInstance() const { 100 GrGLSLFragmentProcessor* DitherEffect::onCreateGLInstance() const {
101 return new GLDitherEffect(*this); 101 return new GLDitherEffect(*this);
102 } 102 }
103 103
104 GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); } 104 GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDistanceFieldGeoProc.cpp ('k') | src/gpu/effects/GrMatrixConvolutionEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698