Lines Matching full:shader
470 String8 shader(gVS_Header_Attributes);
472 shader.append(gVS_Header_Attributes_TexCoords);
476 shader.append(gVS_Header_Attributes_AAVertexShapeParameters);
478 shader.append(gVS_Header_Attributes_AALineParameters);
482 shader.append(gVS_Header_Uniforms);
484 shader.append(gVS_Header_Uniforms_TextureTransform);
487 shader.append(gVS_Header_Uniforms_HasGradient[description.gradientType]);
490 shader.append(gVS_Header_Uniforms_HasBitmap);
493 shader.append(gVS_Header_Uniforms_IsPoint);
497 shader.append(gVS_Header_Varyings_HasTexture);
501 shader.append(gVS_Header_Varyings_IsAAVertexShape);
503 shader.append(gVS_Header_Varyings_IsAALine);
507 shader.append(gVS_Header_Varyings_HasGradient[gradientIndex(description)]);
510 shader.append(description.isPoint ?
515 // Begin the shader
516 shader.append(gVS_Main); {
518 shader.append(gVS_Main_OutTransformedTexCoords);
520 shader.append(gVS_Main_OutTexCoords);
524 shader.append(gVS_Main_AAVertexShape);
526 shader.append(gVS_Main_AALine);
530 shader.append(description.isPoint ?
535 shader.append(gVS_Main_PointSize);
538 shader.append(gVS_Main_Position);
540 shader.append(gVS_Main_OutGradient[gradientIndex(description)]);
543 // End the shader
544 shader.append(gVS_Footer);
546 PROGRAM_LOGD("*** Generated vertex shader:\n\n%s", shader.string());
548 return shader;
551 static bool shaderOp(const ProgramDescription& description, String8& shader,
555 shader.append(snippets[op]);
560 String8 shader;
564 shader.append(gFS_Header_Extension_FramebufferFetch);
567 shader.append(gFS_Header_Extension_ExternalTexture);
570 shader.append(gFS_Header);
574 shader.append(gVS_Header_Varyings_HasTexture);
578 shader.append(gVS_Header_Varyings_IsAAVertexShape);
580 shader.append(gVS_Header_Varyings_IsAALine);
584 shader.append(gVS_Header_Varyings_HasGradient[gradientIndex(description)]);
587 shader.append(description.isPoint ?
598 shader.append(gFS_Uniforms_Color);
602 shader.append(gFS_Uniforms_TextureSampler);
604 shader.append(gFS_Uniforms_ExternalTextureSampler);
607 shader.append(gFS_Uniforms_AALine);
610 shader.append(gFS_Uniforms_GradientSampler[gradientIndex(description)]);
613 shader.append(gFS_Header_Uniforms_PointHasBitmap);
616 shader.append(gFS_Uniforms_Gamma);
635 shader.append(gFS_Fast_SingleColor);
639 shader.append(gFS_Fast_SingleTexture);
641 shader.append(gFS_Fast_SingleModulateTexture);
647 shader.append(gFS_Fast_SingleA8Texture_ApplyGamma);
649 shader.append(gFS_Fast_SingleA8Texture);
653 shader.append(gFS_Fast_SingleModulateA8Texture_ApplyGamma);
655 shader.append(gFS_Fast_SingleModulateA8Texture);
661 shader.append(gFS_Fast_SingleGradient[description.isSimpleGradient]);
663 shader.append(gFS_Fast_SingleModulateGradient[description.isSimpleGradient]);
671 PROGRAM_LOGD("*** Generated fragment shader:\n\n");
672 printLongString(shader);
675 return shader;
680 shader.append(gFS_Uniforms_BitmapSampler);
682 shader.append(gFS_Uniforms_ColorOp[description.colorOp]);
686 generateBlend(shader, "blendShaders", description.shadersMode);
689 generateBlend(shader, "blendColors", description.colorMode);
692 generateBlend(shader, "blendFramebuffer", description.framebufferMode);
695 generateTextureWrap(shader, description.bitmapWrapS, description.bitmapWrapT);
698 // Begin the shader
699 shader.append(gFS_Main); {
704 shader.append(gFS_Main_FetchA8Texture[modulateOp * 2 +
708 shader.append(gFS_Main_FetchTexture[modulateOp]);
712 shader.append(gFS_Main_FetchColor);
716 shader.append(gFS_Main_FetchGradient[gradientIndex(description)]);
717 shader.append(gFS_Main_AddDitherToGradient);
721 shader.append(gFS_Main_PointBitmapTexCoords);
724 shader.append(gFS_Main_FetchBitmap);
726 shader.append(gFS_Main_FetchBitmapNpot);
733 shader.append(gFS_Main_BlendShadersBG);
735 shader.append(gFS_Main_BlendShadersGB);
737 applyModulate = shaderOp(description, shader, modulateOp,
741 applyModulate = shaderOp(description, shader, modulateOp,
744 applyModulate = shaderOp(description, shader, modulateOp,
750 shader.append(gFS_Main_ModulateColor);
754 shader.append(gFS_Main_ApplyColorOp[description.colorOp]);
758 shader.append(gFS_Main_AccountForAAVertexShape);
760 shader.append(gFS_Main_AccountForAALine);
766 shader.append(gFS_Main_FragColor);
768 shader.append(!description.swapSrcDst ?
772 // End the shader
773 shader.append(gFS_Footer);
776 PROGRAM_LOGD("*** Generated fragment shader:\n\n");
777 printLongString(shader);
780 return shader;
783 void ProgramCache::generateBlend(String8& shader, const char* name, SkXfermode::Mode mode) {
784 shader.append("\nvec4 ");
785 shader.append(name);
786 shader.append("(vec4 src, vec4 dst) {\n");
787 shader.append(" ");
788 shader.append(gBlendOps[mode]);
789 shader.append("}\n");
792 void ProgramCache::generateTextureWrap(String8& shader, GLenum wrapS, GLenum wrapT) {
793 shader.append("\nhighp vec2 wrap(highp vec2 texCoords) {\n");
795 shader.append(" highp float xMod2 = mod(texCoords.x, 2.0);\n");
796 shader.append(" if (xMod2 > 1.0) xMod2 = 2.0 - xMod2;\n");
799 shader.append(" highp float yMod2 = mod(texCoords.y, 2.0);\n");
800 shader.append(" if (yMod2 > 1.0) yMod2 = 2.0 - yMod2;\n");
802 shader.append(" return vec2(");
805 shader.append("texCoords.x");
808 shader.append("mod(texCoords.x, 1.0)");
811 shader.append("xMod2");
814 shader.append(", ");
817 shader.append("texCoords.y");
820 shader.append("mod(texCoords.y, 1.0)");
823 shader.append("yMod2");
826 shader.append(");\n");
827 shader.append("}\n");
830 void ProgramCache::printLongString(const String8& shader) const {
833 const char* str = shader.string();
834 while ((index = shader.find("\n", index)) > -1) {