Lines Matching full:shader
428 // program for A8, unmodulated, texture w/o shader (black text/path textures) is equivalent
462 String8 shader(gVS_Header_Attributes);
464 shader.append(gVS_Header_Attributes_TexCoords);
467 shader.append(gVS_Header_Attributes_VertexAlphaParameters);
470 shader.append(gVS_Header_Attributes_Colors);
473 shader.append(gVS_Header_Uniforms);
475 shader.append(gVS_Header_Uniforms_TextureTransform);
478 shader.append(gVS_Header_Uniforms_HasGradient);
481 shader.append(gVS_Header_Uniforms_HasBitmap);
484 shader.append(gVS_Header_Uniforms_HasRoundRectClip);
488 shader.append(gVS_Header_Varyings_HasTexture);
491 shader.append(gVS_Header_Varyings_HasVertexAlpha);
494 shader.append(gVS_Header_Varyings_HasColors);
497 shader.append(gVS_Header_Varyings_HasGradient[gradientIndex(description)]);
500 shader.append(gVS_Header_Varyings_HasBitmap);
503 shader.append(gVS_Header_Varyings_HasRoundRectClip);
506 // Begin the shader
507 shader.append(gVS_Main); {
509 shader.append(gVS_Main_OutTransformedTexCoords);
511 shader.append(gVS_Main_OutTexCoords);
514 shader.append(gVS_Main_VertexAlpha);
517 shader.append(gVS_Main_OutColors);
520 shader.append(gVS_Main_OutBitmapTexCoords);
523 shader.append(gVS_Main_Position);
525 shader.append(gVS_Main_OutGradient[gradientIndex(description)]);
528 shader.append(gVS_Main_HasRoundRectClip);
531 // End the shader
532 shader.append(gVS_Footer);
534 PROGRAM_LOGD("*** Generated vertex shader:\n\n%s", shader.string());
536 return shader;
539 static bool shaderOp(const ProgramDescription& description, String8& shader,
543 shader.append(snippets[op]);
548 String8 shader;
552 shader.append(gFS_Header_Extension_FramebufferFetch);
555 shader.append(gFS_Header_Extension_ExternalTexture);
558 shader.append(gFS_Header);
562 shader.append(gVS_Header_Varyings_HasTexture);
565 shader.append(gVS_Header_Varyings_HasVertexAlpha);
568 shader.append(gVS_Header_Varyings_HasColors);
571 shader.append(gVS_Header_Varyings_HasGradient[gradientIndex(description)]);
574 shader.append(gVS_Header_Varyings_HasBitmap);
577 shader.append(gVS_Header_Varyings_HasRoundRectClip);
586 shader.append(gFS_Uniforms_Color);
590 shader.append(gFS_Uniforms_TextureSampler);
592 shader.append(gFS_Uniforms_ExternalTextureSampler);
595 shader.appendFormat(gFS_Uniforms_GradientSampler[description.isSimpleGradient],
599 shader.append(gFS_Uniforms_Gamma);
602 shader.append(gFS_Uniforms_HasRoundRectClip);
624 shader.append(gFS_Fast_SingleColor);
628 shader.append(gFS_Fast_SingleTexture);
630 shader.append(gFS_Fast_SingleModulateTexture);
636 shader.append(gFS_Fast_SingleA8Texture_ApplyGamma);
638 shader.append(gFS_Fast_SingleA8Texture);
642 shader.append(gFS_Fast_SingleModulateA8Texture_ApplyGamma);
644 shader.append(gFS_Fast_SingleModulateA8Texture);
650 shader.appendFormat(gFS_Fast_SingleGradient[description.isSimpleGradient],
653 shader.appendFormat(gFS_Fast_SingleModulateGradient[description.isSimpleGradient],
662 PROGRAM_LOGD("*** Generated fragment shader:\n\n");
663 printLongString(shader);
666 return shader;
671 shader.append(gFS_Uniforms_BitmapSampler);
673 shader.append(gFS_Uniforms_ColorOp[description.colorOp]);
677 generateBlend(shader, "blendShaders", description.shadersMode);
680 generateBlend(shader, "blendColors", description.colorMode);
683 generateBlend(shader, "blendFramebuffer", description.framebufferMode);
686 generateTextureWrap(shader, description.bitmapWrapS, description.bitmapWrapT);
689 // Begin the shader
690 shader.append(gFS_Main); {
695 shader.append(gFS_Main_FetchA8Texture[modulateOp * 2 +
699 shader.append(gFS_Main_FetchTexture[modulateOp]);
703 shader.append(gFS_Main_FetchColor);
707 shader.append(gFS_Main_FetchGradient[gradientIndex(description)]);
708 shader.appendFormat(gFS_Main_AddDitherToGradient, gFS_Main_Dither[mHasES3]);
712 shader.append(gFS_Main_FetchBitmap);
714 shader.append(gFS_Main_FetchBitmapNpot);
721 shader.append(gFS_Main_BlendShadersBG);
723 shader.append(gFS_Main_BlendShadersGB);
725 applyModulate = shaderOp(description, shader, modulateOp,
729 applyModulate = shaderOp(description, shader, modulateOp,
732 applyModulate = shaderOp(description, shader, modulateOp,
738 shader.append(gFS_Main_ModulateColor);
742 shader.append(gFS_Main_ApplyColorOp[description.colorOp]);
746 shader.append(gFS_Main_ApplyVertexAlphaShadowInterp);
748 shader.append(gFS_Main_ApplyVertexAlphaLinearInterp);
754 shader.append(gFS_Main_FragColor);
756 shader.append(!description.swapSrcDst ?
760 shader.append(gFS_Main_FragColor_HasColors);
763 shader.append(gFS_Main_FragColor_HasRoundRectClip);
766 shader.append(gFS_Main_DebugHighlight);
769 // End the shader
770 shader.append(gFS_Footer);
773 PROGRAM_LOGD("*** Generated fragment shader:\n\n");
774 printLongString(shader);
777 return shader;
780 void ProgramCache::generateBlend(String8& shader, const char* name, SkXfermode::Mode mode) {
781 shader.append("\nvec4 ");
782 shader.append(name);
783 shader.append("(vec4 src, vec4 dst) {\n");
784 shader.append(" ");
785 shader.append(gBlendOps[mode]);
786 shader.append("}\n");
789 void ProgramCache::generateTextureWrap(String8& shader, GLenum wrapS, GLenum wrapT) {
790 shader.append("\nhighp vec2 wrap(highp vec2 texCoords) {\n");
792 shader.append(" highp float xMod2 = mod(texCoords.x, 2.0);\n");
793 shader.append(" if (xMod2 > 1.0) xMod2 = 2.0 - xMod2;\n");
796 shader.append(" highp float yMod2 = mod(texCoords.y, 2.0);\n");
797 shader.append(" if (yMod2 > 1.0) yMod2 = 2.0 - yMod2;\n");
799 shader.append(" return vec2(");
802 shader.append("texCoords.x");
805 shader.append("mod(texCoords.x, 1.0)");
808 shader.append("xMod2");
811 shader.append(", ");
814 shader.append("texCoords.y");
817 shader.append("mod(texCoords.y, 1.0)");
820 shader.append("yMod2");
823 shader.append(");\n");
824 shader.append("}\n");
827 void ProgramCache::printLongString(const String8& shader) const {
830 const char* str = shader.string();
831 while ((index = shader.find("\n", index)) > -1) {