summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-02-07 20:28:35 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-07 20:28:35 +0000
commita98e36657d0e5a78e216f828b3e712e85250c1a7 (patch)
tree4621be8a3be00efafe28eea4639b87675db80d2b
parent2496f8e3f3cb1cbfffd664c9b5d7983dc192887b (diff)
downloadpdfium-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>
-rw-r--r--core/fpdfapi/edit/cpdf_creator_embeddertest.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_stitchfunc_embeddertest.cpp9
-rw-r--r--core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp2
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp6
-rw-r--r--core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp6
-rw-r--r--core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp2
-rw-r--r--core/fxcodec/codec/fx_codec_embeddertest.cpp2
-rw-r--r--core/fxge/fx_ge_text_embeddertest.cpp2
-rw-r--r--fpdfsdk/fpdfannot_embeddertest.cpp45
-rw-r--r--fpdfsdk/fpdfedit_embeddertest.cpp43
-rw-r--r--fpdfsdk/fpdfformfill_embeddertest.cpp6
-rw-r--r--fpdfsdk/fpdfppo_embeddertest.cpp8
-rw-r--r--fpdfsdk/fpdfsave_embeddertest.cpp12
-rw-r--r--fpdfsdk/fpdfview_embeddertest.cpp4
-rw-r--r--testing/embedder_test.cpp79
-rw-r--r--testing/embedder_test.h52
16 files changed, 174 insertions, 106 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp b/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp
index def7d50a97..7d1fb30595 100644
--- a/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp
+++ b/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp
@@ -28,7 +28,7 @@ TEST_F(CPDF_CreatorEmbedderTest, SavedDocsAreEqualAfterParse) {
FPDF_PAGE page = FPDF_LoadPage(document(), 0);
ASSERT_TRUE(page);
FPDF_BITMAP new_bitmap =
- RenderPageWithFlags(page, form_handle(), FPDF_ANNOT);
+ RenderPageWithFlagsDeprecated(page, form_handle(), FPDF_ANNOT);
FPDFBitmap_Destroy(new_bitmap);
UnloadPage(page);
}
diff --git a/core/fpdfapi/page/cpdf_stitchfunc_embeddertest.cpp b/core/fpdfapi/page/cpdf_stitchfunc_embeddertest.cpp
index 6a1b87b570..ebc71926a0 100644
--- a/core/fpdfapi/page/cpdf_stitchfunc_embeddertest.cpp
+++ b/core/fpdfapi/page/cpdf_stitchfunc_embeddertest.cpp
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "testing/embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -13,9 +15,8 @@ TEST_F(FPDFPageFuncEmbeddertest, Bug_551460) {
// and trusted. The number of inputs has to be 1.
EXPECT_TRUE(OpenDocument("bug_551460.pdf"));
FPDF_PAGE page = LoadPage(0);
- EXPECT_NE(nullptr, page);
- FPDF_BITMAP bitmap = RenderPage(page);
- CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
- FPDFBitmap_Destroy(bitmap);
+ ASSERT_TRUE(page);
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ CompareBitmap(bitmap.get(), 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
UnloadPage(page);
}
diff --git a/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp b/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
index cc29b8954e..6c1a0e9ae5 100644
--- a/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
+++ b/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
@@ -58,7 +58,7 @@ TEST_F(CPDFSecurityHandlerEmbeddertest, PasswordAfterGenerateSave) {
EXPECT_TRUE(FPDFPath_SetFillColor(red_rect, 255, 0, 0, 255));
EXPECT_TRUE(FPDFPath_SetDrawMode(red_rect, FPDF_FILLMODE_ALTERNATE, 0));
FPDFPage_InsertObject(page, red_rect);
- FPDF_BITMAP page_bitmap = RenderPage(page);
+ FPDF_BITMAP page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, md5);
FPDFBitmap_Destroy(page_bitmap);
EXPECT_TRUE(FPDFPage_GenerateContent(page));
diff --git a/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp b/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp
index e95a4cc595..20e8cf775c 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp
@@ -93,7 +93,7 @@ TEST_F(FPDFParserDecodeEmbeddertest, Bug_552046) {
// crash when rendered.
EXPECT_TRUE(OpenDocument("bug_552046.pdf"));
FPDF_PAGE page = LoadPage(0);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);
@@ -104,7 +104,7 @@ TEST_F(FPDFParserDecodeEmbeddertest, Bug_555784) {
// Should not cause a crash when rendered.
EXPECT_TRUE(OpenDocument("bug_555784.pdf"));
FPDF_PAGE page = LoadPage(0);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);
@@ -115,7 +115,7 @@ TEST_F(FPDFParserDecodeEmbeddertest, Bug_455199) {
// Should open successfully.
EXPECT_TRUE(OpenDocument("bug_455199.pdf"));
FPDF_PAGE page = LoadPage(0);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
const char kExpectedMd5sum[] = "b90475ca64d1348c3bf5e2b77ad9187a";
#elif _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
diff --git a/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp b/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp
index 5b7cbc6f05..caf4673b85 100644
--- a/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp
+++ b/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp
@@ -13,7 +13,7 @@ TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_554151) {
EXPECT_TRUE(OpenDocument("bug_554151.pdf"));
FPDF_PAGE page = LoadPage(0);
EXPECT_NE(nullptr, page);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
CompareBitmap(bitmap, 612, 792, "a14d7ee573c1b2456d7bf6b7762823cf");
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);
@@ -24,7 +24,7 @@ TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_557223) {
EXPECT_TRUE(OpenDocument("bug_557223.pdf"));
FPDF_PAGE page = LoadPage(0);
EXPECT_NE(nullptr, page);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
CompareBitmap(bitmap, 24, 24, "dc0ea1b743c2edb22c597cadc8537f7b");
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);
@@ -35,7 +35,7 @@ TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_603518) {
EXPECT_TRUE(OpenDocument("bug_603518.pdf"));
FPDF_PAGE page = LoadPage(0);
EXPECT_NE(nullptr, page);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
CompareBitmap(bitmap, 749, 749, "b9e75190cdc5edf0069a408744ca07dc");
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);
diff --git a/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp b/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp
index ed6da46f2a..f141590f46 100644
--- a/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp
+++ b/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp
@@ -11,7 +11,7 @@ TEST_F(FPDFRenderPatternEmbeddertest, LoadError_547706) {
// Test shading where object is a dictionary instead of a stream.
EXPECT_TRUE(OpenDocument("bug_547706.pdf"));
FPDF_PAGE page = LoadPage(0);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);
diff --git a/core/fxcodec/codec/fx_codec_embeddertest.cpp b/core/fxcodec/codec/fx_codec_embeddertest.cpp
index fd02f973a1..50a15c3dc2 100644
--- a/core/fxcodec/codec/fx_codec_embeddertest.cpp
+++ b/core/fxcodec/codec/fx_codec_embeddertest.cpp
@@ -13,7 +13,7 @@ TEST_F(FXCodecEmbeddertest, Bug_631912) {
EXPECT_TRUE(OpenDocument("bug_631912.pdf"));
FPDF_PAGE page = LoadPage(0);
EXPECT_NE(nullptr, page);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
CompareBitmap(bitmap, 691, 432, "24d75af646f8772c5ee7ced260452ae4");
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);
diff --git a/core/fxge/fx_ge_text_embeddertest.cpp b/core/fxge/fx_ge_text_embeddertest.cpp
index 045b6dc869..7aeb3f3e07 100644
--- a/core/fxge/fx_ge_text_embeddertest.cpp
+++ b/core/fxge/fx_ge_text_embeddertest.cpp
@@ -12,7 +12,7 @@ TEST_F(FXGETextEmbedderTest, BadItalic) {
EXPECT_TRUE(OpenDocument("bug_601362.pdf"));
FPDF_PAGE page = LoadPage(0);
EXPECT_NE(nullptr, page);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);
}
diff --git a/fpdfsdk/fpdfannot_embeddertest.cpp b/fpdfsdk/fpdfannot_embeddertest.cpp
index ba9bbe0ea9..5b5c29717b 100644
--- a/fpdfsdk/fpdfannot_embeddertest.cpp
+++ b/fpdfsdk/fpdfannot_embeddertest.cpp
@@ -38,9 +38,9 @@ TEST_F(FPDFAnnotEmbeddertest, RenderAnnotWithOnlyRolloverAP) {
// normal appearance defined, only its rollover appearance. In this case, its
// normal appearance should be generated, allowing the highlight annotation to
// still display.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle(), FPDF_ANNOT);
- CompareBitmap(bitmap, 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e");
- FPDFBitmap_Destroy(bitmap);
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e");
UnloadPage(page);
}
@@ -356,7 +356,8 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
EXPECT_EQ(4, FPDFPage_GetAnnotCount(page));
// Check that the original file renders correctly.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ FPDF_BITMAP bitmap =
+ RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, md5_original);
FPDFBitmap_Destroy(bitmap);
@@ -396,7 +397,7 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
EXPECT_EQ(quadpoints.y4, new_quadpoints.y4);
// Check that updating quadpoints does not change the annotation's position.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, md5_original);
FPDFBitmap_Destroy(bitmap);
@@ -416,7 +417,7 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
}
// Check that updating the rectangle changes the annotation's position.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, md5_modified_highlight);
FPDFBitmap_Destroy(bitmap);
@@ -437,7 +438,7 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
// Check that updating the rectangle changes the square annotation's
// position.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, md5_modified_square);
FPDFBitmap_Destroy(bitmap);
}
@@ -546,7 +547,8 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
EXPECT_EQ(2, FPDFPage_GetAnnotCount(page));
// Check that the page renders correctly.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ FPDF_BITMAP bitmap =
+ RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_original);
FPDFBitmap_Destroy(bitmap);
@@ -569,7 +571,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
EXPECT_TRUE(FPDFAnnot_UpdateObject(annot.get(), path));
// Check that the page with the modified annotation renders correctly.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_modified_path);
FPDFBitmap_Destroy(bitmap);
@@ -583,7 +585,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
EXPECT_EQ(2, FPDFAnnot_GetObjectCount(annot.get()));
// Check that the page with an annotation with two paths renders correctly.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_two_paths);
FPDFBitmap_Destroy(bitmap);
@@ -593,7 +595,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
}
// Check that the page renders the same as before.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_modified_path);
FPDFBitmap_Destroy(bitmap);
@@ -669,7 +671,8 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyAnnotationFlags) {
ASSERT_TRUE(page);
// Check that the page renders correctly.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ FPDF_BITMAP bitmap =
+ RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e");
FPDFBitmap_Destroy(bitmap);
@@ -692,7 +695,7 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyAnnotationFlags) {
EXPECT_TRUE(flags & FPDF_ANNOT_FLAG_PRINT);
// Check that the page renders correctly without rendering the annotation.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
FPDFBitmap_Destroy(bitmap);
@@ -706,7 +709,7 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyAnnotationFlags) {
EXPECT_TRUE(flags & FPDF_ANNOT_FLAG_PRINT);
// Check that the page renders correctly as before.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e");
FPDFBitmap_Destroy(bitmap);
}
@@ -732,7 +735,8 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyImage) {
EXPECT_EQ(2, FPDFPage_GetAnnotCount(page));
// Check that the page renders correctly.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ FPDF_BITMAP bitmap =
+ RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_original);
FPDFBitmap_Destroy(bitmap);
@@ -766,7 +770,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyImage) {
}
// Check that the page renders correctly with the new image object.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_new_image);
FPDFBitmap_Destroy(bitmap);
@@ -813,7 +817,8 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyText) {
EXPECT_EQ(2, FPDFPage_GetAnnotCount(page));
// Check that the page renders correctly.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ FPDF_BITMAP bitmap =
+ RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_original);
FPDFBitmap_Destroy(bitmap);
@@ -842,7 +847,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyText) {
}
// Check that the page renders correctly with the new text object.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_new_text);
FPDFBitmap_Destroy(bitmap);
@@ -863,13 +868,13 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyText) {
}
// Check that the page renders correctly with the modified text object.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_modified_text);
FPDFBitmap_Destroy(bitmap);
// Remove the new annotation, and check that the page renders as before.
EXPECT_TRUE(FPDFPage_RemoveAnnot(page, 2));
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_original);
FPDFBitmap_Destroy(bitmap);
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp
index 1a422bd941..f388107708 100644
--- a/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -197,7 +197,7 @@ TEST_F(FPDFEditEmbeddertest, RasterizePDF) {
EXPECT_TRUE(OpenDocument("black.pdf"));
FPDF_PAGE orig_page = LoadPage(0);
EXPECT_NE(nullptr, orig_page);
- orig_bitmap = RenderPage(orig_page);
+ orig_bitmap = RenderPageDeprecated(orig_page);
CompareBitmap(orig_bitmap, 612, 792, kAllBlackMd5sum);
UnloadPage(orig_page);
}
@@ -241,7 +241,7 @@ TEST_F(FPDFEditEmbeddertest, AddPaths) {
EXPECT_TRUE(FPDFPath_SetFillColor(red_rect, 255, 0, 0, 255));
EXPECT_TRUE(FPDFPath_SetDrawMode(red_rect, FPDF_FILLMODE_ALTERNATE, 0));
FPDFPage_InsertObject(page, red_rect);
- FPDF_BITMAP page_bitmap = RenderPage(page);
+ FPDF_BITMAP page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, "66d02eaa6181e2c069ce2ea99beda497");
FPDFBitmap_Destroy(page_bitmap);
@@ -302,7 +302,7 @@ TEST_F(FPDFEditEmbeddertest, AddPaths) {
EXPECT_TRUE(FPDFPath_SetDrawMode(green_rect, FPDF_FILLMODE_WINDING, 0));
FPDFPage_InsertObject(page, green_rect);
- page_bitmap = RenderPage(page);
+ page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, "7b0b87604594e773add528fae567a558");
FPDFBitmap_Destroy(page_bitmap);
@@ -340,7 +340,7 @@ TEST_F(FPDFEditEmbeddertest, AddPaths) {
EXPECT_EQ(nullptr, FPDFPath_GetPathSegment(black_path, 3));
FPDFPage_InsertObject(page, black_path);
- page_bitmap = RenderPage(page);
+ page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, "eadc8020a14dfcf091da2688733d8806");
FPDFBitmap_Destroy(page_bitmap);
@@ -355,7 +355,7 @@ TEST_F(FPDFEditEmbeddertest, AddPaths) {
EXPECT_TRUE(FPDFPath_BezierTo(blue_path, 375, 330, 390, 360, 400, 400));
EXPECT_TRUE(FPDFPath_Close(blue_path));
FPDFPage_InsertObject(page, blue_path);
- page_bitmap = RenderPage(page);
+ page_bitmap = RenderPageDeprecated(page);
const char last_md5[] = "9823e1a21bd9b72b6a442ba4f12af946";
CompareBitmap(page_bitmap, 612, 792, last_md5);
FPDFBitmap_Destroy(page_bitmap);
@@ -418,7 +418,7 @@ TEST_F(FPDFEditEmbeddertest, PathOnTopOfText) {
FPDFPage_InsertObject(page, black_path);
// Render and check the result. Text is slightly different on Mac.
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
const char md5[] = "f9e6fa74230f234286bfcada9f7606d8";
#else
@@ -447,7 +447,7 @@ TEST_F(FPDFEditEmbeddertest, EditOverExistingContent) {
EXPECT_TRUE(FPDFPath_SetDrawMode(red_rect, FPDF_FILLMODE_ALTERNATE, 0));
FPDFPage_InsertObject(page, red_rect);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
CompareBitmap(bitmap, 612, 792, "ad04e5bd0f471a9a564fb034bd0fb073");
FPDFBitmap_Destroy(bitmap);
EXPECT_TRUE(FPDFPage_GenerateContent(page));
@@ -472,7 +472,8 @@ TEST_F(FPDFEditEmbeddertest, EditOverExistingContent) {
EXPECT_TRUE(FPDFPath_SetFillColor(green_rect2, 0, 255, 0, 100));
EXPECT_TRUE(FPDFPath_SetDrawMode(green_rect2, FPDF_FILLMODE_ALTERNATE, 0));
FPDFPage_InsertObject(page, green_rect2);
- FPDF_BITMAP new_bitmap = RenderPageWithFlags(page, saved_form_handle_, 0);
+ FPDF_BITMAP new_bitmap =
+ RenderPageWithFlagsDeprecated(page, saved_form_handle_, 0);
const char last_md5[] = "4b5b00f824620f8c9b8801ebb98e1cdd";
CompareBitmap(new_bitmap, 612, 792, last_md5);
FPDFBitmap_Destroy(new_bitmap);
@@ -499,7 +500,7 @@ TEST_F(FPDFEditEmbeddertest, AddStrokedPaths) {
EXPECT_TRUE(FPDFPath_SetStrokeWidth(rect, 15.0f));
EXPECT_TRUE(FPDFPath_SetDrawMode(rect, 0, 1));
FPDFPage_InsertObject(page, rect);
- FPDF_BITMAP page_bitmap = RenderPage(page);
+ FPDF_BITMAP page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, "64bd31f862a89e0a9e505a5af6efd506");
FPDFBitmap_Destroy(page_bitmap);
@@ -513,7 +514,7 @@ TEST_F(FPDFEditEmbeddertest, AddStrokedPaths) {
EXPECT_TRUE(FPDFPath_SetStrokeWidth(check, 8.35f));
EXPECT_TRUE(FPDFPath_SetDrawMode(check, 0, 1));
FPDFPage_InsertObject(page, check);
- page_bitmap = RenderPage(page);
+ page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, "4b6f3b9d25c4e194821217d5016c3724");
FPDFBitmap_Destroy(page_bitmap);
@@ -528,7 +529,7 @@ TEST_F(FPDFEditEmbeddertest, AddStrokedPaths) {
EXPECT_TRUE(FPDFPath_SetStrokeWidth(path, 10.5f));
EXPECT_TRUE(FPDFPath_SetDrawMode(path, FPDF_FILLMODE_ALTERNATE, 1));
FPDFPage_InsertObject(page, path);
- page_bitmap = RenderPage(page);
+ page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, "ff3e6a22326754944cc6e56609acd73b");
FPDFBitmap_Destroy(page_bitmap);
FPDF_ClosePage(page);
@@ -547,7 +548,7 @@ TEST_F(FPDFEditEmbeddertest, AddStandardFontText) {
EXPECT_TRUE(FPDFText_SetText(text_object1, text1.get()));
FPDFPageObj_Transform(text_object1, 1, 0, 0, 1, 20, 20);
FPDFPage_InsertObject(page, text_object1);
- FPDF_BITMAP page_bitmap = RenderPage(page);
+ FPDF_BITMAP page_bitmap = RenderPageDeprecated(page);
#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
const char md5[] = "a4dddc1a3930fa694bbff9789dab4161";
#else
@@ -565,7 +566,7 @@ TEST_F(FPDFEditEmbeddertest, AddStandardFontText) {
EXPECT_TRUE(FPDFText_SetText(text_object2, text2.get()));
FPDFPageObj_Transform(text_object2, 1, 0, 0, 1, 100, 600);
FPDFPage_InsertObject(page, text_object2);
- page_bitmap = RenderPage(page);
+ page_bitmap = RenderPageDeprecated(page);
#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
const char md5_2[] = "a5c4ace4c6f27644094813fe1441a21c";
#elif _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
@@ -585,7 +586,7 @@ TEST_F(FPDFEditEmbeddertest, AddStandardFontText) {
EXPECT_TRUE(FPDFText_SetText(text_object3, text3.get()));
FPDFPageObj_Transform(text_object3, 1, 1.5, 2, 0.5, 200, 200);
FPDFPage_InsertObject(page, text_object3);
- page_bitmap = RenderPage(page);
+ page_bitmap = RenderPageDeprecated(page);
#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
const char md5_3[] = "40b3ef04f915ff4c4208948001763544";
#elif _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
@@ -674,7 +675,7 @@ TEST_F(FPDFEditEmbeddertest, DoubleGenerating) {
EXPECT_EQ(2, static_cast<int>(graphics_dict->GetCount()));
// Check the bitmap
- FPDF_BITMAP page_bitmap = RenderPage(page);
+ FPDF_BITMAP page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, "5384da3406d62360ffb5cac4476fff1c");
FPDFBitmap_Destroy(page_bitmap);
@@ -684,14 +685,14 @@ TEST_F(FPDFEditEmbeddertest, DoubleGenerating) {
EXPECT_EQ(3, static_cast<int>(graphics_dict->GetCount()));
// Check that bitmap displays changed content
- page_bitmap = RenderPage(page);
+ page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, "2e51656f5073b0bee611d9cd086aa09c");
FPDFBitmap_Destroy(page_bitmap);
// And now generate, without changes
EXPECT_TRUE(FPDFPage_GenerateContent(page));
EXPECT_EQ(3, static_cast<int>(graphics_dict->GetCount()));
- page_bitmap = RenderPage(page);
+ page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, "2e51656f5073b0bee611d9cd086aa09c");
FPDFBitmap_Destroy(page_bitmap);
@@ -888,7 +889,7 @@ TEST_F(FPDFEditEmbeddertest, AddTrueTypeFontText) {
EXPECT_TRUE(FPDFText_SetText(text_object, text.get()));
FPDFPageObj_Transform(text_object, 1, 0, 0, 1, 400, 400);
FPDFPage_InsertObject(page, text_object);
- FPDF_BITMAP page_bitmap = RenderPage(page);
+ FPDF_BITMAP page_bitmap = RenderPageDeprecated(page);
#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
const char md5[] = "17d2b6cd574cf66170b09c8927529a94";
#else
@@ -906,7 +907,7 @@ TEST_F(FPDFEditEmbeddertest, AddTrueTypeFontText) {
FPDFPageObj_Transform(text_object2, 1, 0, 0, 1, 200, 200);
FPDFPage_InsertObject(page, text_object2);
}
- FPDF_BITMAP page_bitmap2 = RenderPage(page);
+ FPDF_BITMAP page_bitmap2 = RenderPageDeprecated(page);
#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
const char md5_2[] = "8eded4193ff1f0f77b8b600a825e97ea";
#else
@@ -985,7 +986,7 @@ TEST_F(FPDFEditEmbeddertest, AddCIDFontText) {
}
// Check that the text renders properly.
- FPDF_BITMAP page_bitmap = RenderPage(page);
+ FPDF_BITMAP page_bitmap = RenderPageDeprecated(page);
const char md5[] = "c68cd79aa72bf83a7b25271370d46b21";
CompareBitmap(page_bitmap, 612, 792, md5);
FPDFBitmap_Destroy(page_bitmap);
@@ -1018,7 +1019,7 @@ TEST_F(FPDFEditEmbeddertest, SaveAndRender) {
EXPECT_TRUE(FPDFPath_BezierTo(green_path, 38, 33, 39, 36, 40, 40));
EXPECT_TRUE(FPDFPath_Close(green_path));
FPDFPage_InsertObject(page, green_path);
- FPDF_BITMAP page_bitmap = RenderPage(page);
+ FPDF_BITMAP page_bitmap = RenderPageDeprecated(page);
CompareBitmap(page_bitmap, 612, 792, md5);
FPDFBitmap_Destroy(page_bitmap);
diff --git a/fpdfsdk/fpdfformfill_embeddertest.cpp b/fpdfsdk/fpdfformfill_embeddertest.cpp
index ae1c02ede1..8b81467822 100644
--- a/fpdfsdk/fpdfformfill_embeddertest.cpp
+++ b/fpdfsdk/fpdfformfill_embeddertest.cpp
@@ -532,7 +532,7 @@ TEST_F(FPDFFormFillEmbeddertest, FormText) {
EXPECT_TRUE(OpenDocument("text_form.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap1(RenderPage(page));
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap1 = RenderLoadedPage(page);
CompareBitmap(bitmap1.get(), 300, 300, md5_1);
// Click on the textfield
@@ -546,14 +546,14 @@ TEST_F(FPDFFormFillEmbeddertest, FormText) {
FORM_OnChar(form_handle(), page, 65, 0);
FORM_OnChar(form_handle(), page, 66, 0);
FORM_OnChar(form_handle(), page, 67, 0);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap2(RenderPage(page));
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap2 = RenderLoadedPage(page);
CompareBitmap(bitmap2.get(), 300, 300, md5_2);
// Take out focus by clicking out of the textfield
FORM_OnMouseMove(form_handle(), page, 0, 15.0, 15.0);
FORM_OnLButtonDown(form_handle(), page, 0, 15.0, 15.0);
FORM_OnLButtonUp(form_handle(), page, 0, 15.0, 15.0);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap3(RenderPage(page));
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap3 = RenderLoadedPage(page);
CompareBitmap(bitmap3.get(), 300, 300, md5_3);
EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
diff --git a/fpdfsdk/fpdfppo_embeddertest.cpp b/fpdfsdk/fpdfppo_embeddertest.cpp
index 2a4c774bae..0b3463e391 100644
--- a/fpdfsdk/fpdfppo_embeddertest.cpp
+++ b/fpdfsdk/fpdfppo_embeddertest.cpp
@@ -217,7 +217,7 @@ TEST_F(FPDFPPOEmbeddertest, BUG_750568) {
FPDF_PAGE page = LoadPage(i);
ASSERT_NE(nullptr, page);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap));
ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap));
ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap));
@@ -236,7 +236,7 @@ TEST_F(FPDFPPOEmbeddertest, BUG_750568) {
FPDF_PAGE page = FPDF_LoadPage(output_doc, i);
ASSERT_NE(nullptr, page);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap));
ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap));
ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap));
@@ -254,7 +254,7 @@ TEST_F(FPDFPPOEmbeddertest, ImportWithZeroLengthStream) {
FPDF_PAGE page = LoadPage(0);
ASSERT_NE(nullptr, page);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap));
ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap));
ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap));
@@ -270,7 +270,7 @@ TEST_F(FPDFPPOEmbeddertest, ImportWithZeroLengthStream) {
EXPECT_EQ(1, FPDF_GetPageCount(new_doc));
FPDF_PAGE new_page = FPDF_LoadPage(new_doc, 0);
ASSERT_NE(nullptr, new_page);
- FPDF_BITMAP new_bitmap = RenderPage(new_page);
+ FPDF_BITMAP new_bitmap = RenderPageDeprecated(new_page);
ASSERT_EQ(200, FPDFBitmap_GetWidth(new_bitmap));
ASSERT_EQ(200, FPDFBitmap_GetHeight(new_bitmap));
ASSERT_EQ(800, FPDFBitmap_GetStride(new_bitmap));
diff --git a/fpdfsdk/fpdfsave_embeddertest.cpp b/fpdfsdk/fpdfsave_embeddertest.cpp
index 3122be1b53..bbf7566b1c 100644
--- a/fpdfsdk/fpdfsave_embeddertest.cpp
+++ b/fpdfsdk/fpdfsave_embeddertest.cpp
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "public/fpdf_save.h"
-
+#include <memory>
#include <string>
#include "core/fxcrt/fx_string.h"
#include "public/fpdf_edit.h"
#include "public/fpdf_ppo.h"
+#include "public/fpdf_save.h"
#include "public/fpdfview.h"
#include "testing/embedder_test.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
@@ -66,7 +66,7 @@ TEST_F(FPDFSaveEmbedderTest, SaveLinearizedDoc) {
EXPECT_TRUE(OpenDocument("linearized.pdf"));
for (int i = 0; i < kPageCount; ++i) {
FPDF_PAGE page = LoadPage(i);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
EXPECT_EQ(612, FPDFBitmap_GetWidth(bitmap));
EXPECT_EQ(792, FPDFBitmap_GetHeight(bitmap));
original_md5[i] = HashBitmap(bitmap);
@@ -84,9 +84,9 @@ TEST_F(FPDFSaveEmbedderTest, SaveLinearizedDoc) {
EXPECT_TRUE(OpenSavedDocument());
for (int i = 0; i < kPageCount; ++i) {
FPDF_PAGE page = LoadSavedPage(i);
- FPDF_BITMAP bitmap = RenderSavedPage(page);
- EXPECT_EQ(original_md5[i], HashBitmap(bitmap));
- FPDFBitmap_Destroy(bitmap);
+ ASSERT_TRUE(page);
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderSavedPage(page);
+ EXPECT_EQ(original_md5[i], HashBitmap(bitmap.get()));
CloseSavedPage(page);
}
CloseSavedDocument();
diff --git a/fpdfsdk/fpdfview_embeddertest.cpp b/fpdfsdk/fpdfview_embeddertest.cpp
index 47d02235ef..c46b3bd14f 100644
--- a/fpdfsdk/fpdfview_embeddertest.cpp
+++ b/fpdfsdk/fpdfview_embeddertest.cpp
@@ -429,14 +429,14 @@ TEST_F(FPDFViewEmbeddertest, FPDF_RenderPageBitmapWithMatrix) {
EXPECT_EQ(200, page_width);
EXPECT_EQ(300, page_height);
- FPDF_BITMAP bitmap = RenderPage(page);
+ FPDF_BITMAP bitmap = RenderPageDeprecated(page);
CompareBitmap(bitmap, page_width, page_height, kOriginalMD5);
FPDFBitmap_Destroy(bitmap);
FS_RECTF page_rect{0, 0, page_width, page_height};
// Try rendering with an identity matrix. The output should be the same as
- // the RenderPage() output.
+ // the RenderPageDeprecated() output.
FS_MATRIX identity_matrix{1, 0, 0, 1, 0, 0};
TestRenderPageBitmapWithMatrix(page, page_width, page_height, identity_matrix,
page_rect, kOriginalMD5);
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index d7f4376b24..bd52c26286 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -8,6 +8,7 @@
#include <fstream>
#include <list>
+#include <memory>
#include <string>
#include <utility>
#include <vector>
@@ -261,24 +262,6 @@ FPDF_PAGE EmbedderTest::LoadPage(int page_number) {
return page;
}
-FPDF_BITMAP EmbedderTest::RenderPage(FPDF_PAGE page) {
- return RenderPageWithFlags(page, form_handle_, 0);
-}
-
-FPDF_BITMAP EmbedderTest::RenderPageWithFlags(FPDF_PAGE page,
- FPDF_FORMHANDLE handle,
- int flags) {
- int width = static_cast<int>(FPDF_GetPageWidth(page));
- int height = static_cast<int>(FPDF_GetPageHeight(page));
- int alpha = FPDFPage_HasTransparency(page) ? 1 : 0;
- FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, alpha);
- FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF;
- FPDFBitmap_FillRect(bitmap, 0, 0, width, height, fill_color);
- FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, flags);
- FPDF_FFLDraw(handle, bitmap, page, 0, 0, width, height, 0, flags);
- return bitmap;
-}
-
void EmbedderTest::UnloadPage(FPDF_PAGE page) {
ASSERT(form_handle_);
FORM_DoPageAAction(page, form_handle_, FPDFPAGE_AACTION_CLOSE);
@@ -293,6 +276,55 @@ void EmbedderTest::UnloadPage(FPDF_PAGE page) {
page_reverse_map_.erase(it);
}
+FPDF_BITMAP EmbedderTest::RenderPageDeprecated(FPDF_PAGE page) {
+ return RenderPageWithFlagsDeprecated(page, form_handle_, 0);
+}
+
+std::unique_ptr<void, FPDFBitmapDeleter> EmbedderTest::RenderLoadedPage(
+ FPDF_PAGE page) {
+ return RenderLoadedPageWithFlags(page, 0);
+}
+
+std::unique_ptr<void, FPDFBitmapDeleter>
+EmbedderTest::RenderLoadedPageWithFlags(FPDF_PAGE page, int flags) {
+ return RenderPageWithFlags(page, form_handle_, flags);
+}
+
+std::unique_ptr<void, FPDFBitmapDeleter> EmbedderTest::RenderSavedPage(
+ FPDF_PAGE page) {
+ return RenderSavedPageWithFlags(page, 0);
+}
+
+std::unique_ptr<void, FPDFBitmapDeleter> EmbedderTest::RenderSavedPageWithFlags(
+ FPDF_PAGE page,
+ int flags) {
+ return RenderPageWithFlags(page, saved_form_handle_, flags);
+}
+
+// static
+FPDF_BITMAP EmbedderTest::RenderPageWithFlagsDeprecated(FPDF_PAGE page,
+ FPDF_FORMHANDLE handle,
+ int flags) {
+ return RenderPageWithFlags(page, handle, flags).release();
+}
+
+// static
+std::unique_ptr<void, FPDFBitmapDeleter> EmbedderTest::RenderPageWithFlags(
+ FPDF_PAGE page,
+ FPDF_FORMHANDLE handle,
+ int flags) {
+ int width = static_cast<int>(FPDF_GetPageWidth(page));
+ int height = static_cast<int>(FPDF_GetPageHeight(page));
+ int alpha = FPDFPage_HasTransparency(page) ? 1 : 0;
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap(
+ FPDFBitmap_Create(width, height, alpha));
+ FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF;
+ FPDFBitmap_FillRect(bitmap.get(), 0, 0, width, height, fill_color);
+ FPDF_RenderPageBitmap(bitmap.get(), page, 0, 0, width, height, 0, flags);
+ FPDF_FFLDraw(handle, bitmap.get(), page, 0, 0, width, height, 0, flags);
+ return bitmap;
+}
+
FPDF_DOCUMENT EmbedderTest::OpenSavedDocument(const char* password) {
memset(&saved_file_access_, 0, sizeof(saved_file_access_));
saved_file_access_.m_FileLen = data_string_.size();
@@ -330,10 +362,6 @@ FPDF_PAGE EmbedderTest::LoadSavedPage(int page_number) {
return page;
}
-FPDF_BITMAP EmbedderTest::RenderSavedPage(FPDF_PAGE page) {
- return RenderPageWithFlags(page, saved_form_handle_, 0);
-}
-
void EmbedderTest::CloseSavedPage(FPDF_PAGE page) {
ASSERT(page);
FPDF_ClosePage(page);
@@ -346,10 +374,9 @@ void EmbedderTest::VerifySavedRendering(FPDF_PAGE page,
ASSERT(saved_document_);
ASSERT(page);
- FPDF_BITMAP new_bitmap =
- RenderPageWithFlags(page, saved_form_handle_, FPDF_ANNOT);
- CompareBitmap(new_bitmap, width, height, md5);
- FPDFBitmap_Destroy(new_bitmap);
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderSavedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), width, height, md5);
}
void EmbedderTest::VerifySavedDocument(int width, int height, const char* md5) {
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,