| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkNormalFlatSource.h" | 8 #include "SkNormalFlatSource.h" |
| 9 | 9 |
| 10 #include "SkNormalSource.h" | 10 #include "SkNormalSource.h" |
| 11 #include "SkPoint3.h" | 11 #include "SkPoint3.h" |
| 12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
| 13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
| 14 | 14 |
| 15 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
| 16 #include "GrInvariantOutput.h" | 16 #include "GrInvariantOutput.h" |
| 17 #include "glsl/GrGLSLFragmentProcessor.h" | 17 #include "glsl/GrGLSLFragmentProcessor.h" |
| 18 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 18 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 19 | 19 |
| 20 class NormalFlatFP : public GrFragmentProcessor { | 20 class NormalFlatFP : public GrFragmentProcessor { |
| 21 public: | 21 public: |
| 22 NormalFlatFP() { | 22 NormalFlatFP() { |
| 23 this->initClassID<NormalFlatFP>(); | 23 this->initClassID<NormalFlatFP>(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 class GLSLNormalFlatFP : public GrGLSLFragmentProcessor { | 26 class GLSLNormalFlatFP : public GLSLNormalFP { |
| 27 public: | 27 public: |
| 28 GLSLNormalFlatFP() {} | 28 GLSLNormalFlatFP() {} |
| 29 | 29 |
| 30 void emitCode(EmitArgs& args) override { | 30 void onEmitCode(EmitArgs& args) override { |
| 31 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 31 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 32 | 32 |
| 33 fragBuilder->codeAppendf("%s = vec4(0, 0, 1, 0);", args.fOutputColor
); | 33 fragBuilder->codeAppendf("%s = vec4(0, 0, 1, 0);", args.fOutputColor
); |
| 34 } | 34 } |
| 35 | 35 |
| 36 static void GenKey(const GrProcessor& proc, const GrGLSLCaps&, | 36 static void GenKey(const GrProcessor& proc, const GrGLSLCaps&, |
| 37 GrProcessorKeyBuilder* b) { | 37 GrProcessorKeyBuilder* b) { |
| 38 b->add32(0x0); | 38 b->add32(0x0); |
| 39 } | 39 } |
| 40 | 40 |
| 41 protected: | 41 protected: |
| 42 void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor&
proc) override {} | 42 void setNormalData(const GrGLSLProgramDataManager& pdman, |
| 43 const GrProcessor& proc) override {} |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b)
const override { | 46 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b)
const override { |
| 46 GLSLNormalFlatFP::GenKey(*this, caps, b); | 47 GLSLNormalFlatFP::GenKey(*this, caps, b); |
| 47 } | 48 } |
| 48 | 49 |
| 49 const char* name() const override { return "NormalFlatFP"; } | 50 const char* name() const override { return "NormalFlatFP"; } |
| 50 | 51 |
| 51 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | 52 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| 52 inout->setToUnknown(GrInvariantOutput::ReadInput::kWillNot_ReadInput); | 53 inout->setToUnknown(GrInvariantOutput::ReadInput::kWillNot_ReadInput); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 103 |
| 103 void SkNormalFlatSourceImpl::flatten(SkWriteBuffer& buf) const { | 104 void SkNormalFlatSourceImpl::flatten(SkWriteBuffer& buf) const { |
| 104 this->INHERITED::flatten(buf); | 105 this->INHERITED::flatten(buf); |
| 105 } | 106 } |
| 106 | 107 |
| 107 //////////////////////////////////////////////////////////////////////////// | 108 //////////////////////////////////////////////////////////////////////////// |
| 108 | 109 |
| 109 sk_sp<SkNormalSource> SkNormalSource::MakeFlat() { | 110 sk_sp<SkNormalSource> SkNormalSource::MakeFlat() { |
| 110 return sk_make_sp<SkNormalFlatSourceImpl>(); | 111 return sk_make_sp<SkNormalFlatSourceImpl>(); |
| 111 } | 112 } |
| OLD | NEW |