Skip to content

Commit

Permalink
updated comments, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
moagrius committed Nov 21, 2013
1 parent 34945c8 commit e760d6b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 43 deletions.
50 changes: 23 additions & 27 deletions src/com/qozix/tileview/paths/DrawablePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,30 @@

public class DrawablePath {

/**
* The path that this drawable will follow.
*/
public Path path;
/**
* The path that this drawable will follow.
*/
public Path path;

/**
* The paint to be used for this path.
*/
public Paint paint;
/**
* The paint to be used for this path.
*/
public Paint paint;


/**
* Draw the supplied path onto the supplied canvas.
*
* @param canvas
* @param drawingPath
*/
@SuppressLint("NewApi")
public void draw(Canvas canvas, Path drawingPath) {
// quickReject is not supported on hw accelerated canvas versions below
// 16 but isHardwareAccelerated works only from version 11
if (android.os.Build.VERSION.SDK_INT >= 11 && canvas.isHardwareAccelerated()
&& android.os.Build.VERSION.SDK_INT < 16) {
canvas.drawPath(drawingPath, paint);
}
else if (!canvas.quickReject(drawingPath, Canvas.EdgeType.BW)) {
canvas.drawPath(drawingPath, paint);
}
}
/**
* Draw the supplied path onto the supplied canvas.
*
* @param canvas
* @param drawingPath
*/
@SuppressLint("NewApi")
public void draw( Canvas canvas, Path drawingPath ) {
// quickReject is not supported on hw accelerated canvas versions below 16 but isHardwareAccelerated works only from version 11
if ( android.os.Build.VERSION.SDK_INT >= 11 && canvas.isHardwareAccelerated() && android.os.Build.VERSION.SDK_INT < 16 ) {
canvas.drawPath( drawingPath, paint );
} else if ( !canvas.quickReject( drawingPath, Canvas.EdgeType.BW ) ) {
canvas.drawPath( drawingPath, paint );
}
}

}
16 changes: 0 additions & 16 deletions src/com/qozix/tileview/paths/PathManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Matrix;
Expand All @@ -14,19 +13,6 @@
import com.qozix.layouts.StaticLayout;
import com.qozix.tileview.detail.DetailManager;

/**
* Canvas.drawPath takes a lot of resources. Using Canvas.drawLines is more
* performant, but looks terrible for anything beyond a 1px plain line. Creating
* and managing a bitmap either scales the thickness of the path, or if you
* manage that, ends up taking as much juice as Canvas.drawPath. After many
* iterations, the default implementation just offers path drawing via
* Canvas.drawPath. If you are using very large paths, or need more
* customization, consider a custom implementation (most likely a custom View
* subclass added as child view of the TileView, with an overriden onDraw method
* that manages paths in whatever fashion is most appropriate to your need, or
* possibly a SurfaceView, or even OpenGL. ref
* (http://stackoverflow.com/a/15208783/429430)
*/
public class PathManager extends StaticLayout {

private static final int DEFAULT_STROKE_COLOR = 0x883399FF;
Expand Down Expand Up @@ -119,7 +105,6 @@ public void setShouldDraw(boolean should) {
invalidate();
}

@SuppressLint("NewApi")
@Override
public void onDraw(Canvas canvas) {
if (shouldDraw) {
Expand All @@ -128,7 +113,6 @@ public void onDraw(Canvas canvas) {
for (DrawablePath drawablePath : paths) {
drawingPath.set(drawablePath.path);
drawingPath.transform(matrix);

// defer drawing to the path object
drawablePath.draw(canvas, drawingPath);
}
Expand Down

0 comments on commit e760d6b

Please sign in to comment.