aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkRefCnt.h15
-rw-r--r--src/android/SkAnimatedImage.cpp2
-rw-r--r--src/core/SkPictureData.cpp4
-rw-r--r--src/gpu/GrResourceAllocator.h2
-rw-r--r--src/gpu/ccpr/GrCCClipPath.h2
-rw-r--r--src/pdf/SkKeyedImage.h2
6 files changed, 13 insertions, 14 deletions
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index 0c3b23a7d1..eebc9684de 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -13,6 +13,7 @@
#include <atomic>
#include <functional>
#include <memory>
+#include <ostream>
#include <type_traits>
#include <utility>
@@ -244,8 +245,6 @@ private:
* may have its ref/unref be thread-safe, but that is not assumed/imposed by sk_sp.
*/
template <typename T> class sk_sp {
- /** Supports safe bool idiom. Obsolete with explicit operator bool. */
- using unspecified_bool_type = T* sk_sp::*;
public:
using element_type = T;
@@ -322,12 +321,7 @@ public:
return *this->get();
}
- // MSVC 2013 does not work correctly with explicit operator bool.
- // https://chromium-cpp.appspot.com/#core-blacklist
- // When explicit operator bool can be used, remove operator! and operator unspecified_bool_type.
- //explicit operator bool() const { return this->get() != nullptr; }
- operator unspecified_bool_type() const { return this->get() ? &sk_sp::fPtr : nullptr; }
- bool operator!() const { return this->get() == nullptr; }
+ explicit operator bool() const { return this->get() != nullptr; }
T* get() const { return fPtr; }
T* operator->() const { return fPtr; }
@@ -432,6 +426,11 @@ template <typename T> inline bool operator>=(std::nullptr_t, const sk_sp<T>& b)
return !(nullptr < b);
}
+template <typename C, typename CT, typename T>
+auto operator<<(std::basic_ostream<C, CT>& os, const sk_sp<T>& sp) -> decltype(os << sp.get()) {
+ return os << sp.get();
+}
+
template <typename T, typename... Args>
sk_sp<T> sk_make_sp(Args&&... args) {
return sk_sp<T>(new T(std::forward<Args>(args)...));
diff --git a/src/android/SkAnimatedImage.cpp b/src/android/SkAnimatedImage.cpp
index daeec81256..4885ada117 100644
--- a/src/android/SkAnimatedImage.cpp
+++ b/src/android/SkAnimatedImage.cpp
@@ -312,7 +312,7 @@ void SkAnimatedImage::onDraw(SkCanvas* canvas) {
canvas->saveLayer(&bounds, nullptr);
}
{
- SkAutoCanvasRestore acr(canvas, fPostProcess);
+ SkAutoCanvasRestore acr(canvas, fPostProcess != nullptr);
canvas->concat(fMatrix);
SkPaint paint;
paint.setFilterQuality(kLow_SkFilterQuality);
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 6be36dd1d2..4d927380cc 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -378,7 +378,7 @@ bool new_array_from_buffer(SkReadBuffer& buffer, uint32_t inCount,
for (uint32_t i = 0; i < inCount; ++i) {
auto obj = factory(buffer);
- if (!buffer.validate(obj)) {
+ if (!buffer.validate(obj != nullptr)) {
array.reset();
return false;
}
@@ -506,7 +506,7 @@ bool SkPictureData::parseBuffer(SkReadBuffer& buffer) {
}
// Check that we encountered required tags
- if (!buffer.validate(this->opData())) {
+ if (!buffer.validate(this->opData() != nullptr)) {
// If we didn't build any opData, we are invalid. Even an EmptyPicture allocates the
// SkData for the ops (though its length may be zero).
return false;
diff --git a/src/gpu/GrResourceAllocator.h b/src/gpu/GrResourceAllocator.h
index 427ff327cb..e71e3558c2 100644
--- a/src/gpu/GrResourceAllocator.h
+++ b/src/gpu/GrResourceAllocator.h
@@ -137,7 +137,7 @@ private:
}
void assign(sk_sp<GrSurface>);
- bool wasAssignedSurface() const { return fAssignedSurface; }
+ bool wasAssignedSurface() const { return fAssignedSurface != nullptr; }
sk_sp<GrSurface> detachSurface() { return std::move(fAssignedSurface); }
// for SkTDynamicHash
diff --git a/src/gpu/ccpr/GrCCClipPath.h b/src/gpu/ccpr/GrCCClipPath.h
index 290ac29ee4..f15cc9c756 100644
--- a/src/gpu/ccpr/GrCCClipPath.h
+++ b/src/gpu/ccpr/GrCCClipPath.h
@@ -33,7 +33,7 @@ public:
SkASSERT(fHasAtlasTransform);
}
- bool isInitialized() const { return fAtlasLazyProxy; }
+ bool isInitialized() const { return fAtlasLazyProxy != nullptr; }
void init(GrProxyProvider* proxyProvider,
const SkPath& deviceSpacePath, const SkIRect& accessRect,
int rtWidth, int rtHeight);
diff --git a/src/pdf/SkKeyedImage.h b/src/pdf/SkKeyedImage.h
index f489e576cd..792e802b15 100644
--- a/src/pdf/SkKeyedImage.h
+++ b/src/pdf/SkKeyedImage.h
@@ -27,7 +27,7 @@ public:
SkKeyedImage& operator=(SkKeyedImage&&) = default;
SkKeyedImage& operator=(const SkKeyedImage&) = default;
- explicit operator bool() const { return fImage; }
+ explicit operator bool() const { return fImage != nullptr; }
const SkBitmapKey& key() const { return fKey; }
const sk_sp<SkImage>& image() const { return fImage; }
sk_sp<SkImage> release();