This commit is contained in:
Justin Wood 2011-09-09 22:04:09 -04:00
Родитель 990085a2d1 f4d5e257f4
Коммит 13ec002a67
3 изменённых файлов: 39 добавлений и 11 удалений

Просмотреть файл

@ -815,8 +815,10 @@ public:
PRBool CopyDataIfElementArray(const void* data) {
if (mTarget == LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
mData = realloc(mData, mByteLength);
if (!mData)
if (!mData) {
mByteLength = 0;
return PR_FALSE;
}
memcpy(mData, data, mByteLength);
}
return PR_TRUE;
@ -826,8 +828,10 @@ public:
PRBool ZeroDataIfElementArray() {
if (mTarget == LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
mData = realloc(mData, mByteLength);
if (!mData)
if (!mData) {
mByteLength = 0;
return PR_FALSE;
}
memset(mData, 0, mByteLength);
}
return PR_TRUE;
@ -835,7 +839,7 @@ public:
// same comments as for CopyElementArrayData
void CopySubDataIfElementArray(GLuint byteOffset, GLuint byteLength, const void* data) {
if (mTarget == LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
if (mTarget == LOCAL_GL_ELEMENT_ARRAY_BUFFER && mByteLength) {
memcpy((void*) (size_t(mData)+byteOffset), data, byteLength);
}
}
@ -1047,10 +1051,6 @@ protected:
(mMinFilter == LOCAL_GL_NEAREST || mMinFilter == LOCAL_GL_NEAREST_MIPMAP_NEAREST);
}
PRBool DoesMinFilterRequireMipmap() const {
return !(mMinFilter == LOCAL_GL_NEAREST || mMinFilter == LOCAL_GL_LINEAR);
}
PRBool AreBothWrapModesClampToEdge() const {
return mWrapS == LOCAL_GL_CLAMP_TO_EDGE && mWrapT == LOCAL_GL_CLAMP_TO_EDGE;
}
@ -1154,6 +1154,12 @@ public:
mWrapT = aWrapT;
SetDontKnowIfNeedFakeBlack();
}
WebGLenum MinFilter() const { return mMinFilter; }
PRBool DoesMinFilterRequireMipmap() const {
return !(mMinFilter == LOCAL_GL_NEAREST || mMinFilter == LOCAL_GL_LINEAR);
}
void SetGeneratedMipmap() {
if (!mHaveGeneratedMipmap) {

Просмотреть файл

@ -1751,7 +1751,28 @@ WebGLContext::GenerateMipmap(WebGLenum target)
tex->SetGeneratedMipmap();
MakeContextCurrent();
#ifdef XP_MACOSX
// On Mac, glGenerateMipmap on a texture whose minification filter does NOT require a mipmap at the time of the call,
// will happily grab random video memory into certain mipmap levels. See bug 684882. Also, this is Apple bug 9129398.
// Thanks to Kenneth Russell / Google for figuring this out.
// So we temporarily spoof the minification filter, call glGenerateMipmap,
// and restore it. If that turned out to not be enough, we would have to avoid calling glGenerateMipmap altogether and
// emulate it.
if (tex->DoesMinFilterRequireMipmap()) {
gl->fGenerateMipmap(target);
} else {
// spoof the min filter as something that requires a mipmap. The particular choice of a filter doesn't matter as
// we're not rendering anything here. Since LINEAR_MIPMAP_LINEAR is by far the most common use case, and we're trying
// to work around a bug triggered by "unexpected" min filters, it seems to be the safest choice.
gl->fTexParameteri(target, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR_MIPMAP_LINEAR);
gl->fGenerateMipmap(target);
gl->fTexParameteri(target, LOCAL_GL_TEXTURE_MIN_FILTER, tex->MinFilter());
}
#else
gl->fGenerateMipmap(target);
#endif
return NS_OK;
}

Просмотреть файл

@ -63,10 +63,11 @@ DEFINE_OLEGUID(IID_IPersistFile, 0x0000010BL, 0, 0);
#include <sys/stat.h>
typedef PIDLIST_ABSOLUTE (*ILCreateFromPathWPtr)(PCWSTR);
typedef void (*ILFreePtr)(PIDLIST_RELATIVE);
typedef HRESULT (*SHOpenFolderAndSelectItemsPtr)(PCIDLIST_ABSOLUTE, UINT,
PCUITEMID_CHILD_ARRAY, DWORD);
typedef LPITEMIDLIST (WINAPI *ILCreateFromPathWPtr)(PCWSTR);
typedef void (WINAPI *ILFreePtr)(LPITEMIDLIST);
typedef HRESULT (WINAPI *SHOpenFolderAndSelectItemsPtr)(LPCITEMIDLIST, UINT,
PCUITEMID_CHILD_ARRAY,
DWORD);
class nsLocalFile : public nsILocalFileWin,
public nsIHashable