<commit_before>/**
 * @author <NAME> http://matgroves.com/ @Doormat23
 */

/**
* @class TilemapShader
* @constructor
* @param gl {WebGLContext} the current WebGL drawing context
*/
PIXI.TilemapShader = function(gl)
{
    /**
     * @property _UID
     * @type Number
     * @private
     */
    this._UID = PIXI._UID++;
    
    /**
     * @property gl
     * @type WebGLContext
     */
    this.gl = gl;

    /**
     * The WebGL program.
     * @property program
     * @type Any
     */
    this.program = null;

    this.fragmentSrc = [
        "  precision lowp float;",
        "  uniform sampler2D uImageSampler;",
        "  uniform float uAlpha;",
        "  varying vec2 vTexCoord;",
        "  void main(void) {",
        "    gl_FragColor = texture2D(uImageSampler, vTexCoord) * uAlpha;",
        "  }"
        ];

    this.vertexSrc = [
        "  precision lowp float;",
        "  uniform vec2 uScrollOffset;",
        "  attribute vec4 aPosition;",
        "  varying vec2 vTexCoord;",
        "  void main(void) {",
        "    gl_Position.zw = vec2(1, 1);",
        "    gl_Position.xy = aPosition.xy - uScrollOffset;",
        "    vTexCoord = aPosition.zw;",
        "  }"
        ];

    /**
     * A local texture counter for multi-texture shaders.
     * @property textureCount
     * @type Number
     */
    this.textureCount = 0;

    this.init();
};


PIXI.TilemapShader.prototype.constructor = PIXI.TilemapShader;

/**
* Initialises the shader.
* 
* @method init
*/
PIXI.TilemapShader.prototype.init = function()
{
    var gl = this.gl;

    var program = PIXI.compileProgram(gl, this.vertexSrc, this.fragmentSrc);
    gl.useProgram(program);

    // get and store the attributes
    this.aPosition = gl.getAttribLocation(program, 'aPosition');
    this.uSampler = gl.getUniformLocation(program, 'uImageSampler');
    this.uScrollOffset = gl.getUniformLocation(program, 'uScrollOffset');
    this.uAlpha = gl.getUniformLocation(program, 'uAlpha');

    this.attributes = [this.aPosition, this.uSampler];
    this.uniforms = [this.uScrollOffset, this.uAlpha];

    this.program = program;
};

/**
* Destroys the shader.
* <commit_msg>Modify Tile Shader to produce scaled layers that look identical to the Canvas renderer scaling (add uCentreOffset, scale the drawing coordinates, subtract uCentreOffset).<commit_after>/**
 * @author <NAME> http://matgroves.com/ @Doormat23
 */

/**
* @class TilemapShader
* @constructor
* @param gl {WebGLContext} the current WebGL drawing context
*/
PIXI.TilemapShader = function(gl)
{
    /**
     * @property _UID
     * @type Number
     * @private
     */
    this._UID = PIXI._UID++;
    
    /**
     * @property gl
     * @type WebGLContext
     */
    this.gl = gl;

    /**
     * The WebGL program.
     * @property program
     * @type Any
     */
    this.program = null;

    this.fragmentSrc = [
        "  precision lowp float;",
        "  uniform sampler2D uImageSampler;",
        "  uniform float uAlpha;",
        "  varying vec2 vTexCoord;",
        "  void main(void) {",
        "    gl_FragColor = texture2D(uImageSampler, vTexCoord) * uAlpha;",
        "  }"
        ];

    this.vertexSrc = [
        "  precision lowp float;",
        "  uniform vec2 uCentreOffset;",
        "  uniform vec2 uScale;",
        "  attribute vec4 aPosition;",
        "  varying vec2 vTexCoord;",
        "  void main(void) {",
        "    gl_Position.zw = vec2(1, 1);",
        "    gl_Position.xy = (aPosition.xy + uCentreOffset) * uScale - uCentreOffset;",
        "    vTexCoord = aPosition.zw;",
        "  }"
        ];

    /**
     * A local texture counter for multi-texture shaders.
     * @property textureCount
     * @type Number
     */
    this.textureCount = 0;

    this.init();
};


PIXI.TilemapShader.prototype.constructor = PIXI.TilemapShader;

/**
* Initialises the shader.
* 
* @method init
*/
PIXI.TilemapShader.prototype.init = function()
{
    var gl = this.gl;

    var program = PIXI.compileProgram(gl, this.vertexSrc, this.fragmentSrc);
    gl.useProgram(program);

    // get and store the attributes
    this.aPosition = gl.getAttribLocation(program, 'aPosition');
    this.uSampler = gl.getUniformLocation(program, 'uImageSampler');
    this.uCentreOffset = gl.getUniformLocation(program, 'uCentreOffset');
    this.uAlpha = gl.getUniformLocation(program, 'uAlpha');
    this.uScale = gl.getUniformLocation(program, 'uScale');

    this.attributes = [this.aPosition, this.uSampler];
    this.uniforms = [this.uCentreOffset, this.uAlpha, this.uScale];

    this.program = program;
};

/**
* Destroys the shader.
* 
{'fraction_non_alphanumeric': 0.13347778981581798, 'fraction_numerical': 0.005417118093174431, 'mean_word_length': 2.4167283493708362, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4817179', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1498, 'n_words': 315}