use of android.graphics.ColorFilter_Delegate in project android_frameworks_base by ResurrectionRemix.
the class GcSnapshot method drawInLayer.
private void drawInLayer(Layer layer, Drawable drawable, Paint_Delegate paint, boolean compositeOnly, int forceMode) {
Graphics2D originalGraphics = layer.getGraphics();
if (paint == null) {
drawOnGraphics((Graphics2D) originalGraphics.create(), drawable, null, /*paint*/
layer);
} else {
ColorFilter_Delegate filter = paint.getColorFilter();
if (filter == null || !filter.isSupported()) {
// get a Graphics2D object configured with the drawing parameters.
Graphics2D configuredGraphics = createCustomGraphics(originalGraphics, paint, compositeOnly, forceMode);
drawOnGraphics(configuredGraphics, drawable, paint, layer);
return;
}
int x = 0;
int y = 0;
int width;
int height;
Rectangle clipBounds = originalGraphics.getClipBounds();
if (clipBounds != null) {
if (clipBounds.width == 0 || clipBounds.height == 0) {
// Clip is 0 so no need to paint anything.
return;
}
// If we have clipBounds available, use them as they will always be
// smaller than the full layer size.
x = clipBounds.x;
y = clipBounds.y;
width = clipBounds.width;
height = clipBounds.height;
} else {
width = layer.getImage().getWidth();
height = layer.getImage().getHeight();
}
// Create a temporary image to which the color filter will be applied.
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D imageBaseGraphics = (Graphics2D) image.getGraphics();
// Configure the Graphics2D object with drawing parameters and shader.
Graphics2D imageGraphics = createCustomGraphics(imageBaseGraphics, paint, compositeOnly, AlphaComposite.SRC_OVER);
// get a Graphics2D object configured with the drawing parameters, but no shader.
Graphics2D configuredGraphics = createCustomGraphics(originalGraphics, paint, true, /*compositeOnly*/
forceMode);
try {
// The main draw operation.
// We translate the operation to take into account that the rendering does not
// know about the clipping area.
imageGraphics.translate(-x, -y);
drawable.draw(imageGraphics, paint);
// Apply the color filter.
// Restore the original coordinates system and apply the filter only to the
// clipped area.
imageGraphics.translate(x, y);
filter.applyFilter(imageGraphics, width, height);
// Draw the tinted image on the main layer using as start point the clipping
// upper left coordinates.
configuredGraphics.drawImage(image, x, y, null);
layer.change();
} finally {
// dispose Graphics2D objects
imageGraphics.dispose();
imageBaseGraphics.dispose();
configuredGraphics.dispose();
}
}
}
use of android.graphics.ColorFilter_Delegate in project platform_frameworks_base by android.
the class GcSnapshot method drawInLayer.
private void drawInLayer(Layer layer, Drawable drawable, Paint_Delegate paint, boolean compositeOnly, int forceMode) {
Graphics2D originalGraphics = layer.getGraphics();
if (paint == null) {
drawOnGraphics((Graphics2D) originalGraphics.create(), drawable, null, /*paint*/
layer);
} else {
ColorFilter_Delegate filter = paint.getColorFilter();
if (filter == null || !filter.isSupported()) {
// get a Graphics2D object configured with the drawing parameters.
Graphics2D configuredGraphics = createCustomGraphics(originalGraphics, paint, compositeOnly, forceMode);
drawOnGraphics(configuredGraphics, drawable, paint, layer);
return;
}
int x = 0;
int y = 0;
int width;
int height;
Rectangle clipBounds = originalGraphics.getClipBounds();
if (clipBounds != null) {
if (clipBounds.width == 0 || clipBounds.height == 0) {
// Clip is 0 so no need to paint anything.
return;
}
// If we have clipBounds available, use them as they will always be
// smaller than the full layer size.
x = clipBounds.x;
y = clipBounds.y;
width = clipBounds.width;
height = clipBounds.height;
} else {
width = layer.getImage().getWidth();
height = layer.getImage().getHeight();
}
// Create a temporary image to which the color filter will be applied.
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D imageBaseGraphics = (Graphics2D) image.getGraphics();
// Configure the Graphics2D object with drawing parameters and shader.
Graphics2D imageGraphics = createCustomGraphics(imageBaseGraphics, paint, compositeOnly, AlphaComposite.SRC_OVER);
// get a Graphics2D object configured with the drawing parameters, but no shader.
Graphics2D configuredGraphics = createCustomGraphics(originalGraphics, paint, true, /*compositeOnly*/
forceMode);
try {
// The main draw operation.
// We translate the operation to take into account that the rendering does not
// know about the clipping area.
imageGraphics.translate(-x, -y);
drawable.draw(imageGraphics, paint);
// Apply the color filter.
// Restore the original coordinates system and apply the filter only to the
// clipped area.
imageGraphics.translate(x, y);
filter.applyFilter(imageGraphics, width, height);
// Draw the tinted image on the main layer using as start point the clipping
// upper left coordinates.
configuredGraphics.drawImage(image, x, y, null);
layer.change();
} finally {
// dispose Graphics2D objects
imageGraphics.dispose();
imageBaseGraphics.dispose();
configuredGraphics.dispose();
}
}
}
use of android.graphics.ColorFilter_Delegate in project android_frameworks_base by DirtyUnicorns.
the class GcSnapshot method drawInLayer.
private void drawInLayer(Layer layer, Drawable drawable, Paint_Delegate paint, boolean compositeOnly, int forceMode) {
Graphics2D originalGraphics = layer.getGraphics();
if (paint == null) {
drawOnGraphics((Graphics2D) originalGraphics.create(), drawable, null, /*paint*/
layer);
} else {
ColorFilter_Delegate filter = paint.getColorFilter();
if (filter == null || !filter.isSupported()) {
// get a Graphics2D object configured with the drawing parameters.
Graphics2D configuredGraphics = createCustomGraphics(originalGraphics, paint, compositeOnly, forceMode);
drawOnGraphics(configuredGraphics, drawable, paint, layer);
return;
}
int x = 0;
int y = 0;
int width;
int height;
Rectangle clipBounds = originalGraphics.getClipBounds();
if (clipBounds != null) {
if (clipBounds.width == 0 || clipBounds.height == 0) {
// Clip is 0 so no need to paint anything.
return;
}
// If we have clipBounds available, use them as they will always be
// smaller than the full layer size.
x = clipBounds.x;
y = clipBounds.y;
width = clipBounds.width;
height = clipBounds.height;
} else {
width = layer.getImage().getWidth();
height = layer.getImage().getHeight();
}
// Create a temporary image to which the color filter will be applied.
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D imageBaseGraphics = (Graphics2D) image.getGraphics();
// Configure the Graphics2D object with drawing parameters and shader.
Graphics2D imageGraphics = createCustomGraphics(imageBaseGraphics, paint, compositeOnly, AlphaComposite.SRC_OVER);
// get a Graphics2D object configured with the drawing parameters, but no shader.
Graphics2D configuredGraphics = createCustomGraphics(originalGraphics, paint, true, /*compositeOnly*/
forceMode);
try {
// The main draw operation.
// We translate the operation to take into account that the rendering does not
// know about the clipping area.
imageGraphics.translate(-x, -y);
drawable.draw(imageGraphics, paint);
// Apply the color filter.
// Restore the original coordinates system and apply the filter only to the
// clipped area.
imageGraphics.translate(x, y);
filter.applyFilter(imageGraphics, width, height);
// Draw the tinted image on the main layer using as start point the clipping
// upper left coordinates.
configuredGraphics.drawImage(image, x, y, null);
layer.change();
} finally {
// dispose Graphics2D objects
imageGraphics.dispose();
imageBaseGraphics.dispose();
configuredGraphics.dispose();
}
}
}
use of android.graphics.ColorFilter_Delegate in project android_frameworks_base by AOSPA.
the class GcSnapshot method drawInLayer.
private void drawInLayer(Layer layer, Drawable drawable, Paint_Delegate paint, boolean compositeOnly, int forceMode) {
Graphics2D originalGraphics = layer.getGraphics();
if (paint == null) {
drawOnGraphics((Graphics2D) originalGraphics.create(), drawable, null, /*paint*/
layer);
} else {
ColorFilter_Delegate filter = paint.getColorFilter();
if (filter == null || !filter.isSupported()) {
// get a Graphics2D object configured with the drawing parameters.
Graphics2D configuredGraphics = createCustomGraphics(originalGraphics, paint, compositeOnly, forceMode);
drawOnGraphics(configuredGraphics, drawable, paint, layer);
return;
}
int x = 0;
int y = 0;
int width;
int height;
Rectangle clipBounds = originalGraphics.getClipBounds();
if (clipBounds != null) {
if (clipBounds.width == 0 || clipBounds.height == 0) {
// Clip is 0 so no need to paint anything.
return;
}
// If we have clipBounds available, use them as they will always be
// smaller than the full layer size.
x = clipBounds.x;
y = clipBounds.y;
width = clipBounds.width;
height = clipBounds.height;
} else {
width = layer.getImage().getWidth();
height = layer.getImage().getHeight();
}
// Create a temporary image to which the color filter will be applied.
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D imageBaseGraphics = (Graphics2D) image.getGraphics();
// Configure the Graphics2D object with drawing parameters and shader.
Graphics2D imageGraphics = createCustomGraphics(imageBaseGraphics, paint, compositeOnly, AlphaComposite.SRC_OVER);
// get a Graphics2D object configured with the drawing parameters, but no shader.
Graphics2D configuredGraphics = createCustomGraphics(originalGraphics, paint, true, /*compositeOnly*/
forceMode);
try {
// The main draw operation.
// We translate the operation to take into account that the rendering does not
// know about the clipping area.
imageGraphics.translate(-x, -y);
drawable.draw(imageGraphics, paint);
// Apply the color filter.
// Restore the original coordinates system and apply the filter only to the
// clipped area.
imageGraphics.translate(x, y);
filter.applyFilter(imageGraphics, width, height);
// Draw the tinted image on the main layer using as start point the clipping
// upper left coordinates.
configuredGraphics.drawImage(image, x, y, null);
layer.change();
} finally {
// dispose Graphics2D objects
imageGraphics.dispose();
imageBaseGraphics.dispose();
configuredGraphics.dispose();
}
}
}
use of android.graphics.ColorFilter_Delegate in project android_frameworks_base by crdroidandroid.
the class GcSnapshot method drawInLayer.
private void drawInLayer(Layer layer, Drawable drawable, Paint_Delegate paint, boolean compositeOnly, int forceMode) {
Graphics2D originalGraphics = layer.getGraphics();
if (paint == null) {
drawOnGraphics((Graphics2D) originalGraphics.create(), drawable, null, /*paint*/
layer);
} else {
ColorFilter_Delegate filter = paint.getColorFilter();
if (filter == null || !filter.isSupported()) {
// get a Graphics2D object configured with the drawing parameters.
Graphics2D configuredGraphics = createCustomGraphics(originalGraphics, paint, compositeOnly, forceMode);
drawOnGraphics(configuredGraphics, drawable, paint, layer);
return;
}
int x = 0;
int y = 0;
int width;
int height;
Rectangle clipBounds = originalGraphics.getClipBounds();
if (clipBounds != null) {
if (clipBounds.width == 0 || clipBounds.height == 0) {
// Clip is 0 so no need to paint anything.
return;
}
// If we have clipBounds available, use them as they will always be
// smaller than the full layer size.
x = clipBounds.x;
y = clipBounds.y;
width = clipBounds.width;
height = clipBounds.height;
} else {
width = layer.getImage().getWidth();
height = layer.getImage().getHeight();
}
// Create a temporary image to which the color filter will be applied.
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D imageBaseGraphics = (Graphics2D) image.getGraphics();
// Configure the Graphics2D object with drawing parameters and shader.
Graphics2D imageGraphics = createCustomGraphics(imageBaseGraphics, paint, compositeOnly, AlphaComposite.SRC_OVER);
// get a Graphics2D object configured with the drawing parameters, but no shader.
Graphics2D configuredGraphics = createCustomGraphics(originalGraphics, paint, true, /*compositeOnly*/
forceMode);
try {
// The main draw operation.
// We translate the operation to take into account that the rendering does not
// know about the clipping area.
imageGraphics.translate(-x, -y);
drawable.draw(imageGraphics, paint);
// Apply the color filter.
// Restore the original coordinates system and apply the filter only to the
// clipped area.
imageGraphics.translate(x, y);
filter.applyFilter(imageGraphics, width, height);
// Draw the tinted image on the main layer using as start point the clipping
// upper left coordinates.
configuredGraphics.drawImage(image, x, y, null);
layer.change();
} finally {
// dispose Graphics2D objects
imageGraphics.dispose();
imageBaseGraphics.dispose();
configuredGraphics.dispose();
}
}
}
Aggregations