summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-25 18:49:32 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-25 18:49:32 +0000
commite08d2b1fee0db40bac9538ca8b7be0a951675bd6 (patch)
tree81ded468a54adb247f46d7824632f6c4a537619c /core
parenteb3ec8f29846a5df67269a53ca94d1d740c84513 (diff)
downloadpdfium-e08d2b1fee0db40bac9538ca8b7be0a951675bd6.tar.xz
Introduce ScopedFPDF types in public/cpp/fpdf_scopers.h
Applies std::remove_ptr to the public API types so that we can deduce a correct unique ptr type no matter how that API might change away from void* usage. Creates shorter names for std::unique_ptr<std::remove_pointer<>, ...> Change-Id: I04a0ff43cb7d5a4d3867939a53a54c9cef00db86 Reviewed-on: https://pdfium-review.googlesource.com/31292 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/edit/cpdf_creator_embeddertest.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_stitchfunc_embeddertest.cpp3
-rw-r--r--core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp3
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp7
-rw-r--r--core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp7
-rw-r--r--core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp3
-rw-r--r--core/fxcodec/codec/fx_codec_embeddertest.cpp3
-rw-r--r--core/fxge/fx_ge_text_embeddertest.cpp3
8 files changed, 20 insertions, 13 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp b/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp
index 86cd67b121..1913c4ba19 100644
--- a/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp
+++ b/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp
@@ -7,6 +7,7 @@
#include <vector>
#include "core/fxcrt/fx_system.h"
+#include "public/cpp/fpdf_scopers.h"
#include "public/fpdf_annot.h"
#include "public/fpdf_edit.h"
#include "public/fpdfview.h"
@@ -27,8 +28,7 @@ TEST_F(CPDF_CreatorEmbedderTest, SavedDocsAreEqualAfterParse) {
ASSERT_GE(1, FPDF_GetPageCount(document()));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
- RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ ScopedFPDFBitmap bitmap = RenderLoadedPageWithFlags(page, FPDF_ANNOT);
EXPECT_EQ(595, FPDFBitmap_GetWidth(bitmap.get()));
EXPECT_EQ(842, FPDFBitmap_GetHeight(bitmap.get()));
UnloadPage(page);
diff --git a/core/fpdfapi/page/cpdf_stitchfunc_embeddertest.cpp b/core/fpdfapi/page/cpdf_stitchfunc_embeddertest.cpp
index ebc71926a0..9b3b18d425 100644
--- a/core/fpdfapi/page/cpdf_stitchfunc_embeddertest.cpp
+++ b/core/fpdfapi/page/cpdf_stitchfunc_embeddertest.cpp
@@ -4,6 +4,7 @@
#include <memory>
+#include "public/cpp/fpdf_scopers.h"
#include "testing/embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -16,7 +17,7 @@ TEST_F(FPDFPageFuncEmbeddertest, Bug_551460) {
EXPECT_TRUE(OpenDocument("bug_551460.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap 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 4937b3d8d1..95f1dd4977 100644
--- a/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
+++ b/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
@@ -6,6 +6,7 @@
#include <string>
#include "core/fxcrt/fx_system.h"
+#include "public/cpp/fpdf_scopers.h"
#include "public/fpdf_edit.h"
#include "public/fpdf_save.h"
#include "public/fpdfview.h"
@@ -61,7 +62,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);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
CompareBitmap(bitmap.get(), 612, 792, md5);
EXPECT_TRUE(FPDFPage_GenerateContent(page));
SetWholeFileAvailable();
diff --git a/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp b/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp
index 0a7dde9b05..7054db99d7 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp
@@ -7,6 +7,7 @@
#include <string>
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
+#include "public/cpp/fpdf_scopers.h"
#include "testing/embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
@@ -94,7 +95,7 @@ TEST_F(FPDFParserDecodeEmbeddertest, Bug_552046) {
EXPECT_TRUE(OpenDocument("bug_552046.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
CompareBitmap(bitmap.get(), 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
UnloadPage(page);
}
@@ -105,7 +106,7 @@ TEST_F(FPDFParserDecodeEmbeddertest, Bug_555784) {
EXPECT_TRUE(OpenDocument("bug_555784.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
CompareBitmap(bitmap.get(), 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
UnloadPage(page);
}
@@ -116,7 +117,7 @@ TEST_F(FPDFParserDecodeEmbeddertest, Bug_455199) {
EXPECT_TRUE(OpenDocument("bug_455199.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(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 588b974e29..48d7ea3399 100644
--- a/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp
+++ b/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp
@@ -4,6 +4,7 @@
#include <memory>
+#include "public/cpp/fpdf_scopers.h"
#include "testing/embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,7 +16,7 @@ TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_554151) {
EXPECT_TRUE(OpenDocument("bug_554151.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
CompareBitmap(bitmap.get(), 612, 792, "a14d7ee573c1b2456d7bf6b7762823cf");
UnloadPage(page);
}
@@ -25,7 +26,7 @@ TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_557223) {
EXPECT_TRUE(OpenDocument("bug_557223.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
CompareBitmap(bitmap.get(), 24, 24, "dc0ea1b743c2edb22c597cadc8537f7b");
UnloadPage(page);
}
@@ -35,7 +36,7 @@ TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_603518) {
EXPECT_TRUE(OpenDocument("bug_603518.pdf"));
FPDF_PAGE page = LoadPage(0);
EXPECT_NE(nullptr, page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
CompareBitmap(bitmap.get(), 749, 749, "b9e75190cdc5edf0069a408744ca07dc");
UnloadPage(page);
}
diff --git a/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp b/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp
index 00b0933b71..31ce246365 100644
--- a/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp
+++ b/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp
@@ -4,6 +4,7 @@
#include <memory>
+#include "public/cpp/fpdf_scopers.h"
#include "testing/embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -14,7 +15,7 @@ TEST_F(FPDFRenderPatternEmbeddertest, LoadError_547706) {
EXPECT_TRUE(OpenDocument("bug_547706.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
CompareBitmap(bitmap.get(), 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
UnloadPage(page);
}
diff --git a/core/fxcodec/codec/fx_codec_embeddertest.cpp b/core/fxcodec/codec/fx_codec_embeddertest.cpp
index 40a1662839..3773cb21bc 100644
--- a/core/fxcodec/codec/fx_codec_embeddertest.cpp
+++ b/core/fxcodec/codec/fx_codec_embeddertest.cpp
@@ -4,6 +4,7 @@
#include <memory>
+#include "public/cpp/fpdf_scopers.h"
#include "testing/embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,7 +16,7 @@ TEST_F(FXCodecEmbeddertest, Bug_631912) {
EXPECT_TRUE(OpenDocument("bug_631912.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
CompareBitmap(bitmap.get(), 691, 432, "24d75af646f8772c5ee7ced260452ae4");
UnloadPage(page);
}
diff --git a/core/fxge/fx_ge_text_embeddertest.cpp b/core/fxge/fx_ge_text_embeddertest.cpp
index 362ccf5dc1..e47ed5f7c6 100644
--- a/core/fxge/fx_ge_text_embeddertest.cpp
+++ b/core/fxge/fx_ge_text_embeddertest.cpp
@@ -4,6 +4,7 @@
#include <memory>
+#include "public/cpp/fpdf_scopers.h"
#include "testing/embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -14,7 +15,7 @@ TEST_F(FXGETextEmbedderTest, BadItalic) {
EXPECT_TRUE(OpenDocument("bug_601362.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
EXPECT_EQ(612, FPDFBitmap_GetWidth(bitmap.get()));
EXPECT_EQ(792, FPDFBitmap_GetHeight(bitmap.get()));
UnloadPage(page);