<commit_before>import { now, isNil, isArrayHasData, isSVG, IS_NODE, loadImage, hasOwn } from '../../core/util';
import Class from '../../core/Class';
import Browser from '../../core/Browser';
import Promise from '../../core/Promise';
import Canvas2D from '../../core/Canvas';
import Point from '../../geo/Point';

/**
 * @classdesc
 * Base Class to render layer on HTMLCanvasElement
 * @abstract
 * @protected
 * @memberOf renderer
 * @extends Class
 */
class CanvasRenderer extends Class {

    /**
     * @param  {Layer} layer the layer to render
     */
    constructor(layer) {
        super();
        this.layer = layer;
        this._painted = false;
        this._drawTime = 0;
        this.setToRedraw();
    }


    /**
     * Render the layer.
     * Call checkResources
     */
    render(framestamp) {
        this.prepareRender();
        if (!this.getMap() || !this.layer.isVisible()) {
            return;
        }
        if (!this.resources) {
            /* eslint-disable no-use-before-define */
            this.resources = new ResourceCache();
            /* eslint-enable no-use-before-define */
        }
        this.checkAndDraw(this._tryToDraw, framestamp);
    }

    checkAndDraw(drawFn, ...args) {
        if (this.checkResources) {
            const resources = this.checkResources();
            if (resources.length > 0) {
                this._loadingResource = true;
                this.loadResources(resources).then(() => {
                    this._loadingResource = false;
                    if (this.layer) {
                        /**
                         * resourceload event, fired when external resources of the layer complete loading.
                         *
                         * @event Layer#resourceload
                         * @type {Object}
                         * @property {String} type     - resourceload
                         * @property {Layer} target    - layer
                         */
                        this.layer.fire('resourceload');
                        this.setToRedraw();
                    }<commit_msg>set this._toRedraw to false in checkAndDraw<commit_after>import { now, isNil, isArrayHasData, isSVG, IS_NODE, loadImage, hasOwn } from '../../core/util';
import Class from '../../core/Class';
import Browser from '../../core/Browser';
import Promise from '../../core/Promise';
import Canvas2D from '../../core/Canvas';
import Point from '../../geo/Point';

/**
 * @classdesc
 * Base Class to render layer on HTMLCanvasElement
 * @abstract
 * @protected
 * @memberOf renderer
 * @extends Class
 */
class CanvasRenderer extends Class {

    /**
     * @param  {Layer} layer the layer to render
     */
    constructor(layer) {
        super();
        this.layer = layer;
        this._painted = false;
        this._drawTime = 0;
        this.setToRedraw();
    }


    /**
     * Render the layer.
     * Call checkResources
     */
    render(framestamp) {
        this.prepareRender();
        if (!this.getMap() || !this.layer.isVisible()) {
            return;
        }
        if (!this.resources) {
            /* eslint-disable no-use-before-define */
            this.resources = new ResourceCache();
            /* eslint-enable no-use-before-define */
        }
        this.checkAndDraw(this._tryToDraw, framestamp);
    }

    checkAndDraw(drawFn, ...args) {
        this._toRedraw = false;
        if (this.checkResources) {
            const resources = this.checkResources();
            if (resources.length > 0) {
                this._loadingResource = true;
                this.loadResources(resources).then(() => {
                    this._loadingResource = false;
                    if (this.layer) {
                        /**
                         * resourceload event, fired when external resources of the layer complete loading.
                         *
                         * @event Layer#resourceload
                         * @type {Object}
                         * @property {String} type     - resourceload
                         * @property {Layer} target    - layer
                         */
                        this.layer.fire('resourceload');
                        this.setToRedraw();
                    }
{'fraction_non_alphanumeric': 0.12318501170960187, 'fraction_numerical': 0.001405152224824356, 'mean_word_length': 1.470213996529786, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2216134', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1080, 'n_words': 263}