78 CPDF_TilingPattern* pPattern,
79 CPDF_Form* pPatternForm,
92 if (!pdfium::base::IsValueInRangeForNumericType<
int>(ceil_height) ||
93 !pdfium::base::IsValueInRangeForNumericType<
int>(ceil_width)) {
97 int width =
static_cast<
int>(ceil_width);
98 int height =
static_cast<
int>(ceil_height);
106 int min_col =
static_cast<
int>(
108 int max_col =
static_cast<
int>(
110 int min_row =
static_cast<
int>(
112 int max_row =
static_cast<
int>(
116 if (height >
std::numeric_limits<
int>::max() / width)
124 std::unique_ptr<CPDF_GraphicStates> pStates;
129 RetainPtr<
const CPDF_Dictionary> pFormResource =
130 pPatternForm->GetDict()->GetDictFor(
"Resources");
131 for (
int col = min_col; col <= max_col; col++) {
132 for (
int row = min_row; row <= max_row; row++) {
133 CFX_PointF original = mtPattern2Device.Transform(
134 CFX_PointF(col * pPattern->x_step(), row * pPattern->y_step()));
136 matrix.Translate(original.x - mtPattern2Device
.e,
137 original.y - mtPattern2Device
.f);
159 min_col = (clip_box
.left - orig_x) / width;
160 if (clip_box
.left < orig_x)
163 max_col = (clip_box
.right - orig_x) / width;
164 if (clip_box
.right <= orig_x)
167 min_row = (clip_box
.top - orig_y) / height;
168 if (clip_box
.top < orig_y)
171 max_row = (clip_box
.bottom - orig_y) / height;
175 float left_offset = cell_bbox
.left - mtPattern2Device
.e;
176 float top_offset = cell_bbox
.bottom - mtPattern2Device
.f;
178 if (width * height < 16) {
179 RetainPtr<CFX_DIBitmap> pEnlargedBitmap = DrawPatternBitmap(
180 pContext->GetDocument(), pContext->GetPageCache(), pPattern,
181 pPatternForm, mtObj2Device, 8, 8, options.GetOptions());
182 pPatternBitmap = pEnlargedBitmap->StretchTo(
185 pPatternBitmap = DrawPatternBitmap(
186 pContext->GetDocument(), pContext->GetPageCache(), pPattern,
187 pPatternForm, mtObj2Device, width, height, options.GetOptions());
193 pPatternBitmap->ConvertColorScale(0, 0xffffff);
198 auto pScreen = pdfium::MakeRetain<CFX_DIBitmap>();
202 pdfium::span<
const uint8_t> src_buf = pPatternBitmap->GetBuffer();
203 for (
int col = min_col; col <= max_col; col++) {
204 for (
int row = min_row; row <= max_row; row++) {
213 CFX_PointF original = mtPattern2Device.Transform(
214 CFX_PointF(col * pPattern->x_step(), row * pPattern->y_step()));
216 FX_SAFE_INT32 safeStartX = FXSYS_roundf(original.x + left_offset);
217 FX_SAFE_INT32 safeStartY = FXSYS_roundf(original.y + top_offset);
219 safeStartX -= clip_box
.left;
220 safeStartY -= clip_box
.top;
221 if (!safeStartX.IsValid() || !safeStartY.IsValid())
224 start_x = safeStartX.ValueOrDie();
225 start_y = safeStartY.ValueOrDie();
227 if (width == 1 && height == 1) {
228 if (start_x < 0 || start_x >= clip_box
.Width() || start_y < 0 ||
232 uint32_t* dest_buf =
reinterpret_cast<uint32_t*>(
233 pScreen->GetWritableScanline(start_y).subspan(start_x * 4).data());
235 const uint32_t* src_buf32 =
236 fxcrt::reinterpret_span<
const uint32_t>(src_buf).data();
237 *dest_buf = *src_buf32;
239 *dest_buf = (*(src_buf.data()) << 24) | (fill_argb & 0xffffff);
243 pScreen->CompositeBitmap(start_x, start_y, width, height,
247 pScreen->CompositeMask(start_x, start_y, width, height,
248 pPatternBitmap, fill_argb, 0, 0,
const CPDF_Transparency & GetTransparency() const
const CPDF_GraphicStates & graphic_states() const
void AppendLayer(CPDF_PageObjectHolder *pObjectHolder, const CFX_Matrix &mtObject2Device)
void Render(CFX_RenderDevice *pDevice, const CPDF_PageObject *pStopObj, const CPDF_RenderOptions *pOptions, const CFX_Matrix *pLastMatrix)