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

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

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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/fpdfapi/fpdf_render/render_int.h" 7 #include "core/fpdfapi/fpdf_render/render_int.h"
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 FX_BOOL bGroup = Transparency & PDFTRANS_GROUP; 50 FX_BOOL bGroup = Transparency & PDFTRANS_GROUP;
51 if (blend_mode == FXDIB_BLEND_NORMAL) { 51 if (blend_mode == FXDIB_BLEND_NORMAL) {
52 if (!pDIBitmap->IsAlphaMask()) { 52 if (!pDIBitmap->IsAlphaMask()) {
53 if (bitmap_alpha < 255) { 53 if (bitmap_alpha < 255) {
54 pDIBitmap->MultiplyAlpha(bitmap_alpha); 54 pDIBitmap->MultiplyAlpha(bitmap_alpha);
55 } 55 }
56 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { 56 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) {
57 return; 57 return;
58 } 58 }
59 } else { 59 } else {
60 FX_DWORD fill_argb = m_Options.TranslateColor(mask_argb); 60 uint32_t fill_argb = m_Options.TranslateColor(mask_argb);
61 if (bitmap_alpha < 255) { 61 if (bitmap_alpha < 255) {
62 ((uint8_t*)&fill_argb)[3] = 62 ((uint8_t*)&fill_argb)[3] =
63 ((uint8_t*)&fill_argb)[3] * bitmap_alpha / 255; 63 ((uint8_t*)&fill_argb)[3] * bitmap_alpha / 255;
64 } 64 }
65 if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) { 65 if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) {
66 return; 66 return;
67 } 67 }
68 } 68 }
69 } 69 }
70 FX_BOOL bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects; 70 FX_BOOL bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 pDIBitmap, 0, 0, blend_mode); 130 pDIBitmap, 0, 0, blend_mode);
131 } else { 131 } else {
132 pBackdrop->CompositeMask(left - back_left, top - back_top, 132 pBackdrop->CompositeMask(left - back_left, top - back_top,
133 pDIBitmap->GetWidth(), pDIBitmap->GetHeight(), 133 pDIBitmap->GetWidth(), pDIBitmap->GetHeight(),
134 pDIBitmap, mask_argb, 0, 0, blend_mode); 134 pDIBitmap, mask_argb, 0, 0, blend_mode);
135 } 135 }
136 136
137 std::unique_ptr<CFX_DIBitmap> pBackdrop1(new CFX_DIBitmap); 137 std::unique_ptr<CFX_DIBitmap> pBackdrop1(new CFX_DIBitmap);
138 pBackdrop1->Create(pBackdrop->GetWidth(), pBackdrop->GetHeight(), 138 pBackdrop1->Create(pBackdrop->GetWidth(), pBackdrop->GetHeight(),
139 FXDIB_Rgb32); 139 FXDIB_Rgb32);
140 pBackdrop1->Clear((FX_DWORD)-1); 140 pBackdrop1->Clear((uint32_t)-1);
141 pBackdrop1->CompositeBitmap(0, 0, pBackdrop->GetWidth(), 141 pBackdrop1->CompositeBitmap(0, 0, pBackdrop->GetWidth(),
142 pBackdrop->GetHeight(), pBackdrop.get(), 0, 0); 142 pBackdrop->GetHeight(), pBackdrop.get(), 0, 0);
143 pBackdrop = std::move(pBackdrop1); 143 pBackdrop = std::move(pBackdrop1);
144 m_pDevice->SetDIBits(pBackdrop.get(), back_left, back_top); 144 m_pDevice->SetDIBits(pBackdrop.get(), back_left, back_top);
145 } 145 }
146 146
147 CPDF_TransferFunc::CPDF_TransferFunc(CPDF_Document* pDoc) : m_pPDFDoc(pDoc) {} 147 CPDF_TransferFunc::CPDF_TransferFunc(CPDF_Document* pDoc) : m_pPDFDoc(pDoc) {}
148 148
149 FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF rgb) const { 149 FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF rgb) const {
150 return FXSYS_RGB(m_Samples[FXSYS_GetRValue(rgb)], 150 return FXSYS_RGB(m_Samples[FXSYS_GetRValue(rgb)],
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 214 }
215 case FXDIB_8bppRgb: { 215 case FXDIB_8bppRgb: {
216 FX_ARGB* pPal = m_pSrc->GetPalette(); 216 FX_ARGB* pPal = m_pSrc->GetPalette();
217 for (i = 0; i < m_Width; i++) { 217 for (i = 0; i < m_Width; i++) {
218 if (pPal) { 218 if (pPal) {
219 FX_ARGB src_argb = pPal[*src_buf]; 219 FX_ARGB src_argb = pPal[*src_buf];
220 *dest_buf++ = m_RampB[FXARGB_R(src_argb)]; 220 *dest_buf++ = m_RampB[FXARGB_R(src_argb)];
221 *dest_buf++ = m_RampG[FXARGB_G(src_argb)]; 221 *dest_buf++ = m_RampG[FXARGB_G(src_argb)];
222 *dest_buf++ = m_RampR[FXARGB_B(src_argb)]; 222 *dest_buf++ = m_RampR[FXARGB_B(src_argb)];
223 } else { 223 } else {
224 FX_DWORD src_byte = *src_buf; 224 uint32_t src_byte = *src_buf;
225 *dest_buf++ = m_RampB[src_byte]; 225 *dest_buf++ = m_RampB[src_byte];
226 *dest_buf++ = m_RampG[src_byte]; 226 *dest_buf++ = m_RampG[src_byte];
227 *dest_buf++ = m_RampR[src_byte]; 227 *dest_buf++ = m_RampR[src_byte];
228 } 228 }
229 src_buf++; 229 src_buf++;
230 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 230 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
231 dest_buf++; 231 dest_buf++;
232 #endif 232 #endif
233 } 233 }
234 break; 234 break;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 CPDF_Object* pFilters = 410 CPDF_Object* pFilters =
411 m_pImageObject->m_pImage->GetStream()->GetDict()->GetElementValue( 411 m_pImageObject->m_pImage->GetStream()->GetDict()->GetElementValue(
412 "Filter"); 412 "Filter");
413 if (pFilters) { 413 if (pFilters) {
414 if (pFilters->IsName()) { 414 if (pFilters->IsName()) {
415 CFX_ByteStringC bsDecodeType = pFilters->GetConstString(); 415 CFX_ByteStringC bsDecodeType = pFilters->GetConstString();
416 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { 416 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") {
417 m_Flags |= FXRENDER_IMAGE_LOSSY; 417 m_Flags |= FXRENDER_IMAGE_LOSSY;
418 } 418 }
419 } else if (CPDF_Array* pArray = pFilters->AsArray()) { 419 } else if (CPDF_Array* pArray = pFilters->AsArray()) {
420 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { 420 for (uint32_t i = 0; i < pArray->GetCount(); i++) {
421 CFX_ByteStringC bsDecodeType = pArray->GetConstStringAt(i); 421 CFX_ByteStringC bsDecodeType = pArray->GetConstStringAt(i);
422 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { 422 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") {
423 m_Flags |= FXRENDER_IMAGE_LOSSY; 423 m_Flags |= FXRENDER_IMAGE_LOSSY;
424 break; 424 break;
425 } 425 }
426 } 426 }
427 } 427 }
428 } 428 }
429 } 429 }
430 if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) { 430 if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 if (StartLoadDIBSource()) { 487 if (StartLoadDIBSource()) {
488 return TRUE; 488 return TRUE;
489 } 489 }
490 return StartRenderDIBSource(); 490 return StartRenderDIBSource();
491 } 491 }
492 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, 492 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus,
493 const CFX_DIBSource* pDIBSource, 493 const CFX_DIBSource* pDIBSource,
494 FX_ARGB bitmap_argb, 494 FX_ARGB bitmap_argb,
495 int bitmap_alpha, 495 int bitmap_alpha,
496 const CFX_Matrix* pImage2Device, 496 const CFX_Matrix* pImage2Device,
497 FX_DWORD flags, 497 uint32_t flags,
498 FX_BOOL bStdCS, 498 FX_BOOL bStdCS,
499 int blendType) { 499 int blendType) {
500 m_pRenderStatus = pStatus; 500 m_pRenderStatus = pStatus;
501 m_pDIBSource = pDIBSource; 501 m_pDIBSource = pDIBSource;
502 m_FillArgb = bitmap_argb; 502 m_FillArgb = bitmap_argb;
503 m_BitmapAlpha = bitmap_alpha; 503 m_BitmapAlpha = bitmap_alpha;
504 m_ImageMatrix = *pImage2Device; 504 m_ImageMatrix = *pImage2Device;
505 m_Flags = flags; 505 m_Flags = flags;
506 m_bStdCS = bStdCS; 506 m_bStdCS = bStdCS;
507 m_BlendType = blendType; 507 m_BlendType = blendType;
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 dest_rect.top, m_FillArgb, m_BitmapAlpha, 781 dest_rect.top, m_FillArgb, m_BitmapAlpha,
782 m_BlendType, FALSE); 782 m_BlendType, FALSE);
783 } 783 }
784 return FALSE; 784 return FALSE;
785 } 785 }
786 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { 786 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() {
787 if (m_pDIBSource->IsOpaqueImage()) { 787 if (m_pDIBSource->IsOpaqueImage()) {
788 CFX_PathData path; 788 CFX_PathData path;
789 path.AppendRect(0, 0, 1, 1); 789 path.AppendRect(0, 0, 1, 1);
790 path.Transform(&m_ImageMatrix); 790 path.Transform(&m_ImageMatrix);
791 FX_DWORD fill_color = 791 uint32_t fill_color =
792 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha); 792 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha);
793 m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0, 793 m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0,
794 FXFILL_WINDING); 794 FXFILL_WINDING);
795 } else { 795 } else {
796 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() 796 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask()
797 ? m_pDIBSource 797 ? m_pDIBSource
798 : m_pDIBSource->GetAlphaMask(); 798 : m_pDIBSource->GetAlphaMask();
799 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || 799 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f ||
800 FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) { 800 FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) {
801 int left, top; 801 int left, top;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 return TRUE; 861 return TRUE;
862 } 862 }
863 if (StartRenderDIBSource()) { 863 if (StartRenderDIBSource()) {
864 return Continue(pPause); 864 return Continue(pPause);
865 } 865 }
866 } 866 }
867 return FALSE; 867 return FALSE;
868 } 868 }
869 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( 869 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
870 const uint8_t* src_buf, 870 const uint8_t* src_buf,
871 FX_DWORD src_size, 871 uint32_t src_size,
872 int width, 872 int width,
873 int height, 873 int height,
874 int nComps, 874 int nComps,
875 int bpc, 875 int bpc,
876 const CPDF_Dictionary* pParams); 876 const CPDF_Dictionary* pParams);
877 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, 877 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
878 FX_RECT* pClipRect, 878 FX_RECT* pClipRect,
879 const CFX_Matrix* pMatrix) { 879 const CFX_Matrix* pMatrix) {
880 if (!pSMaskDict) { 880 if (!pSMaskDict) {
881 return NULL; 881 return NULL;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 FX_ARGB back_color = 0xff000000; 918 FX_ARGB back_color = 0xff000000;
919 if (pBC) { 919 if (pBC) {
920 CPDF_Dictionary* pDict = pGroup->GetDict(); 920 CPDF_Dictionary* pDict = pGroup->GetDict();
921 if (pDict && pDict->GetDictBy("Group")) 921 if (pDict && pDict->GetDictBy("Group"))
922 pCSObj = pDict->GetDictBy("Group")->GetElementValue("CS"); 922 pCSObj = pDict->GetDictBy("Group")->GetElementValue("CS");
923 else 923 else
924 pCSObj = NULL; 924 pCSObj = NULL;
925 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); 925 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj);
926 if (pCS) { 926 if (pCS) {
927 FX_FLOAT R, G, B; 927 FX_FLOAT R, G, B;
928 FX_DWORD comps = 8; 928 uint32_t comps = 8;
929 if (pCS->CountComponents() > comps) { 929 if (pCS->CountComponents() > comps) {
930 comps = pCS->CountComponents(); 930 comps = pCS->CountComponents();
931 } 931 }
932 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); 932 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps);
933 FX_FLOAT* pFloats = float_array; 933 FX_FLOAT* pFloats = float_array;
934 FX_SAFE_DWORD num_floats = comps; 934 FX_SAFE_DWORD num_floats = comps;
935 num_floats *= sizeof(FX_FLOAT); 935 num_floats *= sizeof(FX_FLOAT);
936 if (!num_floats.IsValid()) { 936 if (!num_floats.IsValid()) {
937 return NULL; 937 return NULL;
938 } 938 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 } else if (pFunc) { 997 } else if (pFunc) {
998 int size = dest_pitch * height; 998 int size = dest_pitch * height;
999 for (int i = 0; i < size; i++) { 999 for (int i = 0; i < size; i++) {
1000 dest_buf[i] = transfers[src_buf[i]]; 1000 dest_buf[i] = transfers[src_buf[i]];
1001 } 1001 }
1002 } else { 1002 } else {
1003 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); 1003 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
1004 } 1004 }
1005 return pMask.release(); 1005 return pMask.release();
1006 } 1006 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_render/fpdf_render_cache.cpp ('k') | core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698