From 156e7d15a4a084f478cdbd507f0e99dfef7dd3f0 Mon Sep 17 00:00:00 2001 From: John Stiles Date: Tue, 8 Feb 2022 01:57:06 +0000 Subject: [PATCH] Revert "Remove skstd::optional entirely." This reverts commit 0596094b811bd689d4b2de50045cc3db547449bc. Reason for revert: Flutter somehow still references skstd::optional flutter_engine in google3 still has old code: http://screen/BHDrjqwzchdFVfQ Original change's description: > Remove skstd::optional entirely. > > Change-Id: Id9862712ea3e769797abd654922879ce6bc4487c > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/504976 > Reviewed-by: Ben Wagner > Reviewed-by: Brian Osman > Commit-Queue: John Stiles Change-Id: Idea391399c2e11b83d5a130023adb340d40cadcb No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/505396 Auto-Submit: John Stiles Bot-Commit: Rubber Stamper Reviewed-by: Heather Miller Commit-Queue: Heather Miller --- gn/core.gni | 1 + include/core/SkCanvas.h | 2 +- include/core/SkImage.h | 2 +- include/core/SkImageGenerator.h | 3 +-- include/core/SkPaint.h | 3 +-- include/effects/SkRuntimeEffect.h | 2 +- include/private/SkTOptional.h | 21 +++++++++++++++++++++ 7 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 include/private/SkTOptional.h diff --git a/gn/core.gni b/gn/core.gni index df2c53797e..dc21e1ec4f 100644 --- a/gn/core.gni +++ b/gn/core.gni @@ -502,6 +502,7 @@ skia_core_sources = [ "$_include/private/SkTFitsIn.h", "$_include/private/SkTHash.h", "$_include/private/SkTLogic.h", + "$_include/private/SkTOptional.h", "$_include/private/SkTemplates.h", "$_include/private/SkThreadAnnotations.h", "$_include/private/SkThreadID.h", diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 35610a278a..7305da2edd 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -28,10 +28,10 @@ #include "include/core/SkTypes.h" #include "include/private/SkDeque.h" #include "include/private/SkMacros.h" +#include "include/private/SkTOptional.h" #include #include -#include #include #ifndef SK_SUPPORT_LEGACY_GETTOTALMATRIX diff --git a/include/core/SkImage.h b/include/core/SkImage.h index 682474a1a3..72dfefa345 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -15,11 +15,11 @@ #include "include/core/SkScalar.h" #include "include/core/SkShader.h" #include "include/core/SkTileMode.h" +#include "include/private/SkTOptional.h" #if SK_SUPPORT_GPU #include "include/gpu/GrTypes.h" #endif #include // std::function -#include #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26 #include diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h index 970ccdbab9..bdd913c61f 100644 --- a/include/core/SkImageGenerator.h +++ b/include/core/SkImageGenerator.h @@ -13,8 +13,7 @@ #include "include/core/SkImage.h" #include "include/core/SkImageInfo.h" #include "include/core/SkYUVAPixmaps.h" - -#include +#include "include/private/SkTOptional.h" class GrRecordingContext; class GrSurfaceProxyView; diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index c4500bf12c..08c4aa9e41 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -11,10 +11,9 @@ #include "include/core/SkBlendMode.h" #include "include/core/SkColor.h" #include "include/core/SkRefCnt.h" +#include "include/private/SkTOptional.h" #include "include/private/SkTo.h" -#include - class SkBlender; class SkColorFilter; class SkColorSpace; diff --git a/include/effects/SkRuntimeEffect.h b/include/effects/SkRuntimeEffect.h index 83ee641702..a6b0b4dc57 100644 --- a/include/effects/SkRuntimeEffect.h +++ b/include/effects/SkRuntimeEffect.h @@ -18,9 +18,9 @@ #include "include/core/SkString.h" #include "include/private/SkOnce.h" #include "include/private/SkSLSampleUsage.h" +#include "include/private/SkTOptional.h" #include -#include #include #ifdef SK_ENABLE_SKSL diff --git a/include/private/SkTOptional.h b/include/private/SkTOptional.h new file mode 100644 index 0000000000..137b3cb267 --- /dev/null +++ b/include/private/SkTOptional.h @@ -0,0 +1,21 @@ +/* + * Copyright 2021 Google LLC. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkTOptional_DEFINED +#define SkTOptional_DEFINED + +#include + +namespace skstd { + +template using optional = std::optional; +using nullopt_t = std::nullopt_t; +inline constexpr nullopt_t nullopt = std::nullopt; + +} // namespace skstd + +#endif