author | Dan Glastonbury <dglastonbury@mozilla.com> |
Thu, 21 May 2015 09:55:34 +1000 | |
changeset 247872 | 8f4e5ac93a6bcd03d13bc259651fea59320cdc07 |
parent 247871 | db0c0147c7fb2bfb82561f30c5a86f2724fdb9e7 |
child 247873 | 0696e1f508f3da0670f403aa4e7b02798a95c184 |
push id | 28885 |
push user | cbook@mozilla.com |
push date | Wed, 10 Jun 2015 13:18:59 +0000 |
treeherder | autoland@e101c589c242 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jgilbert |
bugs | 1167504 |
milestone | 41.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -1875,17 +1875,17 @@ WebGLContext::TexImageFromVideoElement(c srcImage->GetSize().width, srcImage->GetSize().height, 0, format, type, nullptr); } const gl::OriginPos destOrigin = mPixelStoreFlipY ? gl::OriginPos::BottomLeft : gl::OriginPos::TopLeft; bool ok = gl->BlitHelper()->BlitImageToTexture(srcImage.get(), srcImage->GetSize(), - tex->GLName(), + tex->mGLName, texImageTarget.get(), destOrigin); if (ok) { TexInternalFormat effectiveInternalFormat = EffectiveInternalFormatFromInternalFormatAndType(internalFormat, type); MOZ_ASSERT(effectiveInternalFormat != LOCAL_GL_NONE); tex->SetImageInfo(texImageTarget, level, srcImage->GetSize().width,
--- a/dom/canvas/WebGLContextDraw.cpp +++ b/dom/canvas/WebGLContextDraw.cpp @@ -732,21 +732,21 @@ WebGLContext::UnbindFakeBlackTextures() { // this is the generic case: try to return early if (MOZ_LIKELY(ResolvedFakeBlackStatus() == WebGLContextFakeBlackStatus::NotNeeded)) return; for (int32_t i = 0; i < mGLMaxTextureUnits; ++i) { if (mBound2DTextures[i] && mBound2DTextures[i]->ResolvedFakeBlackStatus() != WebGLTextureFakeBlackStatus::NotNeeded) { gl->fActiveTexture(LOCAL_GL_TEXTURE0 + i); - gl->fBindTexture(LOCAL_GL_TEXTURE_2D, mBound2DTextures[i]->GLName()); + gl->fBindTexture(LOCAL_GL_TEXTURE_2D, mBound2DTextures[i]->mGLName); } if (mBoundCubeMapTextures[i] && mBoundCubeMapTextures[i]->ResolvedFakeBlackStatus() != WebGLTextureFakeBlackStatus::NotNeeded) { gl->fActiveTexture(LOCAL_GL_TEXTURE0 + i); - gl->fBindTexture(LOCAL_GL_TEXTURE_CUBE_MAP, mBoundCubeMapTextures[i]->GLName()); + gl->fBindTexture(LOCAL_GL_TEXTURE_CUBE_MAP, mBoundCubeMapTextures[i]->mGLName); } } gl->fActiveTexture(LOCAL_GL_TEXTURE0 + mActiveTexture); } WebGLContext::FakeBlackTexture::FakeBlackTexture(GLContext* gl, TexTarget target, GLenum format) : mGL(gl)
--- a/dom/canvas/WebGLContextGL.cpp +++ b/dom/canvas/WebGLContextGL.cpp @@ -734,17 +734,17 @@ WebGLContext::DeleteTexture(WebGLTexture GLuint activeTexture = mActiveTexture; for (int32_t i = 0; i < mGLMaxTextureUnits; i++) { if ((mBound2DTextures[i] == tex && tex->Target() == LOCAL_GL_TEXTURE_2D) || (mBoundCubeMapTextures[i] == tex && tex->Target() == LOCAL_GL_TEXTURE_CUBE_MAP) || (mBound3DTextures[i] == tex && tex->Target() == LOCAL_GL_TEXTURE_3D)) { ActiveTexture(LOCAL_GL_TEXTURE0 + i); - BindTexture(tex->Target().get(), nullptr); + BindTexture(tex->Target(), nullptr); } } ActiveTexture(LOCAL_GL_TEXTURE0 + activeTexture); tex->RequestDelete(); } void
--- a/dom/canvas/WebGLContextUtils.cpp +++ b/dom/canvas/WebGLContextUtils.cpp @@ -1114,21 +1114,21 @@ WebGLContext::AssertCachedBindings() GLuint bound = mCurrentProgram ? mCurrentProgram->mGLName : 0; AssertUintParamCorrect(gl, LOCAL_GL_CURRENT_PROGRAM, bound); // Textures GLenum activeTexture = mActiveTexture + LOCAL_GL_TEXTURE0; AssertUintParamCorrect(gl, LOCAL_GL_ACTIVE_TEXTURE, activeTexture); WebGLTexture* curTex = ActiveBoundTextureForTarget(LOCAL_GL_TEXTURE_2D); - bound = curTex ? curTex->GLName() : 0; + bound = curTex ? curTex->mGLName : 0; AssertUintParamCorrect(gl, LOCAL_GL_TEXTURE_BINDING_2D, bound); curTex = ActiveBoundTextureForTarget(LOCAL_GL_TEXTURE_CUBE_MAP); - bound = curTex ? curTex->GLName() : 0; + bound = curTex ? curTex->mGLName : 0; AssertUintParamCorrect(gl, LOCAL_GL_TEXTURE_BINDING_CUBE_MAP, bound); // Buffers bound = mBoundArrayBuffer ? mBoundArrayBuffer->GLName() : 0; AssertUintParamCorrect(gl, LOCAL_GL_ARRAY_BUFFER_BINDING, bound); MOZ_ASSERT(mBoundVertexArray); WebGLBuffer* curBuff = mBoundVertexArray->mElementArrayBuffer;
--- a/dom/canvas/WebGLFramebuffer.cpp +++ b/dom/canvas/WebGLFramebuffer.cpp @@ -373,17 +373,17 @@ WebGLFramebuffer::AttachPoint::FinalizeA } MOZ_ASSERT(HasImage()); if (Texture()) { MOZ_ASSERT(gl == Texture()->Context()->GL()); const GLenum imageTarget = ImageTarget().get(); const GLint mipLevel = MipLevel(); - const GLuint glName = Texture()->GLName(); + const GLuint glName = Texture()->mGLName; if (attachmentLoc == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) { gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_DEPTH_ATTACHMENT, imageTarget, glName, mipLevel); gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_STENCIL_ATTACHMENT, imageTarget, glName, mipLevel); } else { gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, attachmentLoc.get(),
--- a/dom/canvas/WebGLTexture.cpp +++ b/dom/canvas/WebGLTexture.cpp @@ -19,18 +19,19 @@ namespace mozilla { JSObject* WebGLTexture::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) { return dom::WebGLTextureBinding::Wrap(cx, this, aGivenProto); } WebGLTexture::WebGLTexture(WebGLContext* webgl, GLuint tex) - : WebGLBindableName<TexTarget>(tex) - , WebGLContextBoundObject(webgl) + : WebGLContextBoundObject(webgl) + , mGLName(tex) + , mTarget(LOCAL_GL_NONE) , mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR) , mMagFilter(LOCAL_GL_LINEAR) , mWrapS(LOCAL_GL_REPEAT) , mWrapT(LOCAL_GL_REPEAT) , mFacesCount(0) , mMaxLevelWithCustomImages(0) , mHaveGeneratedMipmap(false) , mImmutable(false) @@ -137,29 +138,27 @@ void WebGLTexture::Bind(TexTarget texTarget) { // This function should only be called by bindTexture(). It assumes that the // GL context is already current. bool firstTimeThisTextureIsBound = !HasEverBeenBound(); if (firstTimeThisTextureIsBound) { - BindTo(texTarget); + mTarget = texTarget.get(); } else if (texTarget != Target()) { 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; } - GLuint name = GLName(); - - mContext->gl->fBindTexture(texTarget.get(), name); + mContext->gl->fBindTexture(texTarget.get(), mGLName); if (firstTimeThisTextureIsBound) { mFacesCount = (texTarget == LOCAL_GL_TEXTURE_CUBE_MAP) ? 6 : 1; EnsureMaxLevelWithCustomImagesAtLeast(0); SetFakeBlackStatus(WebGLTextureFakeBlackStatus::Unknown); // 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 @@ -224,17 +223,17 @@ WebGLTexture::SetCustomMipmap() EnsureMaxLevelWithCustomImagesAtLeast(maxLevel); for (size_t level = EffectiveBaseMipmapLevel() + 1; level <= EffectiveMaxMipmapLevel(); ++level) { imageInfo.mWidth = std::max(imageInfo.mWidth / 2, 1); imageInfo.mHeight = std::max(imageInfo.mHeight / 2, 1); imageInfo.mDepth = std::max(imageInfo.mDepth / 2, 1); - for(size_t face = 0; face < mFacesCount; ++face) { + for (size_t face = 0; face < mFacesCount; ++face) { ImageInfoAtFace(face, level) = imageInfo; } } } mHaveGeneratedMipmap = false; } bool @@ -271,18 +270,18 @@ WebGLTexture::IsCubeComplete() const bool WebGLTexture::IsMipmapCubeComplete() const { // In particular, this checks that this is a cube map: if (!IsCubeComplete()) return false; for (int i = 0; i < 6; i++) { - const TexImageTarget face = TexImageTargetForTargetAndFace(LOCAL_GL_TEXTURE_CUBE_MAP, - i); + const TexImageTarget face = + TexImageTargetForTargetAndFace(LOCAL_GL_TEXTURE_CUBE_MAP, i); if (!DoesMipmapHaveAllLevelsConsistentlyDefined(face)) return false; } return true; } bool WebGLTexture::IsMipmapRangeValid() const @@ -621,28 +620,28 @@ WebGLTexture::EnsureNoUninitializedImage const ImageInfo& imageInfo = ImageInfoAt(imageTarget, level); if (!imageInfo.HasUninitializedImageData()) return; mContext->MakeContextCurrent(); // Try to clear with glClear. if (imageTarget == LOCAL_GL_TEXTURE_2D) { - bool cleared = ClearWithTempFB(mContext, GLName(), imageTarget, level, + bool cleared = ClearWithTempFB(mContext, mGLName, imageTarget, level, imageInfo.mEffectiveInternalFormat, imageInfo.mHeight, imageInfo.mWidth); if (cleared) { SetImageDataStatus(imageTarget, level, WebGLImageDataStatus::InitializedImageData); return; } } // That didn't work. Try uploading zeros then. - gl::ScopedBindTexture autoBindTex(mContext->gl, GLName(), mTarget.get()); + gl::ScopedBindTexture autoBindTex(mContext->gl, mGLName, mTarget); 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; CheckedUint32 checked_byteLength = WebGLContext::GetImageSize(
--- a/dom/canvas/WebGLTexture.h +++ b/dom/canvas/WebGLTexture.h @@ -7,17 +7,16 @@ #define WEBGL_TEXTURE_H_ #include <algorithm> #include "mozilla/Assertions.h" #include "mozilla/CheckedInt.h" #include "mozilla/LinkedList.h" #include "nsAlgorithm.h" #include "nsWrapperCache.h" -#include "WebGLBindableName.h" #include "WebGLFramebufferAttachable.h" #include "WebGLObjectModel.h" #include "WebGLStrongTypes.h" namespace mozilla { // Zero is not an integer power of two. inline bool @@ -26,27 +25,29 @@ IsPOTAssumingNonnegative(GLsizei x) MOZ_ASSERT(x >= 0); return x && (x & (x-1)) == 0; } // NOTE: When this class is switched to new DOM bindings, update the (then-slow) // WrapObject calls in GetParameter and GetFramebufferAttachmentParameter. class WebGLTexture final : public nsWrapperCache - , public WebGLBindableName<TexTarget> , public WebGLRefCountedObject<WebGLTexture> , public LinkedListElement<WebGLTexture> , public WebGLContextBoundObject , public WebGLFramebufferAttachable { public: explicit WebGLTexture(WebGLContext* webgl, GLuint tex); void Delete(); + bool HasEverBeenBound() const { return mTarget != LOCAL_GL_NONE; } + GLenum Target() const { return mTarget; } + WebGLContext* GetParentObject() const { return Context(); } virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override; NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLTexture) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLTexture) @@ -58,16 +59,22 @@ protected: friend class WebGLContext; friend class WebGLFramebuffer; // We store information about the various images that are part of this // texture. (cubemap faces, mipmap levels) public: + const GLuint mGLName; + +protected: + GLenum mTarget; + +public: class ImageInfo : public WebGLRectangleObject { public: ImageInfo() : mEffectiveInternalFormat(LOCAL_GL_NONE) , mDepth(0) , mImageDataStatus(WebGLImageDataStatus::NoImageData)