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

Side by Side Diff: src/core/SkNormalSourcePriv.h

Issue 2114993002: GrFP can express distance vector field req., program builder declares variable for it (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-bevel-api-change
Patch Set: Fixed GrPaint unintialized bool Created 4 years, 4 months 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/core/SkNormalSource.h ('k') | src/gpu/GrFragmentProcessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkNormalSourcePriv_DEFINED
9 #define SkNormalSourcePriv_DEFINED
10
11 #if SK_SUPPORT_GPU
12 #include "glsl/GrGLSLFragmentProcessor.h"
13 #include "glsl/GrGLSLFragmentShaderBuilder.h"
14
15 /* GLSLFragmentProcessors for NormalSourceImpls must sub-class this class and ov erride onEmitCode,
16 * and setNormalData calls, as well as all other calls FPs normally override, ex cept for the 2
17 * defined in this superclass.
18 * This class exists to intercept emitCode calls and emit <0, 0, 1> if the FP re quires a distance
19 * vector but the GP doesn't provide it. onSetData calls need to be intercepted too because
20 * uniform handlers will be invalid in subclasses where onEmitCode isn't called.
21 * We don't need to adjust the key here since the use of a given GP (through its class ID already in
22 * the key), will determine what code gets emitted here.
23 */
24 class GLSLNormalFP : public GrGLSLFragmentProcessor {
25 public:
26 GLSLNormalFP()
27 : fDidIntercept(false) {}
28
29 void emitCode(EmitArgs& args) final override {
30 if (args.fFp.usesDistanceVectorField() && !args.fGpImplementsDistanceVec tor) {
31 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
32 fragBuilder->codeAppendf("// GLSLNormalFP intercepted emitCode call, GP does not "
33 "implement required distance vector feature\n");
34 fragBuilder->codeAppendf("%s = vec4(0, 0, 1, 0);", args.fOutputColor );
35
36 fDidIntercept = true;
37 } else {
38 this->onEmitCode(args);
39 }
40 }
41
42 void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& pro c) final override {
43 if (!fDidIntercept) {
44 this->setNormalData(pdman, proc);
45 }
46 }
47
48 protected:
49 virtual void onEmitCode(EmitArgs& args) = 0;
50 virtual void setNormalData(const GrGLSLProgramDataManager& pdman, const GrPr ocessor& proc) = 0;
51
52 private:
53 bool fDidIntercept;
54 };
55 #endif
56
57 #endif
OLDNEW
« no previous file with comments | « src/core/SkNormalSource.h ('k') | src/gpu/GrFragmentProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698