Home | History | Annotate | Download | only in page
      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 #ifndef CORE_FPDFAPI_PAGE_CPDF_COLORSTATE_H_
      8 #define CORE_FPDFAPI_PAGE_CPDF_COLORSTATE_H_
      9 
     10 #include "core/fpdfapi/page/cpdf_color.h"
     11 #include "core/fxcrt/fx_system.h"
     12 #include "core/fxcrt/shared_copy_on_write.h"
     13 
     14 class CPDF_Color;
     15 class CPDF_ColorSpace;
     16 class CPDF_Pattern;
     17 
     18 class CPDF_ColorState {
     19  public:
     20   CPDF_ColorState();
     21   CPDF_ColorState(const CPDF_ColorState& that);
     22   ~CPDF_ColorState();
     23 
     24   void Emplace();
     25   void SetDefault();
     26 
     27   uint32_t GetFillRGB() const;
     28   void SetFillRGB(uint32_t rgb);
     29 
     30   uint32_t GetStrokeRGB() const;
     31   void SetStrokeRGB(uint32_t rgb);
     32 
     33   const CPDF_Color* GetFillColor() const;
     34   CPDF_Color* GetMutableFillColor();
     35   bool HasFillColor() const;
     36 
     37   const CPDF_Color* GetStrokeColor() const;
     38   CPDF_Color* GetMutableStrokeColor();
     39   bool HasStrokeColor() const;
     40 
     41   void SetFillColor(CPDF_ColorSpace* pCS, float* pValue, uint32_t nValues);
     42   void SetStrokeColor(CPDF_ColorSpace* pCS, float* pValue, uint32_t nValues);
     43   void SetFillPattern(CPDF_Pattern* pattern, float* pValue, uint32_t nValues);
     44   void SetStrokePattern(CPDF_Pattern* pattern, float* pValue, uint32_t nValues);
     45 
     46   bool HasRef() const { return !!m_Ref; }
     47 
     48  private:
     49   class ColorData : public Retainable {
     50    public:
     51     ColorData();
     52     ColorData(const ColorData& src);
     53     ~ColorData() override;
     54 
     55     void SetDefault();
     56 
     57     uint32_t m_FillRGB;
     58     uint32_t m_StrokeRGB;
     59     CPDF_Color m_FillColor;
     60     CPDF_Color m_StrokeColor;
     61   };
     62 
     63   void SetColor(CPDF_Color& color,
     64                 uint32_t& rgb,
     65                 CPDF_ColorSpace* pCS,
     66                 float* pValue,
     67                 uint32_t nValues);
     68 
     69   SharedCopyOnWrite<ColorData> m_Ref;
     70 };
     71 
     72 #endif  // CORE_FPDFAPI_PAGE_CPDF_COLORSTATE_H_
     73