Fix up issues in PdfRenderer found by test.

Change-Id: I56e403fd425e4b4353383c43077de5c47ff22b5c
This commit is contained in:
Philip P. Moltmann
2016-06-07 17:04:25 -07:00
parent b8e44517a8
commit c859cd068b

View File

@@ -163,7 +163,12 @@ public final class PdfRenderer implements AutoCloseable {
synchronized (sPdfiumLock) {
mNativeDocument = nativeCreate(mInput.getFd(), size);
mPageCount = nativeGetPageCount(mNativeDocument);
try {
mPageCount = nativeGetPageCount(mNativeDocument);
} catch (Throwable t) {
nativeClose(mNativeDocument);
throw t;
}
}
mCloseGuard.open("close");
@@ -368,6 +373,8 @@ public final class PdfRenderer implements AutoCloseable {
*/
public void render(@NonNull Bitmap destination, @Nullable Rect destClip,
@Nullable Matrix transform, @RenderMode int renderMode) {
throwIfClosed();
if (destination.getConfig() != Config.ARGB_8888) {
throw new IllegalArgumentException("Unsupported pixel format");
}