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

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

Issue 2111553003: fix skia unit tests (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix luminosity device bitmap depth Created 4 years, 5 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>
11 11
12 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" 12 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
13 #include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h" 13 #include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h"
14 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" 14 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
15 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" 15 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h"
16 #include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h" 16 #include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h"
17 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 17 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
18 #include "core/fpdfapi/fpdf_page/pageint.h" 18 #include "core/fpdfapi/fpdf_page/pageint.h"
19 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 19 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
20 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 20 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
21 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 21 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
22 #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" 22 #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h"
23 #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" 23 #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h"
24 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" 24 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
25 #include "core/fpdfdoc/include/fpdf_doc.h" 25 #include "core/fpdfdoc/include/fpdf_doc.h"
26 #include "core/fxcodec/include/fx_codec.h" 26 #include "core/fxcodec/include/fx_codec.h"
27 #include "core/fxcrt/include/fx_safe_types.h" 27 #include "core/fxcrt/include/fx_safe_types.h"
28 #include "core/fxge/include/fx_ge.h" 28 #include "core/fxge/include/fx_ge.h"
29 29
30 #ifdef _SKIA_SUPPORT_
31 #include "core/fxge/skia/fx_skia_device.h"
32 #endif
33
30 FX_BOOL CPDF_RenderStatus::ProcessImage(const CPDF_ImageObject* pImageObj, 34 FX_BOOL CPDF_RenderStatus::ProcessImage(const CPDF_ImageObject* pImageObj,
31 const CFX_Matrix* pObj2Device) { 35 const CFX_Matrix* pObj2Device) {
32 CPDF_ImageRenderer render; 36 CPDF_ImageRenderer render;
33 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { 37 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) {
34 render.Continue(nullptr); 38 render.Continue(nullptr);
35 } 39 }
36 return render.m_Result; 40 return render.m_Result;
37 } 41 }
38 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, 42 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
39 int left, 43 int left,
(...skipping 11 matching lines...) Expand all
51 #ifdef _SKIA_SUPPORT_ 55 #ifdef _SKIA_SUPPORT_
52 void* dummy; 56 void* dummy;
53 CFX_Matrix m(pDIBitmap->GetWidth(), 0, 0, -pDIBitmap->GetHeight(), left, 57 CFX_Matrix m(pDIBitmap->GetWidth(), 0, 0, -pDIBitmap->GetHeight(), left,
54 top + pDIBitmap->GetHeight()); 58 top + pDIBitmap->GetHeight());
55 m_pDevice->StartDIBits(pDIBitmap, bitmap_alpha, 0, &m, 0, dummy); 59 m_pDevice->StartDIBits(pDIBitmap, bitmap_alpha, 0, &m, 0, dummy);
56 return; 60 return;
57 #else 61 #else
58 pDIBitmap->MultiplyAlpha(bitmap_alpha); 62 pDIBitmap->MultiplyAlpha(bitmap_alpha);
59 #endif 63 #endif
60 } 64 }
65 #ifdef _SKIA_SUPPORT_
66 static_cast<CFX_SkiaDeviceDriver*>(m_pDevice->GetDeviceDriver())
67 ->PreMultiply(pDIBitmap);
68 #endif
61 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { 69 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) {
62 return; 70 return;
63 } 71 }
64 } else { 72 } else {
65 uint32_t fill_argb = m_Options.TranslateColor(mask_argb); 73 uint32_t fill_argb = m_Options.TranslateColor(mask_argb);
66 if (bitmap_alpha < 255) { 74 if (bitmap_alpha < 255) {
67 ((uint8_t*)&fill_argb)[3] = 75 ((uint8_t*)&fill_argb)[3] =
68 ((uint8_t*)&fill_argb)[3] * bitmap_alpha / 255; 76 ((uint8_t*)&fill_argb)[3] * bitmap_alpha / 255;
69 } 77 }
70 if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) { 78 if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) {
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 921
914 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), 922 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(),
915 pGroup); 923 pGroup);
916 form.ParseContent(nullptr, nullptr, nullptr); 924 form.ParseContent(nullptr, nullptr, nullptr);
917 925
918 CFX_FxgeDevice bitmap_device; 926 CFX_FxgeDevice bitmap_device;
919 FX_BOOL bLuminosity = pSMaskDict->GetStringBy("S") != "Alpha"; 927 FX_BOOL bLuminosity = pSMaskDict->GetStringBy("S") != "Alpha";
920 int width = pClipRect->right - pClipRect->left; 928 int width = pClipRect->right - pClipRect->left;
921 int height = pClipRect->bottom - pClipRect->top; 929 int height = pClipRect->bottom - pClipRect->top;
922 FXDIB_Format format; 930 FXDIB_Format format;
923 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 931 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_
924 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; 932 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask;
925 #else 933 #else
926 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; 934 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask;
927 #endif 935 #endif
928 if (!bitmap_device.Create(width, height, format, nullptr)) 936 if (!bitmap_device.Create(width, height, format, nullptr))
929 return nullptr; 937 return nullptr;
930 938
931 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); 939 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap();
932 CPDF_Object* pCSObj = nullptr; 940 CPDF_Object* pCSObj = nullptr;
933 CPDF_ColorSpace* pCS = nullptr; 941 CPDF_ColorSpace* pCS = nullptr;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 } else if (pFunc) { 1023 } else if (pFunc) {
1016 int size = dest_pitch * height; 1024 int size = dest_pitch * height;
1017 for (int i = 0; i < size; i++) { 1025 for (int i = 0; i < size; i++) {
1018 dest_buf[i] = transfers[src_buf[i]]; 1026 dest_buf[i] = transfers[src_buf[i]];
1019 } 1027 }
1020 } else { 1028 } else {
1021 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); 1029 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
1022 } 1030 }
1023 return pMask.release(); 1031 return pMask.release();
1024 } 1032 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_render/fpdf_render_loadimage_embeddertest.cpp » ('j') | core/fxge/skia/fx_skia_device.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698