• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_COLOR_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_COLOR_H_
9 
10 #include "core/fpdfapi/page/cpdf_colorspace.h"
11 #include "core/fxcrt/fx_system.h"
12 
13 class CPDF_Pattern;
14 
15 class CPDF_Color {
16  public:
17   CPDF_Color();
18   ~CPDF_Color();
19 
IsNull()20   bool IsNull() const { return !m_pBuffer; }
21   bool IsPattern() const;
22 
23   void Copy(const CPDF_Color* pSrc);
24 
25   void SetColorSpace(CPDF_ColorSpace* pCS);
26   void SetValue(const float* comp);
27   void SetValue(CPDF_Pattern* pPattern, const float* comp, uint32_t ncomps);
28 
29   bool GetRGB(int* R, int* G, int* B) const;
30   CPDF_Pattern* GetPattern() const;
GetColorSpace()31   const CPDF_ColorSpace* GetColorSpace() const { return m_pCS; }
32 
33  protected:
34   void ReleaseBuffer();
35   void ReleaseColorSpace();
36   bool IsPatternInternal() const;
37 
38   // TODO(thestig): Convert this to a smart pointer or vector.
39   // |m_pBuffer| is created by |m_pCS|, so if it is non-null, then so is
40   // |m_pCS|.
41   float* m_pBuffer = nullptr;
42   CPDF_ColorSpace* m_pCS = nullptr;
43 };
44 
45 #endif  // CORE_FPDFAPI_PAGE_CPDF_COLOR_H_
46