Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrFragmentProcessor.h" | 8 #include "GrFragmentProcessor.h" |
| 9 #include "GrCoordTransform.h" | 9 #include "GrCoordTransform.h" |
| 10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 136 |
| 137 sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputAlpha( | 137 sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputAlpha( |
| 138 sk_sp<GrFragmentProcessor> fp) { | 138 sk_sp<GrFragmentProcessor> fp) { |
| 139 if (!fp) { | 139 if (!fp) { |
| 140 return nullptr; | 140 return nullptr; |
| 141 } | 141 } |
| 142 return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(fp), | 142 return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(fp), |
| 143 SkXfermode::kDstIn_ Mode); | 143 SkXfermode::kDstIn_ Mode); |
| 144 } | 144 } |
| 145 | 145 |
| 146 sk_sp<GrFragmentProcessor> GrFragmentProcessor::PremulInput(sk_sp<GrFragmentProc essor> fp) { | |
| 147 | |
| 148 class PremulInputFragmentProcessor : public GrFragmentProcessor { | |
| 149 public: | |
| 150 PremulInputFragmentProcessor() { | |
| 151 this->initClassID<PremulInputFragmentProcessor>(); | |
| 152 } | |
| 153 | |
| 154 const char* name() const override { return "PremultiplyInput"; } | |
| 155 | |
| 156 private: | |
| 157 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { | |
| 158 class GLFP : public GrGLSLFragmentProcessor { | |
| 159 public: | |
| 160 void emitCode(EmitArgs& args) override { | |
| 161 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | |
| 162 | |
| 163 fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, args .fInputColor); | |
| 164 fragBuilder->codeAppendf("%s.rgb *= %s.a;", args.fOutputColo r, args.fInputColor); | |
|
egdaniel
2016/07/14 03:22:47
100 chars
dvonbeck
2016/07/14 14:30:33
This was fixed in patch set 6
| |
| 165 } | |
| 166 }; | |
| 167 return new GLFP; | |
| 168 } | |
| 169 | |
| 170 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) co nst override {} | |
| 171 | |
| 172 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } | |
| 173 | |
| 174 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | |
| 175 inout->mulByUnknownFourComponents(); | |
|
egdaniel
2016/07/14 03:22:47
This doesn't seem right. I feel like it should be
dvonbeck
2016/07/14 14:30:33
Adding appropriate invariant option in separate CL
| |
| 176 } | |
| 177 }; | |
| 178 if (!fp) { | |
| 179 return nullptr; | |
| 180 } | |
| 181 sk_sp<GrFragmentProcessor> fpPipeline[] = { sk_make_sp<PremulInputFragmentPr ocessor>(), fp}; | |
| 182 return GrFragmentProcessor::RunInSeries(fpPipeline, 2); | |
| 183 } | |
| 184 | |
| 146 sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputUnpremulColor( | 185 sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputUnpremulColor( |
| 147 sk_sp<GrFragmentProcessor> fp) { | 186 sk_sp<GrFragmentProcessor> fp) { |
| 148 | 187 |
| 149 class PremulFragmentProcessor : public GrFragmentProcessor { | 188 class PremulFragmentProcessor : public GrFragmentProcessor { |
| 150 public: | 189 public: |
| 151 PremulFragmentProcessor(sk_sp<GrFragmentProcessor> processor) { | 190 PremulFragmentProcessor(sk_sp<GrFragmentProcessor> processor) { |
| 152 this->initClassID<PremulFragmentProcessor>(); | 191 this->initClassID<PremulFragmentProcessor>(); |
| 153 this->registerChildProcessor(processor); | 192 this->registerChildProcessor(processor); |
| 154 } | 193 } |
| 155 | 194 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 } else { | 409 } else { |
| 371 series += firstIdx; | 410 series += firstIdx; |
| 372 cnt -= firstIdx; | 411 cnt -= firstIdx; |
| 373 } | 412 } |
| 374 | 413 |
| 375 if (1 == cnt) { | 414 if (1 == cnt) { |
| 376 return series[0]; | 415 return series[0]; |
| 377 } | 416 } |
| 378 return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt)); | 417 return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt)); |
| 379 } | 418 } |
| OLD | NEW |