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

Side by Side Diff: xfa/fxgraphics/cfx_shading.cpp

Issue 1810563002: Move xfa/include/fxgraphics/fx_graphics.h to xfa/fxgraphics. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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 | « xfa/fxgraphics/cfx_shading.h ('k') | xfa/fxgraphics/fx_graphics.cpp » ('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 "xfa/fxgraphics/cfx_shading.h"
8
9 CFX_Shading::CFX_Shading(const CFX_PointF& beginPoint,
10 const CFX_PointF& endPoint,
11 FX_BOOL isExtendedBegin,
12 FX_BOOL isExtendedEnd,
13 const FX_ARGB beginArgb,
14 const FX_ARGB endArgb)
15 : m_type(FX_SHADING_Axial),
16 m_beginPoint(beginPoint),
17 m_endPoint(endPoint),
18 m_beginRadius(0),
19 m_endRadius(0),
20 m_isExtendedBegin(isExtendedBegin),
21 m_isExtendedEnd(isExtendedEnd),
22 m_beginArgb(beginArgb),
23 m_endArgb(endArgb) {
24 InitArgbArray();
25 }
26
27 CFX_Shading::CFX_Shading(const CFX_PointF& beginPoint,
28 const CFX_PointF& endPoint,
29 const FX_FLOAT beginRadius,
30 const FX_FLOAT endRadius,
31 FX_BOOL isExtendedBegin,
32 FX_BOOL isExtendedEnd,
33 const FX_ARGB beginArgb,
34 const FX_ARGB endArgb)
35 : m_type(FX_SHADING_Radial),
36 m_beginPoint(beginPoint),
37 m_endPoint(endPoint),
38 m_beginRadius(beginRadius),
39 m_endRadius(endRadius),
40 m_isExtendedBegin(isExtendedBegin),
41 m_isExtendedEnd(isExtendedEnd),
42 m_beginArgb(beginArgb),
43 m_endArgb(endArgb) {
44 InitArgbArray();
45 }
46
47 CFX_Shading::~CFX_Shading() {}
48
49 void CFX_Shading::InitArgbArray() {
50 int32_t a1;
51 int32_t r1;
52 int32_t g1;
53 int32_t b1;
54 ArgbDecode(m_beginArgb, a1, r1, g1, b1);
55
56 int32_t a2;
57 int32_t r2;
58 int32_t g2;
59 int32_t b2;
60 ArgbDecode(m_endArgb, a2, r2, g2, b2);
61
62 FX_FLOAT f = (FX_FLOAT)(FX_SHADING_Steps - 1);
63 FX_FLOAT aScale = 1.0 * (a2 - a1) / f;
64 FX_FLOAT rScale = 1.0 * (r2 - r1) / f;
65 FX_FLOAT gScale = 1.0 * (g2 - g1) / f;
66 FX_FLOAT bScale = 1.0 * (b2 - b1) / f;
67
68 for (int32_t i = 0; i < FX_SHADING_Steps; i++) {
69 int32_t a3 = static_cast<int32_t>(i * aScale);
70 int32_t r3 = static_cast<int32_t>(i * rScale);
71 int32_t g3 = static_cast<int32_t>(i * gScale);
72 int32_t b3 = static_cast<int32_t>(i * bScale);
73
74 // TODO(dsinclair): Add overloads for FX_ARGB. pdfium:437
75 m_argbArray[i] =
76 FXARGB_TODIB(FXARGB_MAKE(a1 + a3, r1 + r3, g1 + g3, b1 + b3));
77 }
78 }
OLDNEW
« no previous file with comments | « xfa/fxgraphics/cfx_shading.h ('k') | xfa/fxgraphics/fx_graphics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698