Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_isExtendedBegin(isExtendedBegin), | |
| 19 m_beginArgb(beginArgb), | |
| 20 m_endArgb(endArgb) { | |
| 21 InitArgbArray(); | |
| 22 } | |
| 23 | |
| 24 CFX_Shading::CFX_Shading(const CFX_PointF& beginPoint, | |
| 25 const CFX_PointF& endPoint, | |
| 26 const FX_FLOAT beginRadius, | |
| 27 const FX_FLOAT endRadius, | |
| 28 FX_BOOL isExtendedBegin, | |
| 29 FX_BOOL isExtendedEnd, | |
| 30 const FX_ARGB beginArgb, | |
| 31 const FX_ARGB endArgb) | |
| 32 : m_type(FX_SHADING_Radial), | |
| 33 m_beginPoint(beginPoint), | |
| 34 m_endPoint(endPoint), | |
| 35 m_beginRadius(beginRadius), | |
| 36 m_endRadius(endRadius), | |
| 37 m_isExtendedBegin(isExtendedBegin), | |
| 38 m_isExtendedEnd(isExtendedEnd), | |
| 39 m_beginArgb(beginArgb), | |
| 40 m_endArgb(endArgb) { | |
| 41 InitArgbArray(); | |
| 42 } | |
| 43 | |
| 44 CFX_Shading::~CFX_Shading() {} | |
| 45 | |
| 46 void CFX_Shading::InitArgbArray() { | |
| 47 int32_t a1; | |
| 48 int32_t r1; | |
| 49 int32_t g1; | |
| 50 int32_t b1; | |
| 51 ArgbDecode(m_beginArgb, a1, r1, g1, b1); | |
| 52 | |
| 53 int32_t a2; | |
| 54 int32_t r2; | |
| 55 int32_t g2; | |
| 56 int32_t b2; | |
| 57 ArgbDecode(m_endArgb, a2, r2, g2, b2); | |
| 58 | |
| 59 FX_FLOAT f = (FX_FLOAT)(FX_SHADING_Steps - 1); | |
| 60 FX_FLOAT aScale = (FX_FLOAT)(1.0 * (a2 - a1) / f); | |
|
Tom Sepez
2016/03/16 20:53:18
These casts are pointless as we assume an int's ra
dsinclair
2016/03/16 21:13:39
Done.
| |
| 61 FX_FLOAT rScale = (FX_FLOAT)(1.0 * (r2 - r1) / f); | |
| 62 FX_FLOAT gScale = (FX_FLOAT)(1.0 * (g2 - g1) / f); | |
| 63 FX_FLOAT bScale = (FX_FLOAT)(1.0 * (b2 - b1) / f); | |
| 64 | |
| 65 int32_t a3; | |
|
Tom Sepez
2016/03/16 20:53:18
nit: move these inside loop. They needn't persist
dsinclair
2016/03/16 21:13:39
Done.
| |
| 66 int32_t r3; | |
| 67 int32_t g3; | |
| 68 int32_t b3; | |
| 69 for (int32_t i = 0; i < FX_SHADING_Steps; i++) { | |
| 70 a3 = (int32_t)(i * aScale); | |
|
Tom Sepez
2016/03/16 20:53:17
nit: static_cast<>, just to emphasize that we thin
dsinclair
2016/03/16 21:13:39
Done.
| |
| 71 r3 = (int32_t)(i * rScale); | |
| 72 g3 = (int32_t)(i * gScale); | |
| 73 b3 = (int32_t)(i * bScale); | |
|
Tom Sepez
2016/03/16 20:53:18
Pity we dont define addition multiplicaton subtrac
dsinclair
2016/03/16 21:13:39
Done.
| |
| 74 m_argbArray[i] = | |
| 75 FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3))); | |
|
Tom Sepez
2016/03/16 20:53:18
nit: overparenthesized, unless FXARGB_MAKE is not
dsinclair
2016/03/16 21:13:39
Done.
| |
| 76 } | |
| 77 } | |
| OLD | NEW |