OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
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 // This is a GPU-backend specific test. It relies on static intializers to work | 9 // This is a GPU-backend specific test. It relies on static intializers to work |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "SkChecksum.h" | 24 #include "SkChecksum.h" |
25 #include "SkRandom.h" | 25 #include "SkRandom.h" |
26 #include "Test.h" | 26 #include "Test.h" |
27 | 27 |
28 #include "batches/GrDrawBatch.h" | 28 #include "batches/GrDrawBatch.h" |
29 | 29 |
30 #include "effects/GrConfigConversionEffect.h" | 30 #include "effects/GrConfigConversionEffect.h" |
31 #include "effects/GrPorterDuffXferProcessor.h" | 31 #include "effects/GrPorterDuffXferProcessor.h" |
32 #include "effects/GrXfermodeFragmentProcessor.h" | 32 #include "effects/GrXfermodeFragmentProcessor.h" |
33 | 33 |
34 #include "gl/GrGLFragmentProcessor.h" | |
35 #include "gl/GrGLGpu.h" | 34 #include "gl/GrGLGpu.h" |
| 35 #include "glsl/GrGLSLFragmentProcessor.h" |
36 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 36 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
37 #include "glsl/GrGLSLProgramBuilder.h" | 37 #include "glsl/GrGLSLProgramBuilder.h" |
38 | 38 |
39 /* | 39 /* |
40 * A dummy processor which just tries to insert a massive key and verify that it
can retrieve the | 40 * A dummy processor which just tries to insert a massive key and verify that it
can retrieve the |
41 * whole thing correctly | 41 * whole thing correctly |
42 */ | 42 */ |
43 static const uint32_t kMaxKeySize = 1024; | 43 static const uint32_t kMaxKeySize = 1024; |
44 | 44 |
45 class GLBigKeyProcessor : public GrGLFragmentProcessor { | 45 class GLBigKeyProcessor : public GrGLSLFragmentProcessor { |
46 public: | 46 public: |
47 GLBigKeyProcessor(const GrProcessor&) {} | 47 GLBigKeyProcessor(const GrProcessor&) {} |
48 | 48 |
49 virtual void emitCode(EmitArgs& args) override { | 49 virtual void emitCode(EmitArgs& args) override { |
50 // pass through | 50 // pass through |
51 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuild
er(); | 51 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuild
er(); |
52 if (args.fInputColor) { | 52 if (args.fInputColor) { |
53 fsBuilder->codeAppendf("%s = %s;\n", args.fOutputColor, args.fInputC
olor); | 53 fsBuilder->codeAppendf("%s = %s;\n", args.fOutputColor, args.fInputC
olor); |
54 } else { | 54 } else { |
55 fsBuilder->codeAppendf("%s = vec4(1.0);\n", args.fOutputColor); | 55 fsBuilder->codeAppendf("%s = vec4(1.0);\n", args.fOutputColor); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProces
sorKeyBuilder* b) { | 59 static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProces
sorKeyBuilder* b) { |
60 for (uint32_t i = 0; i < kMaxKeySize; i++) { | 60 for (uint32_t i = 0; i < kMaxKeySize; i++) { |
61 b->add32(i); | 61 b->add32(i); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 private: | 65 private: |
66 typedef GrGLFragmentProcessor INHERITED; | 66 typedef GrGLSLFragmentProcessor INHERITED; |
67 }; | 67 }; |
68 | 68 |
69 class BigKeyProcessor : public GrFragmentProcessor { | 69 class BigKeyProcessor : public GrFragmentProcessor { |
70 public: | 70 public: |
71 static GrFragmentProcessor* Create() { | 71 static GrFragmentProcessor* Create() { |
72 return new BigKeyProcessor; | 72 return new BigKeyProcessor; |
73 } | 73 } |
74 | 74 |
75 const char* name() const override { return "Big Ole Key"; } | 75 const char* name() const override { return "Big Ole Key"; } |
76 | 76 |
77 GrGLFragmentProcessor* onCreateGLInstance() const override { | 77 GrGLSLFragmentProcessor* onCreateGLInstance() const override { |
78 return new GLBigKeyProcessor(*this); | 78 return new GLBigKeyProcessor(*this); |
79 } | 79 } |
80 | 80 |
81 private: | 81 private: |
82 BigKeyProcessor() { | 82 BigKeyProcessor() { |
83 this->initClassID<BigKeyProcessor>(); | 83 this->initClassID<BigKeyProcessor>(); |
84 } | 84 } |
85 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 85 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
86 GrProcessorKeyBuilder* b) const override { | 86 GrProcessorKeyBuilder* b) const override { |
87 GLBigKeyProcessor::GenKey(*this, caps, b); | 87 GLBigKeyProcessor::GenKey(*this, caps, b); |
(...skipping 15 matching lines...) Expand all Loading... |
103 ////////////////////////////////////////////////////////////////////////////// | 103 ////////////////////////////////////////////////////////////////////////////// |
104 | 104 |
105 class BlockInputFragmentProcessor : public GrFragmentProcessor { | 105 class BlockInputFragmentProcessor : public GrFragmentProcessor { |
106 public: | 106 public: |
107 static GrFragmentProcessor* Create(const GrFragmentProcessor* fp) { | 107 static GrFragmentProcessor* Create(const GrFragmentProcessor* fp) { |
108 return new BlockInputFragmentProcessor(fp); | 108 return new BlockInputFragmentProcessor(fp); |
109 } | 109 } |
110 | 110 |
111 const char* name() const override { return "Block Input"; } | 111 const char* name() const override { return "Block Input"; } |
112 | 112 |
113 GrGLFragmentProcessor* onCreateGLInstance() const override { return new GLFP
; } | 113 GrGLSLFragmentProcessor* onCreateGLInstance() const override { return new GL
FP; } |
114 | 114 |
115 private: | 115 private: |
116 class GLFP : public GrGLFragmentProcessor { | 116 class GLFP : public GrGLSLFragmentProcessor { |
117 public: | 117 public: |
118 void emitCode(EmitArgs& args) override { | 118 void emitCode(EmitArgs& args) override { |
119 this->emitChild(0, nullptr, args); | 119 this->emitChild(0, nullptr, args); |
120 } | 120 } |
121 | 121 |
122 private: | 122 private: |
123 typedef GrGLFragmentProcessor INHERITED; | 123 typedef GrGLSLFragmentProcessor INHERITED; |
124 }; | 124 }; |
125 | 125 |
126 BlockInputFragmentProcessor(const GrFragmentProcessor* child) { | 126 BlockInputFragmentProcessor(const GrFragmentProcessor* child) { |
127 this->initClassID<BlockInputFragmentProcessor>(); | 127 this->initClassID<BlockInputFragmentProcessor>(); |
128 this->registerChildProcessor(child); | 128 this->registerChildProcessor(child); |
129 } | 129 } |
130 | 130 |
131 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override {} | 131 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override {} |
132 | 132 |
133 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } | 133 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 #endif | 445 #endif |
446 GrTestTarget testTarget; | 446 GrTestTarget testTarget; |
447 context->getTestTarget(&testTarget); | 447 context->getTestTarget(&testTarget); |
448 REPORTER_ASSERT(reporter, GrDrawingManager::ProgramUnitTest( | 448 REPORTER_ASSERT(reporter, GrDrawingManager::ProgramUnitTest( |
449 context, testTarget.target(), maxSta
ges)); | 449 context, testTarget.target(), maxSta
ges)); |
450 } | 450 } |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 #endif | 454 #endif |
OLD | NEW |