diff options
author | Lei Zhang <thestig@chromium.org> | 2018-02-07 20:28:35 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-07 20:28:35 +0000 |
commit | a98e36657d0e5a78e216f828b3e712e85250c1a7 (patch) | |
tree | 4621be8a3be00efafe28eea4639b87675db80d2b /testing/embedder_test.h | |
parent | 2496f8e3f3cb1cbfffd664c9b5d7983dc192887b (diff) | |
download | pdfium-a98e36657d0e5a78e216f828b3e712e85250c1a7.tar.xz |
Clean up RenderPage methods in EmbedderTest.
Add replacement methods that make themselves clear as to what they are
rendering, and return unique_ptrs to help prevent leakage. Mark existing
methods deprecated.
Change-Id: I9055407e614dfbe765428fb32a7da64df3418d1d
Reviewed-on: https://pdfium-review.googlesource.com/25470
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'testing/embedder_test.h')
-rw-r--r-- | testing/embedder_test.h | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/testing/embedder_test.h b/testing/embedder_test.h index b36ac06a89..18b16b7066 100644 --- a/testing/embedder_test.h +++ b/testing/embedder_test.h @@ -9,6 +9,7 @@ #include <memory> #include <string> +#include "public/cpp/fpdf_deleters.h" #include "public/fpdf_dataavail.h" #include "public/fpdf_ext.h" #include "public/fpdf_formfill.h" @@ -108,18 +109,52 @@ class EmbedderTest : public ::testing::Test, // Load a specific page of the open document. FPDF_PAGE LoadPage(int page_number); + // Release the resources obtained from LoadPage(). Further use of |page| + // is prohibited after this call is made. + void UnloadPage(FPDF_PAGE page); + // Convert a loaded page into a bitmap. - FPDF_BITMAP RenderPage(FPDF_PAGE page); + // DEPRECATED. Use some one of the methods below instead. + FPDF_BITMAP RenderPageDeprecated(FPDF_PAGE page); - // Convert a loaded page into a bitmap with page rendering flags specified. + // RenderLoadedPageWithFlags() with no flags. + std::unique_ptr<void, FPDFBitmapDeleter> RenderLoadedPage(FPDF_PAGE page); + + // Convert |page| loaded via LoadPage() into a bitmap with the specified page + // rendering |flags|. + // // See public/fpdfview.h for a list of page rendering flags. - FPDF_BITMAP RenderPageWithFlags(FPDF_PAGE page, - FPDF_FORMHANDLE handle, - int flags); + std::unique_ptr<void, FPDFBitmapDeleter> RenderLoadedPageWithFlags( + FPDF_PAGE page, + int flags); - // Relese the resources obtained from LoadPage(). Further use of |page| - // is prohibited after this call is made. - void UnloadPage(FPDF_PAGE page); + // RenderSavedPageWithFlags() with no flags. + std::unique_ptr<void, FPDFBitmapDeleter> RenderSavedPage(FPDF_PAGE page); + + // Convert |page| loaded via LoadSavedPage() into a bitmap with the specified + // page rendering |flags|. + // + // See public/fpdfview.h for a list of page rendering flags. + std::unique_ptr<void, FPDFBitmapDeleter> RenderSavedPageWithFlags( + FPDF_PAGE page, + int flags); + + // DEPRECATED. Use RenderPageWithFlags() instead. + // Caller takes ownership of the returned bitmap. + // + // See public/fpdfview.h for a list of page rendering flags. + static FPDF_BITMAP RenderPageWithFlagsDeprecated(FPDF_PAGE page, + FPDF_FORMHANDLE handle, + int flags); + + // Convert |page| into a bitmap with the specified page rendering |flags|. + // The form handle associated with |page| should be passed in via |handle|. + // If |handle| is nullptr, then forms on the page will not be rendered. + // + // See public/fpdfview.h for a list of page rendering flags. + // If none of the above Render methods are appropriate, then use this one. + static std::unique_ptr<void, FPDFBitmapDeleter> + RenderPageWithFlags(FPDF_PAGE page, FPDF_FORMHANDLE handle, int flags); protected: bool OpenDocumentHelper(const char* password, @@ -157,7 +192,6 @@ class EmbedderTest : public ::testing::Test, FPDF_DOCUMENT OpenSavedDocument(const char* password = nullptr); void CloseSavedDocument(); FPDF_PAGE LoadSavedPage(int page_number); - FPDF_BITMAP RenderSavedPage(FPDF_PAGE page); void CloseSavedPage(FPDF_PAGE page); void VerifySavedRendering(FPDF_PAGE page, int width, |