<commit_before>/**
 * @fileoverview WebGL based MapRenderer drawing all the supplied layers in OpenGL
 */

goog.provide('ol.renderer.WebGL');

goog.require('ol.renderer.MapRenderer');
goog.require('ol.layer.Layer');
goog.require('ol.Loc');

/**
 * Initialization of the native WebGL renderer (canvas, context, layers)
 * @constructor
 * @param {!Element} target
 * @extends {ol.renderer.MapRenderer}
 */
ol.renderer.WebGL = function(target) {
    
    /** @type {!Element} */
    var canvasEl = goog.dom.createDom('canvas',
        {style: 'width:100%;height:100%;'});


    var upgradeRedirector = function() {
      /** @type {!Element} */
      var upgradeLinkEl = goog.dom.createDom('a',
          {style: 'font-size:110%;display:block;width:100%;top:50%;' +
                'position:relative;text-align:center;color:#800000;' +
                'text-shadow:rgba(0,0,0,0.4) 0 0 6px;',
            href: 'http://get.webgl.org/'
          }, 'You need a WebGL-enabled browser to run this application.');
      goog.dom.append(/** @type {!Element} */ (divEl), upgradeLinkEl);
    };

    /**
     * @type {!we.gl.Context}
     */
    this.context = new we.gl.Context(canvasEl, null, upgradeRedirector);

    if (!goog.isDefAndNotNull(this.context)) return;
    
    goog.base(this, target);
    
    /**
     * @type Array.<ol.renderer.LayerRenderer>
     * @private
     */
    this.renderers_ = [];
    
};

goog.inherits(ol.renderer.WebGL, ol.renderer.MapRenderer);

/**
 * @param {Array.<ol.layer.Layer>} layers
 * @param {ol.Loc} center
 * @param {number} resolution
 */
ol.renderer.WebGL.prototype.draw = function(layers, center, resolution) {
};

/**
 * @param {ol.layer.Layer} layer
 */
ol.renderer.WebGL.prototype.getRenderer = function(layer) {
    function finder(candidate) {
        return candidate.getLayer() === layer;
    }
    return goog.array.find(this.renderers_, finder);
};

/**
 * @param {ol.layer.Layer} layer
 */
ol.renderer.WebGL.prototype.createRenderer = function(layer) {
};

/**
 * List of preferred renderer types.  Layer renderers have a getType method
 * that returns a string describing their type.  This list determines the 
 * preferences for picking a layer renderer.
 *<commit_msg>More complete constructor of the WebGL MapRenderer.<commit_after>/**
 * @fileoverview WebGL based MapRenderer drawing all the supplied layers in OpenGL
 */

goog.provide('ol.renderer.WebGL');

goog.require('ol.renderer.MapRenderer');
goog.require('ol.layer.Layer');
goog.require('ol.Loc');


/**
 * Initialization of the native WebGL renderer (canvas, context, layers)
 * @constructor
 * @param {!Element} target
 * @extends {ol.renderer.MapRenderer}
 */
ol.renderer.WebGL = function(target) {
    
    /**
     * @private
     * @type {!Element}
     */
    this.canvas_ = goog.dom.createDom('canvas', 'ol-renderer-webgl-canvas'}); // Suppose to have: style: 'width:100%;height:100%;'
    
    /**
     * @private
     * @type {WebGLRenderingContext}
     */
    this.gl_ = (canvas.getContext('experimental-webgl', {
        'alpha': false,
        'depth': false,
        'antialias': true,
        'stencil': false,
        'preserveDrawingBuffer': false
    }));
    goog.asserts.assert(!goog.isNull(this.gl_), "The WebGL is not supported on your browser. Check http://get.webgl.org/");
    var gl = this.gl_;

    goog.dom.append(target, this.canvas_);

    var clearColor = opt_bgColor || [0, 0, 0];
    gl.clearColor(clearColor[0], clearColor[1], clearColor[2], 1);
    gl.disable(goog.webgl.DEPTH_TEST);
    gl.disable(goog.webgl.SCISSOR_TEST);
    gl.disable(goog.webgl.CULL_FACE);
    
    goog.base(this, target);
    
    /**
     * @type Array.<ol.renderer.LayerRenderer>
     * @private
     */
    this.renderers_ = [];
};

goog.inherits(ol.renderer.WebGL, ol.renderer.MapRenderer);

/** 
 * Determine if this renderer type is supported in this environment.
 * A static method.
 * @returns {boolean} This renderer is supported.
 */
ol.renderer.WebGL.isSupported = function() {
    return true;
};

/**
 * @param {Array.<ol.layer.Layer>} layers
 * @param {ol.Loc} center
 * @param {number} resolution
 */
ol.renderer.WebGL.prototype.draw = function(layers, center, resolution) {
};

/**
 * @param {ol.layer.Layer} layer
 */
ol.renderer.WebGL.prototype.getRenderer = function(layer) {
    function finder(candidate) {
        return candidate.getLayer() === layer;
    }
    return goog.array.find(this.renderers_, finder);
};

/**
 * @param {ol.layer.Layer} layer
 */
ol.renderer.WebGL.prototype.createRenderer = function(layer) {
};

/**
 * List of preferred renderer types.  Layer renderers have a getType method
 * that returns a string describing their type.  This list determines the 
 * preferences for picking a layer renderer.
 *
{'fraction_non_alphanumeric': 0.15755290173894826, 'fraction_numerical': 0.008589985334171381, 'mean_word_length': 3.2135922330097086, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7025015', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1530, 'n_words': 332}