NopCanvas is only hw accelerated during construction

During construction, we want to make NopCanvas as light as possible so
we just say that we are hw accelerated.
This caused some crashes further down the line for some views that
thought that NopCanvas was hw accelerated. From now on, NopCanvas is
only hw accelerated during construction.

Test: Covered by the existing tests
Change-Id: If09a662312e5c90d011e7ab2cbb524ef7b420d12
This commit is contained in:
Diego Perez
2017-02-02 10:32:03 +00:00
parent 349a8aeff9
commit be4d4fa3df

View File

@@ -31,14 +31,18 @@ import android.graphics.RectF;
* Canvas implementation that does not do any rendering
*/
public class NopCanvas extends Canvas {
private boolean mIsHardwareAccelerated = true;
public NopCanvas() {
super();
// We return true the first time so there are no allocations for the software renderer in
// the constructor
mIsHardwareAccelerated = false;
}
@Override
public boolean isHardwareAccelerated() {
// Return true so there is no allocations for the software renderer in the constructor
return true;
return mIsHardwareAccelerated;
}
@Override