OLD | NEW |
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/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv); | 1196 m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv); |
1197 } | 1197 } |
1198 } | 1198 } |
1199 #endif | 1199 #endif |
1200 CFX_Matrix ctm = m_pDevice->GetCTM(); | 1200 CFX_Matrix ctm = m_pDevice->GetCTM(); |
1201 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); | 1201 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); |
1202 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); | 1202 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); |
1203 m_Matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); | 1203 m_Matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); |
1204 CFX_FloatRect rect(*pRect); | 1204 CFX_FloatRect rect(*pRect); |
1205 m_Matrix.TransformRect(rect); | 1205 m_Matrix.TransformRect(rect); |
1206 FX_RECT bitmap_rect = rect.GetOutterRect(); | 1206 FX_RECT bitmap_rect = rect.GetOuterRect(); |
1207 m_pBitmap.reset(new CFX_DIBitmap); | 1207 m_pBitmap.reset(new CFX_DIBitmap); |
1208 m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb); | 1208 m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb); |
1209 return TRUE; | 1209 return TRUE; |
1210 } | 1210 } |
1211 void CPDF_DeviceBuffer::OutputToDevice() { | 1211 void CPDF_DeviceBuffer::OutputToDevice() { |
1212 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { | 1212 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { |
1213 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) { | 1213 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) { |
1214 m_pDevice->SetDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top); | 1214 m_pDevice->SetDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top); |
1215 } else { | 1215 } else { |
1216 m_pDevice->StretchDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top, | 1216 m_pDevice->StretchDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 m_pBitmapDevice.reset(new CFX_FxgeDevice); | 1264 m_pBitmapDevice.reset(new CFX_FxgeDevice); |
1265 FXDIB_Format dibFormat = FXDIB_Rgb; | 1265 FXDIB_Format dibFormat = FXDIB_Rgb; |
1266 int32_t bpp = 24; | 1266 int32_t bpp = 24; |
1267 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) { | 1267 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) { |
1268 dibFormat = FXDIB_Argb; | 1268 dibFormat = FXDIB_Argb; |
1269 bpp = 32; | 1269 bpp = 32; |
1270 } | 1270 } |
1271 while (1) { | 1271 while (1) { |
1272 CFX_FloatRect rect(pRect); | 1272 CFX_FloatRect rect(pRect); |
1273 m_Matrix.TransformRect(rect); | 1273 m_Matrix.TransformRect(rect); |
1274 FX_RECT bitmap_rect = rect.GetOutterRect(); | 1274 FX_RECT bitmap_rect = rect.GetOuterRect(); |
1275 int32_t iWidth = bitmap_rect.Width(); | 1275 int32_t iWidth = bitmap_rect.Width(); |
1276 int32_t iHeight = bitmap_rect.Height(); | 1276 int32_t iHeight = bitmap_rect.Height(); |
1277 int32_t iPitch = (iWidth * bpp + 31) / 32 * 4; | 1277 int32_t iPitch = (iWidth * bpp + 31) / 32 * 4; |
1278 if (iWidth * iHeight < 1) | 1278 if (iWidth * iHeight < 1) |
1279 return FALSE; | 1279 return FALSE; |
1280 | 1280 |
1281 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && | 1281 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && |
1282 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat, nullptr)) { | 1282 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat, nullptr)) { |
1283 break; | 1283 break; |
1284 } | 1284 } |
1285 m_Matrix.Scale(0.5f, 0.5f); | 1285 m_Matrix.Scale(0.5f, 0.5f); |
1286 } | 1286 } |
1287 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, | 1287 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, |
1288 &m_Matrix); | 1288 &m_Matrix); |
1289 return TRUE; | 1289 return TRUE; |
1290 } | 1290 } |
1291 void CPDF_ScaledRenderBuffer::OutputToDevice() { | 1291 void CPDF_ScaledRenderBuffer::OutputToDevice() { |
1292 if (m_pBitmapDevice) { | 1292 if (m_pBitmapDevice) { |
1293 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, | 1293 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, |
1294 m_Rect.top, m_Rect.Width(), m_Rect.Height()); | 1294 m_Rect.top, m_Rect.Width(), m_Rect.Height()); |
1295 } | 1295 } |
1296 } | 1296 } |
1297 | 1297 |
1298 #if defined _SKIA_SUPPORT_ | 1298 #if defined _SKIA_SUPPORT_ |
1299 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { | 1299 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { |
1300 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); | 1300 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); |
1301 } | 1301 } |
1302 #endif | 1302 #endif |
OLD | NEW |