'<(skia_include_path)/private/SkTDict.h',
'<(skia_include_path)/private/SkTSearch.h',
'<(skia_include_path)/private/SkTLogic.h',
- '<(skia_include_path)/private/SkUniquePtr.h',
'<(skia_include_path)/private/SkWeakRefCnt.h',
# Path ops
#define SkRefCnt_DEFINED
#include "../private/SkAtomics.h"
-#include "../private/SkUniquePtr.h"
+#include "../private/SkTLogic.h"
#include "SkTypes.h"
#include <functional>
+#include <memory>
#include <utility>
#define SK_SUPPORT_TRANSITION_TO_SP_INTERFACES
/**
* Utility class that simply unref's its argument in the destructor.
*/
-template <typename T> class SkAutoTUnref : public skstd::unique_ptr<T, SkTUnref<T>> {
+template <typename T> class SkAutoTUnref : public std::unique_ptr<T, SkTUnref<T>> {
public:
- explicit SkAutoTUnref(T* obj = nullptr) : skstd::unique_ptr<T, SkTUnref<T>>(obj) {}
+ explicit SkAutoTUnref(T* obj = nullptr) : std::unique_ptr<T, SkTUnref<T>>(obj) {}
T* detach() { return this->release(); }
operator T*() const { return this->get(); }
+
+ // Android's std::unique_ptr's operator bool() is sometimes not explicit...
+ // so override it with our own explcitly explicit version.
+ explicit operator bool() const { return this->get() != nullptr; }
};
// Can't use the #define trick below to guard a bare SkAutoTUnref(...) because it's templated. :(
const GrGLInterface* gl() const { return fGL.get(); }
- bool fenceSyncSupport() const { return SkToBool(fFenceSync); }
+ bool fenceSyncSupport() const { return fFenceSync != nullptr; }
bool getMaxGpuFrameLag(int* maxFrameLag) const {
if (!fFenceSync) {
#define SkOncePtr_DEFINED
#include "../private/SkAtomics.h"
-#include "SkUniquePtr.h"
+#include <memory>
template <typename T> class SkBaseOncePtr;
#define SK_DECLARE_STATIC_ONCE_PTR(type, name) namespace {} static SkBaseOncePtr<type> name;
// Use this for a local or member pointer that's initialized exactly once when you call get().
-template <typename T, typename Delete = skstd::default_delete<T>>
+template <typename T, typename Delete = std::default_delete<T>>
class SkOncePtr : SkNoncopyable {
public:
SkOncePtr() { sk_bzero(this, sizeof(*this)); }
// If you ask for SkOncePtr<T[]>, we'll clean up with delete[] by default.
template <typename T>
-class SkOncePtr<T[]> : public SkOncePtr<T, skstd::default_delete<T[]>> {};
+class SkOncePtr<T[]> : public SkOncePtr<T, std::default_delete<T[]>> {};
/* TODO(mtklein): in next CL
typedef SkBaseOncePtr<void> SkOnceFlag;
#include "SkMath.h"
#include "SkTLogic.h"
#include "SkTypes.h"
-#include "SkUniquePtr.h"
#include <limits.h>
+#include <memory>
#include <new>
/** \file SkTemplates.h
function.
*/
template <typename T, void (*P)(T*)> class SkAutoTCallVProc
- : public skstd::unique_ptr<T, SkFunctionWrapper<void, T, P>> {
+ : public std::unique_ptr<T, SkFunctionWrapper<void, T, P>> {
public:
- SkAutoTCallVProc(T* obj): skstd::unique_ptr<T, SkFunctionWrapper<void, T, P>>(obj) {}
+ SkAutoTCallVProc(T* obj): std::unique_ptr<T, SkFunctionWrapper<void, T, P>>(obj) {}
operator T*() const { return this->get(); }
T* detach() { return this->release(); }
function.
*/
template <typename T, int (*P)(T*)> class SkAutoTCallIProc
- : public skstd::unique_ptr<T, SkFunctionWrapper<int, T, P>> {
+ : public std::unique_ptr<T, SkFunctionWrapper<int, T, P>> {
public:
- SkAutoTCallIProc(T* obj): skstd::unique_ptr<T, SkFunctionWrapper<int, T, P>>(obj) {}
+ SkAutoTCallIProc(T* obj): std::unique_ptr<T, SkFunctionWrapper<int, T, P>>(obj) {}
operator T*() const { return this->get(); }
T* detach() { return this->release(); }
The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*)
*/
-template <typename T> class SkAutoTDelete : public skstd::unique_ptr<T> {
+template <typename T> class SkAutoTDelete : public std::unique_ptr<T> {
public:
- SkAutoTDelete(T* obj = NULL) : skstd::unique_ptr<T>(obj) {}
+ SkAutoTDelete(T* obj = NULL) : std::unique_ptr<T>(obj) {}
operator T*() const { return this->get(); }
void free() { this->reset(nullptr); }
T* detach() { return this->release(); }
};
-template <typename T> class SkAutoTDeleteArray : public skstd::unique_ptr<T[]> {
+template <typename T> class SkAutoTDeleteArray : public std::unique_ptr<T[]> {
public:
- SkAutoTDeleteArray(T array[]) : skstd::unique_ptr<T[]>(array) {}
+ SkAutoTDeleteArray(T array[]) : std::unique_ptr<T[]>(array) {}
void free() { this->reset(nullptr); }
T* detach() { return this->release(); }
+++ /dev/null
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkUniquePtr_DEFINED
-#define SkUniquePtr_DEFINED
-
-#include "SkTLogic.h"
-#include <cstddef>
-#include <utility>
-
-namespace skstd {
-
-template <typename T> struct default_delete {
- /*constexpr*/ default_delete() /*noexcept*/ = default;
-
- template <typename U, typename = enable_if_t<is_convertible<U*, T*>::value>>
- default_delete(const default_delete<U>&) /*noexcept*/ {}
-
- void operator()(T* obj) const {
- static_assert(sizeof(T) > 0, "Deleting pointer to incomplete type!");
- delete obj;
- }
-};
-template <typename T> struct default_delete<T[]> {
- /*constexpr*/ default_delete() /*noexcept*/ = default;
-
- void operator()(T* obj) const {
- static_assert(sizeof(T) > 0, "Deleting pointer to incomplete type!");
- delete [] obj;
- }
-};
-
-template <typename T, typename D = default_delete<T>> class unique_ptr {
- // remove_reference_t<D>::pointer if that type exists, otherwise T*.
- struct pointer_type_detector {
- template <typename U> static typename U::pointer detector(typename U::pointer*);
- template <typename U> static T* detector(...);
- using type = decltype(detector<remove_reference_t<D>>(0));
- };
-
-public:
- using pointer = typename pointer_type_detector::type;
- using element_type = T;
- using deleter_type = D;
-
-private:
- template <typename B, bool>
- struct compressed_base : private B {
- /*constexpr*/ compressed_base() : B() {}
- /*constexpr*/ compressed_base(const B& b) : B(b) {}
- /*constexpr*/ compressed_base(B&& b) : B(std::move(b)) {}
- /*constexpr*/ B& get() /*noexcept*/ { return *this; }
- /*constexpr*/ B const& get() const /*noexcept*/ { return *this; }
- void swap(compressed_base&) /*noexcept*/ { }
- };
-
- template <typename B> struct compressed_base<B, false> {
- B fb;
- /*constexpr*/ compressed_base() : B() {}
- /*constexpr*/ compressed_base(const B& b) : fb(b) {}
- /*constexpr*/ compressed_base(B&& b) : fb(std::move(b)) {}
- /*constexpr*/ B& get() /*noexcept*/ { return fb; }
- /*constexpr*/ B const& get() const /*noexcept*/ { return fb; }
- void swap(compressed_base& that) /*noexcept*/ { SkTSwap(fb, that.fB); }
- };
-
- // C++14 adds '&& !std::is_final<deleter_type>::value' to the bool condition.
- // compressed_base_t exists and has this form to work around a bug in vs2013sp2-3
- using compressed_base_t = compressed_base<deleter_type, std::is_empty<deleter_type>::value>;
-
- struct compressed_data : private compressed_base_t {
- pointer fPtr;
- /*constexpr*/ compressed_data() : compressed_base_t(), fPtr() {}
- /*constexpr*/ compressed_data(const pointer& ptr, const deleter_type& d)
- : compressed_base_t(d), fPtr(ptr) {}
- template <typename U1, typename U2, typename = enable_if_t<
- is_convertible<U1, pointer>::value && is_convertible<U2, deleter_type>::value
- >> /*constexpr*/ compressed_data(U1&& ptr, U2&& d)
- : compressed_base_t(std::forward<U2>(d)), fPtr(std::forward<U1>(ptr)) {}
- /*constexpr*/ pointer& getPointer() /*noexcept*/ { return fPtr; }
- /*constexpr*/ pointer const& getPointer() const /*noexcept*/ { return fPtr; }
- /*constexpr*/ deleter_type& getDeleter() /*noexcept*/ {
- return compressed_base_t::get();
- }
- /*constexpr*/ deleter_type const& getDeleter() const /*noexcept*/ {
- return compressed_base_t::get();
- }
- void swap(compressed_data& that) /*noexcept*/ {
- compressed_base_t::swap(static_cast<compressed_base_t>(that));
- SkTSwap(fPtr, that.fPtr);
- }
- };
- compressed_data data;
-
-public:
- /*constexpr*/ unique_ptr() /*noexcept*/ : data() {
- static_assert(!std::is_pointer<deleter_type>::value, "Deleter nullptr function pointer!");
- }
-
- /*constexpr*/ unique_ptr(std::nullptr_t) /*noexcept*/ : unique_ptr() { }
-
- explicit unique_ptr(pointer ptr) /*noexcept*/ : data(ptr, deleter_type()) {
- static_assert(!std::is_pointer<deleter_type>::value, "Deleter nullptr function pointer!");
- }
-
- unique_ptr(pointer ptr,
- conditional_t<std::is_reference<deleter_type>::value,
- deleter_type, const deleter_type&> d)
- /*noexcept*/ : data(ptr, d)
- {}
-
- unique_ptr(pointer ptr, remove_reference_t<deleter_type>&& d) /*noexcept*/
- : data(std::move(ptr), std::move(d))
- {
- static_assert(!std::is_reference<deleter_type>::value,
- "Binding an rvalue reference deleter as an lvalue reference deleter is not allowed.");
- }
-
-
- unique_ptr(unique_ptr&& that) /*noexcept*/
- : data(that.release(), std::forward<deleter_type>(that.get_deleter()))
- {}
-
- template <typename U, typename ThatD, typename = enable_if_t<
- is_convertible<typename unique_ptr<U, ThatD>::pointer, pointer>::value &&
- !std::is_array<U>::value &&
- conditional_t<std::is_reference<D>::value,
- std::is_same<ThatD, D>,
- is_convertible<ThatD, D>>::value>>
- unique_ptr(unique_ptr<U, ThatD>&& that) /*noexcept*/
- : data(that.release(), std::forward<ThatD>(that.get_deleter()))
- {}
-
- ~unique_ptr() /*noexcept*/ {
- pointer& ptr = data.getPointer();
- if (ptr != nullptr) {
- get_deleter()(ptr);
- }
- ptr = pointer();
- }
-
- unique_ptr& operator=(unique_ptr&& that) /*noexcept*/ {
- reset(that.release());
- get_deleter() = std::forward<deleter_type>(that.get_deleter());
- return *this;
- }
-
- template <typename U, typename ThatD> enable_if_t<
- is_convertible<typename unique_ptr<U, ThatD>::pointer, pointer>::value &&
- !std::is_array<U>::value,
- unique_ptr&> operator=(unique_ptr<U, ThatD>&& that) /*noexcept*/ {
- reset(that.release());
- get_deleter() = std::forward<ThatD>(that.get_deleter());
- return *this;
- }
-
- unique_ptr& operator=(std::nullptr_t) /*noexcept*/ {
- reset();
- return *this;
- }
-
- add_lvalue_reference_t<element_type> operator*() const {
- SkASSERT(get() != pointer());
- return *get();
- }
-
- pointer operator->() const /*noexcept*/ {
- SkASSERT(get() != pointer());
- return get();
- }
-
- pointer get() const /*noexcept*/ {
- return data.getPointer();
- }
-
- deleter_type& get_deleter() /*noexcept*/ {
- return data.getDeleter();
- }
-
- const deleter_type& get_deleter() const /*noexcept*/ {
- return data.getDeleter();
- }
-
- //explicit operator bool() const noexcept {
- bool is_attached() const /*noexcept*/ {
- return get() == pointer() ? false : true;
- }
-
- pointer release() /*noexcept*/ {
- pointer ptr = get();
- data.getPointer() = pointer();
- return ptr;
- }
-
- void reset(pointer ptr = pointer()) /*noexcept*/ {
- SkTSwap(data.getPointer(), ptr);
- if (ptr != pointer()) {
- get_deleter()(ptr);
- }
- }
-
- void swap(unique_ptr& that) /*noexcept*/ {
- SkTSwap(data, that.data);
- }
-
- unique_ptr(const unique_ptr&) = delete;
- unique_ptr& operator=(const unique_ptr&) = delete;
-};
-
-template <typename T, typename D> class unique_ptr<T[], D> {
- // remove_reference_t<D>::pointer if that type exists, otherwise T*.
- struct pointer_type_detector {
- template <typename U> static typename U::pointer detector(typename U::pointer*);
- template <typename U> static T* detector(...);
- using type = decltype(detector<remove_reference_t<D>>(0));
- };
-
-public:
- using pointer = typename pointer_type_detector::type;
- using element_type = T;
- using deleter_type = D;
-
-private:
- template <typename B, bool> struct compressed_base : private B {
- /*constexpr*/ compressed_base() : B() {}
- /*constexpr*/ compressed_base(const B& b) : B(b) {}
- /*constexpr*/ compressed_base(B&& b) : B(std::move(b)) {}
- /*constexpr*/ B& get() /*noexcept*/ { return *this; }
- /*constexpr*/ B const& get() const /*noexcept*/ { return *this; }
- void swap(compressed_base&) /*noexcept*/ { }
- };
-
- template <typename B> struct compressed_base<B, false> {
- B fb;
- /*constexpr*/ compressed_base() : B() {}
- /*constexpr*/ compressed_base(const B& b) : fb(b) {}
- /*constexpr*/ compressed_base(B&& b) : fb(std::move(b)) {}
- /*constexpr*/ B& get() /*noexcept*/ { return fb; }
- /*constexpr*/ B const& get() const /*noexcept*/ { return fb; }
- void swap(compressed_base& that) /*noexcept*/ { SkTSwap(fb, that.fB); }
- };
-
- // C++14 adds '&& !std::is_final<deleter_type>::value' to the bool condition.
- // compressed_base_t exists and has this form to work around a bug in vs2013sp2-3
- using compressed_base_t = compressed_base<deleter_type, std::is_empty<deleter_type>::value>;
-
- struct compressed_data : private compressed_base_t {
- pointer fPtr;
- /*constexpr*/ compressed_data() : compressed_base_t(), fPtr() {}
- /*constexpr*/ compressed_data(const pointer& ptr, const deleter_type& d)
- : compressed_base_t(d), fPtr(ptr) {}
- template <typename U1, typename U2, typename = enable_if_t<
- is_convertible<U1, pointer>::value && is_convertible<U2, deleter_type>::value
- >> /*constexpr*/ compressed_data(U1&& ptr, U2&& d)
- : compressed_base_t(std::forward<U2>(d)), fPtr(std::forward<U1>(ptr)) {}
- /*constexpr*/ pointer& getPointer() /*noexcept*/ { return fPtr; }
- /*constexpr*/ pointer const& getPointer() const /*noexcept*/ { return fPtr; }
- /*constexpr*/ deleter_type& getDeleter() /*noexcept*/ {
- return compressed_base_t::get();
- }
- /*constexpr*/ deleter_type const& getDeleter() const /*noexcept*/ {
- return compressed_base_t::get();
- }
- void swap(compressed_data& that) /*noexcept*/ {
- compressed_base_t::swap(static_cast<compressed_base_t>(that));
- SkTSwap(fPtr, that.fPtr);
- }
- };
- compressed_data data;
-
-public:
- /*constexpr*/ unique_ptr() /*noexcept*/ : data() {
- static_assert(!std::is_pointer<deleter_type>::value, "Deleter nullptr function pointer!");
- }
-
- /*constexpr*/ unique_ptr(std::nullptr_t) /*noexcept*/ : unique_ptr() { }
-
- explicit unique_ptr(pointer ptr) /*noexcept*/ : data(ptr, deleter_type()) {
- static_assert(!std::is_pointer<deleter_type>::value, "Deleter nullptr function pointer!");
- }
-
- unique_ptr(pointer ptr,
- conditional_t<std::is_reference<deleter_type>::value,
- deleter_type, const deleter_type&> d)
- /*noexcept*/ : data(ptr, d)
- {}
-
- unique_ptr(pointer ptr, remove_reference_t<deleter_type>&& d) /*noexcept*/
- : data(std::move(ptr), std::move(d))
- {
- static_assert(!std::is_reference<deleter_type>::value,
- "Binding an rvalue reference deleter as an lvalue reference deleter is not allowed.");
- }
-
- unique_ptr(unique_ptr&& that) /*noexcept*/
- : data(that.release(), std::forward<deleter_type>(that.get_deleter()))
- {}
-
- ~unique_ptr() {
- pointer& ptr = data.getPointer();
- if (ptr != nullptr) {
- get_deleter()(ptr);
- }
- ptr = pointer();
- }
-
- unique_ptr& operator=(unique_ptr&& that) /*noexcept*/ {
- reset(that.release());
- get_deleter() = std::forward<deleter_type>(that.get_deleter());
- return *this;
- }
-
- unique_ptr& operator=(std::nullptr_t) /*noexcept*/ {
- reset();
- return *this;
- }
-
- add_lvalue_reference_t<element_type> operator[](size_t i) const {
- SkASSERT(get() != pointer());
- return get()[i];
- }
-
- pointer get() const /*noexcept*/ {
- return data.getPointer();
- }
-
- deleter_type& get_deleter() /*noexcept*/ {
- return data.getDeleter();
- }
-
- const deleter_type& get_deleter() const /*noexcept*/ {
- return data.getDeleter();
- }
-
- //explicit operator bool() const noexcept {
- bool is_attached() const /*noexcept*/ {
- return get() == pointer() ? false : true;
- }
-
- pointer release() /*noexcept*/ {
- pointer ptr = get();
- data.getPointer() = pointer();
- return ptr;
- }
-
- void reset(pointer ptr = pointer()) /*noexcept*/ {
- SkTSwap(data.getPointer(), ptr);
- if (ptr != pointer()) {
- get_deleter()(ptr);
- }
- }
-
- template <typename U> void reset(U*) = delete;
-
- void swap(unique_ptr& that) /*noexcept*/ {
- data.swap(that.data);
- }
-
- unique_ptr(const unique_ptr&) = delete;
- unique_ptr& operator=(const unique_ptr&) = delete;
-};
-
-template <typename T, typename D>
-inline void swap(unique_ptr<T, D>& a, unique_ptr<T, D>& b) /*noexcept*/ {
- a.swap(b);
-}
-
-template <typename T, typename D, typename U, typename ThatD>
-inline bool operator==(const unique_ptr<T, D>& a, const unique_ptr<U, ThatD>& b) {
- return a.get() == b.get();
-}
-
-template <typename T, typename D>
-inline bool operator==(const unique_ptr<T, D>& a, std::nullptr_t) /*noexcept*/ {
- //return !a;
- return !a.is_attached();
-}
-
-template <typename T, typename D>
-inline bool operator==(std::nullptr_t, const unique_ptr<T, D>& b) /*noexcept*/ {
- //return !b;
- return !b.is_attached();
-}
-
-template <typename T, typename D, typename U, typename ThatD>
-inline bool operator!=(const unique_ptr<T, D>& a, const unique_ptr<U, ThatD>& b) {
- return a.get() != b.get();
-}
-
-template <typename T, typename D>
-inline bool operator!=(const unique_ptr<T, D>& a, std::nullptr_t) /*noexcept*/ {
- //return (bool)a;
- return a.is_attached();
-}
-
-template <typename T, typename D>
-inline bool operator!=(std::nullptr_t, const unique_ptr<T, D>& b) /*noexcept*/ {
- //return (bool)b;
- return b.is_attached();
-}
-
-} // namespace skstd
-
-#endif
AuxProcRec* fAuxProcList;
};
-class SkAutoGlyphCache : public skstd::unique_ptr<SkGlyphCache, SkGlyphCache::AttachCacheFunctor> {
+class SkAutoGlyphCache : public std::unique_ptr<SkGlyphCache, SkGlyphCache::AttachCacheFunctor> {
public:
/** deprecated: use get() */
SkGlyphCache* getCache() const { return this->get(); }
: INHERITED(paint.detachCache(surfaceProps, fakeGamma, matrix))
{}
private:
- using INHERITED = skstd::unique_ptr<SkGlyphCache, SkGlyphCache::AttachCacheFunctor>;
+ using INHERITED = std::unique_ptr<SkGlyphCache, SkGlyphCache::AttachCacheFunctor>;
};
class SkAutoGlyphCacheNoGamma : public SkAutoGlyphCache {
#ifdef SK_DEBUG
#include "SkMutex.h"
- #include "SkUniquePtr.h"
+ #include <memory>
#endif // SK_DEBUG
// There are two shared lock implementations one debug the other is high performance. They implement
private:
#ifdef SK_DEBUG
class ThreadIDSet;
- skstd::unique_ptr<ThreadIDSet> fCurrentShared;
- skstd::unique_ptr<ThreadIDSet> fWaitingExclusive;
- skstd::unique_ptr<ThreadIDSet> fWaitingShared;
+ std::unique_ptr<ThreadIDSet> fCurrentShared;
+ std::unique_ptr<ThreadIDSet> fWaitingExclusive;
+ std::unique_ptr<ThreadIDSet> fWaitingShared;
int fSharedQueueSelect{0};
mutable SkMutex fMu;
SkSemaphore fSharedQueue[2];
#include "GrTextureProvider.h"
///////////////////////////////////////////////////////////////////////////////
-GrLayerAtlas::Plot::Plot()
+GrLayerAtlas::Plot::Plot()
: fID(-1)
, fRects(nullptr) {
fOffset.set(0, 0);
SkASSERT(!fTexture);
fTexture.reset(fTexProvider->findAndRefTextureByUniqueKey(get_layer_atlas_key()));
- return SkToBool(fTexture);
+ return fTexture != nullptr;
}
void GrLayerAtlas::createBackingTexture() {
fTexture->resourcePriv().setUniqueKey(get_layer_atlas_key());
}
-GrLayerAtlas::GrLayerAtlas(GrTextureProvider* texProvider, GrPixelConfig config,
+GrLayerAtlas::GrLayerAtlas(GrTextureProvider* texProvider, GrPixelConfig config,
GrSurfaceFlags flags,
const SkISize& backingTextureSize,
int numPlotsX, int numPlotsY) {
public:
FallbackBlobBuilder() : fBuffIdx(0), fCount(0) {}
- bool isInitialized() const { return SkToBool(fBuilder); }
+ bool isInitialized() const { return fBuilder != nullptr; }
void init(const SkPaint& font, SkScalar textRatio);
return mediaBox;
}
-skstd::unique_ptr<SkStreamAsset> SkPDFDevice::content() const {
+std::unique_ptr<SkStreamAsset> SkPDFDevice::content() const {
SkDynamicMemoryWStream buffer;
this->writeContent(&buffer);
- return skstd::unique_ptr<SkStreamAsset>(
+ return std::unique_ptr<SkStreamAsset>(
buffer.bytesWritten() > 0
? buffer.detachAsStream()
: new SkMemoryStream);
/** Returns a SkStream with the page contents.
*/
- skstd::unique_ptr<SkStreamAsset> content() const;
+ std::unique_ptr<SkStreamAsset> content() const;
/** Writes the page contents to the stream. */
void writeContent(SkWStream*) const;
#include "SkString.h"
#include "SkTemplates.h"
#include "SkTypes.h"
-#include "SkUniquePtr.h"
+#include <memory>
#if defined(SK_CAN_USE_DLOPEN)
#include <dlfcn.h>
// load the font file
using UnrefFTFace = SkFunctionWrapper<void, skstd::remove_pointer_t<FT_Face>, unref_ft_face>;
- skstd::unique_ptr<skstd::remove_pointer_t<FT_Face>, UnrefFTFace> ftFace(ref_ft_face(typeface));
+ std::unique_ptr<skstd::remove_pointer_t<FT_Face>, UnrefFTFace> ftFace(ref_ft_face(typeface));
if (nullptr == ftFace) {
SkDEBUGF(("Could not create FT_Face.\n"));
return;
}
using DoneFTSize = SkFunctionWrapper<FT_Error, skstd::remove_pointer_t<FT_Size>, FT_Done_Size>;
- skstd::unique_ptr<skstd::remove_pointer_t<FT_Size>, DoneFTSize> ftSize([&ftFace]() -> FT_Size {
+ std::unique_ptr<skstd::remove_pointer_t<FT_Size>, DoneFTSize> ftSize([&ftFace]() -> FT_Size {
FT_Size size;
FT_Error err = FT_New_Size(ftFace.get(), &size);
if (err != 0) {
Moveable src1; Moveable dst1(std::move(src1));
Moveable src2, dst2; dst2 = std::move(src2);
}
-
-#define TOO_BIG "The unique_ptr was bigger than expected."
-#define WEIRD_SIZE "The unique_ptr was a different size than expected."
-
-DEF_TEST(CPlusPlusEleven_UniquePtr, r) {
- struct SmallUniquePtr {
- Moveable* p;
- };
- struct BigUniquePtr {
- void(*d)(Moveable*);
- Moveable* p;
- };
-
- static_assert(sizeof(skstd::unique_ptr<Moveable>) == sizeof(SmallUniquePtr), TOO_BIG);
- static_assert(sizeof(skstd::unique_ptr<Moveable[]>) == sizeof(SmallUniquePtr), TOO_BIG);
-
- using proc = void(*)(Moveable*);
- static_assert(sizeof(skstd::unique_ptr<Moveable, proc>) == sizeof(BigUniquePtr), WEIRD_SIZE);
- static_assert(sizeof(skstd::unique_ptr<Moveable[], proc>) == sizeof(BigUniquePtr), WEIRD_SIZE);
-
- {
- skstd::unique_ptr<Moveable, void(*)(Moveable*)> u(nullptr, deleter<Moveable>);
- static_assert(sizeof(u) == sizeof(BigUniquePtr), WEIRD_SIZE);
-
- auto u2 = std::move(u);
- static_assert(sizeof(u2) == sizeof(BigUniquePtr), WEIRD_SIZE);
- }
-
- {
- skstd::unique_ptr<Moveable, void(*)(Moveable*)> u(nullptr, [](Moveable* m){ deleter(m); });
- static_assert(sizeof(u) == sizeof(BigUniquePtr), WEIRD_SIZE);
-
- auto u2 = std::move(u);
- static_assert(sizeof(u2) == sizeof(BigUniquePtr), WEIRD_SIZE);
- }
-
- {
- auto d = [](Moveable* m){ deleter(m); };
- skstd::unique_ptr<Moveable, decltype(d)> u(nullptr, d);
- static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
-
- auto u2 = std::move(u);
- static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
- }
-
- {
- skstd::unique_ptr<Moveable, Deleter<Moveable>> u(nullptr, Deleter<Moveable>());
- static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
-
- auto u2 = std::move(u);
- static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
- }
-
- {
- skstd::unique_ptr<Moveable, Deleter<Moveable>> u(new Moveable(), Deleter<Moveable>());
- static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
-
- auto u2 = std::move(u);
- static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
- }
-
- {
- skstd::unique_ptr<const void, Deleter<const void>> u(new Moveable(), Deleter<const void>());
- static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
-
- auto u2 = std::move(u);
- static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
- }
-}
GrRenderTarget* rt = (*rtKeepAlive)->asRenderTarget();
SkASSERT(rt->getUniqueID() != oldID);
dc->reset(context->drawContext(rt));
- return SkToBool(*dc);
+ return *dc != nullptr;
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, context) {
assert_equal(reporter, image, nullptr, decoded);
// Now see if we can instantiate an image from a subset of the surface/origEncoded
-
+
decoded.reset(SkImage::NewFromEncoded(origEncoded, &ir));
REPORTER_ASSERT(reporter, decoded);
assert_equal(reporter, image, &ir, decoded);
for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
SkAutoTUnref<SkImage> newImage(
SkImage::NewFromDeferredTextureImageData(context, buffer, budgeted));
- REPORTER_ASSERT(reporter, SkToBool(newImage));
+ REPORTER_ASSERT(reporter, newImage != nullptr);
if (newImage) {
check_images_same(reporter, image, newImage);
}
SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstream));
- REPORTER_ASSERT(r, SkToBool(deserializedPicture));
+ REPORTER_ASSERT(r, deserializedPicture != nullptr);
REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2);
REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3);
resourceProvider->attachStencilAttachment(bigRT->asRenderTarget()));
if (context->caps()->maxSampleCount() >= 4) {
- // An RT with a different sample count should not share.
+ // An RT with a different sample count should not share.
GrSurfaceDesc smallMSAADesc = smallDesc;
smallMSAADesc.fSampleCnt = 4;
SkAutoTUnref<GrTexture> smallMSAART0(cache->createTexture(smallMSAADesc, SkBudgeted::kNo));
SkAutoTUnref<GrTexture> adopted(context->textureProvider()->wrapBackendTexture(
desc, kAdopt_GrWrapOwnership));
- REPORTER_ASSERT(reporter, SkToBool(borrowed) && SkToBool(adopted));
- if (!SkToBool(borrowed) || !SkToBool(adopted)) {
+ REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr);
+ if (!borrowed || !adopted) {
return;
}
enum ScratchConstructor { kScratchConstructor };
public:
static const size_t kDefaultSize = 100;
-
+
/** Property that distinctly categorizes the resource.
* For example, textures have width, height, ... */
enum SimulatedProperty { kA_SimulatedProperty, kB_SimulatedProperty };
REPORTER_ASSERT(reporter, SkBudgeted::kYes == resource->resourcePriv().isBudgeted());
if (0 == i) {
- // If made unbudgeted, it should return to original state: ref'ed and unbudgeted. Try
+ // If made unbudgeted, it should return to original state: ref'ed and unbudgeted. Try
// the above tests again.
resource->resourcePriv().makeUnbudgeted();
} else {
GrUniqueKey key;
make_unique_key<0>(&key, 0);
-
+
// Create two resources that we will attempt to register with the same unique key.
TestResource* a = new TestResource(context->getGpu());
a->setSize(11);
-
+
// Set key on resource a.
a->resourcePriv().setUniqueKey(key);
REPORTER_ASSERT(reporter, a == cache->findAndRefUniqueResource(key));
make_unique_key<0>(&key1, 1);
make_unique_key<0>(&key2, 2);
make_unique_key<0>(&key3, 3);
-
+
// Add three resources to the cache. Only c is usable as scratch.
TestResource* a = new TestResource(context->getGpu());
TestResource* b = new TestResource(context->getGpu());