зеркало из https://github.com/mozilla/pjs.git
Bug 670096 - cairo fails to compile on mingw with D2D and DWrite enabled r=bas.schouten
This commit is contained in:
Родитель
839d470660
Коммит
f67a0216ae
|
@ -2595,7 +2595,7 @@ _cairo_d2d_acquire_source_image(void *abstract_surface,
|
|||
assert(cairo_surface_status(image_out) == CAIRO_STATUS_SUCCESS ||
|
||||
cairo_surface_status(image_out) == CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
*image_extra = softTexture.forget();
|
||||
*image_extra = softTexture.forget().drop();
|
||||
*image_out_ret = (cairo_image_surface_t*)image_out;
|
||||
|
||||
return cairo_surface_status(image_out);
|
||||
|
@ -2668,7 +2668,7 @@ _cairo_d2d_acquire_dest_image(void *abstract_surface,
|
|||
size.width,
|
||||
size.height,
|
||||
data.RowPitch);
|
||||
*image_extra = softTexture.forget();
|
||||
*image_extra = softTexture.forget().drop();
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -36,55 +36,68 @@
|
|||
#ifndef CAIRO_WIN32_REFPTR_H
|
||||
#define CAIRO_WIN32_REFPTR_H
|
||||
|
||||
template<class T>
|
||||
template<typename T> class TemporaryRef;
|
||||
|
||||
/**
|
||||
* RefPtr points to a refcounted thing that has AddRef and Release
|
||||
* methods to increase/decrease the refcount, respectively. After a
|
||||
* RefPtr<T> is assigned a T*, the T* can be used through the RefPtr
|
||||
* as if it were a T*.
|
||||
*
|
||||
* A RefPtr can forget its underlying T*, which results in the T*
|
||||
* being wrapped in a temporary object until the T* is either
|
||||
* re-adopted from or released by the temporary.
|
||||
*/
|
||||
template<typename T>
|
||||
class RefPtr
|
||||
{
|
||||
// To allow them to use unref()
|
||||
friend class TemporaryRef<T>;
|
||||
|
||||
struct dontRef {};
|
||||
|
||||
public:
|
||||
RefPtr() : mPtr(NULL)
|
||||
{ }
|
||||
RefPtr() : ptr(0) { }
|
||||
RefPtr(const RefPtr& o) : ptr(ref(o.ptr)) {}
|
||||
RefPtr(const TemporaryRef<T>& o) : ptr(o.drop()) {}
|
||||
RefPtr(T* t) : ptr(ref(t)) {}
|
||||
|
||||
RefPtr(T *aPtr) : mPtr(aPtr)
|
||||
{
|
||||
if (mPtr) {
|
||||
mPtr->AddRef();
|
||||
}
|
||||
template<typename U>
|
||||
RefPtr(const RefPtr<U>& o) : ptr(ref(o.get())) {}
|
||||
|
||||
~RefPtr() { unref(ptr); }
|
||||
|
||||
RefPtr& operator=(const RefPtr& o) {
|
||||
assign(ref(o.ptr));
|
||||
return *this;
|
||||
}
|
||||
RefPtr& operator=(const TemporaryRef<T>& o) {
|
||||
assign(o.drop());
|
||||
return *this;
|
||||
}
|
||||
RefPtr& operator=(T* t) {
|
||||
assign(ref(t));
|
||||
return *this;
|
||||
}
|
||||
|
||||
RefPtr(const RefPtr<T> &aRefPtr)
|
||||
{
|
||||
mPtr = aRefPtr.mPtr;
|
||||
if (mPtr) {
|
||||
mPtr->AddRef();
|
||||
}
|
||||
template<typename U>
|
||||
RefPtr& operator=(const RefPtr<U>& o) {
|
||||
assign(ref(o.get()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class newType>
|
||||
explicit RefPtr(const RefPtr<newType> &aRefPtr)
|
||||
{
|
||||
mPtr = aRefPtr.get();
|
||||
if (mPtr) {
|
||||
mPtr->AddRef();
|
||||
}
|
||||
TemporaryRef<T> forget() {
|
||||
T* tmp = ptr;
|
||||
ptr = 0;
|
||||
return TemporaryRef<T>(tmp, dontRef());
|
||||
}
|
||||
|
||||
~RefPtr()
|
||||
{
|
||||
if (mPtr) {
|
||||
mPtr->Release();
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<T> &operator =(const RefPtr<T> aPtr)
|
||||
{
|
||||
assignPtr(aPtr.mPtr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RefPtr<T> &operator =(T* aPtr)
|
||||
{
|
||||
assignPtr(aPtr);
|
||||
return *this;
|
||||
}
|
||||
T* get() const { return ptr; }
|
||||
operator T*() const { return ptr; }
|
||||
T* operator->() const { return ptr; }
|
||||
T& operator*() const { return *ptr; }
|
||||
template<typename U>
|
||||
operator TemporaryRef<U>() { return TemporaryRef<U>(ptr); }
|
||||
|
||||
/**
|
||||
* WARNING for ease of use, passing a reference will release/clear out ptr!
|
||||
|
@ -95,67 +108,71 @@ public:
|
|||
*/
|
||||
T** operator&()
|
||||
{
|
||||
if (mPtr) {
|
||||
mPtr->Release();
|
||||
mPtr = NULL;
|
||||
}
|
||||
return &mPtr;
|
||||
}
|
||||
|
||||
T* operator->()
|
||||
{
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
T* operator->() const
|
||||
{
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
operator bool()
|
||||
{
|
||||
return (mPtr ? true : false);
|
||||
}
|
||||
|
||||
operator T*()
|
||||
{
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
template <class newType>
|
||||
operator RefPtr<newType>()
|
||||
{
|
||||
RefPtr<newType> newPtr;
|
||||
newPtr = mPtr;
|
||||
return newPtr;
|
||||
}
|
||||
|
||||
T* get() const
|
||||
{
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
T* forget()
|
||||
{
|
||||
T* ptr = mPtr;
|
||||
mPtr = NULL;
|
||||
return ptr;
|
||||
if (ptr) {
|
||||
ptr->Release();
|
||||
ptr = NULL;
|
||||
}
|
||||
return &ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
void assignPtr(T* aPtr)
|
||||
{
|
||||
T *oldPtr = mPtr;
|
||||
mPtr = aPtr;
|
||||
if (mPtr) {
|
||||
mPtr->AddRef();
|
||||
}
|
||||
if (oldPtr) {
|
||||
oldPtr->Release();
|
||||
}
|
||||
void assign(T* t) {
|
||||
unref(ptr);
|
||||
ptr = t;
|
||||
}
|
||||
|
||||
T *mPtr;
|
||||
T* ptr;
|
||||
|
||||
static inline T* ref(T* t) {
|
||||
if (t) {
|
||||
t->AddRef();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
static inline void unref(T* t) {
|
||||
if (t) {
|
||||
t->Release();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* TemporaryRef<T> represents an object that holds a temporary
|
||||
* reference to a T. TemporaryRef objects can't be manually ref'd or
|
||||
* unref'd (being temporaries, not lvalues), so can only relinquish
|
||||
* references to other objects, or unref on destruction.
|
||||
*/
|
||||
template<typename T>
|
||||
class TemporaryRef
|
||||
{
|
||||
// To allow it to construct TemporaryRef from a bare T*
|
||||
friend class RefPtr<T>;
|
||||
|
||||
typedef typename RefPtr<T>::dontRef dontRef;
|
||||
|
||||
public:
|
||||
TemporaryRef(T* t) : ptr(RefPtr<T>::ref(t)) {}
|
||||
TemporaryRef(const TemporaryRef& o) : ptr(o.drop()) {}
|
||||
|
||||
template<typename U>
|
||||
TemporaryRef(const TemporaryRef<U>& o) : ptr(o.drop()) {}
|
||||
|
||||
~TemporaryRef() { RefPtr<T>::unref(ptr); }
|
||||
|
||||
T* drop() const {
|
||||
T* tmp = ptr;
|
||||
ptr = 0;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private:
|
||||
TemporaryRef(T* t, const dontRef&) : ptr(t) {}
|
||||
|
||||
mutable T* ptr;
|
||||
|
||||
TemporaryRef();
|
||||
TemporaryRef& operator=(const TemporaryRef&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче