• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The PDFium Authors
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 #ifndef XFA_FGAS_GRAPHICS_CFGAS_GESHADING_H_
8 #define XFA_FGAS_GRAPHICS_CFGAS_GESHADING_H_
9 
10 #include <stddef.h>
11 
12 #include "core/fxcrt/fx_coordinates.h"
13 #include "core/fxge/dib/fx_dib.h"
14 
15 class CFGAS_GEShading final {
16  public:
17   enum class Type { kAxial = 1, kRadial };
18 
19   static constexpr size_t kSteps = 256;
20 
21   // Axial shading.
22   CFGAS_GEShading(const CFX_PointF& beginPoint,
23                   const CFX_PointF& endPoint,
24                   bool isExtendedBegin,
25                   bool isExtendedEnd,
26                   FX_ARGB beginArgb,
27                   FX_ARGB endArgb);
28 
29   // Radial shading.
30   CFGAS_GEShading(const CFX_PointF& beginPoint,
31                   const CFX_PointF& endPoint,
32                   float beginRadius,
33                   float endRadius,
34                   bool isExtendedBegin,
35                   bool isExtendedEnd,
36                   FX_ARGB beginArgb,
37                   FX_ARGB endArgb);
38 
39   ~CFGAS_GEShading();
40 
GetType()41   Type GetType() const { return m_type; }
GetBeginPoint()42   CFX_PointF GetBeginPoint() const { return m_beginPoint; }
GetEndPoint()43   CFX_PointF GetEndPoint() const { return m_endPoint; }
GetBeginRadius()44   float GetBeginRadius() const { return m_beginRadius; }
GetEndRadius()45   float GetEndRadius() const { return m_endRadius; }
IsExtendedBegin()46   bool IsExtendedBegin() const { return m_isExtendedBegin; }
IsExtendedEnd()47   bool IsExtendedEnd() const { return m_isExtendedEnd; }
GetArgb(size_t index)48   FX_ARGB GetArgb(size_t index) const { return m_argbArray[index]; }
49 
50  private:
51   void InitArgbArray(FX_ARGB beginArgb, FX_ARGB endArgb);
52 
53   const Type m_type;
54   const CFX_PointF m_beginPoint;
55   const CFX_PointF m_endPoint;
56   const float m_beginRadius;
57   const float m_endRadius;
58   const bool m_isExtendedBegin;
59   const bool m_isExtendedEnd;
60   FX_ARGB m_argbArray[kSteps];
61 };
62 
63 #endif  // XFA_FGAS_GRAPHICS_CFGAS_GESHADING_H_
64