package com.backfire.doudizhu.common;

import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;

/**
 * @author wf
 *
 */
public class CriticalPool {
	private static Paint paint = null;                   //画笔
	private static Matrix matrix = null;				//矩阵
	private static Path path = null;					//路径
				
	
	private static Rect rect = null;					
	
	public static Paint getPaint() {
		if (paint == null) {
			paint = new Paint();
		}
		paint.reset();
		return paint;
	}
	
	/**
	 * 房间内按钮单击加亮?
	 */
	private static Paint paintUp = null;
	private static Paint paintDown = null;

	public static Paint getPaintUp() {
		if (null == paintUp) {
			ColorMatrix cMatrix1 = new ColorMatrix();
			float[] keyUp = new float[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
					1, 0, 0, 0, 0, 0, 1, 0 };
			cMatrix1.set(keyUp);
			paintUp = new Paint();
			paintUp.setColorFilter(new ColorMatrixColorFilter(cMatrix1));
		}
		return paintUp;
	}

	public static Paint getPaintDown() {
		if (null == paintDown) {
			ColorMatrix cMatrix1 = new ColorMatrix();
			float[] keyDown = new float[] { 
					1, 0, 0, 0, 50, 
					0, 1, 0, 0, 50, 
					0, 0, 1, 0, 50, 
					0, 0, 0, 1, 0 };
			cMatrix1.set(keyDown);
			paintDown = new Paint();
			paintDown.setColorFilter(new ColorMatrixColorFilter(cMatrix1));
		}
		return paintDown;
	}
	
	/*
	 * 调整图片调整会灰色?
	 * 
	 */
	private static ColorMatrixColorFilter cmcf = null;

	public static ColorMatrixColorFilter getColorMatrixColorFilter() {
		if (null == cmcf) {
			ColorMatrix cm = new ColorMatrix();
			cm.setSaturation(0);
			cmcf = new ColorMatrixColorFilter(cm);
		}
		return cmcf;
	}
	public static Path getPath() {
		if (path == null) {
			path = new Path();
		}
		
		path.reset();
		return path;
	}
	
	public static Matrix getMatrix() {
		if (matrix == null) {
			matrix = new Matrix();
		}
		matrix.reset();
		return matrix;
	}
	public static Rect getRect(){
		if (rect == null) {
			rect = new Rect();
		}
		rect.setEmpty();
		return rect;
	}
}
