Skip to content

Commit

Permalink
Avoid creating new Paint during OnDraw()
Browse files Browse the repository at this point in the history
  • Loading branch information
tgirard12 committed Jul 28, 2015
1 parent 1097304 commit 2909977
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion com/android/graphics/CanvasView.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public enum Drawer {
private List<Path> pathLists = new ArrayList<Path>();
private List<Paint> paintLists = new ArrayList<Paint>();

private final Paint emptyPaint = new Paint();

// for Eraser
private int baseColor = Color.WHITE;

Expand Down Expand Up @@ -418,7 +420,7 @@ protected void onDraw(Canvas canvas) {
canvas.drawColor(this.baseColor);

if (this.bitmap != null) {
canvas.drawBitmap(this.bitmap, 0F, 0F, new Paint());
canvas.drawBitmap(this.bitmap, 0F, 0F, emptyPaint);
}

for (int i = 0; i < this.historyPointer; i++) {
Expand Down

1 comment on commit 2909977

@Korilakkuma
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

Please sign in to comment.