Make CFX_FillRenderOptions construction constexpr.
CFX_FillRenderOptions can be constructed at compile time instead of
runtime. By making CFX_FillRenderOptions constexpr,
cfx_fillrenderoptions.cpp is no longer required.
Change-Id: Ic7746328b17651453eb92978e40c11e77a231cf2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/73130
Reviewed-by: Hui Yingst <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/BUILD.gn b/core/fxge/BUILD.gn
index 46ea2d6..0e68139 100644
--- a/core/fxge/BUILD.gn
+++ b/core/fxge/BUILD.gn
@@ -27,7 +27,6 @@
"cfx_drawutils.h",
"cfx_face.cpp",
"cfx_face.h",
- "cfx_fillrenderoptions.cpp",
"cfx_fillrenderoptions.h",
"cfx_folderfontinfo.cpp",
"cfx_folderfontinfo.h",
diff --git a/core/fxge/cfx_fillrenderoptions.cpp b/core/fxge/cfx_fillrenderoptions.cpp
deleted file mode 100644
index 111a433..0000000
--- a/core/fxge/cfx_fillrenderoptions.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2020 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.
-
-#include "core/fxge/cfx_fillrenderoptions.h"
-
-#include "core/fxcrt/fx_system.h"
-#include "third_party/base/no_destructor.h"
-
-// static
-const CFX_FillRenderOptions& CFX_FillRenderOptions::EvenOddOptions() {
- static const pdfium::base::NoDestructor<CFX_FillRenderOptions>
- alternate_options(CFX_FillRenderOptions::FillType::kEvenOdd);
- return *alternate_options;
-}
-
-// static
-const CFX_FillRenderOptions& CFX_FillRenderOptions::WindingOptions() {
- static const pdfium::base::NoDestructor<CFX_FillRenderOptions>
- winding_options(CFX_FillRenderOptions::FillType::kWinding);
- return *winding_options;
-}
-
-CFX_FillRenderOptions::CFX_FillRenderOptions() = default;
-
-CFX_FillRenderOptions::CFX_FillRenderOptions(
- CFX_FillRenderOptions::FillType fill_type)
- : fill_type(fill_type) {}
diff --git a/core/fxge/cfx_fillrenderoptions.h b/core/fxge/cfx_fillrenderoptions.h
index 6969bd4..42aa957 100644
--- a/core/fxge/cfx_fillrenderoptions.h
+++ b/core/fxge/cfx_fillrenderoptions.h
@@ -21,11 +21,16 @@
kWinding = 2,
};
- static const CFX_FillRenderOptions& EvenOddOptions();
- static const CFX_FillRenderOptions& WindingOptions();
+ static constexpr CFX_FillRenderOptions EvenOddOptions() {
+ return CFX_FillRenderOptions(FillType::kEvenOdd);
+ }
+ static constexpr CFX_FillRenderOptions WindingOptions() {
+ return CFX_FillRenderOptions(FillType::kWinding);
+ }
- CFX_FillRenderOptions();
- explicit CFX_FillRenderOptions(FillType fill_type);
+ constexpr CFX_FillRenderOptions() = default;
+ constexpr explicit CFX_FillRenderOptions(FillType fill_type)
+ : fill_type(fill_type) {}
// Fill type.
FillType fill_type = FillType::kNoFill;