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

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

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 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 "../../../include/fpdfapi/fpdf_module.h" 7 #include "../../../include/fpdfapi/fpdf_module.h"
8 #include "../../../include/fpdfapi/fpdf_pageobj.h" 8 #include "../../../include/fpdfapi/fpdf_pageobj.h"
9 #include "../../../include/fpdfapi/fpdf_render.h" 9 #include "../../../include/fpdfapi/fpdf_render.h"
10 #include "../../../include/fxcodec/fx_codec.h" 10 #include "../../../include/fxcodec/fx_codec.h"
(...skipping 22 matching lines...) Expand all
33 if (!pDIBitmap->IsAlphaMask()) { 33 if (!pDIBitmap->IsAlphaMask()) {
34 if (bitmap_alpha < 255) { 34 if (bitmap_alpha < 255) {
35 pDIBitmap->MultiplyAlpha(bitmap_alpha); 35 pDIBitmap->MultiplyAlpha(bitmap_alpha);
36 } 36 }
37 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { 37 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) {
38 return; 38 return;
39 } 39 }
40 } else { 40 } else {
41 FX_DWORD fill_argb = m_Options.TranslateColor(mask_argb); 41 FX_DWORD fill_argb = m_Options.TranslateColor(mask_argb);
42 if (bitmap_alpha < 255) { 42 if (bitmap_alpha < 255) {
43 ((FX_BYTE*)&fill_argb)[3] = ((FX_BYTE*)&fill_argb)[3] * bitmap_a lpha / 255; 43 ((uint8_t*)&fill_argb)[3] = ((uint8_t*)&fill_argb)[3] * bitmap_a lpha / 255;
44 } 44 }
45 if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) { 45 if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) {
46 return; 46 return;
47 } 47 }
48 } 48 }
49 } 49 }
50 FX_BOOL bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects; 50 FX_BOOL bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects;
51 FX_BOOL bGetBackGround = ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) || 51 FX_BOOL bGetBackGround = ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) ||
52 (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) && (m_pDevice->GetRenderCaps() 52 (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) && (m_pDevice->GetRenderCaps()
53 & FXRC_GET_BITS) && !bBackAlphaRequired); 53 & FXRC_GET_BITS) && !bBackAlphaRequired);
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 if (pBC) { 1003 if (pBC) {
1004 CPDF_Dictionary* pDict = pGroup->GetDict(); 1004 CPDF_Dictionary* pDict = pGroup->GetDict();
1005 if (pDict && pDict->GetDict(FX_BSTRC("Group"))) 1005 if (pDict && pDict->GetDict(FX_BSTRC("Group")))
1006 pCSObj = pDict->GetDict(FX_BSTRC("Group"))->GetElementValue(FX_B STRC("CS")); 1006 pCSObj = pDict->GetDict(FX_BSTRC("Group"))->GetElementValue(FX_B STRC("CS"));
1007 else 1007 else
1008 pCSObj = NULL; 1008 pCSObj = NULL;
1009 pCS = m_pContext->m_pDocument->LoadColorSpace(pCSObj); 1009 pCS = m_pContext->m_pDocument->LoadColorSpace(pCSObj);
1010 if (pCS) { 1010 if (pCS) {
1011 FX_FLOAT R, G, B; 1011 FX_FLOAT R, G, B;
1012 FX_DWORD comps = 8; 1012 FX_DWORD comps = 8;
1013 if (pCS->CountComponents() > static_cast<FX_INT32>(comps)) { 1013 if (pCS->CountComponents() > static_cast<int32_t>(comps)) {
1014 comps = (FX_DWORD)pCS->CountComponents(); 1014 comps = (FX_DWORD)pCS->CountComponents();
1015 } 1015 }
1016 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); 1016 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps);
1017 FX_FLOAT* pFloats = float_array; 1017 FX_FLOAT* pFloats = float_array;
1018 FX_SAFE_DWORD num_floats = comps; 1018 FX_SAFE_DWORD num_floats = comps;
1019 num_floats *= sizeof(FX_FLOAT); 1019 num_floats *= sizeof(FX_FLOAT);
1020 if (!num_floats.IsValid()) { 1020 if (!num_floats.IsValid()) {
1021 return NULL; 1021 return NULL;
1022 } 1022 }
1023 FXSYS_memset32(pFloats, 0, num_floats.ValueOrDie()); 1023 FXSYS_memset32(pFloats, 0, num_floats.ValueOrDie());
1024 int count = pBC->GetCount() > 8 ? 8 : pBC->GetCount(); 1024 int count = pBC->GetCount() > 8 ? 8 : pBC->GetCount();
1025 for (int i = 0; i < count; i ++) { 1025 for (int i = 0; i < count; i ++) {
1026 pFloats[i] = pBC->GetNumber(i); 1026 pFloats[i] = pBC->GetNumber(i);
1027 } 1027 }
1028 pCS->GetRGB(pFloats, R, G, B); 1028 pCS->GetRGB(pFloats, R, G, B);
1029 back_color = 0xff000000 | ((FX_INT32)(R * 255) << 16) | ((FX_INT 32)(G * 255) << 8) | (FX_INT32)(B * 255); 1029 back_color = 0xff000000 | ((int32_t)(R * 255) << 16) | ((int32_t )(G * 255) << 8) | (int32_t)(B * 255);
1030 m_pContext->m_pDocument->GetPageData()->ReleaseColorSpace(pCSObj ); 1030 m_pContext->m_pDocument->GetPageData()->ReleaseColorSpace(pCSObj );
1031 } 1031 }
1032 } 1032 }
1033 bitmap.Clear(back_color); 1033 bitmap.Clear(back_color);
1034 } else { 1034 } else {
1035 bitmap.Clear(0); 1035 bitmap.Clear(0);
1036 } 1036 }
1037 CPDF_Dictionary* pFormResource = NULL; 1037 CPDF_Dictionary* pFormResource = NULL;
1038 if (form.m_pFormDict) { 1038 if (form.m_pFormDict) {
1039 pFormResource = form.m_pFormDict->GetDict(FX_BSTRC("Resources")); 1039 pFormResource = form.m_pFormDict->GetDict(FX_BSTRC("Resources"));
1040 } 1040 }
1041 CPDF_RenderOptions options; 1041 CPDF_RenderOptions options;
1042 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA ; 1042 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA ;
1043 CPDF_RenderStatus status; 1043 CPDF_RenderStatus status;
1044 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL, 1044 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL,
1045 &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0, pCS ? pCS->GetFamily() : 0, bLuminosity); 1045 &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0, pCS ? pCS->GetFamily() : 0, bLuminosity);
1046 status.RenderObjectList(&form, &matrix); 1046 status.RenderObjectList(&form, &matrix);
1047 pMask = new CFX_DIBitmap; 1047 pMask = new CFX_DIBitmap;
1048 if (!pMask->Create(width, height, FXDIB_8bppMask)) { 1048 if (!pMask->Create(width, height, FXDIB_8bppMask)) {
1049 delete pMask; 1049 delete pMask;
1050 return NULL; 1050 return NULL;
1051 } 1051 }
1052 FX_LPBYTE dest_buf = pMask->GetBuffer(); 1052 FX_LPBYTE dest_buf = pMask->GetBuffer();
1053 int dest_pitch = pMask->GetPitch(); 1053 int dest_pitch = pMask->GetPitch();
1054 FX_LPBYTE src_buf = bitmap.GetBuffer(); 1054 FX_LPBYTE src_buf = bitmap.GetBuffer();
1055 int src_pitch = bitmap.GetPitch(); 1055 int src_pitch = bitmap.GetPitch();
1056 FX_LPBYTE pTransfer = FX_Alloc(FX_BYTE, 256); 1056 FX_LPBYTE pTransfer = FX_Alloc(uint8_t, 256);
1057 if (pFunc) { 1057 if (pFunc) {
1058 CFX_FixedBufGrow<FX_FLOAT, 16> results(pFunc->CountOutputs()); 1058 CFX_FixedBufGrow<FX_FLOAT, 16> results(pFunc->CountOutputs());
1059 for (int i = 0; i < 256; i ++) { 1059 for (int i = 0; i < 256; i ++) {
1060 FX_FLOAT input = (FX_FLOAT)i / 255.0f; 1060 FX_FLOAT input = (FX_FLOAT)i / 255.0f;
1061 int nresult; 1061 int nresult;
1062 pFunc->Call(&input, 1, results, nresult); 1062 pFunc->Call(&input, 1, results, nresult);
1063 pTransfer[i] = FXSYS_round(results[0] * 255); 1063 pTransfer[i] = FXSYS_round(results[0] * 255);
1064 } 1064 }
1065 } else { 1065 } else {
1066 for (int i = 0; i < 256; i ++) { 1066 for (int i = 0; i < 256; i ++) {
(...skipping 17 matching lines...) Expand all
1084 } 1084 }
1085 } else { 1085 } else {
1086 FXSYS_memcpy32(dest_buf, src_buf, dest_pitch * height); 1086 FXSYS_memcpy32(dest_buf, src_buf, dest_pitch * height);
1087 } 1087 }
1088 if (pFunc) { 1088 if (pFunc) {
1089 delete pFunc; 1089 delete pFunc;
1090 } 1090 }
1091 FX_Free(pTransfer); 1091 FX_Free(pTransfer);
1092 return pMask; 1092 return pMask;
1093 } 1093 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698