Skip to content

Commit 8aa0edf

Browse files
Mike KleinSkia Commit-Bot
authored andcommitted
move SkTPin to include/private
Change-Id: Ib0dc823d331a7cddc5da1d1be83136ce803a7871 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327783 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Reed <reed@google.com>
1 parent d6bf999 commit 8aa0edf

File tree

96 files changed

+120
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+120
-17
lines changed

RELEASE_NOTES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Milestone 88
99

1010
* <insert new release notes here>
1111

12+
* SkTPin() removed from public API.
13+
1214
* Add new SkImageFilters::Blend factory function, in place of the now deprecated
1315
SkImageFilters::Xfermode factory function. Behavior is identical, but name better matches
1416
conventions in SkShader and SkColorFilter.

gm/animatedimageblurs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "include/core/SkString.h"
1818
#include "include/core/SkTypes.h"
1919
#include "include/effects/SkImageFilters.h"
20+
#include "include/private/SkTPin.h"
2021
#include "include/utils/SkRandom.h"
2122
#include "tools/timer/TimeUtils.h"
2223

gm/jpg_color_cube.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "include/core/SkSize.h"
1818
#include "include/core/SkString.h"
1919
#include "include/core/SkTypes.h"
20+
#include "include/private/SkTPin.h"
2021

2122
#include <utility>
2223

gm/p3.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "include/core/SkTypes.h"
2727
#include "include/effects/SkDashPathEffect.h"
2828
#include "include/effects/SkGradientShader.h"
29+
#include "include/private/SkTPin.h"
2930
#include "src/core/SkColorSpaceXformSteps.h"
3031

3132
#include <math.h>

gm/wacky_yuv_formats.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "include/private/GrTypesPriv.h"
4343
#include "include/private/SkTArray.h"
4444
#include "include/private/SkTDArray.h"
45+
#include "include/private/SkTPin.h"
4546
#include "include/private/SkTemplates.h"
4647
#include "include/utils/SkTextUtils.h"
4748
#include "src/core/SkConvertPixels.h"

include/core/SkColorPriv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "include/core/SkColor.h"
1212
#include "include/core/SkMath.h"
13+
#include "include/private/SkTPin.h"
1314
#include "include/private/SkTo.h"
1415

1516
/** Turn 0..255 into 0..256 by adding 1 at the half-way point. Used to turn a

include/core/SkFontStyle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define SkFontStyle_DEFINED
1010

1111
#include "include/core/SkTypes.h"
12+
#include "include/private/SkTPin.h"
1213

1314
class SK_API SkFontStyle {
1415
public:

include/core/SkTypes.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -581,23 +581,6 @@ template <typename T> static inline T SkTAbs(T value) {
581581
return value;
582582
}
583583

584-
/** @return x pinned (clamped) between lo and hi, inclusively.
585-
586-
Unlike std::clamp(), SkTPin() always returns a value between lo and hi.
587-
If x is NaN, SkTPin() returns hi but std::clamp() returns NaN.
588-
*/
589-
template <typename T>
590-
static constexpr const T& SkTPin(const T& x, const T& lo, const T& hi) {
591-
#if 0
592-
return std::max(std::min(hi, x), lo);
593-
#else
594-
// To avoid the need to #include <algorithm>, we use this equivalent logic:
595-
return x < lo ? lo
596-
: x < hi ? x
597-
: /*else*/ hi;
598-
#endif
599-
}
600-
601584
////////////////////////////////////////////////////////////////////////////////
602585

603586
/** Indicates whether an allocation should count against a cache budget.

include/private/SkFixed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "include/core/SkScalar.h"
1212
#include "include/core/SkTypes.h"
1313
#include "include/private/SkSafe_math.h"
14+
#include "include/private/SkTPin.h"
1415
#include "include/private/SkTo.h"
1516

1617
/** \file SkFixed.h

include/private/SkTPin.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2020 Google Inc.
3+
*
4+
* Use of this source code is governed by a BSD-style license that can be
5+
* found in the LICENSE file.
6+
*/
7+
8+
#ifndef SkTPin_DEFINED
9+
#define SkTPin_DEFINED
10+
11+
/** @return x pinned (clamped) between lo and hi, inclusively.
12+
13+
Unlike std::clamp(), SkTPin() always returns a value between lo and hi.
14+
If x is NaN, SkTPin() returns hi but std::clamp() returns NaN.
15+
*/
16+
template <typename T>
17+
static constexpr const T& SkTPin(const T& x, const T& lo, const T& hi) {
18+
// TODO: return std::max(std::min(hi, x), lo)
19+
// TODO: return std::max(lo, std::min(x, hi)) ? (clamps NaN to lo)
20+
return x < lo ? lo
21+
: x < hi ? x
22+
: /*else*/ hi;
23+
}
24+
25+
#endif

0 commit comments

Comments
 (0)