2012-10-04 20:35:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2012-12-04 00:13:47 +00:00
|
|
|
#include "WebGLTexture.h"
|
2014-04-30 21:30:21 +00:00
|
|
|
|
2013-09-04 12:14:52 +00:00
|
|
|
#include "GLContext.h"
|
2014-04-30 21:30:21 +00:00
|
|
|
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
|
|
|
#include "mozilla/Scoped.h"
|
2013-11-26 03:25:25 +00:00
|
|
|
#include "ScopedGLHelpers.h"
|
2014-04-30 21:30:21 +00:00
|
|
|
#include "WebGLContext.h"
|
2014-05-02 03:15:58 +00:00
|
|
|
#include "WebGLContextUtils.h"
|
2013-10-11 13:16:43 +00:00
|
|
|
#include "WebGLTexelConversions.h"
|
2014-04-30 21:30:21 +00:00
|
|
|
|
2013-01-15 12:22:03 +00:00
|
|
|
#include <algorithm>
|
2014-10-16 20:07:01 +00:00
|
|
|
#include "mozilla/MathAlgorithms.h"
|
2012-10-04 20:35:54 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
|
|
|
|
JSObject*
|
2014-11-14 05:51:22 +00:00
|
|
|
WebGLTexture::WrapObject(JSContext *cx) {
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return dom::WebGLTextureBinding::Wrap(cx, this);
|
2012-10-04 20:35:54 +00:00
|
|
|
}
|
|
|
|
|
2014-11-14 05:51:22 +00:00
|
|
|
WebGLTexture::WebGLTexture(WebGLContext *context)
|
|
|
|
: WebGLBindableName<TexTarget>()
|
2014-05-07 03:11:18 +00:00
|
|
|
, WebGLContextBoundObject(context)
|
2012-12-04 00:13:47 +00:00
|
|
|
, mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR)
|
|
|
|
, mMagFilter(LOCAL_GL_LINEAR)
|
|
|
|
, mWrapS(LOCAL_GL_REPEAT)
|
|
|
|
, mWrapT(LOCAL_GL_REPEAT)
|
|
|
|
, mFacesCount(0)
|
|
|
|
, mMaxLevelWithCustomImages(0)
|
|
|
|
, mHaveGeneratedMipmap(false)
|
2014-07-14 23:55:56 +00:00
|
|
|
, mImmutable(false)
|
2014-10-16 20:07:01 +00:00
|
|
|
, mBaseMipmapLevel(0)
|
|
|
|
, mMaxMipmapLevel(1000)
|
2013-10-11 13:16:43 +00:00
|
|
|
, mFakeBlackStatus(WebGLTextureFakeBlackStatus::IncompleteTexture)
|
2012-12-04 00:13:47 +00:00
|
|
|
{
|
2014-11-14 05:51:22 +00:00
|
|
|
mContext->MakeContextCurrent();
|
|
|
|
mContext->gl->fGenTextures(1, &mGLName);
|
2012-12-04 00:13:47 +00:00
|
|
|
mContext->mTextures.insertBack(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WebGLTexture::Delete() {
|
|
|
|
mImageInfos.Clear();
|
|
|
|
mContext->MakeContextCurrent();
|
|
|
|
mContext->gl->fDeleteTextures(1, &mGLName);
|
|
|
|
LinkedListElement<WebGLTexture>::removeFrom(mContext->mTextures);
|
|
|
|
}
|
|
|
|
|
2014-10-13 23:42:20 +00:00
|
|
|
size_t
|
2012-12-04 00:13:47 +00:00
|
|
|
WebGLTexture::ImageInfo::MemoryUsage() const {
|
2013-10-11 13:16:43 +00:00
|
|
|
if (mImageDataStatus == WebGLImageDataStatus::NoImageData)
|
2012-12-04 00:13:47 +00:00
|
|
|
return 0;
|
2014-10-13 23:42:20 +00:00
|
|
|
size_t bitsPerTexel = GetBitsPerTexel(mEffectiveInternalFormat);
|
|
|
|
return size_t(mWidth) * size_t(mHeight) * size_t(mDepth) * bitsPerTexel / 8;
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
|
2014-10-13 23:42:20 +00:00
|
|
|
size_t
|
2012-12-04 00:13:47 +00:00
|
|
|
WebGLTexture::MemoryUsage() const {
|
|
|
|
if (IsDeleted())
|
|
|
|
return 0;
|
2014-10-13 23:42:20 +00:00
|
|
|
size_t result = 0;
|
2012-12-04 00:13:47 +00:00
|
|
|
for(size_t face = 0; face < mFacesCount; face++) {
|
2014-10-16 20:04:35 +00:00
|
|
|
for(size_t level = 0; level <= mMaxLevelWithCustomImages; level++)
|
|
|
|
result += ImageInfoAtFace(face, level).MemoryUsage();
|
|
|
|
}
|
2012-12-04 00:13:47 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-10-16 20:07:01 +00:00
|
|
|
static inline size_t
|
|
|
|
MipmapLevelsForSize(const WebGLTexture::ImageInfo &info)
|
|
|
|
{
|
|
|
|
GLsizei size = std::max(std::max(info.Width(), info.Height()), info.Depth());
|
|
|
|
|
|
|
|
// Find floor(log2(size)). (ES 3.0.4, 3.8 - Mipmapping).
|
|
|
|
return mozilla::FloorLog2(size);
|
|
|
|
}
|
|
|
|
|
2012-12-04 00:13:47 +00:00
|
|
|
bool
|
2014-10-13 23:42:20 +00:00
|
|
|
WebGLTexture::DoesMipmapHaveAllLevelsConsistentlyDefined(TexImageTarget texImageTarget) const
|
|
|
|
{
|
2014-10-16 20:07:01 +00:00
|
|
|
// We could not have generated a mipmap if the base image wasn't defined.
|
2012-12-04 00:13:47 +00:00
|
|
|
if (mHaveGeneratedMipmap)
|
|
|
|
return true;
|
|
|
|
|
2014-10-16 20:07:01 +00:00
|
|
|
if (!IsMipmapRangeValid())
|
|
|
|
return false;
|
|
|
|
|
2013-10-02 00:30:38 +00:00
|
|
|
// We want a copy here so we can modify it temporarily.
|
2014-10-16 20:07:01 +00:00
|
|
|
ImageInfo expected = ImageInfoAt(texImageTarget, EffectiveBaseMipmapLevel());
|
|
|
|
if (!expected.IsPositive())
|
|
|
|
return false;
|
2012-12-04 00:13:47 +00:00
|
|
|
|
2014-10-16 20:07:01 +00:00
|
|
|
// If Level{max} is > mMaxLevelWithCustomImages, then check if we are
|
|
|
|
// missing any image levels.
|
|
|
|
if (mMaxMipmapLevel > mMaxLevelWithCustomImages) {
|
|
|
|
if (MipmapLevelsForSize(expected) > mMaxLevelWithCustomImages)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checks if custom images are all defined up to the highest level and
|
|
|
|
// have the expected dimensions.
|
|
|
|
for (size_t level = EffectiveBaseMipmapLevel(); level <= EffectiveMaxMipmapLevel(); ++level) {
|
2013-10-02 00:30:38 +00:00
|
|
|
const ImageInfo& actual = ImageInfoAt(texImageTarget, level);
|
2012-12-04 00:13:47 +00:00
|
|
|
if (actual != expected)
|
|
|
|
return false;
|
2014-10-16 20:07:01 +00:00
|
|
|
|
2014-10-13 23:42:20 +00:00
|
|
|
expected.mWidth = std::max(1, expected.mWidth / 2);
|
|
|
|
expected.mHeight = std::max(1, expected.mHeight / 2);
|
|
|
|
expected.mDepth = std::max(1, expected.mDepth / 2);
|
2012-12-04 00:13:47 +00:00
|
|
|
|
|
|
|
// if the current level has size 1x1, we can stop here: the spec doesn't seem to forbid the existence
|
|
|
|
// of extra useless levels.
|
2014-10-13 23:42:20 +00:00
|
|
|
if (actual.mWidth == 1 &&
|
|
|
|
actual.mHeight == 1 &&
|
|
|
|
actual.mDepth == 1)
|
|
|
|
{
|
2012-12-04 00:13:47 +00:00
|
|
|
return true;
|
2014-10-13 23:42:20 +00:00
|
|
|
}
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
|
2014-10-16 20:07:01 +00:00
|
|
|
return true;
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-18 23:14:22 +00:00
|
|
|
WebGLTexture::Bind(TexTarget aTexTarget) {
|
2012-12-04 00:13:47 +00:00
|
|
|
// this function should only be called by bindTexture().
|
|
|
|
// it assumes that the GL context is already current.
|
|
|
|
|
2014-05-07 03:11:18 +00:00
|
|
|
bool firstTimeThisTextureIsBound = !HasEverBeenBound();
|
2012-12-04 00:13:47 +00:00
|
|
|
|
2014-05-07 03:11:18 +00:00
|
|
|
if (firstTimeThisTextureIsBound) {
|
2014-09-18 23:14:22 +00:00
|
|
|
BindTo(aTexTarget);
|
|
|
|
} else if (aTexTarget != Target()) {
|
2012-12-04 00:13:47 +00:00
|
|
|
mContext->ErrorInvalidOperation("bindTexture: this texture has already been bound to a different target");
|
|
|
|
// very important to return here before modifying texture state! This was the place when I lost a whole day figuring
|
|
|
|
// very strange 'invalid write' crashes.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-07 03:11:18 +00:00
|
|
|
GLuint name = GLName();
|
2012-12-04 00:13:47 +00:00
|
|
|
|
2014-09-18 23:14:22 +00:00
|
|
|
mContext->gl->fBindTexture(aTexTarget.get(), name);
|
2012-12-04 00:13:47 +00:00
|
|
|
|
|
|
|
if (firstTimeThisTextureIsBound) {
|
2014-10-13 23:42:20 +00:00
|
|
|
mFacesCount = (aTexTarget == LOCAL_GL_TEXTURE_CUBE_MAP) ? 6 : 1;
|
2012-12-04 00:13:47 +00:00
|
|
|
EnsureMaxLevelWithCustomImagesAtLeast(0);
|
2013-10-11 13:16:43 +00:00
|
|
|
SetFakeBlackStatus(WebGLTextureFakeBlackStatus::Unknown);
|
2012-12-04 00:13:47 +00:00
|
|
|
|
|
|
|
// thanks to the WebKit people for finding this out: GL_TEXTURE_WRAP_R is not
|
|
|
|
// present in GLES 2, but is present in GL and it seems as if for cube maps
|
|
|
|
// we need to set it to GL_CLAMP_TO_EDGE to get the expected GLES behavior.
|
2014-03-31 09:10:49 +00:00
|
|
|
if (mTarget == LOCAL_GL_TEXTURE_CUBE_MAP && !mContext->gl->IsGLES())
|
2014-09-18 23:14:22 +00:00
|
|
|
mContext->gl->fTexParameteri(aTexTarget.get(), LOCAL_GL_TEXTURE_WRAP_R, LOCAL_GL_CLAMP_TO_EDGE);
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-18 23:14:22 +00:00
|
|
|
WebGLTexture::SetImageInfo(TexImageTarget aTexImageTarget, GLint aLevel,
|
2014-10-13 23:42:20 +00:00
|
|
|
GLsizei aWidth, GLsizei aHeight, GLsizei aDepth,
|
2014-10-07 23:52:58 +00:00
|
|
|
TexInternalFormat aEffectiveInternalFormat, WebGLImageDataStatus aStatus)
|
2012-12-04 00:13:47 +00:00
|
|
|
{
|
2014-10-13 23:42:20 +00:00
|
|
|
MOZ_ASSERT(aDepth == 1 || aTexImageTarget == LOCAL_GL_TEXTURE_3D);
|
2014-09-03 19:17:18 +00:00
|
|
|
MOZ_ASSERT(TexImageTargetToTexTarget(aTexImageTarget) == mTarget);
|
2012-12-04 00:13:47 +00:00
|
|
|
|
|
|
|
EnsureMaxLevelWithCustomImagesAtLeast(aLevel);
|
|
|
|
|
2014-10-13 23:42:20 +00:00
|
|
|
ImageInfoAt(aTexImageTarget, aLevel) = ImageInfo(aWidth, aHeight, aDepth, aEffectiveInternalFormat, aStatus);
|
2012-12-04 00:13:47 +00:00
|
|
|
|
|
|
|
if (aLevel > 0)
|
|
|
|
SetCustomMipmap();
|
|
|
|
|
2014-03-04 07:14:35 +00:00
|
|
|
// Invalidate framebuffer status cache
|
|
|
|
NotifyFBsStatusChanged();
|
|
|
|
|
2013-10-11 13:16:43 +00:00
|
|
|
SetFakeBlackStatus(WebGLTextureFakeBlackStatus::Unknown);
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WebGLTexture::SetGeneratedMipmap() {
|
|
|
|
if (!mHaveGeneratedMipmap) {
|
|
|
|
mHaveGeneratedMipmap = true;
|
2013-10-11 13:16:43 +00:00
|
|
|
SetFakeBlackStatus(WebGLTextureFakeBlackStatus::Unknown);
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WebGLTexture::SetCustomMipmap() {
|
|
|
|
if (mHaveGeneratedMipmap) {
|
2014-10-16 20:07:01 +00:00
|
|
|
if (!IsMipmapRangeValid())
|
|
|
|
return;
|
2012-12-04 00:13:47 +00:00
|
|
|
|
2014-10-16 20:07:01 +00:00
|
|
|
// If we were in GeneratedMipmap mode and are now switching to CustomMipmap mode,
|
|
|
|
// we now need to compute all the mipmap image info.
|
|
|
|
ImageInfo imageInfo = ImageInfoAtFace(0, EffectiveBaseMipmapLevel());
|
2014-10-15 02:10:15 +00:00
|
|
|
NS_ASSERTION(mContext->IsWebGL2() || imageInfo.IsPowerOfTwo(),
|
|
|
|
"this texture is NPOT, so how could GenerateMipmap() ever accept it?");
|
2012-12-04 00:13:47 +00:00
|
|
|
|
2014-10-16 20:07:01 +00:00
|
|
|
size_t maxLevel = MipmapLevelsForSize(imageInfo);
|
|
|
|
EnsureMaxLevelWithCustomImagesAtLeast(EffectiveBaseMipmapLevel() + maxLevel);
|
2012-12-04 00:13:47 +00:00
|
|
|
|
2014-10-16 20:07:01 +00:00
|
|
|
for (size_t level = EffectiveBaseMipmapLevel() + 1; level <= EffectiveMaxMipmapLevel(); ++level) {
|
2014-10-13 23:42:20 +00:00
|
|
|
imageInfo.mWidth = std::max(imageInfo.mWidth / 2, 1);
|
|
|
|
imageInfo.mHeight = std::max(imageInfo.mHeight / 2, 1);
|
|
|
|
imageInfo.mDepth = std::max(imageInfo.mDepth / 2, 1);
|
2012-12-04 00:13:47 +00:00
|
|
|
for(size_t face = 0; face < mFacesCount; ++face)
|
2013-10-02 00:30:38 +00:00
|
|
|
ImageInfoAtFace(face, level) = imageInfo;
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
mHaveGeneratedMipmap = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
WebGLTexture::AreAllLevel0ImageInfosEqual() const {
|
|
|
|
for (size_t face = 1; face < mFacesCount; ++face) {
|
2013-10-02 00:30:38 +00:00
|
|
|
if (ImageInfoAtFace(face, 0) != ImageInfoAtFace(0, 0))
|
2012-12-04 00:13:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-10-13 23:42:20 +00:00
|
|
|
WebGLTexture::IsMipmapComplete() const {
|
|
|
|
MOZ_ASSERT(mTarget == LOCAL_GL_TEXTURE_2D ||
|
|
|
|
mTarget == LOCAL_GL_TEXTURE_3D);
|
|
|
|
return DoesMipmapHaveAllLevelsConsistentlyDefined(LOCAL_GL_TEXTURE_2D);
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
WebGLTexture::IsCubeComplete() const {
|
2014-10-13 23:42:20 +00:00
|
|
|
MOZ_ASSERT(mTarget == LOCAL_GL_TEXTURE_CUBE_MAP);
|
|
|
|
|
2013-10-02 00:30:38 +00:00
|
|
|
const ImageInfo &first = ImageInfoAt(LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
|
2012-12-04 00:13:47 +00:00
|
|
|
if (!first.IsPositive() || !first.IsSquare())
|
|
|
|
return false;
|
|
|
|
return AreAllLevel0ImageInfosEqual();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
WebGLTexture::IsMipmapCubeComplete() const {
|
|
|
|
if (!IsCubeComplete()) // in particular, this checks that this is a cube map
|
|
|
|
return false;
|
2013-10-02 00:30:38 +00:00
|
|
|
for (int i = 0; i < 6; i++) {
|
2014-07-14 23:55:56 +00:00
|
|
|
const TexImageTarget face = TexImageTargetForTargetAndFace(LOCAL_GL_TEXTURE_CUBE_MAP, i);
|
2014-10-13 23:42:20 +00:00
|
|
|
if (!DoesMipmapHaveAllLevelsConsistentlyDefined(face))
|
2012-12-04 00:13:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-16 20:07:01 +00:00
|
|
|
bool
|
|
|
|
WebGLTexture::IsMipmapRangeValid() const
|
|
|
|
{
|
|
|
|
// In ES3, if a texture is immutable, the mipmap levels are clamped.
|
|
|
|
if (IsImmutable())
|
|
|
|
return true;
|
|
|
|
if (mBaseMipmapLevel > std::min(mMaxLevelWithCustomImages, mMaxMipmapLevel))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-11 13:16:43 +00:00
|
|
|
WebGLTextureFakeBlackStatus
|
|
|
|
WebGLTexture::ResolvedFakeBlackStatus() {
|
|
|
|
if (MOZ_LIKELY(mFakeBlackStatus != WebGLTextureFakeBlackStatus::Unknown)) {
|
|
|
|
return mFakeBlackStatus;
|
|
|
|
}
|
2012-12-04 00:13:47 +00:00
|
|
|
|
2013-10-11 13:16:43 +00:00
|
|
|
// Determine if the texture needs to be faked as a black texture.
|
2014-10-16 20:07:01 +00:00
|
|
|
// See 3.8.2 Shader Execution in the OpenGL ES 2.0.24 spec, and 3.8.13 in
|
|
|
|
// the OpenGL ES 3.0.4 spec.
|
|
|
|
if (!IsMipmapRangeValid()) {
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
|
|
|
return mFakeBlackStatus;
|
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
for (size_t face = 0; face < mFacesCount; ++face) {
|
2014-10-16 20:07:01 +00:00
|
|
|
if (ImageInfoAtFace(face, EffectiveBaseMipmapLevel()).mImageDataStatus == WebGLImageDataStatus::NoImageData) {
|
2013-10-11 13:16:43 +00:00
|
|
|
// In case of undefined texture image, we don't print any message because this is a very common
|
|
|
|
// and often legitimate case (asynchronous texture loading).
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
|
|
|
return mFakeBlackStatus;
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
}
|
2012-12-04 00:13:47 +00:00
|
|
|
|
2013-10-11 13:16:43 +00:00
|
|
|
const char *msg_rendering_as_black
|
|
|
|
= "A texture is going to be rendered as if it were black, as per the OpenGL ES 2.0.24 spec section 3.8.2, "
|
|
|
|
"because it";
|
2012-12-04 00:13:47 +00:00
|
|
|
|
2014-10-13 23:42:20 +00:00
|
|
|
if (mTarget == LOCAL_GL_TEXTURE_2D ||
|
|
|
|
mTarget == LOCAL_GL_TEXTURE_3D)
|
2013-10-11 13:16:43 +00:00
|
|
|
{
|
2014-10-13 23:42:20 +00:00
|
|
|
int dim = mTarget == LOCAL_GL_TEXTURE_2D ? 2 : 3;
|
2013-10-11 13:16:43 +00:00
|
|
|
if (DoesMinFilterRequireMipmap())
|
2012-12-04 00:13:47 +00:00
|
|
|
{
|
2014-10-13 23:42:20 +00:00
|
|
|
if (!IsMipmapComplete()) {
|
2013-10-11 13:16:43 +00:00
|
|
|
mContext->GenerateWarning
|
2014-10-13 23:42:20 +00:00
|
|
|
("%s is a %dD texture, with a minification filter requiring a mipmap, "
|
|
|
|
"and is not mipmap complete (as defined in section 3.7.10).", msg_rendering_as_black, dim);
|
2013-10-11 13:16:43 +00:00
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
2014-10-15 02:10:15 +00:00
|
|
|
} else if (!mContext->IsWebGL2() && !ImageInfoBase().IsPowerOfTwo()) {
|
2013-10-11 13:16:43 +00:00
|
|
|
mContext->GenerateWarning
|
2014-10-13 23:42:20 +00:00
|
|
|
("%s is a %dD texture, with a minification filter requiring a mipmap, "
|
2013-10-11 13:16:43 +00:00
|
|
|
"and either its width or height is not a power of two.", msg_rendering_as_black);
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
else // no mipmap required
|
2012-12-04 00:13:47 +00:00
|
|
|
{
|
2014-09-18 23:14:22 +00:00
|
|
|
if (!ImageInfoBase().IsPositive()) {
|
2013-10-11 13:16:43 +00:00
|
|
|
mContext->GenerateWarning
|
2014-10-13 23:42:20 +00:00
|
|
|
("%s is a %dD texture and its width or height is equal to zero.",
|
|
|
|
msg_rendering_as_black, dim);
|
2013-10-11 13:16:43 +00:00
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
2014-10-15 02:10:15 +00:00
|
|
|
} else if (!AreBothWrapModesClampToEdge() && !mContext->IsWebGL2() && !ImageInfoBase().IsPowerOfTwo()) {
|
2013-10-11 13:16:43 +00:00
|
|
|
mContext->GenerateWarning
|
2014-10-13 23:42:20 +00:00
|
|
|
("%s is a %dD texture, with a minification filter not requiring a mipmap, "
|
2013-10-11 13:16:43 +00:00
|
|
|
"with its width or height not a power of two, and with a wrap mode "
|
2014-10-13 23:42:20 +00:00
|
|
|
"different from CLAMP_TO_EDGE.", msg_rendering_as_black, dim);
|
2013-10-11 13:16:43 +00:00
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
}
|
|
|
|
else // cube map
|
|
|
|
{
|
2014-10-15 02:10:15 +00:00
|
|
|
bool legalImageSize = true;
|
|
|
|
if (!mContext->IsWebGL2()) {
|
|
|
|
for (size_t face = 0; face < mFacesCount; ++face)
|
|
|
|
legalImageSize &= ImageInfoAtFace(face, 0).IsPowerOfTwo();
|
|
|
|
}
|
2012-12-04 00:13:47 +00:00
|
|
|
|
2013-10-11 13:16:43 +00:00
|
|
|
if (DoesMinFilterRequireMipmap())
|
2013-06-10 20:00:46 +00:00
|
|
|
{
|
2013-10-11 13:16:43 +00:00
|
|
|
if (!IsMipmapCubeComplete()) {
|
|
|
|
mContext->GenerateWarning("%s is a cube map texture, with a minification filter requiring a mipmap, "
|
|
|
|
"and is not mipmap cube complete (as defined in section 3.7.10).",
|
|
|
|
msg_rendering_as_black);
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
2014-10-15 02:10:15 +00:00
|
|
|
} else if (!legalImageSize) {
|
2013-10-11 13:16:43 +00:00
|
|
|
mContext->GenerateWarning("%s is a cube map texture, with a minification filter requiring a mipmap, "
|
|
|
|
"and either the width or the height of some level 0 image is not a power of two.",
|
|
|
|
msg_rendering_as_black);
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
2013-06-10 20:00:46 +00:00
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
}
|
|
|
|
else // no mipmap required
|
|
|
|
{
|
|
|
|
if (!IsCubeComplete()) {
|
|
|
|
mContext->GenerateWarning("%s is a cube map texture, with a minification filter not requiring a mipmap, "
|
|
|
|
"and is not cube complete (as defined in section 3.7.10).",
|
|
|
|
msg_rendering_as_black);
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
2014-10-15 02:10:15 +00:00
|
|
|
} else if (!AreBothWrapModesClampToEdge() && !legalImageSize) {
|
2013-10-11 13:16:43 +00:00
|
|
|
mContext->GenerateWarning("%s is a cube map texture, with a minification filter not requiring a mipmap, "
|
|
|
|
"with some level 0 image having width or height not a power of two, and with a wrap mode "
|
|
|
|
"different from CLAMP_TO_EDGE.", msg_rendering_as_black);
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
2013-06-10 20:00:46 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
}
|
|
|
|
|
2014-10-07 23:52:58 +00:00
|
|
|
TexType type = TypeFromInternalFormat(ImageInfoBase().mEffectiveInternalFormat);
|
|
|
|
|
|
|
|
if (type == LOCAL_GL_FLOAT &&
|
2014-04-26 02:34:07 +00:00
|
|
|
!Context()->IsExtensionEnabled(WebGLExtensionID::OES_texture_float_linear))
|
2013-10-11 13:16:43 +00:00
|
|
|
{
|
|
|
|
if (mMinFilter == LOCAL_GL_LINEAR ||
|
|
|
|
mMinFilter == LOCAL_GL_LINEAR_MIPMAP_LINEAR ||
|
|
|
|
mMinFilter == LOCAL_GL_LINEAR_MIPMAP_NEAREST ||
|
|
|
|
mMinFilter == LOCAL_GL_NEAREST_MIPMAP_LINEAR)
|
|
|
|
{
|
|
|
|
mContext->GenerateWarning("%s is a texture with a linear minification filter, "
|
|
|
|
"which is not compatible with gl.FLOAT by default. "
|
|
|
|
"Try enabling the OES_texture_float_linear extension if supported.", msg_rendering_as_black);
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
|
|
|
}
|
|
|
|
else if (mMagFilter == LOCAL_GL_LINEAR)
|
|
|
|
{
|
|
|
|
mContext->GenerateWarning("%s is a texture with a linear magnification filter, "
|
|
|
|
"which is not compatible with gl.FLOAT by default. "
|
|
|
|
"Try enabling the OES_texture_float_linear extension if supported.", msg_rendering_as_black);
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
|
|
|
}
|
2014-10-07 23:52:58 +00:00
|
|
|
} else if (type == LOCAL_GL_HALF_FLOAT &&
|
2014-04-26 02:34:07 +00:00
|
|
|
!Context()->IsExtensionEnabled(WebGLExtensionID::OES_texture_half_float_linear))
|
2014-01-23 21:47:37 +00:00
|
|
|
{
|
|
|
|
if (mMinFilter == LOCAL_GL_LINEAR ||
|
|
|
|
mMinFilter == LOCAL_GL_LINEAR_MIPMAP_LINEAR ||
|
|
|
|
mMinFilter == LOCAL_GL_LINEAR_MIPMAP_NEAREST ||
|
|
|
|
mMinFilter == LOCAL_GL_NEAREST_MIPMAP_LINEAR)
|
|
|
|
{
|
|
|
|
mContext->GenerateWarning("%s is a texture with a linear minification filter, "
|
|
|
|
"which is not compatible with gl.HALF_FLOAT by default. "
|
|
|
|
"Try enabling the OES_texture_half_float_linear extension if supported.", msg_rendering_as_black);
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
|
|
|
}
|
|
|
|
else if (mMagFilter == LOCAL_GL_LINEAR)
|
|
|
|
{
|
|
|
|
mContext->GenerateWarning("%s is a texture with a linear magnification filter, "
|
|
|
|
"which is not compatible with gl.HALF_FLOAT by default. "
|
|
|
|
"Try enabling the OES_texture_half_float_linear extension if supported.", msg_rendering_as_black);
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
|
|
|
|
}
|
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
|
|
|
|
// We have exhausted all cases of incomplete textures, where we would need opaque black.
|
|
|
|
// We may still need transparent black in case of uninitialized image data.
|
|
|
|
bool hasUninitializedImageData = false;
|
|
|
|
for (size_t level = 0; level <= mMaxLevelWithCustomImages; ++level) {
|
|
|
|
for (size_t face = 0; face < mFacesCount; ++face) {
|
|
|
|
hasUninitializedImageData |= (ImageInfoAtFace(face, level).mImageDataStatus == WebGLImageDataStatus::UninitializedImageData);
|
|
|
|
}
|
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
|
2013-10-11 13:16:43 +00:00
|
|
|
if (hasUninitializedImageData) {
|
2013-10-11 13:16:43 +00:00
|
|
|
bool hasAnyInitializedImageData = false;
|
|
|
|
for (size_t level = 0; level <= mMaxLevelWithCustomImages; ++level) {
|
|
|
|
for (size_t face = 0; face < mFacesCount; ++face) {
|
|
|
|
if (ImageInfoAtFace(face, level).mImageDataStatus == WebGLImageDataStatus::InitializedImageData) {
|
|
|
|
hasAnyInitializedImageData = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hasAnyInitializedImageData) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasAnyInitializedImageData) {
|
|
|
|
// The texture contains some initialized image data, and some uninitialized image data.
|
|
|
|
// In this case, we have no choice but to initialize all image data now. Fortunately,
|
|
|
|
// in this case we know that we can't be dealing with a depth texture per WEBGL_depth_texture
|
|
|
|
// and ANGLE_depth_texture (which allow only one image per texture) so we can assume that
|
|
|
|
// glTexImage2D is able to upload data to images.
|
|
|
|
for (size_t level = 0; level <= mMaxLevelWithCustomImages; ++level) {
|
|
|
|
for (size_t face = 0; face < mFacesCount; ++face) {
|
2014-07-14 23:55:56 +00:00
|
|
|
TexImageTarget imageTarget = TexImageTargetForTargetAndFace(mTarget, face);
|
2013-10-11 13:16:43 +00:00
|
|
|
const ImageInfo& imageInfo = ImageInfoAt(imageTarget, level);
|
|
|
|
if (imageInfo.mImageDataStatus == WebGLImageDataStatus::UninitializedImageData) {
|
2014-10-15 02:10:15 +00:00
|
|
|
EnsureNoUninitializedImageData(imageTarget, level);
|
2013-10-11 13:16:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::NotNeeded;
|
|
|
|
} else {
|
|
|
|
// The texture only contains uninitialized image data. In this case,
|
|
|
|
// we can use a black texture for it.
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::UninitializedImageData;
|
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
}
|
2013-06-10 20:00:46 +00:00
|
|
|
|
2013-10-11 13:16:43 +00:00
|
|
|
// we have exhausted all cases where we do need fakeblack, so if the status is still unknown,
|
|
|
|
// that means that we do NOT need it.
|
|
|
|
if (mFakeBlackStatus == WebGLTextureFakeBlackStatus::Unknown) {
|
|
|
|
mFakeBlackStatus = WebGLTextureFakeBlackStatus::NotNeeded;
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 13:16:43 +00:00
|
|
|
MOZ_ASSERT(mFakeBlackStatus != WebGLTextureFakeBlackStatus::Unknown);
|
|
|
|
return mFakeBlackStatus;
|
2012-12-04 00:13:47 +00:00
|
|
|
}
|
|
|
|
|
2014-04-30 21:30:21 +00:00
|
|
|
|
|
|
|
static bool
|
|
|
|
ClearByMask(WebGLContext* context, GLbitfield mask)
|
|
|
|
{
|
|
|
|
gl::GLContext* gl = context->GL();
|
|
|
|
MOZ_ASSERT(gl->IsCurrent());
|
|
|
|
|
|
|
|
GLenum status = gl->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
|
|
|
if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE)
|
|
|
|
return false;
|
|
|
|
|
2014-04-30 21:30:23 +00:00
|
|
|
bool colorAttachmentsMask[WebGLContext::kMaxColorAttachments] = {false};
|
2014-04-30 21:30:21 +00:00
|
|
|
if (mask & LOCAL_GL_COLOR_BUFFER_BIT) {
|
|
|
|
colorAttachmentsMask[0] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
context->ForceClearFramebufferWithDefaultValues(mask, colorAttachmentsMask);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// `mask` from glClear.
|
|
|
|
static bool
|
|
|
|
ClearWithTempFB(WebGLContext* context, GLuint tex,
|
2014-09-18 23:14:22 +00:00
|
|
|
TexImageTarget texImageTarget, GLint level,
|
2014-09-23 17:48:27 +00:00
|
|
|
TexInternalFormat baseInternalFormat,
|
2014-04-30 21:30:21 +00:00
|
|
|
GLsizei width, GLsizei height)
|
|
|
|
{
|
2014-10-13 23:42:20 +00:00
|
|
|
MOZ_ASSERT(texImageTarget == LOCAL_GL_TEXTURE_2D);
|
2014-04-30 21:30:21 +00:00
|
|
|
|
|
|
|
gl::GLContext* gl = context->GL();
|
|
|
|
MOZ_ASSERT(gl->IsCurrent());
|
|
|
|
|
|
|
|
gl::ScopedFramebuffer fb(gl);
|
|
|
|
gl::ScopedBindFramebuffer autoFB(gl, fb.FB());
|
|
|
|
GLbitfield mask = 0;
|
|
|
|
|
2014-09-23 17:48:27 +00:00
|
|
|
switch (baseInternalFormat.get()) {
|
2014-04-30 21:30:21 +00:00
|
|
|
case LOCAL_GL_LUMINANCE:
|
|
|
|
case LOCAL_GL_LUMINANCE_ALPHA:
|
|
|
|
case LOCAL_GL_ALPHA:
|
|
|
|
case LOCAL_GL_RGB:
|
|
|
|
case LOCAL_GL_RGBA:
|
|
|
|
case LOCAL_GL_BGR:
|
|
|
|
case LOCAL_GL_BGRA:
|
|
|
|
mask = LOCAL_GL_COLOR_BUFFER_BIT;
|
|
|
|
gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0,
|
2014-09-18 23:14:22 +00:00
|
|
|
texImageTarget.get(), tex, level);
|
2014-04-30 21:30:21 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_DEPTH_COMPONENT:
|
|
|
|
mask = LOCAL_GL_DEPTH_BUFFER_BIT;
|
|
|
|
gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_DEPTH_ATTACHMENT,
|
2014-09-18 23:14:22 +00:00
|
|
|
texImageTarget.get(), tex, level);
|
2014-04-30 21:30:21 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_DEPTH_STENCIL:
|
|
|
|
mask = LOCAL_GL_DEPTH_BUFFER_BIT |
|
|
|
|
LOCAL_GL_STENCIL_BUFFER_BIT;
|
|
|
|
gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_DEPTH_ATTACHMENT,
|
2014-09-18 23:14:22 +00:00
|
|
|
texImageTarget.get(), tex, level);
|
2014-04-30 21:30:21 +00:00
|
|
|
gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_STENCIL_ATTACHMENT,
|
2014-09-18 23:14:22 +00:00
|
|
|
texImageTarget.get(), tex, level);
|
2014-04-30 21:30:21 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mask);
|
|
|
|
|
|
|
|
if (ClearByMask(context, mask))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Failed to simply build an FB from the tex, but maybe it needs a
|
|
|
|
// color buffer to be complete.
|
|
|
|
|
|
|
|
if (mask & LOCAL_GL_COLOR_BUFFER_BIT) {
|
|
|
|
// Nope, it already had one.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
gl::ScopedRenderbuffer rb(gl);
|
|
|
|
{
|
|
|
|
gl::ScopedBindRenderbuffer(gl, rb.RB());
|
|
|
|
gl->fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
|
|
|
LOCAL_GL_RGBA4,
|
|
|
|
width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
gl->fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0,
|
|
|
|
LOCAL_GL_RENDERBUFFER, rb.RB());
|
|
|
|
mask |= LOCAL_GL_COLOR_BUFFER_BIT;
|
|
|
|
|
|
|
|
// Last chance!
|
|
|
|
return ClearByMask(context, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-11 13:16:43 +00:00
|
|
|
void
|
2014-10-15 02:10:15 +00:00
|
|
|
WebGLTexture::EnsureNoUninitializedImageData(TexImageTarget imageTarget, GLint level)
|
2013-10-11 13:16:43 +00:00
|
|
|
{
|
|
|
|
const ImageInfo& imageInfo = ImageInfoAt(imageTarget, level);
|
2014-10-15 02:10:15 +00:00
|
|
|
if (!imageInfo.HasUninitializedImageData())
|
|
|
|
return;
|
2013-10-11 13:16:43 +00:00
|
|
|
|
|
|
|
mContext->MakeContextCurrent();
|
|
|
|
|
2014-04-30 21:30:21 +00:00
|
|
|
// Try to clear with glCLear.
|
|
|
|
|
2014-10-13 23:42:20 +00:00
|
|
|
if (imageTarget == LOCAL_GL_TEXTURE_2D) {
|
|
|
|
bool cleared = ClearWithTempFB(mContext, GLName(),
|
|
|
|
imageTarget, level,
|
|
|
|
imageInfo.mEffectiveInternalFormat,
|
|
|
|
imageInfo.mHeight, imageInfo.mWidth);
|
|
|
|
if (cleared) {
|
|
|
|
SetImageDataStatus(imageTarget, level, WebGLImageDataStatus::InitializedImageData);
|
|
|
|
return;
|
|
|
|
}
|
2014-04-30 21:30:28 +00:00
|
|
|
}
|
2014-04-30 21:30:21 +00:00
|
|
|
|
|
|
|
// That didn't work. Try uploading zeros then.
|
2014-09-18 23:14:22 +00:00
|
|
|
gl::ScopedBindTexture autoBindTex(mContext->gl, GLName(), mTarget.get());
|
2014-04-30 21:30:21 +00:00
|
|
|
|
2014-10-07 23:52:58 +00:00
|
|
|
size_t bitspertexel = GetBitsPerTexel(imageInfo.mEffectiveInternalFormat);
|
|
|
|
MOZ_ASSERT((bitspertexel % 8) == 0); // that would only happen for compressed images, which
|
|
|
|
// cannot use deferred initialization.
|
|
|
|
size_t bytespertexel = bitspertexel / 8;
|
2013-10-11 13:16:43 +00:00
|
|
|
CheckedUint32 checked_byteLength
|
|
|
|
= WebGLContext::GetImageSize(
|
|
|
|
imageInfo.mHeight,
|
|
|
|
imageInfo.mWidth,
|
2014-10-13 23:42:20 +00:00
|
|
|
imageInfo.mDepth,
|
2014-10-07 23:52:58 +00:00
|
|
|
bytespertexel,
|
2013-10-11 13:16:43 +00:00
|
|
|
mContext->mPixelStoreUnpackAlignment);
|
|
|
|
MOZ_ASSERT(checked_byteLength.isValid()); // should have been checked earlier
|
2014-10-16 03:11:30 +00:00
|
|
|
|
|
|
|
UniquePtr<uint8_t> zeros((uint8_t*)moz_xcalloc(1, checked_byteLength.value())); // Infallible for now.
|
2013-10-31 17:00:32 +00:00
|
|
|
|
2014-05-02 03:15:58 +00:00
|
|
|
gl::GLContext* gl = mContext->gl;
|
|
|
|
GLenum driverInternalFormat = LOCAL_GL_NONE;
|
|
|
|
GLenum driverFormat = LOCAL_GL_NONE;
|
2014-10-07 23:52:58 +00:00
|
|
|
GLenum driverType = LOCAL_GL_NONE;
|
|
|
|
DriverFormatsFromEffectiveInternalFormat(gl, imageInfo.mEffectiveInternalFormat,
|
|
|
|
&driverInternalFormat, &driverFormat, &driverType);
|
2014-05-02 03:15:58 +00:00
|
|
|
|
2014-03-07 21:16:34 +00:00
|
|
|
mContext->GetAndFlushUnderlyingGLErrors();
|
2014-10-13 23:42:20 +00:00
|
|
|
if (imageTarget == LOCAL_GL_TEXTURE_3D) {
|
|
|
|
MOZ_ASSERT(mImmutable, "Shouldn't be possible to have non-immutable-format 3D textures in WebGL");
|
|
|
|
gl->fTexSubImage3D(imageTarget.get(), level, 0, 0, 0,
|
|
|
|
imageInfo.mWidth, imageInfo.mHeight, imageInfo.mDepth,
|
|
|
|
driverFormat, driverType,
|
2014-10-16 03:11:30 +00:00
|
|
|
zeros.get());
|
2014-10-13 23:42:20 +00:00
|
|
|
} else {
|
|
|
|
if (mImmutable) {
|
|
|
|
gl->fTexSubImage2D(imageTarget.get(), level, 0, 0,
|
|
|
|
imageInfo.mWidth, imageInfo.mHeight,
|
|
|
|
driverFormat, driverType,
|
2014-10-16 03:11:30 +00:00
|
|
|
zeros.get());
|
2014-10-13 23:42:20 +00:00
|
|
|
} else {
|
|
|
|
gl->fTexImage2D(imageTarget.get(), level, driverInternalFormat,
|
|
|
|
imageInfo.mWidth, imageInfo.mHeight,
|
|
|
|
0, driverFormat, driverType,
|
2014-10-16 03:11:30 +00:00
|
|
|
zeros.get());
|
2014-10-13 23:42:20 +00:00
|
|
|
}
|
2014-10-09 20:07:07 +00:00
|
|
|
}
|
2014-03-07 21:16:34 +00:00
|
|
|
GLenum error = mContext->GetAndFlushUnderlyingGLErrors();
|
2014-04-30 21:30:21 +00:00
|
|
|
if (error) {
|
|
|
|
// Should only be OUT_OF_MEMORY. Anyway, there's no good way to recover from this here.
|
2014-04-30 21:30:23 +00:00
|
|
|
printf_stderr("Error: 0x%4x\n", error);
|
2014-04-30 21:30:21 +00:00
|
|
|
MOZ_CRASH(); // errors on texture upload have been related to video memory exposure in the past.
|
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
|
|
|
|
SetImageDataStatus(imageTarget, level, WebGLImageDataStatus::InitializedImageData);
|
2014-04-30 21:30:21 +00:00
|
|
|
}
|
2013-10-11 13:16:43 +00:00
|
|
|
|
2014-04-30 21:30:21 +00:00
|
|
|
void
|
|
|
|
WebGLTexture::SetFakeBlackStatus(WebGLTextureFakeBlackStatus x)
|
|
|
|
{
|
2014-04-30 21:30:28 +00:00
|
|
|
mFakeBlackStatus = x;
|
|
|
|
mContext->SetFakeBlackStatus(WebGLContextFakeBlackStatus::Unknown);
|
2013-10-11 13:16:43 +00:00
|
|
|
}
|
|
|
|
|
2012-10-04 20:35:54 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLTexture)
|
|
|
|
|
2013-08-29 15:39:17 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLTexture, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLTexture, Release)
|