зеркало из https://github.com/mozilla/moz-skia.git
Remove GrStringBuilder
Review URL: http://codereview.appspot.com/6343093/ git-svn-id: http://skia.googlecode.com/svn/trunk@4514 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
5c0b3134ab
Коммит
f0a104e6f1
|
@ -266,7 +266,6 @@
|
|||
'../src/gpu/GrStencilAndCoverPathRenderer.h',
|
||||
'../src/gpu/GrStencilBuffer.cpp',
|
||||
'../src/gpu/GrStencilBuffer.h',
|
||||
'../src/gpu/GrStringBuilder.h',
|
||||
'../src/gpu/GrTBSearch.h',
|
||||
'../src/gpu/GrTDArray.h',
|
||||
'../src/gpu/GrSWMaskHelper.cpp',
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef GrStringBuilder_DEFINED
|
||||
#define GrStringBuilder_DEFINED
|
||||
|
||||
#include "SkString.h"
|
||||
|
||||
typedef SkString GrStringBuilder;
|
||||
|
||||
#endif
|
||||
|
|
@ -73,7 +73,7 @@ void GrGLConvolutionEffect::setupVariables(GrGLShaderBuilder* state,
|
|||
|
||||
void GrGLConvolutionEffect::emitVS(GrGLShaderBuilder* state,
|
||||
const char* vertexCoords) {
|
||||
GrStringBuilder* code = &state->fVSCode;
|
||||
SkString* code = &state->fVSCode;
|
||||
code->appendf("\t\t%s -= vec2(%d, %d) * %s;\n",
|
||||
vertexCoords, fRadius, fRadius,
|
||||
fImageIncrementVar->getName().c_str());
|
||||
|
@ -83,7 +83,7 @@ void GrGLConvolutionEffect::emitFS(GrGLShaderBuilder* state,
|
|||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const char* samplerName) {
|
||||
GrStringBuilder* code = &state->fFSCode;
|
||||
SkString* code = &state->fFSCode;
|
||||
|
||||
code->appendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor);
|
||||
|
||||
|
@ -92,8 +92,8 @@ void GrGLConvolutionEffect::emitFS(GrGLShaderBuilder* state,
|
|||
int width = this ->width();
|
||||
// Manually unroll loop because some drivers don't; yields 20-30% speedup.
|
||||
for (int i = 0; i < width; i++) {
|
||||
GrStringBuilder index;
|
||||
GrStringBuilder kernelIndex;
|
||||
SkString index;
|
||||
SkString kernelIndex;
|
||||
index.appendS32(i);
|
||||
fKernelVar->appendArrayAccess(index.c_str(), &kernelIndex);
|
||||
code->appendf("\t\t%s += ", outputColor);
|
||||
|
|
|
@ -162,9 +162,9 @@ void GrGLRadial2Gradient::setupVariables(GrGLShaderBuilder* state, int stage) {
|
|||
|
||||
void GrGLRadial2Gradient::emitVS(GrGLShaderBuilder* state,
|
||||
const char* vertexCoords) {
|
||||
GrStringBuilder* code = &state->fVSCode;
|
||||
GrStringBuilder p2;
|
||||
GrStringBuilder p3;
|
||||
SkString* code = &state->fVSCode;
|
||||
SkString p2;
|
||||
SkString p3;
|
||||
fVSParamVar->appendArrayAccess(2, &p2);
|
||||
fVSParamVar->appendArrayAccess(3, &p3);
|
||||
|
||||
|
@ -182,16 +182,16 @@ void GrGLRadial2Gradient::emitFS(GrGLShaderBuilder* state,
|
|||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const char* samplerName) {
|
||||
GrStringBuilder* code = &state->fFSCode;
|
||||
GrStringBuilder cName("c");
|
||||
GrStringBuilder ac4Name("ac4");
|
||||
GrStringBuilder rootName("root");
|
||||
GrStringBuilder p0;
|
||||
GrStringBuilder p1;
|
||||
GrStringBuilder p2;
|
||||
GrStringBuilder p3;
|
||||
GrStringBuilder p4;
|
||||
GrStringBuilder p5;
|
||||
SkString* code = &state->fFSCode;
|
||||
SkString cName("c");
|
||||
SkString ac4Name("ac4");
|
||||
SkString rootName("root");
|
||||
SkString p0;
|
||||
SkString p1;
|
||||
SkString p2;
|
||||
SkString p3;
|
||||
SkString p4;
|
||||
SkString p5;
|
||||
fFSParamVar->appendArrayAccess(0, &p0);
|
||||
fFSParamVar->appendArrayAccess(1, &p1);
|
||||
fFSParamVar->appendArrayAccess(2, &p2);
|
||||
|
@ -201,7 +201,7 @@ void GrGLRadial2Gradient::emitFS(GrGLShaderBuilder* state,
|
|||
|
||||
// If we we're able to interpolate the linear component,
|
||||
// bVar is the varying; otherwise compute it
|
||||
GrStringBuilder bVar;
|
||||
SkString bVar;
|
||||
if (state->fCoordDims == state->fVaryingDims) {
|
||||
bVar = fFSVaryingName;
|
||||
GrAssert(2 == state->fVaryingDims);
|
||||
|
@ -419,10 +419,10 @@ void GrGLConical2Gradient::setupVariables(GrGLShaderBuilder* state, int stage) {
|
|||
|
||||
void GrGLConical2Gradient::emitVS(GrGLShaderBuilder* state,
|
||||
const char* vertexCoords) {
|
||||
GrStringBuilder* code = &state->fVSCode;
|
||||
GrStringBuilder p2; // distance between centers
|
||||
GrStringBuilder p3; // start radius
|
||||
GrStringBuilder p5; // difference in radii (r1 - r0)
|
||||
SkString* code = &state->fVSCode;
|
||||
SkString p2; // distance between centers
|
||||
SkString p3; // start radius
|
||||
SkString p5; // difference in radii (r1 - r0)
|
||||
fVSParamVar->appendArrayAccess(2, &p2);
|
||||
fVSParamVar->appendArrayAccess(3, &p3);
|
||||
fVSParamVar->appendArrayAccess(5, &p5);
|
||||
|
@ -441,21 +441,21 @@ void GrGLConical2Gradient::emitFS(GrGLShaderBuilder* state,
|
|||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const char* samplerName) {
|
||||
GrStringBuilder* code = &state->fFSCode;
|
||||
SkString* code = &state->fFSCode;
|
||||
|
||||
GrStringBuilder cName("c");
|
||||
GrStringBuilder ac4Name("ac4");
|
||||
GrStringBuilder dName("d");
|
||||
GrStringBuilder qName("q");
|
||||
GrStringBuilder r0Name("r0");
|
||||
GrStringBuilder r1Name("r1");
|
||||
GrStringBuilder tName("t");
|
||||
GrStringBuilder p0; // 4a
|
||||
GrStringBuilder p1; // 1/(2a)
|
||||
GrStringBuilder p2; // distance between centers
|
||||
GrStringBuilder p3; // start radius
|
||||
GrStringBuilder p4; // start radius squared
|
||||
GrStringBuilder p5; // difference in radii (r1 - r0)
|
||||
SkString cName("c");
|
||||
SkString ac4Name("ac4");
|
||||
SkString dName("d");
|
||||
SkString qName("q");
|
||||
SkString r0Name("r0");
|
||||
SkString r1Name("r1");
|
||||
SkString tName("t");
|
||||
SkString p0; // 4a
|
||||
SkString p1; // 1/(2a)
|
||||
SkString p2; // distance between centers
|
||||
SkString p3; // start radius
|
||||
SkString p4; // start radius squared
|
||||
SkString p5; // difference in radii (r1 - r0)
|
||||
fFSParamVar->appendArrayAccess(0, &p0);
|
||||
fFSParamVar->appendArrayAccess(1, &p1);
|
||||
fFSParamVar->appendArrayAccess(2, &p2);
|
||||
|
@ -465,7 +465,7 @@ void GrGLConical2Gradient::emitFS(GrGLShaderBuilder* state,
|
|||
|
||||
// If we we're able to interpolate the linear component,
|
||||
// bVar is the varying; otherwise compute it
|
||||
GrStringBuilder bVar;
|
||||
SkString bVar;
|
||||
if (state->fCoordDims == state->fVaryingDims) {
|
||||
bVar = fFSVaryingName;
|
||||
GrAssert(2 == state->fVaryingDims);
|
||||
|
|
|
@ -64,7 +64,7 @@ void GrGLMorphologyEffect::setupVariables(GrGLShaderBuilder* state, int stage) {
|
|||
|
||||
void GrGLMorphologyEffect::emitVS(GrGLShaderBuilder* state,
|
||||
const char* vertexCoords) {
|
||||
GrStringBuilder* code = &state->fVSCode;
|
||||
SkString* code = &state->fVSCode;
|
||||
code->appendf("\t\t%s -= vec2(%d, %d) * %s;\n",
|
||||
vertexCoords, fRadius, fRadius,
|
||||
fImageIncrementVar->getName().c_str());
|
||||
|
@ -81,7 +81,7 @@ void GrGLMorphologyEffect ::emitFS(GrGLShaderBuilder* state,
|
|||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const char* samplerName) {
|
||||
GrStringBuilder* code = &state->fFSCode;
|
||||
SkString* code = &state->fFSCode;
|
||||
// const char* texFunc = "texture2D";
|
||||
// bool complexCoord = false;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ typedef GrGLProgram::ProgramDesc::StageDesc StageDesc;
|
|||
#define COL_MATRIX_VEC_UNI_NAME "uColorMatrixVec"
|
||||
|
||||
namespace {
|
||||
inline void tex_attr_name(int coordIdx, GrStringBuilder* s) {
|
||||
inline void tex_attr_name(int coordIdx, SkString* s) {
|
||||
*s = "aTexCoord";
|
||||
s->appendS32(coordIdx);
|
||||
}
|
||||
|
@ -75,17 +75,17 @@ inline const char* all_zeros_vec(int count) {
|
|||
inline const char* declared_color_output_name() { return "fsColorOut"; }
|
||||
inline const char* dual_source_output_name() { return "dualSourceOut"; }
|
||||
|
||||
inline void tex_matrix_name(int stage, GrStringBuilder* s) {
|
||||
inline void tex_matrix_name(int stage, SkString* s) {
|
||||
*s = "uTexM";
|
||||
s->appendS32(stage);
|
||||
}
|
||||
|
||||
inline void sampler_name(int stage, GrStringBuilder* s) {
|
||||
inline void sampler_name(int stage, SkString* s) {
|
||||
*s = "uSampler";
|
||||
s->appendS32(stage);
|
||||
}
|
||||
|
||||
inline void tex_domain_name(int stage, GrStringBuilder* s) {
|
||||
inline void tex_domain_name(int stage, SkString* s) {
|
||||
*s = "uTexDom";
|
||||
s->appendS32(stage);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ void GrGLProgram::overrideBlend(GrBlendCoeff* srcCoeff,
|
|||
static inline void modulate_helper(const char* outputVar,
|
||||
const char* var0,
|
||||
const char* var1,
|
||||
GrStringBuilder* code) {
|
||||
SkString* code) {
|
||||
GrAssert(NULL != outputVar);
|
||||
GrAssert(NULL != var0);
|
||||
GrAssert(NULL != var1);
|
||||
|
@ -151,7 +151,7 @@ static inline void modulate_helper(const char* outputVar,
|
|||
static inline void add_helper(const char* outputVar,
|
||||
const char* var0,
|
||||
const char* var1,
|
||||
GrStringBuilder* code) {
|
||||
SkString* code) {
|
||||
GrAssert(NULL != outputVar);
|
||||
GrAssert(NULL != var0);
|
||||
GrAssert(NULL != var1);
|
||||
|
@ -215,7 +215,7 @@ static inline void needBlendInputs(SkXfermode::Coeff srcCoeff,
|
|||
* Create a blend_coeff * value string to be used in shader code. Sets empty
|
||||
* string if result is trivially zero.
|
||||
*/
|
||||
static void blendTermString(GrStringBuilder* str, SkXfermode::Coeff coeff,
|
||||
static void blendTermString(SkString* str, SkXfermode::Coeff coeff,
|
||||
const char* src, const char* dst,
|
||||
const char* value) {
|
||||
switch (coeff) {
|
||||
|
@ -258,11 +258,11 @@ static void blendTermString(GrStringBuilder* str, SkXfermode::Coeff coeff,
|
|||
* Adds a line to the fragment shader code which modifies the color by
|
||||
* the specified color filter.
|
||||
*/
|
||||
static void addColorFilter(GrStringBuilder* fsCode, const char * outputVar,
|
||||
static void addColorFilter(SkString* fsCode, const char * outputVar,
|
||||
SkXfermode::Coeff uniformCoeff,
|
||||
SkXfermode::Coeff colorCoeff,
|
||||
const char* inColor) {
|
||||
GrStringBuilder colorStr, constStr;
|
||||
SkString colorStr, constStr;
|
||||
blendTermString(&colorStr, colorCoeff, COL_FILTER_UNI_NAME,
|
||||
inColor, inColor);
|
||||
blendTermString(&constStr, uniformCoeff, COL_FILTER_UNI_NAME,
|
||||
|
@ -274,7 +274,7 @@ static void addColorFilter(GrStringBuilder* fsCode, const char * outputVar,
|
|||
* Adds code to the fragment shader code which modifies the color by
|
||||
* the specified color matrix.
|
||||
*/
|
||||
static void addColorMatrix(GrStringBuilder* fsCode, const char * outputVar,
|
||||
static void addColorMatrix(SkString* fsCode, const char * outputVar,
|
||||
const char* inColor) {
|
||||
fsCode->appendf("\t%s = %s * vec4(%s.rgb / %s.a, %s.a) + %s;\n", outputVar, COL_MATRIX_UNI_NAME, inColor, inColor, inColor, COL_MATRIX_VEC_UNI_NAME);
|
||||
fsCode->appendf("\t%s.rgb *= %s.a;\n", outputVar, outputVar);
|
||||
|
@ -283,7 +283,7 @@ static void addColorMatrix(GrStringBuilder* fsCode, const char * outputVar,
|
|||
void GrGLProgram::genEdgeCoverage(const GrGLContextInfo& gl,
|
||||
GrVertexLayout layout,
|
||||
CachedData* programData,
|
||||
GrStringBuilder* coverageVar,
|
||||
SkString* coverageVar,
|
||||
GrGLShaderBuilder* segments) const {
|
||||
if (layout & GrDrawTarget::kEdge_VertexLayoutBit) {
|
||||
const char *vsName, *fsName;
|
||||
|
@ -350,7 +350,7 @@ namespace {
|
|||
void genInputColor(GrGLProgram::ProgramDesc::ColorInput colorInput,
|
||||
GrGLProgram::CachedData* programData,
|
||||
GrGLShaderBuilder* segments,
|
||||
GrStringBuilder* inColor) {
|
||||
SkString* inColor) {
|
||||
switch (colorInput) {
|
||||
case GrGLProgram::ProgramDesc::kAttribute_ColorInput: {
|
||||
segments->fVSAttrs.push_back().set(kVec4f_GrSLType,
|
||||
|
@ -379,7 +379,7 @@ void genInputColor(GrGLProgram::ProgramDesc::ColorInput colorInput,
|
|||
}
|
||||
|
||||
void genAttributeCoverage(GrGLShaderBuilder* segments,
|
||||
GrStringBuilder* inOutCoverage) {
|
||||
SkString* inOutCoverage) {
|
||||
segments->fVSAttrs.push_back().set(kVec4f_GrSLType,
|
||||
GrGLShaderVar::kAttribute_TypeModifier,
|
||||
COV_ATTR_NAME);
|
||||
|
@ -397,7 +397,7 @@ void genAttributeCoverage(GrGLShaderBuilder* segments,
|
|||
|
||||
void genUniformCoverage(GrGLShaderBuilder* segments,
|
||||
GrGLProgram::CachedData* programData,
|
||||
GrStringBuilder* inOutCoverage) {
|
||||
SkString* inOutCoverage) {
|
||||
segments->addUniform(GrGLShaderBuilder::kFragment_VariableLifetime,
|
||||
kVec4f_GrSLType, COV_UNI_NAME);
|
||||
programData->fUniLocations.fCoverageUni = kUseUniform;
|
||||
|
@ -440,7 +440,7 @@ void GrGLProgram::genGeometryShader(const GrGLContextInfo& gl,
|
|||
#endif
|
||||
}
|
||||
|
||||
const char* GrGLProgram::adjustInColor(const GrStringBuilder& inColor) const {
|
||||
const char* GrGLProgram::adjustInColor(const SkString& inColor) const {
|
||||
if (inColor.size()) {
|
||||
return inColor.c_str();
|
||||
} else {
|
||||
|
@ -542,7 +542,7 @@ bool GrGLProgram::genProgram(const GrGLContextInfo& gl,
|
|||
"\tgl_Position = vec4(pos3.xy, 0, pos3.z);\n");
|
||||
|
||||
// incoming color to current stage being processed.
|
||||
GrStringBuilder inColor;
|
||||
SkString inColor;
|
||||
|
||||
if (needComputedColor) {
|
||||
genInputColor((ProgramDesc::ColorInput) fProgramDesc.fColorInput,
|
||||
|
@ -557,7 +557,7 @@ bool GrGLProgram::genProgram(const GrGLContextInfo& gl,
|
|||
segments.fFSCode.append("void main() {\n");
|
||||
|
||||
// add texture coordinates that are used to the list of vertex attr decls
|
||||
GrStringBuilder texCoordAttrs[GrDrawState::kMaxTexCoords];
|
||||
SkString texCoordAttrs[GrDrawState::kMaxTexCoords];
|
||||
for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
|
||||
if (GrDrawTarget::VertexUsesTexCoordIdx(t, layout)) {
|
||||
tex_attr_name(t, texCoordAttrs + t);
|
||||
|
@ -582,7 +582,7 @@ bool GrGLProgram::genProgram(const GrGLContextInfo& gl,
|
|||
// if we have color stages string them together, feeding the output color
|
||||
// of each to the next and generating code for each stage.
|
||||
if (needComputedColor) {
|
||||
GrStringBuilder outColor;
|
||||
SkString outColor;
|
||||
for (int s = 0; s < fProgramDesc.fFirstCoverageStage; ++s) {
|
||||
if (fProgramDesc.fStages[s].isEnabled()) {
|
||||
// create var to hold stage result
|
||||
|
@ -670,7 +670,7 @@ bool GrGLProgram::genProgram(const GrGLContextInfo& gl,
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// compute the partial coverage (coverage stages and edge aa)
|
||||
|
||||
GrStringBuilder inCoverage;
|
||||
SkString inCoverage;
|
||||
bool coverageIsZero = ProgramDesc::kTransBlack_ColorInput ==
|
||||
fProgramDesc.fCoverageInput;
|
||||
// we don't need to compute coverage at all if we know the final shader
|
||||
|
@ -699,7 +699,7 @@ bool GrGLProgram::genProgram(const GrGLContextInfo& gl,
|
|||
GrCrash("Unexpected input coverage.");
|
||||
}
|
||||
|
||||
GrStringBuilder outCoverage;
|
||||
SkString outCoverage;
|
||||
const int& startStage = fProgramDesc.fFirstCoverageStage;
|
||||
for (int s = startStage; s < GrDrawState::kNumStages; ++s) {
|
||||
if (fProgramDesc.fStages[s].isEnabled()) {
|
||||
|
@ -745,7 +745,7 @@ bool GrGLProgram::genProgram(const GrGLContextInfo& gl,
|
|||
GrGLShaderVar::kOut_TypeModifier,
|
||||
dual_source_output_name());
|
||||
bool outputIsZero = coverageIsZero;
|
||||
GrStringBuilder coeff;
|
||||
SkString coeff;
|
||||
if (!outputIsZero &&
|
||||
ProgramDesc::kCoverage_DualSrcOutput !=
|
||||
fProgramDesc.fDualSrcOutput && !wroteFragColorZero) {
|
||||
|
@ -839,7 +839,7 @@ namespace {
|
|||
|
||||
inline void expand_decls(const VarArray& vars,
|
||||
const GrGLContextInfo& gl,
|
||||
GrStringBuilder* string) {
|
||||
SkString* string) {
|
||||
const int count = vars.count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
vars[i].appendDecl(gl, string);
|
||||
|
@ -865,10 +865,10 @@ typedef SkTArray<int, true> LengthArray;
|
|||
#define PREALLOC_LENGTH_ARRAY(N) SkSTArray<(N), int, true>
|
||||
|
||||
// these shouldn't relocate
|
||||
typedef GrTAllocator<GrStringBuilder> TempArray;
|
||||
#define PREALLOC_TEMP_ARRAY(N) GrSTAllocator<(N), GrStringBuilder>
|
||||
typedef GrTAllocator<SkString> TempArray;
|
||||
#define PREALLOC_TEMP_ARRAY(N) GrSTAllocator<(N), SkString>
|
||||
|
||||
inline void append_string(const GrStringBuilder& str,
|
||||
inline void append_string(const SkString& str,
|
||||
StrArray* strings,
|
||||
LengthArray* lengths) {
|
||||
int length = (int) str.size();
|
||||
|
@ -899,9 +899,9 @@ bool GrGLProgram::CompileShaders(const GrGLContextInfo& gl,
|
|||
PREALLOC_LENGTH_ARRAY(kPreAllocStringCnt) lengths;
|
||||
PREALLOC_TEMP_ARRAY(kPreAllocStringCnt) temps;
|
||||
|
||||
GrStringBuilder unis;
|
||||
GrStringBuilder inputs;
|
||||
GrStringBuilder outputs;
|
||||
SkString unis;
|
||||
SkString inputs;
|
||||
SkString outputs;
|
||||
|
||||
append_string(segments.fHeader, &strs, &lengths);
|
||||
append_decls(segments.fVSUnis, gl, &strs, &lengths, &temps);
|
||||
|
@ -946,7 +946,7 @@ bool GrGLProgram::CompileShaders(const GrGLContextInfo& gl,
|
|||
temps.reset();
|
||||
|
||||
append_string(segments.fHeader, &strs, &lengths);
|
||||
GrStringBuilder precisionStr(GrGetGLSLShaderPrecisionDecl(gl.binding()));
|
||||
SkString precisionStr(GrGetGLSLShaderPrecisionDecl(gl.binding()));
|
||||
append_string(precisionStr, &strs, &lengths);
|
||||
append_decls(segments.fFSUnis, gl, &strs, &lengths, &temps);
|
||||
append_decls(segments.fFSInputs, gl, &strs, &lengths, &temps);
|
||||
|
@ -1017,7 +1017,7 @@ GrGLuint GrGLProgram::CompileShader(const GrGLContextInfo& gl,
|
|||
|
||||
bool GrGLProgram::bindOutputsAttribsAndLinkProgram(
|
||||
const GrGLContextInfo& gl,
|
||||
GrStringBuilder texCoordAttrNames[],
|
||||
SkString texCoordAttrNames[],
|
||||
bool bindColorOut,
|
||||
bool bindDualSrcOut,
|
||||
CachedData* programData) const {
|
||||
|
@ -1121,7 +1121,7 @@ void GrGLProgram::getUniformLocationsAndInitCache(const GrGLContextInfo& gl,
|
|||
StageUniLocations& locations = programData->fUniLocations.fStages[s];
|
||||
if (fProgramDesc.fStages[s].isEnabled()) {
|
||||
if (kUseUniform == locations.fTextureMatrixUni) {
|
||||
GrStringBuilder texMName;
|
||||
SkString texMName;
|
||||
tex_matrix_name(s, &texMName);
|
||||
GL_CALL_RET(locations.fTextureMatrixUni,
|
||||
GetUniformLocation(progID, texMName.c_str()));
|
||||
|
@ -1129,7 +1129,7 @@ void GrGLProgram::getUniformLocationsAndInitCache(const GrGLContextInfo& gl,
|
|||
}
|
||||
|
||||
if (kUseUniform == locations.fSamplerUni) {
|
||||
GrStringBuilder samplerName;
|
||||
SkString samplerName;
|
||||
sampler_name(s, &samplerName);
|
||||
GL_CALL_RET(locations.fSamplerUni,
|
||||
GetUniformLocation(progID,samplerName.c_str()));
|
||||
|
@ -1137,7 +1137,7 @@ void GrGLProgram::getUniformLocationsAndInitCache(const GrGLContextInfo& gl,
|
|||
}
|
||||
|
||||
if (kUseUniform == locations.fTexDomUni) {
|
||||
GrStringBuilder texDomName;
|
||||
SkString texDomName;
|
||||
tex_domain_name(s, &texDomName);
|
||||
GL_CALL_RET(locations.fTexDomUni,
|
||||
GetUniformLocation(progID, texDomName.c_str()));
|
||||
|
@ -1196,7 +1196,7 @@ void GrGLProgram::genStageCode(const GrGLContextInfo& gl,
|
|||
if (desc.fOptFlags & StageDesc::kIdentityMatrix_OptFlagBit) {
|
||||
segments->fVaryingDims = segments->fCoordDims;
|
||||
} else {
|
||||
GrStringBuilder texMatName;
|
||||
SkString texMatName;
|
||||
tex_matrix_name(stageNum, &texMatName);
|
||||
const GrGLShaderVar* mat = &segments->addUniform(
|
||||
GrGLShaderBuilder::kVertex_VariableLifetime, kMat33f_GrSLType,
|
||||
|
@ -1218,7 +1218,7 @@ void GrGLProgram::genStageCode(const GrGLContextInfo& gl,
|
|||
customStage->setupVariables(segments, stageNum);
|
||||
}
|
||||
|
||||
GrStringBuilder samplerName;
|
||||
SkString samplerName;
|
||||
sampler_name(stageNum, &samplerName);
|
||||
// const GrGLShaderVar* sampler = &
|
||||
segments->addUniform(GrGLShaderBuilder::kFragment_VariableLifetime,
|
||||
|
@ -1273,13 +1273,13 @@ void GrGLProgram::genStageCode(const GrGLContextInfo& gl,
|
|||
StageDesc::kMulRGBByAlpha_RoundDown_InConfigFlag);
|
||||
|
||||
if (desc.fOptFlags & StageDesc::kCustomTextureDomain_OptFlagBit) {
|
||||
GrStringBuilder texDomainName;
|
||||
SkString texDomainName;
|
||||
tex_domain_name(stageNum, &texDomainName);
|
||||
// const GrGLShaderVar* texDomain = &
|
||||
segments->addUniform(
|
||||
GrGLShaderBuilder::kFragment_VariableLifetime,
|
||||
kVec4f_GrSLType, texDomainName.c_str());
|
||||
GrStringBuilder coordVar("clampCoord");
|
||||
SkString coordVar("clampCoord");
|
||||
segments->fFSCode.appendf("\t%s %s = clamp(%s, %s.xy, %s.zw);\n",
|
||||
float_vector_type_str(segments->fCoordDims),
|
||||
coordVar.c_str(),
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include "GrGLContextInfo.h"
|
||||
#include "GrGLSL.h"
|
||||
#include "GrGLTexture.h"
|
||||
#include "GrStringBuilder.h"
|
||||
#include "GrGpu.h"
|
||||
|
||||
#include "SkString.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
class GrBinHashKeyBuilder;
|
||||
|
@ -234,7 +234,7 @@ public:
|
|||
private:
|
||||
|
||||
const ProgramDesc& getDesc() { return fProgramDesc; }
|
||||
const char* adjustInColor(const GrStringBuilder& inColor) const;
|
||||
const char* adjustInColor(const SkString& inColor) const;
|
||||
|
||||
public:
|
||||
enum {
|
||||
|
@ -354,7 +354,7 @@ private:
|
|||
void genEdgeCoverage(const GrGLContextInfo& gl,
|
||||
GrVertexLayout layout,
|
||||
CachedData* programData,
|
||||
GrStringBuilder* coverageVar,
|
||||
SkString* coverageVar,
|
||||
GrGLShaderBuilder* segments) const;
|
||||
|
||||
static bool CompileShaders(const GrGLContextInfo& gl,
|
||||
|
@ -372,7 +372,7 @@ private:
|
|||
// links the program
|
||||
bool bindOutputsAttribsAndLinkProgram(
|
||||
const GrGLContextInfo& gl,
|
||||
GrStringBuilder texCoordAttrNames[GrDrawState::kMaxTexCoords],
|
||||
SkString texCoordAttrNames[GrDrawState::kMaxTexCoords],
|
||||
bool bindColorOut,
|
||||
bool bindDualSrcOut,
|
||||
CachedData* programData) const;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "GrGLShaderBuilder.h"
|
||||
#include "GrGLShaderVar.h"
|
||||
#include "GrGLSL.h"
|
||||
#include "GrStringBuilder.h"
|
||||
|
||||
struct GrGLInterface;
|
||||
class GrGLTexture;
|
||||
|
@ -51,7 +50,7 @@ public:
|
|||
/** Create any uniforms or varyings the vertex shader requires. */
|
||||
virtual void setupVariables(GrGLShaderBuilder* state, int stage);
|
||||
|
||||
/** Appends vertex code to the appropriate GrStringBuilder
|
||||
/** Appends vertex code to the appropriate SkString
|
||||
on the state.
|
||||
The code will be inside an otherwise-empty block.
|
||||
Vertex shader input is a vec2 of coordinates, which may
|
||||
|
@ -60,7 +59,7 @@ public:
|
|||
virtual void emitVS(GrGLShaderBuilder* state,
|
||||
const char* vertexCoords) = 0;
|
||||
|
||||
/** Appends fragment code to the appropriate GrStringBuilder
|
||||
/** Appends fragment code to the appropriate SkString
|
||||
on the state.
|
||||
The code will be inside an otherwise-empty block.
|
||||
Fragment shader inputs are a vec2 of coordinates, one texture,
|
||||
|
|
|
@ -73,7 +73,7 @@ void GrGLShaderBuilder::computeModulate(const char* fsInColor) {
|
|||
|
||||
void GrGLShaderBuilder::setupTextureAccess(SamplerMode samplerMode,
|
||||
int stageNum) {
|
||||
GrStringBuilder retval;
|
||||
SkString retval;
|
||||
|
||||
fTexFunc = "texture2D";
|
||||
switch (samplerMode) {
|
||||
|
@ -161,7 +161,7 @@ void GrGLShaderBuilder::addVarying(GrSLType type,
|
|||
*vsOutName = fVSOutputs.back().getName().c_str();
|
||||
}
|
||||
// input to FS comes either from VS or GS
|
||||
const GrStringBuilder* fsName;
|
||||
const SkString* fsName;
|
||||
if (fUsesGS) {
|
||||
// if we have a GS take each varying in as an array
|
||||
// and output as non-array.
|
||||
|
@ -193,7 +193,7 @@ void GrGLShaderBuilder::addVarying(GrSLType type,
|
|||
int stageNum,
|
||||
const char** vsOutName,
|
||||
const char** fsInName) {
|
||||
GrStringBuilder nameWithStage(name);
|
||||
SkString nameWithStage(name);
|
||||
nameWithStage.appendS32(stageNum);
|
||||
this->addVarying(type, nameWithStage.c_str(), vsOutName, fsInName);
|
||||
}
|
||||
|
|
|
@ -92,21 +92,20 @@ public:
|
|||
const char** vsOutName = NULL,
|
||||
const char** fsInName = NULL);
|
||||
|
||||
|
||||
GrStringBuilder fHeader; // VS+FS, GLSL version, etc
|
||||
SkString fHeader; // VS+FS, GLSL version, etc
|
||||
VarArray fVSUnis;
|
||||
VarArray fVSAttrs;
|
||||
VarArray fVSOutputs;
|
||||
VarArray fGSInputs;
|
||||
VarArray fGSOutputs;
|
||||
VarArray fFSInputs;
|
||||
GrStringBuilder fGSHeader; // layout qualifiers specific to GS
|
||||
SkString fGSHeader; // layout qualifiers specific to GS
|
||||
VarArray fFSUnis;
|
||||
VarArray fFSOutputs;
|
||||
GrStringBuilder fFSFunctions;
|
||||
GrStringBuilder fVSCode;
|
||||
GrStringBuilder fGSCode;
|
||||
GrStringBuilder fFSCode;
|
||||
SkString fFSFunctions;
|
||||
SkString fVSCode;
|
||||
SkString fGSCode;
|
||||
SkString fFSCode;
|
||||
bool fUsesGS;
|
||||
|
||||
/// Per-stage settings - only valid while we're inside
|
||||
|
@ -119,12 +118,12 @@ public:
|
|||
/// True if fSampleCoords is an expression; false if it's a bare
|
||||
/// variable name
|
||||
bool fComplexCoord;
|
||||
GrStringBuilder fSampleCoords;
|
||||
SkString fSampleCoords;
|
||||
|
||||
GrStringBuilder fSwizzle;
|
||||
GrStringBuilder fModulate;
|
||||
SkString fSwizzle;
|
||||
SkString fModulate;
|
||||
|
||||
GrStringBuilder fTexFunc;
|
||||
SkString fTexFunc;
|
||||
|
||||
//@}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "GrGLContextInfo.h"
|
||||
#include "GrGLSL.h"
|
||||
#include "GrStringBuilder.h"
|
||||
#include "SkString.h"
|
||||
|
||||
#define USE_UNIFORM_FLOAT_ARRAYS true
|
||||
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
*/
|
||||
void set(GrSLType type,
|
||||
TypeModifier typeModifier,
|
||||
const GrStringBuilder& name,
|
||||
const SkString& name,
|
||||
bool emitPrecision = false,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
fType = type;
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
*/
|
||||
void set(GrSLType type,
|
||||
TypeModifier typeModifier,
|
||||
const GrStringBuilder& name,
|
||||
const SkString& name,
|
||||
int count,
|
||||
bool specifyPrecision = false,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
|
@ -154,16 +154,16 @@ public:
|
|||
/**
|
||||
* Access the var name as a writable string
|
||||
*/
|
||||
GrStringBuilder* accessName() { return &fName; }
|
||||
SkString* accessName() { return &fName; }
|
||||
/**
|
||||
* Set the var name
|
||||
*/
|
||||
void setName(const GrStringBuilder& n) { fName = n; }
|
||||
void setName(const SkString& n) { fName = n; }
|
||||
void setName(const char* n) { fName = n; }
|
||||
/**
|
||||
* Get the var name.
|
||||
*/
|
||||
const GrStringBuilder& getName() const { return fName; }
|
||||
const SkString& getName() const { return fName; }
|
||||
|
||||
/**
|
||||
* Get the type of the var
|
||||
|
@ -189,7 +189,7 @@ public:
|
|||
/**
|
||||
* Write a declaration of this variable to out.
|
||||
*/
|
||||
void appendDecl(const GrGLContextInfo& gl, GrStringBuilder* out) const {
|
||||
void appendDecl(const GrGLContextInfo& gl, SkString* out) const {
|
||||
if (this->getTypeModifier() != kNone_TypeModifier) {
|
||||
out->append(TypeModifierString(this->getTypeModifier(),
|
||||
gl.glslGeneration()));
|
||||
|
@ -242,14 +242,14 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void appendArrayAccess(int index, GrStringBuilder* out) const {
|
||||
void appendArrayAccess(int index, SkString* out) const {
|
||||
out->appendf("%s[%d]%s",
|
||||
this->getName().c_str(),
|
||||
index,
|
||||
fUseUniformFloatArrays ? "" : ".x");
|
||||
}
|
||||
|
||||
void appendArrayAccess(const char* indexName, GrStringBuilder* out) const {
|
||||
void appendArrayAccess(const char* indexName, SkString* out) const {
|
||||
out->appendf("%s[%s]%s",
|
||||
this->getName().c_str(),
|
||||
indexName,
|
||||
|
@ -278,7 +278,7 @@ private:
|
|||
|
||||
GrSLType fType;
|
||||
TypeModifier fTypeModifier;
|
||||
GrStringBuilder fName;
|
||||
SkString fName;
|
||||
int fCount;
|
||||
bool fEmitPrecision;
|
||||
/// Work around driver bugs on some hardware that don't correctly
|
||||
|
|
Загрузка…
Ссылка в новой задаче