Loading core/jni/android/graphics/pdf/PdfEditor.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -52,11 +52,9 @@ static struct { } gRectClassInfo; // Also used in PdfRenderer.cpp Mutex sPdfiumLock; int sUnmatchedPdfiumInitRequestCount = 0; static void initializeLibraryIfNeeded() { Mutex::Autolock _l(sPdfiumLock); if (sUnmatchedPdfiumInitRequestCount == 0) { FPDF_InitLibrary(); } Loading @@ -64,7 +62,6 @@ static void initializeLibraryIfNeeded() { } static void destroyLibraryIfNeeded() { Mutex::Autolock _l(sPdfiumLock); sUnmatchedPdfiumInitRequestCount--; if (sUnmatchedPdfiumInitRequestCount == 0) { FPDF_DestroyLibrary(); Loading core/jni/android/graphics/pdf/PdfRenderer.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -44,11 +44,9 @@ static struct { } gPointClassInfo; // See PdfEditor.cpp extern Mutex sPdfiumLock; extern int sUnmatchedPdfiumInitRequestCount; static void initializeLibraryIfNeeded() { Mutex::Autolock _l(sPdfiumLock); if (sUnmatchedPdfiumInitRequestCount == 0) { FPDF_InitLibrary(); } Loading @@ -56,7 +54,6 @@ static void initializeLibraryIfNeeded() { } static void destroyLibraryIfNeeded() { Mutex::Autolock _l(sPdfiumLock); sUnmatchedPdfiumInitRequestCount--; if (sUnmatchedPdfiumInitRequestCount == 0) { FPDF_DestroyLibrary(); Loading graphics/java/android/graphics/pdf/PdfEditor.java +50 −15 Original line number Diff line number Diff line Loading @@ -79,8 +79,12 @@ public final class PdfEditor { } mInput = input; synchronized (PdfRenderer.sPdfiumLock) { mNativeDocument = nativeOpen(mInput.getFd(), size); mPageCount = nativeGetPageCount(mNativeDocument); } mCloseGuard.open("close"); } Loading @@ -102,8 +106,11 @@ public final class PdfEditor { public void removePage(int pageIndex) { throwIfClosed(); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { mPageCount = nativeRemovePage(mNativeDocument, pageIndex); } } /** * Sets a transformation and clip for a given page. The transformation matrix if Loading @@ -125,13 +132,18 @@ public final class PdfEditor { if (clip == null) { Point size = new Point(); getPageSize(pageIndex, size); synchronized (PdfRenderer.sPdfiumLock) { nativeSetTransformAndClip(mNativeDocument, pageIndex, transform.native_instance, 0, 0, size.x, size.y); } } else { synchronized (PdfRenderer.sPdfiumLock) { nativeSetTransformAndClip(mNativeDocument, pageIndex, transform.native_instance, clip.left, clip.top, clip.right, clip.bottom); } } } /** * Gets the size of a given page in mils (1/72"). Loading @@ -143,8 +155,11 @@ public final class PdfEditor { throwIfClosed(); throwIfOutSizeNull(outSize); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { nativeGetPageSize(mNativeDocument, pageIndex, outSize); } } /** * Gets the media box of a given page in mils (1/72"). Loading @@ -156,8 +171,11 @@ public final class PdfEditor { throwIfClosed(); throwIfOutMediaBoxNull(outMediaBox); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { return nativeGetPageMediaBox(mNativeDocument, pageIndex, outMediaBox); } } /** * Sets the media box of a given page in mils (1/72"). Loading @@ -169,8 +187,11 @@ public final class PdfEditor { throwIfClosed(); throwIfMediaBoxNull(mediaBox); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { nativeSetPageMediaBox(mNativeDocument, pageIndex, mediaBox); } } /** * Gets the crop box of a given page in mils (1/72"). Loading @@ -182,8 +203,11 @@ public final class PdfEditor { throwIfClosed(); throwIfOutCropBoxNull(outCropBox); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { return nativeGetPageCropBox(mNativeDocument, pageIndex, outCropBox); } } /** * Sets the crop box of a given page in mils (1/72"). Loading @@ -195,8 +219,11 @@ public final class PdfEditor { throwIfClosed(); throwIfCropBoxNull(cropBox); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { nativeSetPageCropBox(mNativeDocument, pageIndex, cropBox); } } /** * Gets whether the document prefers to be scaled for printing. Loading @@ -205,8 +232,11 @@ public final class PdfEditor { */ public boolean shouldScaleForPrinting() { throwIfClosed(); synchronized (PdfRenderer.sPdfiumLock) { return nativeScaleForPrinting(mNativeDocument); } } /** * Writes the PDF file to the provided destination. Loading @@ -219,7 +249,10 @@ public final class PdfEditor { public void write(ParcelFileDescriptor output) throws IOException { try { throwIfClosed(); synchronized (PdfRenderer.sPdfiumLock) { nativeWrite(mNativeDocument, output.getFd()); } } finally { IoUtils.closeQuietly(output); } Loading Loading @@ -247,7 +280,9 @@ public final class PdfEditor { } private void doClose() { synchronized (PdfRenderer.sPdfiumLock) { nativeClose(mNativeDocument); } IoUtils.closeQuietly(mInput); mInput = null; mCloseGuard.close(); Loading graphics/java/android/graphics/pdf/PdfRenderer.java +29 −8 Original line number Diff line number Diff line Loading @@ -99,6 +99,12 @@ import java.lang.annotation.RetentionPolicy; * @see #close() */ public final class PdfRenderer implements AutoCloseable { /** * Any call the native pdfium code has to be single threaded as the library does not support * parallel use. */ final static Object sPdfiumLock = new Object(); private final CloseGuard mCloseGuard = CloseGuard.get(); private final Point mTempPoint = new Point(); Loading Loading @@ -154,8 +160,12 @@ public final class PdfRenderer implements AutoCloseable { } mInput = input; synchronized (sPdfiumLock) { mNativeDocument = nativeCreate(mInput.getFd(), size); mPageCount = nativeGetPageCount(mNativeDocument); } mCloseGuard.open("close"); } Loading Loading @@ -189,8 +199,11 @@ public final class PdfRenderer implements AutoCloseable { */ public boolean shouldScaleForPrinting() { throwIfClosed(); synchronized (sPdfiumLock) { return nativeScaleForPrinting(mNativeDocument); } } /** * Opens a page for rendering. Loading Loading @@ -224,7 +237,9 @@ public final class PdfRenderer implements AutoCloseable { if (mCurrentPage != null) { mCurrentPage.close(); } synchronized (sPdfiumLock) { nativeClose(mNativeDocument); } try { mInput.close(); } catch (IOException ioe) { Loading Loading @@ -277,7 +292,9 @@ public final class PdfRenderer implements AutoCloseable { private Page(int index) { Point size = mTempPoint; synchronized (sPdfiumLock) { mNativePage = nativeOpenPageAndGetSize(mNativeDocument, index, size); } mIndex = index; mWidth = size.x; mHeight = size.y; Loading Loading @@ -384,9 +401,11 @@ public final class PdfRenderer implements AutoCloseable { final long transformPtr = (transform != null) ? transform.native_instance : 0; synchronized (sPdfiumLock) { nativeRenderPage(mNativeDocument, mNativePage, destination, contentLeft, contentTop, contentRight, contentBottom, transformPtr, renderMode); } } /** * Closes this page. Loading @@ -412,7 +431,9 @@ public final class PdfRenderer implements AutoCloseable { } private void doClose() { synchronized (sPdfiumLock) { nativeClosePage(mNativePage); } mNativePage = 0; mCloseGuard.close(); mCurrentPage = null; Loading Loading
core/jni/android/graphics/pdf/PdfEditor.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -52,11 +52,9 @@ static struct { } gRectClassInfo; // Also used in PdfRenderer.cpp Mutex sPdfiumLock; int sUnmatchedPdfiumInitRequestCount = 0; static void initializeLibraryIfNeeded() { Mutex::Autolock _l(sPdfiumLock); if (sUnmatchedPdfiumInitRequestCount == 0) { FPDF_InitLibrary(); } Loading @@ -64,7 +62,6 @@ static void initializeLibraryIfNeeded() { } static void destroyLibraryIfNeeded() { Mutex::Autolock _l(sPdfiumLock); sUnmatchedPdfiumInitRequestCount--; if (sUnmatchedPdfiumInitRequestCount == 0) { FPDF_DestroyLibrary(); Loading
core/jni/android/graphics/pdf/PdfRenderer.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -44,11 +44,9 @@ static struct { } gPointClassInfo; // See PdfEditor.cpp extern Mutex sPdfiumLock; extern int sUnmatchedPdfiumInitRequestCount; static void initializeLibraryIfNeeded() { Mutex::Autolock _l(sPdfiumLock); if (sUnmatchedPdfiumInitRequestCount == 0) { FPDF_InitLibrary(); } Loading @@ -56,7 +54,6 @@ static void initializeLibraryIfNeeded() { } static void destroyLibraryIfNeeded() { Mutex::Autolock _l(sPdfiumLock); sUnmatchedPdfiumInitRequestCount--; if (sUnmatchedPdfiumInitRequestCount == 0) { FPDF_DestroyLibrary(); Loading
graphics/java/android/graphics/pdf/PdfEditor.java +50 −15 Original line number Diff line number Diff line Loading @@ -79,8 +79,12 @@ public final class PdfEditor { } mInput = input; synchronized (PdfRenderer.sPdfiumLock) { mNativeDocument = nativeOpen(mInput.getFd(), size); mPageCount = nativeGetPageCount(mNativeDocument); } mCloseGuard.open("close"); } Loading @@ -102,8 +106,11 @@ public final class PdfEditor { public void removePage(int pageIndex) { throwIfClosed(); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { mPageCount = nativeRemovePage(mNativeDocument, pageIndex); } } /** * Sets a transformation and clip for a given page. The transformation matrix if Loading @@ -125,13 +132,18 @@ public final class PdfEditor { if (clip == null) { Point size = new Point(); getPageSize(pageIndex, size); synchronized (PdfRenderer.sPdfiumLock) { nativeSetTransformAndClip(mNativeDocument, pageIndex, transform.native_instance, 0, 0, size.x, size.y); } } else { synchronized (PdfRenderer.sPdfiumLock) { nativeSetTransformAndClip(mNativeDocument, pageIndex, transform.native_instance, clip.left, clip.top, clip.right, clip.bottom); } } } /** * Gets the size of a given page in mils (1/72"). Loading @@ -143,8 +155,11 @@ public final class PdfEditor { throwIfClosed(); throwIfOutSizeNull(outSize); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { nativeGetPageSize(mNativeDocument, pageIndex, outSize); } } /** * Gets the media box of a given page in mils (1/72"). Loading @@ -156,8 +171,11 @@ public final class PdfEditor { throwIfClosed(); throwIfOutMediaBoxNull(outMediaBox); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { return nativeGetPageMediaBox(mNativeDocument, pageIndex, outMediaBox); } } /** * Sets the media box of a given page in mils (1/72"). Loading @@ -169,8 +187,11 @@ public final class PdfEditor { throwIfClosed(); throwIfMediaBoxNull(mediaBox); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { nativeSetPageMediaBox(mNativeDocument, pageIndex, mediaBox); } } /** * Gets the crop box of a given page in mils (1/72"). Loading @@ -182,8 +203,11 @@ public final class PdfEditor { throwIfClosed(); throwIfOutCropBoxNull(outCropBox); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { return nativeGetPageCropBox(mNativeDocument, pageIndex, outCropBox); } } /** * Sets the crop box of a given page in mils (1/72"). Loading @@ -195,8 +219,11 @@ public final class PdfEditor { throwIfClosed(); throwIfCropBoxNull(cropBox); throwIfPageNotInDocument(pageIndex); synchronized (PdfRenderer.sPdfiumLock) { nativeSetPageCropBox(mNativeDocument, pageIndex, cropBox); } } /** * Gets whether the document prefers to be scaled for printing. Loading @@ -205,8 +232,11 @@ public final class PdfEditor { */ public boolean shouldScaleForPrinting() { throwIfClosed(); synchronized (PdfRenderer.sPdfiumLock) { return nativeScaleForPrinting(mNativeDocument); } } /** * Writes the PDF file to the provided destination. Loading @@ -219,7 +249,10 @@ public final class PdfEditor { public void write(ParcelFileDescriptor output) throws IOException { try { throwIfClosed(); synchronized (PdfRenderer.sPdfiumLock) { nativeWrite(mNativeDocument, output.getFd()); } } finally { IoUtils.closeQuietly(output); } Loading Loading @@ -247,7 +280,9 @@ public final class PdfEditor { } private void doClose() { synchronized (PdfRenderer.sPdfiumLock) { nativeClose(mNativeDocument); } IoUtils.closeQuietly(mInput); mInput = null; mCloseGuard.close(); Loading
graphics/java/android/graphics/pdf/PdfRenderer.java +29 −8 Original line number Diff line number Diff line Loading @@ -99,6 +99,12 @@ import java.lang.annotation.RetentionPolicy; * @see #close() */ public final class PdfRenderer implements AutoCloseable { /** * Any call the native pdfium code has to be single threaded as the library does not support * parallel use. */ final static Object sPdfiumLock = new Object(); private final CloseGuard mCloseGuard = CloseGuard.get(); private final Point mTempPoint = new Point(); Loading Loading @@ -154,8 +160,12 @@ public final class PdfRenderer implements AutoCloseable { } mInput = input; synchronized (sPdfiumLock) { mNativeDocument = nativeCreate(mInput.getFd(), size); mPageCount = nativeGetPageCount(mNativeDocument); } mCloseGuard.open("close"); } Loading Loading @@ -189,8 +199,11 @@ public final class PdfRenderer implements AutoCloseable { */ public boolean shouldScaleForPrinting() { throwIfClosed(); synchronized (sPdfiumLock) { return nativeScaleForPrinting(mNativeDocument); } } /** * Opens a page for rendering. Loading Loading @@ -224,7 +237,9 @@ public final class PdfRenderer implements AutoCloseable { if (mCurrentPage != null) { mCurrentPage.close(); } synchronized (sPdfiumLock) { nativeClose(mNativeDocument); } try { mInput.close(); } catch (IOException ioe) { Loading Loading @@ -277,7 +292,9 @@ public final class PdfRenderer implements AutoCloseable { private Page(int index) { Point size = mTempPoint; synchronized (sPdfiumLock) { mNativePage = nativeOpenPageAndGetSize(mNativeDocument, index, size); } mIndex = index; mWidth = size.x; mHeight = size.y; Loading Loading @@ -384,9 +401,11 @@ public final class PdfRenderer implements AutoCloseable { final long transformPtr = (transform != null) ? transform.native_instance : 0; synchronized (sPdfiumLock) { nativeRenderPage(mNativeDocument, mNativePage, destination, contentLeft, contentTop, contentRight, contentBottom, transformPtr, renderMode); } } /** * Closes this page. Loading @@ -412,7 +431,9 @@ public final class PdfRenderer implements AutoCloseable { } private void doClose() { synchronized (sPdfiumLock) { nativeClosePage(mNativePage); } mNativePage = 0; mCloseGuard.close(); mCurrentPage = null; Loading