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

Side by Side Diff: core/fpdfapi/fpdf_page/cpdf_generalstatedata.cpp

Issue 2302683002: Make StateData private (Closed)
Patch Set: Alphabetical order 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
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "core/fpdfapi/fpdf_page/include/cpdf_generalstatedata.h"
8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
10 #include "core/fpdfapi/fpdf_render/render_int.h"
11
12 namespace {
13
14 static int GetBlendTypeInternal(const CFX_ByteStringC& mode) {
15 switch (mode.GetID()) {
16 case FXBSTR_ID('N', 'o', 'r', 'm'):
17 case FXBSTR_ID('C', 'o', 'm', 'p'):
18 return FXDIB_BLEND_NORMAL;
19 case FXBSTR_ID('M', 'u', 'l', 't'):
20 return FXDIB_BLEND_MULTIPLY;
21 case FXBSTR_ID('S', 'c', 'r', 'e'):
22 return FXDIB_BLEND_SCREEN;
23 case FXBSTR_ID('O', 'v', 'e', 'r'):
24 return FXDIB_BLEND_OVERLAY;
25 case FXBSTR_ID('D', 'a', 'r', 'k'):
26 return FXDIB_BLEND_DARKEN;
27 case FXBSTR_ID('L', 'i', 'g', 'h'):
28 return FXDIB_BLEND_LIGHTEN;
29 case FXBSTR_ID('C', 'o', 'l', 'o'):
30 if (mode.GetLength() == 10)
31 return FXDIB_BLEND_COLORDODGE;
32
33 if (mode.GetLength() == 9)
34 return FXDIB_BLEND_COLORBURN;
35
36 return FXDIB_BLEND_COLOR;
37 case FXBSTR_ID('H', 'a', 'r', 'd'):
38 return FXDIB_BLEND_HARDLIGHT;
39 case FXBSTR_ID('S', 'o', 'f', 't'):
40 return FXDIB_BLEND_SOFTLIGHT;
41 case FXBSTR_ID('D', 'i', 'f', 'f'):
42 return FXDIB_BLEND_DIFFERENCE;
43 case FXBSTR_ID('E', 'x', 'c', 'l'):
44 return FXDIB_BLEND_EXCLUSION;
45 case FXBSTR_ID('H', 'u', 'e', 0):
46 return FXDIB_BLEND_HUE;
47 case FXBSTR_ID('S', 'a', 't', 'u'):
48 return FXDIB_BLEND_SATURATION;
49 case FXBSTR_ID('L', 'u', 'm', 'i'):
50 return FXDIB_BLEND_LUMINOSITY;
51 }
52 return FXDIB_BLEND_NORMAL;
53 }
54
55 } // namespace
56
57 CPDF_GeneralStateData::CPDF_GeneralStateData() {
58 FXSYS_memset(this, 0, sizeof(CPDF_GeneralStateData));
59 FXSYS_strcpy((FX_CHAR*)m_BlendMode, "Normal");
60 m_StrokeAlpha = 1.0f;
61 m_FillAlpha = 1.0f;
62 m_Flatness = 1.0f;
63 m_Matrix.SetIdentity();
64 }
65
66 CPDF_GeneralStateData::CPDF_GeneralStateData(const CPDF_GeneralStateData& src) {
67 FXSYS_memcpy(this, &src, sizeof(CPDF_GeneralStateData));
68 if (src.m_pTransferFunc && src.m_pTransferFunc->m_pPDFDoc) {
69 CPDF_DocRenderData* pDocCache =
70 src.m_pTransferFunc->m_pPDFDoc->GetRenderData();
71 if (!pDocCache)
72 return;
73
74 m_pTransferFunc = pDocCache->GetTransferFunc(m_pTR);
75 }
76 }
77
78 CPDF_GeneralStateData::~CPDF_GeneralStateData() {
79 if (m_pTransferFunc && m_pTransferFunc->m_pPDFDoc) {
80 CPDF_DocRenderData* pDocCache = m_pTransferFunc->m_pPDFDoc->GetRenderData();
81 if (!pDocCache)
82 return;
83
84 pDocCache->ReleaseTransferFunc(m_pTR);
85 }
86 }
87
88 void CPDF_GeneralStateData::SetBlendMode(const CFX_ByteStringC& blend_mode) {
89 if (blend_mode.GetLength() > 15) {
90 return;
91 }
92 FXSYS_memcpy(m_BlendMode, blend_mode.raw_str(), blend_mode.GetLength());
93 m_BlendMode[blend_mode.GetLength()] = 0;
94 m_BlendType = GetBlendTypeInternal(blend_mode);
95 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_generalstate.cpp ('k') | core/fpdfapi/fpdf_page/include/cpdf_generalstate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698