Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrGLSLVertexGeoBuilder.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2017 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
9
13
15 SkSLType devPosType) {
16 if (this->getProgramBuilder()->snapVerticesToPixelCenters()) {
17 if (SkSLType::kFloat3 == devPosType) {
18 const char* p = devPos;
19 out->appendf("{float2 _posTmp = %s.xy / %s.z;", p, p);
20 } else {
21 SkASSERT(SkSLType::kFloat2 == devPosType);
22 out->appendf("{float2 _posTmp = %s;", devPos);
23 }
24 out->appendf("_posTmp = floor(_posTmp) + float2(0.5);"
25 "sk_Position = _posTmp.xy01;}");
26 } else if (SkSLType::kFloat3 == devPosType) {
27 out->appendf("sk_Position = %s.xy0z;", devPos);
28 } else {
29 SkASSERT(SkSLType::kFloat2 == devPosType);
30 out->appendf("sk_Position = %s.xy01;", devPos);
31 }
32}
33
35 // We could have the GrGeometryProcessor do this, but its just easier to have it performed
36 // here. If we ever need to set variable pointsize, then we can reinvestigate.
37 if (this->getProgramBuilder()->hasPointSize()) {
38 this->codeAppend("sk_PointSize = 1.0;");
39 }
41}
#define SkASSERT(cond)
Definition SkAssert.h:116
SkSLType
virtual GrGLSLVaryingHandler * varyingHandler()=0
void codeAppend(const char *str)
GrGLSLProgramBuilder * fProgramBuilder
GrGLSLProgramBuilder * getProgramBuilder()
void getVertexDecls(SkString *inputDecls, SkString *outputDecls) const
void emitNormalizedSkPosition(const char *devPos, SkSLType devPosType=SkSLType::kFloat2)