2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-12-04 04:13:47 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#ifndef WEBGL_TEXTURE_H_
|
|
|
|
#define WEBGL_TEXTURE_H_
|
2012-12-04 04:13:47 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#include <algorithm>
|
2015-11-25 07:15:29 +03:00
|
|
|
#include <map>
|
2016-07-22 09:25:41 +03:00
|
|
|
#include <set>
|
|
|
|
#include <vector>
|
2015-07-15 03:37:28 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "mozilla/Assertions.h"
|
2019-04-02 20:00:41 +03:00
|
|
|
#include "mozilla/Casting.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "mozilla/CheckedInt.h"
|
2015-08-04 00:34:46 +03:00
|
|
|
#include "mozilla/dom/TypedArray.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
#include "CacheInvalidator.h"
|
2014-05-07 07:11:18 +04:00
|
|
|
#include "WebGLObjectModel.h"
|
2014-09-19 03:14:22 +04:00
|
|
|
#include "WebGLStrongTypes.h"
|
2016-07-22 09:25:41 +03:00
|
|
|
#include "WebGLTypes.h"
|
2012-12-04 04:13:47 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2015-08-04 00:34:46 +03:00
|
|
|
class ErrorResult;
|
2015-11-25 07:15:29 +03:00
|
|
|
class WebGLContext;
|
2018-10-17 07:18:15 +03:00
|
|
|
class WebGLFramebuffer;
|
|
|
|
class WebGLSampler;
|
2016-12-23 00:52:53 +03:00
|
|
|
struct FloatOrInt;
|
2016-10-21 04:03:40 +03:00
|
|
|
struct TexImageSource;
|
2015-08-04 00:34:46 +03:00
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class Element;
|
2016-07-22 09:25:41 +03:00
|
|
|
class HTMLVideoElement;
|
2015-08-04 00:34:46 +03:00
|
|
|
class ImageData;
|
2015-10-14 08:48:19 +03:00
|
|
|
class ArrayBufferViewOrSharedArrayBufferView;
|
2015-08-04 00:34:46 +03:00
|
|
|
} // namespace dom
|
2012-12-04 04:13:47 +04:00
|
|
|
|
2016-07-22 09:25:41 +03:00
|
|
|
namespace layers {
|
|
|
|
class Image;
|
|
|
|
} // namespace layers
|
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
namespace webgl {
|
2016-07-22 09:25:41 +03:00
|
|
|
struct DriverUnpackInfo;
|
|
|
|
struct FormatUsageInfo;
|
|
|
|
struct PackingInfo;
|
2015-11-25 07:15:29 +03:00
|
|
|
class TexUnpackBlob;
|
|
|
|
} // namespace webgl
|
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
bool DoesTargetMatchDimensions(WebGLContext* webgl, TexImageTarget target,
|
|
|
|
uint8_t dims);
|
2015-08-04 00:34:46 +03:00
|
|
|
|
2018-08-07 22:12:09 +03:00
|
|
|
namespace webgl {
|
|
|
|
|
|
|
|
struct SamplingState final {
|
|
|
|
// Only store that which changes validation.
|
|
|
|
TexMinFilter minFilter = LOCAL_GL_NEAREST_MIPMAP_LINEAR;
|
|
|
|
TexMagFilter magFilter = LOCAL_GL_LINEAR;
|
|
|
|
TexWrap wrapS = LOCAL_GL_REPEAT;
|
|
|
|
TexWrap wrapT = LOCAL_GL_REPEAT;
|
|
|
|
// TexWrap wrapR = LOCAL_GL_REPEAT;
|
|
|
|
// GLfloat minLod = -1000;
|
|
|
|
// GLfloat maxLod = 1000;
|
|
|
|
TexCompareMode compareMode = LOCAL_GL_NONE;
|
|
|
|
// TexCompareFunc compareFunc = LOCAL_GL_LEQUAL;
|
|
|
|
};
|
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
struct ImageInfo final {
|
|
|
|
static const ImageInfo kUndefined;
|
|
|
|
|
|
|
|
const webgl::FormatUsageInfo* mFormat = nullptr;
|
|
|
|
uint32_t mWidth = 0;
|
|
|
|
uint32_t mHeight = 0;
|
|
|
|
uint32_t mDepth = 0;
|
2019-07-26 12:04:54 +03:00
|
|
|
mutable bool mHasData = false;
|
2018-10-17 07:18:15 +03:00
|
|
|
uint8_t mSamples = 0;
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
// -
|
2018-10-17 07:18:15 +03:00
|
|
|
|
|
|
|
size_t MemoryUsage() const;
|
|
|
|
|
|
|
|
bool IsDefined() const {
|
|
|
|
if (!mFormat) {
|
|
|
|
MOZ_ASSERT(!mWidth && !mHeight && !mDepth);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
Maybe<ImageInfo> NextMip(GLenum target) const;
|
|
|
|
};
|
|
|
|
|
2018-08-07 22:12:09 +03:00
|
|
|
} // namespace webgl
|
2015-11-25 07:15:29 +03:00
|
|
|
|
2012-12-04 04:13:47 +04:00
|
|
|
// NOTE: When this class is switched to new DOM bindings, update the (then-slow)
|
|
|
|
// WrapObject calls in GetParameter and GetFramebufferAttachmentParameter.
|
2015-03-21 19:28:04 +03:00
|
|
|
class WebGLTexture final : public nsWrapperCache,
|
2012-12-04 04:13:47 +04:00
|
|
|
public WebGLRefCountedObject<WebGLTexture>,
|
2015-11-25 07:15:29 +03:00
|
|
|
public LinkedListElement<WebGLTexture>,
|
2018-10-17 07:18:15 +03:00
|
|
|
public CacheInvalidator {
|
|
|
|
// Friends
|
|
|
|
friend class WebGLContext;
|
|
|
|
friend class WebGLFramebuffer;
|
2015-11-25 07:15:29 +03:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
////////////////////////////////////
|
|
|
|
// Members
|
|
|
|
public:
|
|
|
|
const GLuint mGLName;
|
2015-11-25 07:15:29 +03:00
|
|
|
|
2015-08-04 00:34:46 +03:00
|
|
|
protected:
|
2015-11-25 07:15:29 +03:00
|
|
|
TexTarget mTarget;
|
2018-10-17 07:18:15 +03:00
|
|
|
|
2015-08-04 00:34:46 +03:00
|
|
|
static const uint8_t kMaxFaceCount = 6;
|
|
|
|
uint8_t mFaceCount; // 6 for cube maps, 1 otherwise.
|
|
|
|
|
2016-07-22 09:29:19 +03:00
|
|
|
bool mImmutable; // Set by texStorage*
|
|
|
|
uint8_t mImmutableLevelCount;
|
2012-12-04 04:13:47 +04:00
|
|
|
|
|
|
|
uint32_t mBaseMipmapLevel; // Set by texParameter (defaults to 0)
|
2015-11-25 07:15:29 +03:00
|
|
|
uint32_t mMaxMipmapLevel; // Set by texParameter (defaults to 1000)
|
2012-12-04 04:13:47 +04:00
|
|
|
// You almost certainly don't want to query mMaxMipmapLevel.
|
|
|
|
// You almost certainly want MaxEffectiveMipmapLevel().
|
|
|
|
|
2018-08-07 22:12:09 +03:00
|
|
|
webgl::SamplingState mSamplingState;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
mutable const GLint* mCurSwizzle =
|
|
|
|
nullptr; // nullptr means 'default swizzle'.
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
// -
|
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
struct CompletenessInfo final {
|
|
|
|
uint8_t levels = 0;
|
|
|
|
bool powerOfTwo = false;
|
|
|
|
bool mipmapComplete = false;
|
|
|
|
const webgl::FormatUsageInfo* usage = nullptr;
|
|
|
|
const char* incompleteReason = nullptr;
|
2018-11-30 13:46:48 +03:00
|
|
|
};
|
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
mutable CacheWeakMap<const WebGLSampler*, webgl::SampleableInfo>
|
|
|
|
mSamplingCache;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
public:
|
2018-10-19 02:52:39 +03:00
|
|
|
Maybe<const CompletenessInfo> CalcCompletenessInfo(
|
|
|
|
bool ensureInit, bool skipMips = false) const;
|
2018-10-17 07:18:15 +03:00
|
|
|
Maybe<const webgl::SampleableInfo> CalcSampleableInfo(
|
|
|
|
const WebGLSampler*) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
const webgl::SampleableInfo* GetSampleableInfo(const WebGLSampler*) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
// -
|
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
const auto& Immutable() const { return mImmutable; }
|
|
|
|
const auto& BaseMipmapLevel() const { return mBaseMipmapLevel; }
|
2019-05-23 23:48:21 +03:00
|
|
|
const auto& FaceCount() const { return mFaceCount; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
// We can just max this out to 31, which is the number of unsigned bits in
|
|
|
|
// GLsizei.
|
|
|
|
static const uint8_t kMaxLevelCount = 31;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
// We store information about the various images that are part of this
|
|
|
|
// texture. (cubemap faces, mipmap levels)
|
|
|
|
webgl::ImageInfo mImageInfoArr[kMaxLevelCount * kMaxFaceCount];
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
////////////////////////////////////
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-08-04 00:34:46 +03:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLTexture)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLTexture)
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-07-22 09:29:19 +03:00
|
|
|
WebGLTexture(WebGLContext* webgl, GLuint tex);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-06-26 17:30:49 +04:00
|
|
|
void Delete();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
TexTarget Target() const { return mTarget; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext* GetParentObject() const { return mContext; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx,
|
|
|
|
JS::Handle<JSObject*> givenProto) override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-12-04 04:13:47 +04:00
|
|
|
protected:
|
2015-11-25 07:15:29 +03:00
|
|
|
~WebGLTexture() { DeleteOnce(); }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
public:
|
2015-08-04 00:34:46 +03:00
|
|
|
////////////////////////////////////
|
|
|
|
// GL calls
|
|
|
|
bool BindTexture(TexTarget texTarget);
|
2018-10-17 07:18:15 +03:00
|
|
|
void GenerateMipmap();
|
2015-08-04 00:34:46 +03:00
|
|
|
JS::Value GetTexParameter(TexTarget texTarget, GLenum pname);
|
2016-12-23 00:52:53 +03:00
|
|
|
void TexParameter(TexTarget texTarget, GLenum pname, const FloatOrInt& param);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-08-04 00:34:46 +03:00
|
|
|
////////////////////////////////////
|
|
|
|
// WebGLTextureUpload.cpp
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-24 06:27:13 +03:00
|
|
|
protected:
|
2018-07-27 07:46:33 +03:00
|
|
|
void TexOrSubImageBlob(bool isSubImage, TexImageTarget target, GLint level,
|
2016-06-22 20:28:11 +03:00
|
|
|
GLenum internalFormat, GLint xOffset, GLint yOffset,
|
2016-10-21 04:03:40 +03:00
|
|
|
GLint zOffset, const webgl::PackingInfo& pi,
|
2016-06-22 20:28:11 +03:00
|
|
|
const webgl::TexUnpackBlob* blob);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
bool ValidateTexImageSpecification(TexImageTarget target, GLint level,
|
2016-06-22 20:28:11 +03:00
|
|
|
uint32_t width, uint32_t height,
|
|
|
|
uint32_t depth,
|
2018-10-17 07:18:15 +03:00
|
|
|
webgl::ImageInfo** const out_imageInfo);
|
2018-07-27 07:46:33 +03:00
|
|
|
bool ValidateTexImageSelection(TexImageTarget target, GLint level,
|
2016-10-21 04:03:40 +03:00
|
|
|
GLint xOffset, GLint yOffset, GLint zOffset,
|
2016-06-22 20:28:11 +03:00
|
|
|
uint32_t width, uint32_t height,
|
|
|
|
uint32_t depth,
|
2018-10-17 07:18:15 +03:00
|
|
|
webgl::ImageInfo** const out_imageInfo);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
bool ValidateUnpack(const webgl::TexUnpackBlob* blob, bool isFunc3D,
|
2016-06-22 20:28:11 +03:00
|
|
|
const webgl::PackingInfo& srcPI) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
public:
|
2018-07-27 07:46:33 +03:00
|
|
|
void TexStorage(TexTarget target, GLsizei levels, GLenum sizedFormat,
|
2015-11-25 07:15:29 +03:00
|
|
|
GLsizei width, GLsizei height, GLsizei depth);
|
|
|
|
void TexImage(TexImageTarget target, GLint level, GLenum internalFormat,
|
2016-10-21 04:03:40 +03:00
|
|
|
GLsizei width, GLsizei height, GLsizei depth, GLint border,
|
|
|
|
const webgl::PackingInfo& pi, const TexImageSource& src);
|
2015-11-25 07:15:29 +03:00
|
|
|
void TexSubImage(TexImageTarget target, GLint level, GLint xOffset,
|
|
|
|
GLint yOffset, GLint zOffset, GLsizei width, GLsizei height,
|
2016-10-21 04:03:40 +03:00
|
|
|
GLsizei depth, const webgl::PackingInfo& pi,
|
|
|
|
const TexImageSource& src);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
protected:
|
|
|
|
void TexImage(TexImageTarget target, GLint level, GLenum internalFormat,
|
2016-06-22 20:28:11 +03:00
|
|
|
const webgl::PackingInfo& pi, const webgl::TexUnpackBlob* blob);
|
2015-11-25 07:15:29 +03:00
|
|
|
void TexSubImage(TexImageTarget target, GLint level, GLint xOffset,
|
2016-10-21 04:03:40 +03:00
|
|
|
GLint yOffset, GLint zOffset, const webgl::PackingInfo& pi,
|
2016-06-22 20:28:11 +03:00
|
|
|
const webgl::TexUnpackBlob* blob);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
public:
|
2018-07-27 07:46:33 +03:00
|
|
|
void CompressedTexImage(TexImageTarget target, GLint level,
|
2015-11-25 07:15:29 +03:00
|
|
|
GLenum internalFormat, GLsizei width, GLsizei height,
|
2017-07-18 21:02:57 +03:00
|
|
|
GLsizei depth, GLint border,
|
|
|
|
const TexImageSource& src,
|
2015-11-25 07:15:29 +03:00
|
|
|
const Maybe<GLsizei>& expectedImageSize);
|
2018-07-27 07:46:33 +03:00
|
|
|
void CompressedTexSubImage(TexImageTarget target, GLint level, GLint xOffset,
|
2015-11-25 07:15:29 +03:00
|
|
|
GLint yOffset, GLint zOffset, GLsizei width,
|
|
|
|
GLsizei height, GLsizei depth,
|
|
|
|
GLenum sizedUnpackFormat,
|
2017-07-18 21:02:57 +03:00
|
|
|
const TexImageSource& src,
|
|
|
|
const Maybe<GLsizei>& expectedImageSize);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
void CopyTexImage2D(TexImageTarget target, GLint level, GLenum internalFormat,
|
|
|
|
GLint x, GLint y, GLsizei width, GLsizei height,
|
|
|
|
GLint border);
|
|
|
|
void CopyTexSubImage(TexImageTarget target, GLint level, GLint xOffset,
|
|
|
|
GLint yOffset, GLint zOffset, GLint x, GLint y,
|
|
|
|
GLsizei width, GLsizei height);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
////////////////////////////////////
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
protected:
|
|
|
|
void ClampLevelBaseAndMax();
|
2018-10-17 07:18:15 +03:00
|
|
|
void RefreshSwizzle() const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
public:
|
2015-11-25 07:15:29 +03:00
|
|
|
uint32_t EffectiveMaxLevel() const; // GLES 3.0.5 p158: `q`
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
protected:
|
2015-11-25 07:15:29 +03:00
|
|
|
static uint8_t FaceForTarget(TexImageTarget texImageTarget) {
|
|
|
|
GLenum rawTexImageTarget = texImageTarget.get();
|
|
|
|
switch (rawTexImageTarget) {
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
2019-04-02 20:00:41 +03:00
|
|
|
return AutoAssertCast(rawTexImageTarget -
|
|
|
|
LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
default:
|
2014-09-19 03:14:22 +04:00
|
|
|
return 0;
|
2012-12-04 04:13:47 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2012-12-04 04:13:47 +04:00
|
|
|
|
2019-05-23 23:48:21 +03:00
|
|
|
public:
|
2015-07-15 03:37:28 +03:00
|
|
|
auto& ImageInfoAtFace(uint8_t face, uint32_t level) {
|
|
|
|
MOZ_ASSERT(face < mFaceCount);
|
2015-11-25 07:15:29 +03:00
|
|
|
MOZ_ASSERT(level < kMaxLevelCount);
|
2015-07-15 03:37:28 +03:00
|
|
|
size_t pos = (level * mFaceCount) + face;
|
2014-06-26 17:30:49 +04:00
|
|
|
return mImageInfoArr[pos];
|
|
|
|
}
|
2015-11-25 07:15:29 +03:00
|
|
|
|
2016-06-22 20:28:11 +03:00
|
|
|
const auto& ImageInfoAtFace(uint8_t face, uint32_t level) const {
|
2015-11-25 07:15:29 +03:00
|
|
|
return const_cast<WebGLTexture*>(this)->ImageInfoAtFace(face, level);
|
2014-10-14 03:42:20 +04:00
|
|
|
}
|
2013-10-02 04:30:38 +04:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
auto& ImageInfoAt(TexImageTarget texImageTarget, GLint level) {
|
|
|
|
const auto& face = FaceForTarget(texImageTarget);
|
2013-10-02 04:30:38 +04:00
|
|
|
return ImageInfoAtFace(face, level);
|
|
|
|
}
|
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
const auto& ImageInfoAt(TexImageTarget texImageTarget, GLint level) const {
|
2015-11-25 07:15:29 +03:00
|
|
|
return const_cast<WebGLTexture*>(this)->ImageInfoAt(texImageTarget, level);
|
2012-12-04 04:13:47 +04:00
|
|
|
}
|
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
const auto& BaseImageInfo() const {
|
2015-11-25 07:15:29 +03:00
|
|
|
if (mBaseMipmapLevel >= kMaxLevelCount) return webgl::ImageInfo::kUndefined;
|
2013-10-02 04:30:38 +04:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
return ImageInfoAtFace(0, mBaseMipmapLevel);
|
2012-12-04 04:13:47 +04:00
|
|
|
}
|
|
|
|
|
2014-10-14 03:42:20 +04:00
|
|
|
size_t MemoryUsage() const;
|
2012-12-04 04:13:47 +04:00
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
bool EnsureImageDataInitialized(TexImageTarget target, uint32_t level);
|
2018-10-17 07:18:15 +03:00
|
|
|
void PopulateMipChain(uint32_t maxLevel);
|
2018-10-19 02:52:39 +03:00
|
|
|
bool IsMipAndCubeComplete(uint32_t maxLevel, bool ensureInit,
|
|
|
|
bool* out_initFailed) const;
|
2019-06-14 06:26:18 +03:00
|
|
|
void Truncate();
|
2015-11-24 08:55:59 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
bool IsCubeMap() const { return (mTarget == LOCAL_GL_TEXTURE_CUBE_MAP); }
|
2012-12-04 04:13:47 +04:00
|
|
|
};
|
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
inline TexImageTarget TexImageTargetForTargetAndFace(TexTarget target,
|
|
|
|
uint8_t face) {
|
2014-10-14 03:42:20 +04:00
|
|
|
switch (target.get()) {
|
2014-11-14 07:03:50 +03:00
|
|
|
case LOCAL_GL_TEXTURE_2D:
|
|
|
|
case LOCAL_GL_TEXTURE_3D:
|
|
|
|
MOZ_ASSERT(face == 0);
|
|
|
|
return target.get();
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP:
|
|
|
|
MOZ_ASSERT(face < 6);
|
|
|
|
return LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
|
|
|
|
default:
|
2016-05-13 23:34:41 +03:00
|
|
|
MOZ_CRASH("GFX: TexImageTargetForTargetAndFace");
|
2014-10-14 03:42:20 +04:00
|
|
|
}
|
2014-07-15 03:55:56 +04:00
|
|
|
}
|
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
already_AddRefed<mozilla::layers::Image> ImageFromVideo(
|
|
|
|
dom::HTMLVideoElement* elem);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-07-12 08:51:19 +03:00
|
|
|
bool IsTarget3D(TexImageTarget target);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
GLenum DoTexImage(gl::GLContext* gl, TexImageTarget target, GLint level,
|
|
|
|
const webgl::DriverUnpackInfo* dui, GLsizei width,
|
|
|
|
GLsizei height, GLsizei depth, const void* data);
|
|
|
|
GLenum DoTexSubImage(gl::GLContext* gl, TexImageTarget target, GLint level,
|
|
|
|
GLint xOffset, GLint yOffset, GLint zOffset, GLsizei width,
|
|
|
|
GLsizei height, GLsizei depth,
|
|
|
|
const webgl::PackingInfo& pi, const void* data);
|
|
|
|
GLenum DoCompressedTexSubImage(gl::GLContext* gl, TexImageTarget target,
|
|
|
|
GLint level, GLint xOffset, GLint yOffset,
|
|
|
|
GLint zOffset, GLsizei width, GLsizei height,
|
|
|
|
GLsizei depth, GLenum sizedUnpackFormat,
|
|
|
|
GLsizei dataSize, const void* data);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-12-04 04:13:47 +04:00
|
|
|
} // namespace mozilla
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#endif // WEBGL_TEXTURE_H_
|