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

Unified Diff: core/fpdfapi/fpdf_page/cpdf_colorstate.h

Issue 2294133002: Make CPDF_ColorState have a CFX_ColorStateData rather than inheriting (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, nits. Created 4 years, 4 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
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/cpdf_colorstate.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_page/cpdf_colorstate.h
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstate.h b/core/fpdfapi/fpdf_page/cpdf_colorstate.h
index 128d67558d4b5c5e93f6786cb5a3e5f530f1547f..d928dbdb2ea47724a3788fd4526f72c81148e2ac 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstate.h
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.h
@@ -16,17 +16,28 @@ class CPDF_Color;
class CPDF_ColorSpace;
class CPDF_Pattern;
-class CPDF_ColorState : public CFX_CountRef<CPDF_ColorStateData> {
+class CPDF_ColorState {
public:
- const CPDF_Color* GetFillColor() const {
- const CPDF_ColorStateData* pData = GetObject();
- return pData ? &pData->m_FillColor : nullptr;
- }
+ CPDF_ColorState();
+ CPDF_ColorState(const CPDF_ColorState& that);
+ ~CPDF_ColorState();
- const CPDF_Color* GetStrokeColor() const {
- const CPDF_ColorStateData* pData = GetObject();
- return pData ? &pData->m_StrokeColor : nullptr;
- }
+ void Emplace();
+ void SetDefault();
+
+ uint32_t GetFillRGB() const;
+ void SetFillRGB(uint32_t rgb);
+
+ uint32_t GetStrokeRGB() const;
+ void SetStrokeRGB(uint32_t rgb);
+
+ const CPDF_Color* GetFillColor() const;
+ CPDF_Color* GetMutableFillColor();
+ bool HasFillColor() const;
+
+ const CPDF_Color* GetStrokeColor() const;
+ CPDF_Color* GetMutableStrokeColor();
+ bool HasStrokeColor() const;
void SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues);
void SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues);
@@ -37,12 +48,19 @@ class CPDF_ColorState : public CFX_CountRef<CPDF_ColorStateData> {
FX_FLOAT* pValue,
uint32_t nValues);
+ // TODO(tsepez): Stop leaking ColorStateData outside this class.
+ const CPDF_ColorStateData* GetObject() const { return m_Ref.GetObject(); }
+
+ operator bool() const { return !!m_Ref; }
+
private:
void SetColor(CPDF_Color& color,
uint32_t& rgb,
CPDF_ColorSpace* pCS,
FX_FLOAT* pValue,
uint32_t nValues);
+
+ CFX_CountRef<CPDF_ColorStateData> m_Ref;
};
#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATE_H_
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/cpdf_colorstate.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698