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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "pageint.h" 7 #include "pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 if (m_pAlterCS && m_bOwn) { 681 if (m_pAlterCS && m_bOwn) {
682 m_pAlterCS->ReleaseCS(); 682 m_pAlterCS->ReleaseCS();
683 } 683 }
684 if (m_pProfile && m_pDocument) { 684 if (m_pProfile && m_pDocument) {
685 m_pDocument->GetPageData()->ReleaseIccProfile(m_pProfile); 685 m_pDocument->GetPageData()->ReleaseIccProfile(m_pProfile);
686 } 686 }
687 } 687 }
688 688
689 FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { 689 FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
690 CPDF_Stream* pStream = pArray->GetStream(1); 690 CPDF_Stream* pStream = pArray->GetStream(1);
691 if (pStream == NULL) { 691 if (!pStream) {
692 return FALSE; 692 return FALSE;
693 } 693 }
694 m_pProfile = pDoc->LoadIccProfile(pStream); 694 m_pProfile = pDoc->LoadIccProfile(pStream);
695 if (!m_pProfile) { 695 if (!m_pProfile) {
696 return FALSE; 696 return FALSE;
697 } 697 }
698 m_nComponents = 698 m_nComponents =
699 m_pProfile 699 m_pProfile
700 ->GetComponents(); // Try using the nComponents from ICC profile 700 ->GetComponents(); // Try using the nComponents from ICC profile
701 CPDF_Dictionary* pDict = pStream->GetDict(); 701 CPDF_Dictionary* pDict = pStream->GetDict();
702 if (m_pProfile->m_pTransform == NULL) { // No valid ICC profile or using sRGB 702 if (!m_pProfile->m_pTransform) { // No valid ICC profile or using sRGB
703 CPDF_Object* pAlterCSObj = 703 CPDF_Object* pAlterCSObj =
704 pDict ? pDict->GetElementValue("Alternate") : NULL; 704 pDict ? pDict->GetElementValue("Alternate") : NULL;
705 if (pAlterCSObj) { 705 if (pAlterCSObj) {
706 CPDF_ColorSpace* pAlterCS = CPDF_ColorSpace::Load(pDoc, pAlterCSObj); 706 CPDF_ColorSpace* pAlterCS = CPDF_ColorSpace::Load(pDoc, pAlterCSObj);
707 if (pAlterCS) { 707 if (pAlterCS) {
708 if (m_nComponents == 0) { // NO valid ICC profile 708 if (m_nComponents == 0) { // NO valid ICC profile
709 if (pAlterCS->CountComponents() > 0) { // Use Alternative colorspace 709 if (pAlterCS->CountComponents() > 0) { // Use Alternative colorspace
710 m_nComponents = pAlterCS->CountComponents(); 710 m_nComponents = pAlterCS->CountComponents();
711 m_pAlterCS = pAlterCS; 711 m_pAlterCS = pAlterCS;
712 m_bOwn = TRUE; 712 m_bOwn = TRUE;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 FX_FLOAT& R, 757 FX_FLOAT& R,
758 FX_FLOAT& G, 758 FX_FLOAT& G,
759 FX_FLOAT& B) const { 759 FX_FLOAT& B) const {
760 if (m_pProfile && m_pProfile->m_bsRGB) { 760 if (m_pProfile && m_pProfile->m_bsRGB) {
761 R = pBuf[0]; 761 R = pBuf[0];
762 G = pBuf[1]; 762 G = pBuf[1];
763 B = pBuf[2]; 763 B = pBuf[2];
764 return TRUE; 764 return TRUE;
765 } 765 }
766 ICodec_IccModule* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule(); 766 ICodec_IccModule* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule();
767 if (m_pProfile->m_pTransform == NULL || pIccModule == NULL) { 767 if (!m_pProfile->m_pTransform || !pIccModule) {
768 if (m_pAlterCS) { 768 if (m_pAlterCS) {
769 return m_pAlterCS->GetRGB(pBuf, R, G, B); 769 return m_pAlterCS->GetRGB(pBuf, R, G, B);
770 } 770 }
771 R = G = B = 0.0f; 771 R = G = B = 0.0f;
772 return TRUE; 772 return TRUE;
773 } 773 }
774 FX_FLOAT rgb[3]; 774 FX_FLOAT rgb[3];
775 pIccModule->SetComponents(m_nComponents); 775 pIccModule->SetComponents(m_nComponents);
776 pIccModule->Translate(m_pProfile->m_pTransform, pBuf, rgb); 776 pIccModule->Translate(m_pProfile->m_pTransform, pBuf, rgb);
777 R = rgb[0]; 777 R = rgb[0];
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 ReverseRGB(pDestBuf, pSrcBuf, pixels); 815 ReverseRGB(pDestBuf, pSrcBuf, pixels);
816 } else if (m_pProfile->m_pTransform) { 816 } else if (m_pProfile->m_pTransform) {
817 int nMaxColors = 1; 817 int nMaxColors = 1;
818 for (int i = 0; i < m_nComponents; i++) { 818 for (int i = 0; i < m_nComponents; i++) {
819 nMaxColors *= 52; 819 nMaxColors *= 52;
820 } 820 }
821 if (m_nComponents > 3 || image_width * image_height < nMaxColors * 3 / 2) { 821 if (m_nComponents > 3 || image_width * image_height < nMaxColors * 3 / 2) {
822 CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline( 822 CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline(
823 m_pProfile->m_pTransform, pDestBuf, pSrcBuf, pixels); 823 m_pProfile->m_pTransform, pDestBuf, pSrcBuf, pixels);
824 } else { 824 } else {
825 if (m_pCache == NULL) { 825 if (!m_pCache) {
826 ((CPDF_ICCBasedCS*)this)->m_pCache = FX_Alloc2D(uint8_t, nMaxColors, 3); 826 ((CPDF_ICCBasedCS*)this)->m_pCache = FX_Alloc2D(uint8_t, nMaxColors, 3);
827 uint8_t* temp_src = FX_Alloc2D(uint8_t, nMaxColors, m_nComponents); 827 uint8_t* temp_src = FX_Alloc2D(uint8_t, nMaxColors, m_nComponents);
828 uint8_t* pSrc = temp_src; 828 uint8_t* pSrc = temp_src;
829 for (int i = 0; i < nMaxColors; i++) { 829 for (int i = 0; i < nMaxColors; i++) {
830 FX_DWORD color = i; 830 FX_DWORD color = i;
831 FX_DWORD order = nMaxColors / 52; 831 FX_DWORD order = nMaxColors / 52;
832 for (int c = 0; c < m_nComponents; c++) { 832 for (int c = 0; c < m_nComponents; c++) {
833 *pSrc++ = (uint8_t)(color / order * 5); 833 *pSrc++ = (uint8_t)(color / order * 5);
834 color %= order; 834 color %= order;
835 order /= 52; 835 order /= 52;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { 890 FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
891 if (pArray->GetCount() < 4) { 891 if (pArray->GetCount() < 4) {
892 return FALSE; 892 return FALSE;
893 } 893 }
894 CPDF_Object* pBaseObj = pArray->GetElementValue(1); 894 CPDF_Object* pBaseObj = pArray->GetElementValue(1);
895 if (pBaseObj == m_pArray) { 895 if (pBaseObj == m_pArray) {
896 return FALSE; 896 return FALSE;
897 } 897 }
898 CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); 898 CPDF_DocPageData* pDocPageData = pDoc->GetPageData();
899 m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, NULL); 899 m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, NULL);
900 if (m_pBaseCS == NULL) { 900 if (!m_pBaseCS) {
901 return FALSE; 901 return FALSE;
902 } 902 }
903 m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray()); 903 m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray());
904 m_nBaseComponents = m_pBaseCS->CountComponents(); 904 m_nBaseComponents = m_pBaseCS->CountComponents();
905 m_pCompMinMax = FX_Alloc2D(FX_FLOAT, m_nBaseComponents, 2); 905 m_pCompMinMax = FX_Alloc2D(FX_FLOAT, m_nBaseComponents, 2);
906 FX_FLOAT defvalue; 906 FX_FLOAT defvalue;
907 for (int i = 0; i < m_nBaseComponents; i++) { 907 for (int i = 0; i < m_nBaseComponents; i++) {
908 m_pBaseCS->GetDefaultValue(i, defvalue, m_pCompMinMax[i * 2], 908 m_pBaseCS->GetDefaultValue(i, defvalue, m_pCompMinMax[i * 2],
909 m_pCompMinMax[i * 2 + 1]); 909 m_pCompMinMax[i * 2 + 1]);
910 m_pCompMinMax[i * 2 + 1] -= m_pCompMinMax[i * 2]; 910 m_pCompMinMax[i * 2 + 1] -= m_pCompMinMax[i * 2];
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 } 1071 }
1072 return TRUE; 1072 return TRUE;
1073 } 1073 }
1074 FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, 1074 FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf,
1075 FX_FLOAT& R, 1075 FX_FLOAT& R,
1076 FX_FLOAT& G, 1076 FX_FLOAT& G,
1077 FX_FLOAT& B) const { 1077 FX_FLOAT& B) const {
1078 if (m_Type == None) { 1078 if (m_Type == None) {
1079 return FALSE; 1079 return FALSE;
1080 } 1080 }
1081 if (m_pFunc == NULL) { 1081 if (!m_pFunc) {
1082 if (m_pAltCS == NULL) { 1082 if (!m_pAltCS) {
1083 return FALSE; 1083 return FALSE;
1084 } 1084 }
1085 int nComps = m_pAltCS->CountComponents(); 1085 int nComps = m_pAltCS->CountComponents();
1086 CFX_FixedBufGrow<FX_FLOAT, 16> results(nComps); 1086 CFX_FixedBufGrow<FX_FLOAT, 16> results(nComps);
1087 for (int i = 0; i < nComps; i++) { 1087 for (int i = 0; i < nComps; i++) {
1088 results[i] = *pBuf; 1088 results[i] = *pBuf;
1089 } 1089 }
1090 return m_pAltCS->GetRGB(results, R, G, B); 1090 return m_pAltCS->GetRGB(results, R, G, B);
1091 } 1091 }
1092 CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs()); 1092 CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 if (!pObj) 1147 if (!pObj)
1148 return FALSE; 1148 return FALSE;
1149 1149
1150 m_nComponents = pObj->GetCount(); 1150 m_nComponents = pObj->GetCount();
1151 CPDF_Object* pAltCS = pArray->GetElementValue(2); 1151 CPDF_Object* pAltCS = pArray->GetElementValue(2);
1152 if (!pAltCS || pAltCS == m_pArray) { 1152 if (!pAltCS || pAltCS == m_pArray) {
1153 return FALSE; 1153 return FALSE;
1154 } 1154 }
1155 m_pAltCS = Load(pDoc, pAltCS); 1155 m_pAltCS = Load(pDoc, pAltCS);
1156 m_pFunc = CPDF_Function::Load(pArray->GetElementValue(3)); 1156 m_pFunc = CPDF_Function::Load(pArray->GetElementValue(3));
1157 if (m_pAltCS == NULL || m_pFunc == NULL) { 1157 if (!m_pAltCS || !m_pFunc) {
1158 return FALSE; 1158 return FALSE;
1159 } 1159 }
1160 if (m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) { 1160 if (m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) {
1161 return FALSE; 1161 return FALSE;
1162 } 1162 }
1163 return TRUE; 1163 return TRUE;
1164 } 1164 }
1165 FX_BOOL CPDF_DeviceNCS::GetRGB(FX_FLOAT* pBuf, 1165 FX_BOOL CPDF_DeviceNCS::GetRGB(FX_FLOAT* pBuf,
1166 FX_FLOAT& R, 1166 FX_FLOAT& R,
1167 FX_FLOAT& G, 1167 FX_FLOAT& G,
1168 FX_FLOAT& B) const { 1168 FX_FLOAT& B) const {
1169 if (m_pFunc == NULL) { 1169 if (!m_pFunc) {
1170 return FALSE; 1170 return FALSE;
1171 } 1171 }
1172 CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs()); 1172 CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs());
1173 int nresults = 0; 1173 int nresults = 0;
1174 m_pFunc->Call(pBuf, m_nComponents, results, nresults); 1174 m_pFunc->Call(pBuf, m_nComponents, results, nresults);
1175 if (nresults == 0) { 1175 if (nresults == 0) {
1176 return FALSE; 1176 return FALSE;
1177 } 1177 }
1178 return m_pAltCS->GetRGB(results, R, G, B); 1178 return m_pAltCS->GetRGB(results, R, G, B);
1179 } 1179 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 FX_FLOAT y, 1324 FX_FLOAT y,
1325 FX_FLOAT k) const { 1325 FX_FLOAT k) const {
1326 if (v_SetCMYK(pBuf, c, m, y, k)) { 1326 if (v_SetCMYK(pBuf, c, m, y, k)) {
1327 return TRUE; 1327 return TRUE;
1328 } 1328 }
1329 FX_FLOAT R, G, B; 1329 FX_FLOAT R, G, B;
1330 AdobeCMYK_to_sRGB(c, m, y, k, R, G, B); 1330 AdobeCMYK_to_sRGB(c, m, y, k, R, G, B);
1331 return SetRGB(pBuf, R, G, B); 1331 return SetRGB(pBuf, R, G, B);
1332 } 1332 }
1333 void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const { 1333 void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const {
1334 if (buf == NULL || m_Family == PDFCS_PATTERN) { 1334 if (!buf || m_Family == PDFCS_PATTERN) {
1335 return; 1335 return;
1336 } 1336 }
1337 FX_FLOAT min, max; 1337 FX_FLOAT min, max;
1338 for (int i = 0; i < m_nComponents; i++) { 1338 for (int i = 0; i < m_nComponents; i++) {
1339 GetDefaultValue(i, buf[i], min, max); 1339 GetDefaultValue(i, buf[i], min, max);
1340 } 1340 }
1341 } 1341 }
1342 int CPDF_ColorSpace::GetMaxIndex() const { 1342 int CPDF_ColorSpace::GetMaxIndex() const {
1343 if (m_Family != PDFCS_INDEXED) { 1343 if (m_Family != PDFCS_INDEXED) {
1344 return 0; 1344 return 0;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 m_pBuffer = NULL; 1411 m_pBuffer = NULL;
1412 } 1412 }
1413 void CPDF_Color::ReleaseColorSpace() { 1413 void CPDF_Color::ReleaseColorSpace() {
1414 if (m_pCS && m_pCS->m_pDocument && m_pCS->GetArray()) { 1414 if (m_pCS && m_pCS->m_pDocument && m_pCS->GetArray()) {
1415 m_pCS->m_pDocument->GetPageData()->ReleaseColorSpace(m_pCS->GetArray()); 1415 m_pCS->m_pDocument->GetPageData()->ReleaseColorSpace(m_pCS->GetArray());
1416 m_pCS = NULL; 1416 m_pCS = NULL;
1417 } 1417 }
1418 } 1418 }
1419 void CPDF_Color::SetColorSpace(CPDF_ColorSpace* pCS) { 1419 void CPDF_Color::SetColorSpace(CPDF_ColorSpace* pCS) {
1420 if (m_pCS == pCS) { 1420 if (m_pCS == pCS) {
1421 if (m_pBuffer == NULL) { 1421 if (!m_pBuffer) {
1422 m_pBuffer = pCS->CreateBuf(); 1422 m_pBuffer = pCS->CreateBuf();
1423 } 1423 }
1424 ReleaseColorSpace(); 1424 ReleaseColorSpace();
1425 m_pCS = pCS; 1425 m_pCS = pCS;
1426 return; 1426 return;
1427 } 1427 }
1428 ReleaseBuffer(); 1428 ReleaseBuffer();
1429 ReleaseColorSpace(); 1429 ReleaseColorSpace();
1430 m_pCS = pCS; 1430 m_pCS = pCS;
1431 if (m_pCS) { 1431 if (m_pCS) {
1432 m_pBuffer = pCS->CreateBuf(); 1432 m_pBuffer = pCS->CreateBuf();
1433 pCS->GetDefaultColor(m_pBuffer); 1433 pCS->GetDefaultColor(m_pBuffer);
1434 } 1434 }
1435 } 1435 }
1436 void CPDF_Color::SetValue(FX_FLOAT* comps) { 1436 void CPDF_Color::SetValue(FX_FLOAT* comps) {
1437 if (m_pBuffer == NULL) { 1437 if (!m_pBuffer) {
1438 return; 1438 return;
1439 } 1439 }
1440 if (m_pCS->GetFamily() != PDFCS_PATTERN) { 1440 if (m_pCS->GetFamily() != PDFCS_PATTERN) {
1441 FXSYS_memcpy(m_pBuffer, comps, m_pCS->CountComponents() * sizeof(FX_FLOAT)); 1441 FXSYS_memcpy(m_pBuffer, comps, m_pCS->CountComponents() * sizeof(FX_FLOAT));
1442 } 1442 }
1443 } 1443 }
1444 void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) { 1444 void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) {
1445 if (ncomps > MAX_PATTERN_COLORCOMPS) { 1445 if (ncomps > MAX_PATTERN_COLORCOMPS) {
1446 return; 1446 return;
1447 } 1447 }
1448 if (m_pCS == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) { 1448 if (!m_pCS || m_pCS->GetFamily() != PDFCS_PATTERN) {
1449 FX_Free(m_pBuffer); 1449 FX_Free(m_pBuffer);
1450 m_pCS = CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN); 1450 m_pCS = CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN);
1451 m_pBuffer = m_pCS->CreateBuf(); 1451 m_pBuffer = m_pCS->CreateBuf();
1452 } 1452 }
1453 CPDF_DocPageData* pDocPageData = NULL; 1453 CPDF_DocPageData* pDocPageData = NULL;
1454 PatternValue* pvalue = (PatternValue*)m_pBuffer; 1454 PatternValue* pvalue = (PatternValue*)m_pBuffer;
1455 if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) { 1455 if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) {
1456 pDocPageData = pvalue->m_pPattern->m_pDocument->GetPageData(); 1456 pDocPageData = pvalue->m_pPattern->m_pDocument->GetPageData();
1457 if (pDocPageData) { 1457 if (pDocPageData) {
1458 pDocPageData->ReleasePattern(pvalue->m_pPattern->m_pPatternObj); 1458 pDocPageData->ReleasePattern(pvalue->m_pPattern->m_pPatternObj);
(...skipping 16 matching lines...) Expand all
1475 void CPDF_Color::Copy(const CPDF_Color* pSrc) { 1475 void CPDF_Color::Copy(const CPDF_Color* pSrc) {
1476 ReleaseBuffer(); 1476 ReleaseBuffer();
1477 ReleaseColorSpace(); 1477 ReleaseColorSpace();
1478 m_pCS = pSrc->m_pCS; 1478 m_pCS = pSrc->m_pCS;
1479 if (m_pCS && m_pCS->m_pDocument) { 1479 if (m_pCS && m_pCS->m_pDocument) {
1480 CPDF_Array* pArray = m_pCS->GetArray(); 1480 CPDF_Array* pArray = m_pCS->GetArray();
1481 if (pArray) { 1481 if (pArray) {
1482 m_pCS = m_pCS->m_pDocument->GetPageData()->GetCopiedColorSpace(pArray); 1482 m_pCS = m_pCS->m_pDocument->GetPageData()->GetCopiedColorSpace(pArray);
1483 } 1483 }
1484 } 1484 }
1485 if (m_pCS == NULL) { 1485 if (!m_pCS) {
1486 return; 1486 return;
1487 } 1487 }
1488 m_pBuffer = m_pCS->CreateBuf(); 1488 m_pBuffer = m_pCS->CreateBuf();
1489 FXSYS_memcpy(m_pBuffer, pSrc->m_pBuffer, m_pCS->GetBufSize()); 1489 FXSYS_memcpy(m_pBuffer, pSrc->m_pBuffer, m_pCS->GetBufSize());
1490 if (m_pCS->GetFamily() == PDFCS_PATTERN) { 1490 if (m_pCS->GetFamily() == PDFCS_PATTERN) {
1491 PatternValue* pvalue = (PatternValue*)m_pBuffer; 1491 PatternValue* pvalue = (PatternValue*)m_pBuffer;
1492 if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) { 1492 if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) {
1493 pvalue->m_pPattern = 1493 pvalue->m_pPattern =
1494 pvalue->m_pPattern->m_pDocument->GetPageData()->GetPattern( 1494 pvalue->m_pPattern->m_pDocument->GetPageData()->GetPattern(
1495 pvalue->m_pPattern->m_pPatternObj, FALSE, 1495 pvalue->m_pPattern->m_pPatternObj, FALSE,
1496 &pvalue->m_pPattern->m_ParentMatrix); 1496 &pvalue->m_pPattern->m_ParentMatrix);
1497 } 1497 }
1498 } 1498 }
1499 } 1499 }
1500 FX_BOOL CPDF_Color::GetRGB(int& R, int& G, int& B) const { 1500 FX_BOOL CPDF_Color::GetRGB(int& R, int& G, int& B) const {
1501 if (m_pCS == NULL || m_pBuffer == NULL) { 1501 if (!m_pCS || !m_pBuffer) {
1502 return FALSE; 1502 return FALSE;
1503 } 1503 }
1504 FX_FLOAT r = 0.0f, g = 0.0f, b = 0.0f; 1504 FX_FLOAT r = 0.0f, g = 0.0f, b = 0.0f;
1505 if (!m_pCS->GetRGB(m_pBuffer, r, g, b)) { 1505 if (!m_pCS->GetRGB(m_pBuffer, r, g, b)) {
1506 return FALSE; 1506 return FALSE;
1507 } 1507 }
1508 R = (int32_t)(r * 255 + 0.5f); 1508 R = (int32_t)(r * 255 + 0.5f);
1509 G = (int32_t)(g * 255 + 0.5f); 1509 G = (int32_t)(g * 255 + 0.5f);
1510 B = (int32_t)(b * 255 + 0.5f); 1510 B = (int32_t)(b * 255 + 0.5f);
1511 return TRUE; 1511 return TRUE;
1512 } 1512 }
1513 CPDF_Pattern* CPDF_Color::GetPattern() const { 1513 CPDF_Pattern* CPDF_Color::GetPattern() const {
1514 if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) { 1514 if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN) {
1515 return NULL; 1515 return NULL;
1516 } 1516 }
1517 PatternValue* pvalue = (PatternValue*)m_pBuffer; 1517 PatternValue* pvalue = (PatternValue*)m_pBuffer;
1518 return pvalue->m_pPattern; 1518 return pvalue->m_pPattern;
1519 } 1519 }
1520 CPDF_ColorSpace* CPDF_Color::GetPatternCS() const { 1520 CPDF_ColorSpace* CPDF_Color::GetPatternCS() const {
1521 if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) { 1521 if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN) {
1522 return NULL; 1522 return NULL;
1523 } 1523 }
1524 return m_pCS->GetBaseCS(); 1524 return m_pCS->GetBaseCS();
1525 } 1525 }
1526 FX_FLOAT* CPDF_Color::GetPatternColor() const { 1526 FX_FLOAT* CPDF_Color::GetPatternColor() const {
1527 if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) { 1527 if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN) {
1528 return NULL; 1528 return NULL;
1529 } 1529 }
1530 PatternValue* pvalue = (PatternValue*)m_pBuffer; 1530 PatternValue* pvalue = (PatternValue*)m_pBuffer;
1531 return pvalue->m_nComps ? pvalue->m_Comps : NULL; 1531 return pvalue->m_nComps ? pvalue->m_Comps : NULL;
1532 } 1532 }
1533 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const { 1533 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const {
1534 if (m_pCS != other.m_pCS || m_pCS == NULL) { 1534 return m_pCS && m_pCS == other.m_pCS &&
1535 return FALSE; 1535 FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0;
1536 }
1537 return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0;
1538 } 1536 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698