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

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

Issue 2303553002: Make CPDF_GeneralState have a CPDF_GeneralStateData (Closed)
Patch Set: Move functions .cpp file 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 15 matching lines...) Expand all
26 #include "core/fpdfdoc/include/cpdf_occontext.h" 26 #include "core/fpdfdoc/include/cpdf_occontext.h"
27 #include "core/fxcodec/include/fx_codec.h" 27 #include "core/fxcodec/include/fx_codec.h"
28 #include "core/fxcrt/include/fx_safe_types.h" 28 #include "core/fxcrt/include/fx_safe_types.h"
29 #include "core/fxge/include/cfx_fxgedevice.h" 29 #include "core/fxge/include/cfx_fxgedevice.h"
30 #include "core/fxge/include/cfx_pathdata.h" 30 #include "core/fxge/include/cfx_pathdata.h"
31 31
32 #ifdef _SKIA_SUPPORT_ 32 #ifdef _SKIA_SUPPORT_
33 #include "core/fxge/skia/fx_skia_device.h" 33 #include "core/fxge/skia/fx_skia_device.h"
34 #endif 34 #endif
35 35
36 FX_BOOL CPDF_RenderStatus::ProcessImage(const CPDF_ImageObject* pImageObj, 36 FX_BOOL CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj,
37 const CFX_Matrix* pObj2Device) { 37 const CFX_Matrix* pObj2Device) {
38 CPDF_ImageRenderer render; 38 CPDF_ImageRenderer render;
39 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { 39 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) {
40 render.Continue(nullptr); 40 render.Continue(nullptr);
41 } 41 }
42 return render.m_Result; 42 return render.m_Result;
43 } 43 }
44 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, 44 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
45 int left, 45 int left,
46 int top, 46 int top,
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 dest_height)) { 381 dest_height)) {
382 if (m_LoadHandle) { 382 if (m_LoadHandle) {
383 m_Status = 4; 383 m_Status = 4;
384 return TRUE; 384 return TRUE;
385 } 385 }
386 } 386 }
387 return FALSE; 387 return FALSE;
388 } 388 }
389 389
390 FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { 390 FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() {
391 if (!m_Loader.m_pBitmap) { 391 if (!m_Loader.m_pBitmap)
392 return FALSE; 392 return FALSE;
393 } 393
394 m_BitmapAlpha = 255; 394 m_BitmapAlpha =
395 const CPDF_GeneralStateData* pGeneralState = 395 FXSYS_round(255 * m_pImageObject->m_GeneralState.GetFillAlpha());
396 m_pImageObject->m_GeneralState.GetObject();
397 if (pGeneralState) {
398 m_BitmapAlpha = FXSYS_round(pGeneralState->m_FillAlpha * 255);
399 }
400 m_pDIBSource = m_Loader.m_pBitmap; 396 m_pDIBSource = m_Loader.m_pBitmap;
401 if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA && 397 if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA &&
402 !m_Loader.m_pMask) { 398 !m_Loader.m_pMask) {
403 return StartBitmapAlpha(); 399 return StartBitmapAlpha();
404 } 400 }
405 if (pGeneralState && pGeneralState->m_pTR) { 401 if (m_pImageObject->m_GeneralState.GetTR()) {
406 if (!pGeneralState->m_pTransferFunc) { 402 if (!m_pImageObject->m_GeneralState.GetTransferFunc()) {
407 ((CPDF_GeneralStateData*)pGeneralState)->m_pTransferFunc = 403 m_pImageObject->m_GeneralState.SetTransferFunc(
408 m_pRenderStatus->GetTransferFunc(pGeneralState->m_pTR); 404 m_pRenderStatus->GetTransferFunc(
405 m_pImageObject->m_GeneralState.GetTR()));
409 } 406 }
410 if (pGeneralState->m_pTransferFunc && 407 if (m_pImageObject->m_GeneralState.GetTransferFunc() &&
411 !pGeneralState->m_pTransferFunc->m_bIdentity) { 408 !m_pImageObject->m_GeneralState.GetTransferFunc()->m_bIdentity) {
412 m_pDIBSource = m_Loader.m_pBitmap = 409 m_pDIBSource = m_Loader.m_pBitmap =
413 pGeneralState->m_pTransferFunc->TranslateImage(m_Loader.m_pBitmap, 410 m_pImageObject->m_GeneralState.GetTransferFunc()->TranslateImage(
414 !m_Loader.m_bCached); 411 m_Loader.m_pBitmap, !m_Loader.m_bCached);
415 if (m_Loader.m_bCached && m_Loader.m_pMask) { 412 if (m_Loader.m_bCached && m_Loader.m_pMask) {
416 m_Loader.m_pMask = m_Loader.m_pMask->Clone(); 413 m_Loader.m_pMask = m_Loader.m_pMask->Clone();
417 } 414 }
418 m_Loader.m_bCached = FALSE; 415 m_Loader.m_bCached = FALSE;
419 } 416 }
420 } 417 }
421 m_FillArgb = 0; 418 m_FillArgb = 0;
422 m_bPatternColor = FALSE; 419 m_bPatternColor = FALSE;
423 m_pPattern = nullptr; 420 m_pPattern = nullptr;
424 if (m_pDIBSource->IsAlphaMask()) { 421 if (m_pDIBSource->IsAlphaMask()) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 m_Flags |= FXDIB_NOSMOOTH; 464 m_Flags |= FXDIB_NOSMOOTH;
468 } else if (m_pImageObject->GetImage()->IsInterpol()) { 465 } else if (m_pImageObject->GetImage()->IsInterpol()) {
469 m_Flags |= FXDIB_INTERPOL; 466 m_Flags |= FXDIB_INTERPOL;
470 } 467 }
471 if (m_Loader.m_pMask) { 468 if (m_Loader.m_pMask) {
472 return DrawMaskedImage(); 469 return DrawMaskedImage();
473 } 470 }
474 if (m_bPatternColor) { 471 if (m_bPatternColor) {
475 return DrawPatternImage(m_pObj2Device); 472 return DrawPatternImage(m_pObj2Device);
476 } 473 }
477 if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP && 474 if (m_BitmapAlpha == 255 && m_pImageObject->m_GeneralState &&
478 pGeneralState->m_OPMode == 0 && 475 m_pImageObject->m_GeneralState.GetFillOP() &&
479 pGeneralState->m_BlendType == FXDIB_BLEND_NORMAL && 476 m_pImageObject->m_GeneralState.GetOPMode() == 0 &&
480 pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) { 477 m_pImageObject->m_GeneralState.GetBlendType() == FXDIB_BLEND_NORMAL &&
478 m_pImageObject->m_GeneralState.GetStrokeAlpha() == 1.0f &&
479 m_pImageObject->m_GeneralState.GetFillAlpha() == 1.0f) {
481 CPDF_Document* pDocument = nullptr; 480 CPDF_Document* pDocument = nullptr;
482 CPDF_Page* pPage = nullptr; 481 CPDF_Page* pPage = nullptr;
483 if (m_pRenderStatus->m_pContext->GetPageCache()) { 482 if (m_pRenderStatus->m_pContext->GetPageCache()) {
484 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage(); 483 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage();
485 pDocument = pPage->m_pDocument; 484 pDocument = pPage->m_pDocument;
486 } else { 485 } else {
487 pDocument = m_pImageObject->GetImage()->GetDocument(); 486 pDocument = m_pImageObject->GetImage()->GetDocument();
488 } 487 }
489 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; 488 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr;
490 CPDF_Object* pCSObj = 489 CPDF_Object* pCSObj =
491 m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectBy( 490 m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectBy(
492 "ColorSpace"); 491 "ColorSpace");
493 CPDF_ColorSpace* pColorSpace = 492 CPDF_ColorSpace* pColorSpace =
494 pDocument->LoadColorSpace(pCSObj, pPageResources); 493 pDocument->LoadColorSpace(pCSObj, pPageResources);
495 if (pColorSpace) { 494 if (pColorSpace) {
496 int format = pColorSpace->GetFamily(); 495 int format = pColorSpace->GetFamily();
497 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || 496 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION ||
498 format == PDFCS_DEVICEN) { 497 format == PDFCS_DEVICEN) {
499 m_BlendType = FXDIB_BLEND_DARKEN; 498 m_BlendType = FXDIB_BLEND_DARKEN;
500 } 499 }
501 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); 500 pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
502 } 501 }
503 } 502 }
504 return StartDIBSource(); 503 return StartDIBSource();
505 } 504 }
506 505
507 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, 506 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus,
508 const CPDF_PageObject* pObj, 507 CPDF_PageObject* pObj,
509 const CFX_Matrix* pObj2Device, 508 const CFX_Matrix* pObj2Device,
510 FX_BOOL bStdCS, 509 FX_BOOL bStdCS,
511 int blendType) { 510 int blendType) {
512 m_pRenderStatus = pStatus; 511 m_pRenderStatus = pStatus;
513 m_bStdCS = bStdCS; 512 m_bStdCS = bStdCS;
514 m_pImageObject = pObj->AsImage(); 513 m_pImageObject = pObj->AsImage();
515 m_BlendType = blendType; 514 m_BlendType = blendType;
516 m_pObj2Device = pObj2Device; 515 m_pObj2Device = pObj2Device;
517 CPDF_Dictionary* pOC = m_pImageObject->GetImage()->GetOC(); 516 CPDF_Dictionary* pOC = m_pImageObject->GetImage()->GetOC();
518 if (pOC && m_pRenderStatus->m_Options.m_pOCContext && 517 if (pOC && m_pRenderStatus->m_Options.m_pOCContext &&
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 } else if (pFunc) { 1067 } else if (pFunc) {
1069 int size = dest_pitch * height; 1068 int size = dest_pitch * height;
1070 for (int i = 0; i < size; i++) { 1069 for (int i = 0; i < size; i++) {
1071 dest_buf[i] = transfers[src_buf[i]]; 1070 dest_buf[i] = transfers[src_buf[i]];
1072 } 1071 }
1073 } else { 1072 } else {
1074 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); 1073 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
1075 } 1074 }
1076 return pMask.release(); 1075 return pMask.release();
1077 } 1076 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698