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

Side by Side Diff: src/core/SkNormalFlatSource.cpp

Issue 2080993002: Added API for Bevel NormalSource. (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-diffuse-api-change
Patch Set: fixed unused field 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/SkNormalFlatSource.h ('k') | src/core/SkNormalMapSource.h » ('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 #include "SkNormalFlatSource.h"
9
10 #include "SkNormalSource.h"
11 #include "SkPoint3.h"
12 #include "SkReadBuffer.h"
13 #include "SkWriteBuffer.h"
14
15 #if SK_SUPPORT_GPU
16 #include "GrInvariantOutput.h"
17 #include "glsl/GrGLSLFragmentProcessor.h"
18 #include "glsl/GrGLSLFragmentShaderBuilder.h"
19
20 class NormalFlatFP : public GrFragmentProcessor {
21 public:
22 NormalFlatFP() {
23 this->initClassID<NormalFlatFP>();
24 }
25
26 class GLSLNormalFlatFP : public GrGLSLFragmentProcessor {
27 public:
28 GLSLNormalFlatFP() {}
29
30 void emitCode(EmitArgs& args) override {
31 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
32
33 fragBuilder->codeAppendf("%s = vec4(0, 0, 1, 0);", args.fOutputColor );
34 }
35
36 static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
37 GrProcessorKeyBuilder* b) {
38 b->add32(0x0);
39 }
40
41 protected:
42 void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& proc) override {}
43 };
44
45 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {
46 GLSLNormalFlatFP::GenKey(*this, caps, b);
47 }
48
49 const char* name() const override { return "NormalFlatFP"; }
50
51 void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
52 inout->setToUnknown(GrInvariantOutput::ReadInput::kWillNot_ReadInput);
53 }
54
55 private:
56 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { return new GLSLNormalFlatFP; }
57
58 bool onIsEqual(const GrFragmentProcessor& proc) const override {
59 return true;
60 }
61 };
62
63 sk_sp<GrFragmentProcessor> SkNormalFlatSourceImpl::asFragmentProcessor(
64 const SkShader::AsFPArgs&) const {
65
66 return sk_make_sp<NormalFlatFP>();
67 }
68
69 #endif // SK_SUPPORT_GPU
70
71 ////////////////////////////////////////////////////////////////////////////
72
73 SkNormalFlatSourceImpl::Provider::Provider() {}
74
75 SkNormalFlatSourceImpl::Provider::~Provider() {}
76
77 SkNormalSource::Provider* SkNormalFlatSourceImpl::asProvider(const SkShader::Con textRec &rec,
78 void *storage) const {
79 return new (storage) Provider();
80 }
81
82 size_t SkNormalFlatSourceImpl::providerSize(const SkShader::ContextRec&) const {
83 return sizeof(Provider);
84 }
85
86 void SkNormalFlatSourceImpl::Provider::fillScanLine(int x, int y, SkPoint3 outpu t[],
87 int count) const {
88 for (int i = 0; i < count; i++) {
89 output[i] = {0.0f, 0.0f, 1.0f};
90 }
91 }
92
93 ////////////////////////////////////////////////////////////////////////////////
94
95 sk_sp<SkFlattenable> SkNormalFlatSourceImpl::CreateProc(SkReadBuffer& buf) {
96 return sk_make_sp<SkNormalFlatSourceImpl>();
97 }
98
99 void SkNormalFlatSourceImpl::flatten(SkWriteBuffer& buf) const {
100 this->INHERITED::flatten(buf);
101 }
102
103 ////////////////////////////////////////////////////////////////////////////
104
105 sk_sp<SkNormalSource> SkNormalSource::MakeFlat() {
106 return sk_make_sp<SkNormalFlatSourceImpl>();
107 }
OLDNEW
« no previous file with comments | « src/core/SkNormalFlatSource.h ('k') | src/core/SkNormalMapSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698