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

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

Issue 2294553002: Revert "Use ->() in CPDF_ColorState" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
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
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_colorstate.h ('k') | core/fpdfapi/fpdf_page/cpdf_colorstatedata.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cpdf_colorstate.h"
8
9 #include "core/fpdfapi/fpdf_page/cpdf_pattern.h"
10 #include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h"
11 #include "core/fxge/include/fx_dib.h"
12
13 void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS,
14 FX_FLOAT* pValue,
15 uint32_t nValues) {
16 MakePrivateCopy();
17 CPDF_ColorStateData* pData = GetObject();
18 SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues);
19 }
20
21 void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
22 FX_FLOAT* pValue,
23 uint32_t nValues) {
24 MakePrivateCopy();
25 CPDF_ColorStateData* pData = GetObject();
26 SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues);
27 }
28
29 void CPDF_ColorState::SetColor(CPDF_Color& color,
30 uint32_t& rgb,
31 CPDF_ColorSpace* pCS,
32 FX_FLOAT* pValue,
33 uint32_t nValues) {
34 if (pCS) {
35 color.SetColorSpace(pCS);
36 } else if (color.IsNull()) {
37 color.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
38 }
39 if (color.GetColorSpace()->CountComponents() > nValues)
40 return;
41
42 color.SetValue(pValue);
43 int R, G, B;
44 rgb = color.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
45 }
46
47 void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
48 FX_FLOAT* pValue,
49 uint32_t nValues) {
50 MakePrivateCopy();
51 CPDF_ColorStateData* pData = GetObject();
52 pData->m_FillColor.SetValue(pPattern, pValue, nValues);
53 int R, G, B;
54 FX_BOOL ret = pData->m_FillColor.GetRGB(R, G, B);
55 if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
56 if (!ret && pTilingPattern->colored()) {
57 pData->m_FillRGB = 0x00BFBFBF;
58 return;
59 }
60 }
61 pData->m_FillRGB = ret ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
62 }
63
64 void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
65 FX_FLOAT* pValue,
66 uint32_t nValues) {
67 MakePrivateCopy();
68 CPDF_ColorStateData* pData = GetObject();
69 pData->m_StrokeColor.SetValue(pPattern, pValue, nValues);
70 int R, G, B;
71 FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B);
72 if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
73 if (!ret && pTilingPattern->colored()) {
74 pData->m_StrokeRGB = 0x00BFBFBF;
75 return;
76 }
77 }
78 pData->m_StrokeRGB =
79 pData->m_StrokeColor.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
80 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_colorstate.h ('k') | core/fpdfapi/fpdf_page/cpdf_colorstatedata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698