Merge "Replace native crash with IAE when calling picture.draw() w/ a HW canvas" into lmp-dev

This commit is contained in:
Chris Craik
2014-09-05 17:49:19 +00:00
committed by Android (Google) Code Review
3 changed files with 6 additions and 23 deletions

View File

@@ -799,28 +799,6 @@ class GLES20Canvas extends HardwareCanvas {
// TODO: Implement rendering
}
@Override
public void drawPicture(Picture picture, Rect dst) {
save();
translate(dst.left, dst.top);
if (picture.getWidth() > 0 && picture.getHeight() > 0) {
scale(dst.width() / picture.getWidth(), dst.height() / picture.getHeight());
}
drawPicture(picture);
restore();
}
@Override
public void drawPicture(Picture picture, RectF dst) {
save();
translate(dst.left, dst.top);
if (picture.getWidth() > 0 && picture.getHeight() > 0) {
scale(dst.width() / picture.getWidth(), dst.height() / picture.getHeight());
}
drawPicture(picture);
restore();
}
@Override
public void drawPoint(float x, float y, Paint paint) {
float[] point = getPointStorage();

View File

@@ -203,7 +203,7 @@ public class Canvas {
*/
public void setBitmap(@Nullable Bitmap bitmap) {
if (isHardwareAccelerated()) {
throw new RuntimeException("Can't set a bitmap device on a GL canvas");
throw new RuntimeException("Can't set a bitmap device on a HW accelerated canvas");
}
if (bitmap == null) {

View File

@@ -122,6 +122,11 @@ public class Picture {
* @param canvas The picture is drawn to this canvas
*/
public void draw(Canvas canvas) {
if (canvas.isHardwareAccelerated()) {
throw new IllegalArgumentException(
"Picture playback is only supported on software canvas.");
}
if (mRecordingCanvas != null) {
endRecording();
}