<commit_before>package org.andengine.opengl.shader;

import java.util.ArrayList;


/**
 * (c) 2011 Zynga Inc.
 * 
 * @author <NAME>
 * @since 12:55:26 - 11.08.2011
 */
public class ShaderProgramManager {
	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Fields
	// ===========================================================

	private static final ArrayList<ShaderProgram> sShaderProgramsManaged = new ArrayList<ShaderProgram>();

	// ===========================================================
	// Constructors
	// ===========================================================

	private ShaderProgramManager() {

	}

	// ===========================================================
	// Getter & Setter
	// ===========================================================

	// ===========================================================
	// Methods for/from SuperClass/Interfaces
	// ===========================================================

	// ===========================================================
	// Methods
	// ===========================================================

	public synchronized static void onCreate() {
		ShaderProgramManager.loadShaderProgram(PositionColorTextureCoordinatesShaderProgram.getInstance());
		ShaderProgramManager.loadShaderProgram(PositionTextureCoordinatesShaderProgram.getInstance());
		ShaderProgramManager.loadShaderProgram(PositionColorShaderProgram.getInstance());
		ShaderProgramManager.loadShaderProgram(PositionTextureCoordinatesTextureSelectShaderProgram.getInstance());
		ShaderProgramManager.loadShaderProgram(PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.getInstance());
	}

	public static synchronized void onDestroy() {
		final ArrayList<ShaderProgram> managedShaderPrograms = ShaderProgramManager.sShaderProgramsManaged;
		for(int i = managedShaderPrograms.size() - 1; i >= 0; i--) {
			managedShaderPrograms.get(i).setCompiled(false);
		}

		ShaderProgramManager.sShaderProgramsManaged.clear();
	}

	public static synchronized void loadShaderProgram(final ShaderProgram pShaderProgram) {
		if(pShaderProgram == null) {
			throw new IllegalArgumentException("pShaderProgram must not be null!");
		}
		ShaderProgramManager.sShaderProgramsManaged.add(pShaderProgram);
	}

	public static void loadShaderPrograms(final ShaderProgram ... pShaderPrograms) {
		for(int i = pShaderPrograms.length - 1; i >= 0; i--) {
			ShaderProgramManager.loadShaderProgram(pShaderPrograms[i]);
		}
	}

	public static synchronized void onReload() {
		final ArrayList<ShaderProgram> managedShaderPrograms = ShaderProgramManager.sShaderProgramsManaged;
		for(int i = managedShaderPrograms.size() - 1; i >= 0; i--) {
			managedShaderPrograms.get(i).setCompiled(false);
		}
	}

	// ===========================================================
	// Inner and Anonymous Classes
	// ===========================================================
}
<commit_msg>When loading a ShaderProgram to the ShaderProgramManager that is already compiled, a WARNING is logged and the ShaderProgram gets recompiled.<commit_after>package org.andengine.opengl.shader;

import java.util.ArrayList;

import org.andengine.util.debug.Debug;


/**
 * (c) 2011 Zynga Inc.
 * 
 * @author <NAME>
 * @since 12:55:26 - 11.08.2011
 */
public class ShaderProgramManager {
	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Fields
	// ===========================================================

	private static final ArrayList<ShaderProgram> sShaderProgramsManaged = new ArrayList<ShaderProgram>();

	// ===========================================================
	// Constructors
	// ===========================================================

	private ShaderProgramManager() {

	}

	// ===========================================================
	// Getter & Setter
	// ===========================================================

	// ===========================================================
	// Methods for/from SuperClass/Interfaces
	// ===========================================================

	// ===========================================================
	// Methods
	// ===========================================================

	public synchronized static void onCreate() {
		ShaderProgramManager.loadShaderProgram(PositionColorTextureCoordinatesShaderProgram.getInstance());
		ShaderProgramManager.loadShaderProgram(PositionTextureCoordinatesShaderProgram.getInstance());
		ShaderProgramManager.loadShaderProgram(PositionColorShaderProgram.getInstance());
		ShaderProgramManager.loadShaderProgram(PositionTextureCoordinatesTextureSelectShaderProgram.getInstance());
		ShaderProgramManager.loadShaderProgram(PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.getInstance());
	}

	public static synchronized void onDestroy() {
		final ArrayList<ShaderProgram> managedShaderPrograms = ShaderProgramManager.sShaderProgramsManaged;
		for(int i = managedShaderPrograms.size() - 1; i >= 0; i--) {
			managedShaderPrograms.get(i).setCompiled(false);
		}

		ShaderProgramManager.sShaderProgramsManaged.clear();
	}

	public static synchronized void loadShaderProgram(final ShaderProgram pShaderProgram) {
		if(pShaderProgram == null) {
			throw new IllegalArgumentException("pShaderProgram must not be null!");
		}

		if(pShaderProgram.isCompiled()) {
			Debug.w("Loading a compiled " + ShaderProgram.class.getSimpleName() + ": '" + pShaderProgram.getClass().getSimpleName() + "' will be recompiled.");

			pShaderProgram.setCompiled(false);
		}

		ShaderProgramManager.sShaderProgramsManaged.add(pShaderProgram);
	}

	public static void loadShaderPrograms(final ShaderProgram ... pShaderPrograms) {
		for(int i = pShaderPrograms.length - 1; i >= 0; i--) {
			ShaderProgramManager.loadShaderProgram(pShaderPrograms[i]);
		}
	}

	public static synchronized void onReload() {
		final ArrayList<ShaderProgram> managedShaderPrograms = ShaderProgramManager.sShaderProgramsManaged;
		for(int i = managedShaderPrograms.size() - 1; i >= 0; i--) {
			managedShaderPrograms.get(i).setCompiled(false);
		}
	}

	// ===========================================================
	// Inner and Anonymous Classes
	// ===========================================================
}

{'fraction_non_alphanumeric': 0.33435394978567057, 'fraction_numerical': 0.007348438456827924, 'mean_word_length': 6.731360946745562, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 0, '>': 19, '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': '6813408', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1464, 'n_words': 259}