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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: xfa/fxgraphics/cfx_shading.cpp
diff --git a/xfa/fxgraphics/cfx_shading.cpp b/xfa/fxgraphics/cfx_shading.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c3c482cd4de23b489f57cbf70fd92b71f8dcd28f
--- /dev/null
+++ b/xfa/fxgraphics/cfx_shading.cpp
@@ -0,0 +1,73 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxgraphics/cfx_shading.h"
+
+CFX_Shading::CFX_Shading(CFX_Shading_Type type) : m_type(type) {}
+
+CFX_Shading::~CFX_Shading() {}
+
+FX_ERR CFX_Shading::CreateAxial(const CFX_PointF& beginPoint,
+ const CFX_PointF& endPoint,
+ FX_BOOL isExtendedBegin,
+ FX_BOOL isExtendedEnd,
+ const FX_ARGB beginArgb,
+ const FX_ARGB endArgb) {
+ if (m_type != FX_SHADING_Axial)
+ return FX_ERR_Property_Invalid;
+
+ m_beginPoint = beginPoint;
+ m_endPoint = endPoint;
+ m_isExtendedBegin = isExtendedBegin;
+ m_isExtendedEnd = isExtendedEnd;
+ m_beginArgb = beginArgb;
+ m_endArgb = endArgb;
+ return InitArgbArray();
+}
+
+FX_ERR CFX_Shading::CreateRadial(const CFX_PointF& beginPoint,
+ const CFX_PointF& endPoint,
+ const FX_FLOAT beginRadius,
+ const FX_FLOAT endRadius,
+ FX_BOOL isExtendedBegin,
+ FX_BOOL isExtendedEnd,
+ const FX_ARGB beginArgb,
+ const FX_ARGB endArgb) {
+ if (m_type != FX_SHADING_Radial)
+ return FX_ERR_Property_Invalid;
+
+ m_beginPoint = beginPoint;
+ m_endPoint = endPoint;
+ m_beginRadius = beginRadius;
+ m_endRadius = endRadius;
+ m_isExtendedBegin = isExtendedBegin;
+ m_isExtendedEnd = isExtendedEnd;
+ m_beginArgb = beginArgb;
+ m_endArgb = endArgb;
+ return InitArgbArray();
+}
+
+FX_ERR CFX_Shading::InitArgbArray() {
+ int32_t a1, r1, g1, b1;
+ ArgbDecode(m_beginArgb, a1, r1, g1, b1);
+ int32_t a2, r2, g2, b2;
+ ArgbDecode(m_endArgb, a2, r2, g2, b2);
+ FX_FLOAT f = (FX_FLOAT)(FX_SHADING_Steps - 1);
+ FX_FLOAT aScale = (FX_FLOAT)(1.0 * (a2 - a1) / f);
+ FX_FLOAT rScale = (FX_FLOAT)(1.0 * (r2 - r1) / f);
+ FX_FLOAT gScale = (FX_FLOAT)(1.0 * (g2 - g1) / f);
+ FX_FLOAT bScale = (FX_FLOAT)(1.0 * (b2 - b1) / f);
+ int32_t a3, r3, g3, b3;
+ for (int32_t i = 0; i < FX_SHADING_Steps; i++) {
+ a3 = (int32_t)(i * aScale);
+ r3 = (int32_t)(i * rScale);
+ g3 = (int32_t)(i * gScale);
+ b3 = (int32_t)(i * bScale);
+ m_argbArray[i] =
+ FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3)));
+ }
+ return FX_ERR_Succeeded;
+}

Powered by Google App Engine
This is Rietveld 408576698