Skip to content

Commit

Permalink
Merge pull request #2 from florina-muntenescu/readme
Browse files Browse the repository at this point in the history
Readme
  • Loading branch information
florina-muntenescu committed Oct 15, 2016
2 parents 5386244 + 8e7744f commit 088eb44
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
@@ -1 +1,23 @@
# vectordrawable-vs-png
# VectorDrawable vs PNG

This is a test project to check the duration of an `ImageView#onDraw` method when what we need to draw is a VectorDrawable or a PNG image. The app allows selecting using either a ViewDrawable or a PNG that will be displayed on the entire size of the screen and shows the draw duration on screen. The PNG and the VectorDrawable used are versions of the same SVG file.

The `ImageView` class is extended in the `MeasurableImageView` class and the `onDraw` method is overriden. The `System.nanoTime` is used to get the time before and after the `onDraw` of the base `ImageView` class.


```java
@Override
protected void onDraw(final Canvas canvas) {
long startTime = System.nanoTime();

super.onDraw(canvas);

long endTime = System.nanoTime();
notifyDraw(startTime, endTime);
}
```

The test app proves the following:
* The 1st rendering of a VectorDrawable takes a long time. The next renderings take considerably less time.
* The PNG is rendered in a similar amount of time at every rendering.
* When changing the orientation, the drawing of the VectorDrawable takes longer, for the 1st rendering.

0 comments on commit 088eb44

Please sign in to comment.