Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render.cpp

Issue 1745683002: Fixup FX_RECT and FX_SMALL_RECT classes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, Dan's comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/src/fpdfapi/fpdf_render/render_int.h" 7 #include "core/src/fpdfapi/fpdf_render/render_int.h"
8 8
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_render.h" 10 #include "core/include/fpdfapi/fpdf_render.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } else { 233 } else {
234 m_InitialStates.DefaultStates(); 234 m_InitialStates.DefaultStates();
235 } 235 }
236 m_pObjectRenderer.reset(); 236 m_pObjectRenderer.reset();
237 m_Transparency = transparency; 237 m_Transparency = transparency;
238 return TRUE; 238 return TRUE;
239 } 239 }
240 void CPDF_RenderStatus::RenderObjectList( 240 void CPDF_RenderStatus::RenderObjectList(
241 const CPDF_PageObjectHolder* pObjectHolder, 241 const CPDF_PageObjectHolder* pObjectHolder,
242 const CFX_Matrix* pObj2Device) { 242 const CFX_Matrix* pObj2Device) {
243 CFX_FloatRect clip_rect = m_pDevice->GetClipBox(); 243 CFX_FloatRect clip_rect(m_pDevice->GetClipBox());
244 CFX_Matrix device2object; 244 CFX_Matrix device2object;
245 device2object.SetReverse(*pObj2Device); 245 device2object.SetReverse(*pObj2Device);
246 device2object.TransformRect(clip_rect); 246 device2object.TransformRect(clip_rect);
247 247
248 for (const auto& pCurObj : *pObjectHolder->GetPageObjectList()) { 248 for (const auto& pCurObj : *pObjectHolder->GetPageObjectList()) {
249 if (pCurObj.get() == m_pStopObj) { 249 if (pCurObj.get() == m_pStopObj) {
250 m_bStopped = TRUE; 250 m_bStopped = TRUE;
251 return; 251 return;
252 } 252 }
253 if (!pCurObj) 253 if (!pCurObj)
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 return; 1052 return;
1053 } 1053 }
1054 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex); 1054 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex);
1055 m_LastObjectRendered = 1055 m_LastObjectRendered =
1056 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); 1056 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end();
1057 m_pRenderStatus.reset(new CPDF_RenderStatus()); 1057 m_pRenderStatus.reset(new CPDF_RenderStatus());
1058 m_pRenderStatus->Initialize( 1058 m_pRenderStatus->Initialize(
1059 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, 1059 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions,
1060 m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); 1060 m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, NULL);
1061 m_pDevice->SaveState(); 1061 m_pDevice->SaveState();
1062 m_ClipRect = m_pDevice->GetClipBox(); 1062 m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox());
1063 CFX_Matrix device2object; 1063 CFX_Matrix device2object;
1064 device2object.SetReverse(m_pCurrentLayer->m_Matrix); 1064 device2object.SetReverse(m_pCurrentLayer->m_Matrix);
1065 device2object.TransformRect(m_ClipRect); 1065 device2object.TransformRect(m_ClipRect);
1066 } 1066 }
1067 CPDF_PageObjectList::iterator iter; 1067 CPDF_PageObjectList::iterator iter;
1068 CPDF_PageObjectList::iterator iterEnd = 1068 CPDF_PageObjectList::iterator iterEnd =
1069 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); 1069 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end();
1070 if (m_LastObjectRendered != iterEnd) { 1070 if (m_LastObjectRendered != iterEnd) {
1071 iter = m_LastObjectRendered; 1071 iter = m_LastObjectRendered;
1072 ++iter; 1072 ++iter;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv); 1288 m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv);
1289 } 1289 }
1290 } 1290 }
1291 m_pBitmapDevice.reset(new CFX_FxgeDevice); 1291 m_pBitmapDevice.reset(new CFX_FxgeDevice);
1292 FXDIB_Format dibFormat = FXDIB_Rgb; 1292 FXDIB_Format dibFormat = FXDIB_Rgb;
1293 int32_t bpp = 24; 1293 int32_t bpp = 24;
1294 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) { 1294 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) {
1295 dibFormat = FXDIB_Argb; 1295 dibFormat = FXDIB_Argb;
1296 bpp = 32; 1296 bpp = 32;
1297 } 1297 }
1298 CFX_FloatRect rect;
1299 int32_t iWidth, iHeight, iPitch;
1300 while (1) { 1298 while (1) {
1301 rect = pRect; 1299 CFX_FloatRect rect(pRect);
1302 m_Matrix.TransformRect(rect); 1300 m_Matrix.TransformRect(rect);
1303 FX_RECT bitmap_rect = rect.GetOutterRect(); 1301 FX_RECT bitmap_rect = rect.GetOutterRect();
1304 iWidth = bitmap_rect.Width(); 1302 int32_t iWidth = bitmap_rect.Width();
1305 iHeight = bitmap_rect.Height(); 1303 int32_t iHeight = bitmap_rect.Height();
1306 iPitch = (iWidth * bpp + 31) / 32 * 4; 1304 int32_t iPitch = (iWidth * bpp + 31) / 32 * 4;
1307 if (iWidth * iHeight < 1) { 1305 if (iWidth * iHeight < 1)
1308 return FALSE; 1306 return FALSE;
1309 } 1307
1310 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && 1308 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ &&
1311 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat)) { 1309 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat)) {
1312 break; 1310 break;
1313 } 1311 }
1314 m_Matrix.Scale(0.5f, 0.5f); 1312 m_Matrix.Scale(0.5f, 0.5f);
1315 } 1313 }
1316 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, 1314 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions,
1317 &m_Matrix); 1315 &m_Matrix);
1318 return TRUE; 1316 return TRUE;
1319 } 1317 }
1320 void CPDF_ScaledRenderBuffer::OutputToDevice() { 1318 void CPDF_ScaledRenderBuffer::OutputToDevice() {
1321 if (m_pBitmapDevice) { 1319 if (m_pBitmapDevice) {
1322 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, 1320 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left,
1323 m_Rect.top, m_Rect.Width(), m_Rect.Height()); 1321 m_Rect.top, m_Rect.Width(), m_Rect.Height());
1324 } 1322 }
1325 } 1323 }
1326 FX_BOOL IPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) { 1324 FX_BOOL IPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) {
1327 const CPDF_ContentMarkData* pData = pObj->m_ContentMark; 1325 const CPDF_ContentMarkData* pData = pObj->m_ContentMark;
1328 int nItems = pData->CountItems(); 1326 int nItems = pData->CountItems();
1329 for (int i = 0; i < nItems; i++) { 1327 for (int i = 0; i < nItems; i++) {
1330 const CPDF_ContentMarkItem& item = pData->GetItem(i); 1328 const CPDF_ContentMarkItem& item = pData->GetItem(i);
1331 if (item.GetName() == "OC" && 1329 if (item.GetName() == "OC" &&
1332 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict && 1330 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict &&
1333 !CheckOCGVisible(item.GetParam())) { 1331 !CheckOCGVisible(item.GetParam())) {
1334 return FALSE; 1332 return FALSE;
1335 } 1333 }
1336 } 1334 }
1337 return TRUE; 1335 return TRUE;
1338 } 1336 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698