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

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

Issue 2334323005: Rename dictionary set and get methods (Closed)
Patch Set: Created 4 years, 3 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 <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 m_pDIBSource = m_pClone.get(); 437 m_pDIBSource = m_pClone.get();
438 } 438 }
439 m_Flags = 0; 439 m_Flags = 0;
440 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) { 440 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) {
441 m_Flags |= RENDER_FORCE_DOWNSAMPLE; 441 m_Flags |= RENDER_FORCE_DOWNSAMPLE;
442 } else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) { 442 } else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) {
443 m_Flags |= RENDER_FORCE_HALFTONE; 443 m_Flags |= RENDER_FORCE_HALFTONE;
444 } 444 }
445 if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) { 445 if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) {
446 CPDF_Object* pFilters = 446 CPDF_Object* pFilters =
447 m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectBy( 447 m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectFor(
448 "Filter"); 448 "Filter");
449 if (pFilters) { 449 if (pFilters) {
450 if (pFilters->IsName()) { 450 if (pFilters->IsName()) {
451 CFX_ByteString bsDecodeType = pFilters->GetString(); 451 CFX_ByteString bsDecodeType = pFilters->GetString();
452 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { 452 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") {
453 m_Flags |= FXRENDER_IMAGE_LOSSY; 453 m_Flags |= FXRENDER_IMAGE_LOSSY;
454 } 454 }
455 } else if (CPDF_Array* pArray = pFilters->AsArray()) { 455 } else if (CPDF_Array* pArray = pFilters->AsArray()) {
456 for (size_t i = 0; i < pArray->GetCount(); i++) { 456 for (size_t i = 0; i < pArray->GetCount(); i++) {
457 CFX_ByteString bsDecodeType = pArray->GetStringAt(i); 457 CFX_ByteString bsDecodeType = pArray->GetStringAt(i);
(...skipping 25 matching lines...) Expand all
483 CPDF_Document* pDocument = nullptr; 483 CPDF_Document* pDocument = nullptr;
484 CPDF_Page* pPage = nullptr; 484 CPDF_Page* pPage = nullptr;
485 if (m_pRenderStatus->m_pContext->GetPageCache()) { 485 if (m_pRenderStatus->m_pContext->GetPageCache()) {
486 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage(); 486 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage();
487 pDocument = pPage->m_pDocument; 487 pDocument = pPage->m_pDocument;
488 } else { 488 } else {
489 pDocument = m_pImageObject->GetImage()->GetDocument(); 489 pDocument = m_pImageObject->GetImage()->GetDocument();
490 } 490 }
491 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; 491 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr;
492 CPDF_Object* pCSObj = 492 CPDF_Object* pCSObj =
493 m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectBy( 493 m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectFor(
494 "ColorSpace"); 494 "ColorSpace");
495 CPDF_ColorSpace* pColorSpace = 495 CPDF_ColorSpace* pColorSpace =
496 pDocument->LoadColorSpace(pCSObj, pPageResources); 496 pDocument->LoadColorSpace(pCSObj, pPageResources);
497 if (pColorSpace) { 497 if (pColorSpace) {
498 int format = pColorSpace->GetFamily(); 498 int format = pColorSpace->GetFamily();
499 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || 499 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION ||
500 format == PDFCS_DEVICEN) { 500 format == PDFCS_DEVICEN) {
501 m_BlendType = FXDIB_BLEND_DARKEN; 501 m_BlendType = FXDIB_BLEND_DARKEN;
502 } 502 }
503 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); 503 pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 int nComps, 947 int nComps,
948 int bpc, 948 int bpc,
949 const CPDF_Dictionary* pParams); 949 const CPDF_Dictionary* pParams);
950 950
951 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, 951 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
952 FX_RECT* pClipRect, 952 FX_RECT* pClipRect,
953 const CFX_Matrix* pMatrix) { 953 const CFX_Matrix* pMatrix) {
954 if (!pSMaskDict) 954 if (!pSMaskDict)
955 return nullptr; 955 return nullptr;
956 956
957 CPDF_Stream* pGroup = pSMaskDict->GetStreamBy("G"); 957 CPDF_Stream* pGroup = pSMaskDict->GetStreamFor("G");
958 if (!pGroup) 958 if (!pGroup)
959 return nullptr; 959 return nullptr;
960 960
961 std::unique_ptr<CPDF_Function> pFunc; 961 std::unique_ptr<CPDF_Function> pFunc;
962 CPDF_Object* pFuncObj = pSMaskDict->GetDirectObjectBy("TR"); 962 CPDF_Object* pFuncObj = pSMaskDict->GetDirectObjectFor("TR");
963 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) 963 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream()))
964 pFunc = CPDF_Function::Load(pFuncObj); 964 pFunc = CPDF_Function::Load(pFuncObj);
965 965
966 CFX_Matrix matrix = *pMatrix; 966 CFX_Matrix matrix = *pMatrix;
967 matrix.TranslateI(-pClipRect->left, -pClipRect->top); 967 matrix.TranslateI(-pClipRect->left, -pClipRect->top);
968 968
969 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), 969 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(),
970 pGroup); 970 pGroup);
971 form.ParseContent(nullptr, nullptr, nullptr); 971 form.ParseContent(nullptr, nullptr, nullptr);
972 972
973 CFX_FxgeDevice bitmap_device; 973 CFX_FxgeDevice bitmap_device;
974 FX_BOOL bLuminosity = pSMaskDict->GetStringBy("S") != "Alpha"; 974 FX_BOOL bLuminosity = pSMaskDict->GetStringFor("S") != "Alpha";
975 int width = pClipRect->right - pClipRect->left; 975 int width = pClipRect->right - pClipRect->left;
976 int height = pClipRect->bottom - pClipRect->top; 976 int height = pClipRect->bottom - pClipRect->top;
977 FXDIB_Format format; 977 FXDIB_Format format;
978 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_ 978 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_
979 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; 979 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask;
980 #else 980 #else
981 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; 981 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask;
982 #endif 982 #endif
983 if (!bitmap_device.Create(width, height, format, nullptr)) 983 if (!bitmap_device.Create(width, height, format, nullptr))
984 return nullptr; 984 return nullptr;
985 985
986 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); 986 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap();
987 CPDF_Object* pCSObj = nullptr; 987 CPDF_Object* pCSObj = nullptr;
988 CPDF_ColorSpace* pCS = nullptr; 988 CPDF_ColorSpace* pCS = nullptr;
989 if (bLuminosity) { 989 if (bLuminosity) {
990 CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); 990 CPDF_Array* pBC = pSMaskDict->GetArrayFor("BC");
991 FX_ARGB back_color = 0xff000000; 991 FX_ARGB back_color = 0xff000000;
992 if (pBC) { 992 if (pBC) {
993 CPDF_Dictionary* pDict = pGroup->GetDict(); 993 CPDF_Dictionary* pDict = pGroup->GetDict();
994 if (pDict && pDict->GetDictBy("Group")) 994 if (pDict && pDict->GetDictFor("Group"))
995 pCSObj = pDict->GetDictBy("Group")->GetDirectObjectBy("CS"); 995 pCSObj = pDict->GetDictFor("Group")->GetDirectObjectFor("CS");
996 else 996 else
997 pCSObj = nullptr; 997 pCSObj = nullptr;
998 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); 998 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj);
999 if (pCS) { 999 if (pCS) {
1000 FX_FLOAT R, G, B; 1000 FX_FLOAT R, G, B;
1001 uint32_t comps = 8; 1001 uint32_t comps = 8;
1002 if (pCS->CountComponents() > comps) { 1002 if (pCS->CountComponents() > comps) {
1003 comps = pCS->CountComponents(); 1003 comps = pCS->CountComponents();
1004 } 1004 }
1005 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); 1005 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps);
(...skipping 13 matching lines...) Expand all
1019 ((int32_t)(G * 255) << 8) | (int32_t)(B * 255); 1019 ((int32_t)(G * 255) << 8) | (int32_t)(B * 255);
1020 m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj); 1020 m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj);
1021 } 1021 }
1022 } 1022 }
1023 bitmap.Clear(back_color); 1023 bitmap.Clear(back_color);
1024 } else { 1024 } else {
1025 bitmap.Clear(0); 1025 bitmap.Clear(0);
1026 } 1026 }
1027 CPDF_Dictionary* pFormResource = nullptr; 1027 CPDF_Dictionary* pFormResource = nullptr;
1028 if (form.m_pFormDict) { 1028 if (form.m_pFormDict) {
1029 pFormResource = form.m_pFormDict->GetDictBy("Resources"); 1029 pFormResource = form.m_pFormDict->GetDictFor("Resources");
1030 } 1030 }
1031 CPDF_RenderOptions options; 1031 CPDF_RenderOptions options;
1032 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; 1032 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA;
1033 CPDF_RenderStatus status; 1033 CPDF_RenderStatus status;
1034 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr, 1034 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr,
1035 nullptr, &options, 0, m_bDropObjects, pFormResource, TRUE, 1035 nullptr, &options, 0, m_bDropObjects, pFormResource, TRUE,
1036 nullptr, 0, pCS ? pCS->GetFamily() : 0, bLuminosity); 1036 nullptr, 0, pCS ? pCS->GetFamily() : 0, bLuminosity);
1037 status.RenderObjectList(&form, &matrix); 1037 status.RenderObjectList(&form, &matrix);
1038 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); 1038 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap);
1039 if (!pMask->Create(width, height, FXDIB_8bppMask)) 1039 if (!pMask->Create(width, height, FXDIB_8bppMask))
(...skipping 30 matching lines...) Expand all
1070 } else if (pFunc) { 1070 } else if (pFunc) {
1071 int size = dest_pitch * height; 1071 int size = dest_pitch * height;
1072 for (int i = 0; i < size; i++) { 1072 for (int i = 0; i < size; i++) {
1073 dest_buf[i] = transfers[src_buf[i]]; 1073 dest_buf[i] = transfers[src_buf[i]];
1074 } 1074 }
1075 } else { 1075 } else {
1076 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); 1076 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
1077 } 1077 }
1078 return pMask.release(); 1078 return pMask.release();
1079 } 1079 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_render/fpdf_render.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