// This case should hopefully never or seldom happen
canvas = new Canvas(bitmap);
}
-
+ boolean enabledHwBitmapsInSwMode = canvas.isHwBitmapsInSwModeEnabled();
+ canvas.setHwBitmapsInSwModeEnabled(true);
if ((backgroundColor & 0xff000000) != 0) {
bitmap.eraseColor(backgroundColor);
}
canvas.restoreToCount(restoreCount);
canvas.setBitmap(null);
+ canvas.setHwBitmapsInSwModeEnabled(enabledHwBitmapsInSwMode);
if (attachInfo != null) {
// Restore the cached Canvas for our siblings
*/
protected int mScreenDensity = Bitmap.DENSITY_NONE;
protected int mDensity = Bitmap.DENSITY_NONE;
+ private boolean mAllowHwBitmapsInSwMode = false;
protected void throwIfCannotDraw(Bitmap bitmap) {
if (bitmap.isRecycled()) {
indices, indexOffset, indexCount, paint.getNativeInstance());
}
+ /**
+ * @hide
+ */
+ public void setHwBitmapsInSwModeEnabled(boolean enabled) {
+ mAllowHwBitmapsInSwMode = enabled;
+ }
+
+ /**
+ * @hide
+ */
+ public boolean isHwBitmapsInSwModeEnabled() {
+ return mAllowHwBitmapsInSwMode;
+ }
+
private void throwIfHwBitmapInSwMode(Bitmap bitmap) {
- if (!isHardwareAccelerated() && bitmap.getConfig() == Bitmap.Config.HARDWARE) {
+ if (!mAllowHwBitmapsInSwMode && !isHardwareAccelerated()
+ && bitmap.getConfig() == Bitmap.Config.HARDWARE) {
throw new IllegalStateException("Software rendering doesn't support hardware bitmaps");
}
}