5#include "core/fxge/dib/cstretchengine.h"
9#include "core/fpdfapi/page/cpdf_dib.h"
10#include "core/fpdfapi/parser/cpdf_dictionary.h"
11#include "core/fpdfapi/parser/cpdf_number.h"
12#include "core/fpdfapi/parser/cpdf_stream.h"
13#include "core/fxge/dib/fx_dib.h"
14#include "testing/gtest/include/gtest/gtest.h"
19constexpr uint32_t kTooBigSrcLen = 20;
20constexpr uint32_t kTooBigDestLen = 32 * 1024 * 1024 + 1;
30void ExecuteOneStretchTest(int32_t dest_width,
37 for (int32_t i = 0; i < dest_width; ++i) {
39 <<
"for { " << src_width <<
", " << dest_width <<
" } at " << i;
43void ExecuteOneReversedStretchTest(int32_t dest_width,
50 for (int32_t i = 0; i < dest_width; ++i) {
52 <<
"for { " << src_width <<
", " << dest_width <<
" } at " << i
59 constexpr int32_t kDestWidths[] = {1, 2, 337, 512, 808, 2550};
60 constexpr int32_t kSrcWidths[] = {1, 2, 187, 256, 809, 1110};
61 for (int32_t src_width : kSrcWidths) {
62 for (int32_t dest_width : kDestWidths) {
63 ExecuteOneStretchTest(dest_width, src_width, options);
64 ExecuteOneReversedStretchTest(dest_width, src_width, options);
73 RetainPtr<CPDF_Dictionary> dict_obj = pdfium::MakeRetain<CPDF_Dictionary>();
74 dict_obj->SetNewFor<CPDF_Number>(
"Width", 71000);
75 dict_obj->SetNewFor<CPDF_Number>(
"Height", 12500);
77 pdfium::MakeRetain<CPDF_Stream>(std::move(dict_obj));
78 auto dib_source = pdfium::MakeRetain<CPDF_DIB>(
nullptr, stream);
90 ExecuteStretchTests(options);
96 ExecuteStretchTests(options);
102 ExecuteStretchTests(options);
109 ExecuteStretchTests(options);
150 kTooBigSrcLen
, 0
, kTooBigSrcLen
,
PixelWeight * GetPixelWeight(int pixel)
bool CalculateWeights(int dest_len, int dest_min, int dest_max, int src_len, int src_min, int src_max, const FXDIB_ResampleOptions &options)
static constexpr uint32_t kFixedPointOne
const FXDIB_ResampleOptions & GetResampleOptionsForTest() const
TEST(CStretchEngine, OverflowInCtor)
uint32_t GetWeightForPosition(int position) const
bool bInterpolateBilinear