void YCbCrDeprecatedTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage, nsIntRegion* aRegion, nsIntPoint* aOffset) { if (!mGL) { return; } NS_ASSERTION(aImage.type() == SurfaceDescriptor::TYCbCrImage, "SurfaceDescriptor mismatch"); YCbCrImageDataDeserializer deserializer(aImage.get_YCbCrImage().data().get<uint8_t>()); gfxIntSize gfxSize = deserializer.GetYSize(); gfxIntSize gfxCbCrSize = deserializer.GetCbCrSize(); if (!mYTexture->mTexImage || mYTexture->mTexImage->GetSize() != gfxSize) { mYTexture->mTexImage = CreateBasicTextureImage(mGL, gfxSize, gfxASurface::CONTENT_ALPHA, WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT), FlagsToGLFlags(mFlags)); } if (!mCbTexture->mTexImage || mCbTexture->mTexImage->GetSize() != gfxCbCrSize) { mCbTexture->mTexImage = CreateBasicTextureImage(mGL, gfxCbCrSize, gfxASurface::CONTENT_ALPHA, WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT), FlagsToGLFlags(mFlags)); } if (!mCrTexture->mTexImage || mCrTexture->mTexImage->GetSize() != gfxCbCrSize) { mCrTexture->mTexImage = CreateBasicTextureImage(mGL, gfxCbCrSize, gfxASurface::CONTENT_ALPHA, WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT), FlagsToGLFlags(mFlags)); } RefPtr<gfxImageSurface> tempY = new gfxImageSurface(deserializer.GetYData(), gfxSize, deserializer.GetYStride(), gfxASurface::ImageFormatA8); RefPtr<gfxImageSurface> tempCb = new gfxImageSurface(deserializer.GetCbData(), gfxCbCrSize, deserializer.GetCbCrStride(), gfxASurface::ImageFormatA8); RefPtr<gfxImageSurface> tempCr = new gfxImageSurface(deserializer.GetCrData(), gfxCbCrSize, deserializer.GetCbCrStride(), gfxASurface::ImageFormatA8); nsIntRegion yRegion(nsIntRect(0, 0, gfxSize.width, gfxSize.height)); nsIntRegion cbCrRegion(nsIntRect(0, 0, gfxCbCrSize.width, gfxCbCrSize.height)); mYTexture->mTexImage->DirectUpdate(tempY, yRegion); mCbTexture->mTexImage->DirectUpdate(tempCb, cbCrRegion); mCrTexture->mTexImage->DirectUpdate(tempCr, cbCrRegion); }
bool TextureImageTextureSourceOGL::Update(gfx::DataSourceSurface* aSurface, nsIntRegion* aDestRegion, gfx::IntPoint* aSrcOffset) { MOZ_ASSERT(mGL); if (!mGL) { NS_WARNING("trying to update TextureImageTextureSourceOGL without a GLContext"); return false; } MOZ_ASSERT(aSurface); IntSize size = aSurface->GetSize(); if (!mTexImage || (mTexImage->GetSize() != size && !aSrcOffset) || mTexImage->GetContentType() != gfx::ContentForFormat(aSurface->GetFormat())) { if (mFlags & TEXTURE_DISALLOW_BIGIMAGE) { mTexImage = CreateBasicTextureImage(mGL, size, gfx::ContentForFormat(aSurface->GetFormat()), WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT), FlagsToGLFlags(mFlags), SurfaceFormatToImageFormat(aSurface->GetFormat())); } else { // XXX - clarify which size we want to use. IncrementalContentHost will // require the size of the destination surface to be different from // the size of aSurface. // See bug 893300 (tracks the implementation of ContentHost for new textures). mTexImage = CreateTextureImage(mGL, size, gfx::ContentForFormat(aSurface->GetFormat()), WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT), FlagsToGLFlags(mFlags), SurfaceFormatToImageFormat(aSurface->GetFormat())); } ClearCachedFilter(); } mTexImage->UpdateFromDataSource(aSurface, aDestRegion, aSrcOffset); if (mTexImage->InUpdate()) { mTexImage->EndUpdate(); } return true; }
void TextureImageDeprecatedTextureHostOGL::EnsureBuffer(const nsIntSize& aSize, gfxContentType aContentType) { if (!mTexture || mTexture->GetSize() != aSize || mTexture->GetContentType() != aContentType) { mTexture = mGL->CreateTextureImage(aSize, aContentType, WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT), FlagsToGLFlags(mFlags)); } mTexture->Resize(aSize); }
void TextureImageTextureHostOGL::EnsureBuffer(const nsIntSize& aSize, gfxContentType aContentType) { if (!mTexture || mTexture->GetSize() != aSize || mTexture->GetContentType() != aContentType) { mTexture = mGL->CreateTextureImage(aSize, aContentType, WrapMode(mGL, mFlags & AllowRepeat), FlagsToGLFlags(mFlags)); } mTexture->Resize(aSize); }
void TextureImageTextureSourceOGL::EnsureBuffer(const nsIntSize& aSize, gfxContentType aContentType) { if (!mTexImage || mTexImage->GetSize() != aSize.ToIntSize() || mTexImage->GetContentType() != aContentType) { mTexImage = CreateTextureImage(mCompositor->gl(), aSize.ToIntSize(), aContentType, LOCAL_GL_CLAMP_TO_EDGE, FlagsToGLFlags(mFlags)); } mTexImage->Resize(aSize.ToIntSize()); }
void TextureImageTextureSourceOGL::EnsureBuffer(const nsIntSize& aSize, gfxContentType aContentType) { if (!mTexImage || mTexImage->GetSize() != aSize.ToIntSize() || mTexImage->GetContentType() != aContentType) { mTexImage = CreateTextureImage(mGL, aSize.ToIntSize(), aContentType, WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT), FlagsToGLFlags(mFlags)); } mTexImage->Resize(aSize.ToIntSize()); }
void TextureImageDeprecatedTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage, nsIntRegion* aRegion, nsIntPoint* aOffset) { if (!mGL) { NS_WARNING("trying to update TextureImageDeprecatedTextureHostOGL without a compositor?"); return; } AutoOpenSurface surf(OPEN_READ_ONLY, aImage); nsIntSize size = surf.Size(); TextureImage::ImageFormat format = surf.ImageFormat(); if (!mTexture || (mTexture->GetSize() != size && !aOffset) || mTexture->GetContentType() != surf.ContentType() || (mTexture->GetImageFormat() != format && mTexture->GetImageFormat() != gfxASurface::ImageFormatUnknown)) { mTexture = mGL->CreateTextureImage(size, surf.ContentType(), WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT), FlagsToGLFlags(mFlags), format); } // XXX this is always just ridiculously slow nsIntRegion updateRegion; if (!aRegion) { updateRegion = nsIntRegion(nsIntRect(0, 0, size.width, size.height)); } else { updateRegion = *aRegion; } nsIntPoint offset; if (aOffset) { offset = *aOffset; } mTexture->DirectUpdate(surf.Get(), updateRegion, offset); mFormat = mTexture->GetTextureFormat(); if (mTexture->InUpdate()) { mTexture->EndUpdate(); } }
bool TextureImageTextureSourceOGL::Update(gfx::DataSourceSurface* aSurface, nsIntRegion* aDestRegion, gfx::IntPoint* aSrcOffset) { GLContext *gl = mCompositor->gl(); MOZ_ASSERT(gl); if (!gl) { NS_WARNING("trying to update TextureImageTextureSourceOGL without a GLContext"); return false; } if (!aSurface) { gfxCriticalError() << "Invalid surface for OGL update"; return false; } MOZ_ASSERT(aSurface); IntSize size = aSurface->GetSize(); if (!mTexImage || (mTexImage->GetSize() != size && !aSrcOffset) || mTexImage->GetContentType() != gfx::ContentForFormat(aSurface->GetFormat())) { if (mFlags & TextureFlags::DISALLOW_BIGIMAGE) { GLint maxTextureSize; gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &maxTextureSize); if (size.width > maxTextureSize || size.height > maxTextureSize) { NS_WARNING("Texture exceeds maximum texture size, refusing upload"); return false; } // Explicitly use CreateBasicTextureImage instead of CreateTextureImage, // because CreateTextureImage might still choose to create a tiled // texture image. mTexImage = CreateBasicTextureImage(gl, size, gfx::ContentForFormat(aSurface->GetFormat()), LOCAL_GL_CLAMP_TO_EDGE, FlagsToGLFlags(mFlags), SurfaceFormatToImageFormat(aSurface->GetFormat())); } else { // XXX - clarify which size we want to use. IncrementalContentHost will // require the size of the destination surface to be different from // the size of aSurface. // See bug 893300 (tracks the implementation of ContentHost for new textures). mTexImage = CreateTextureImage(gl, size, gfx::ContentForFormat(aSurface->GetFormat()), LOCAL_GL_CLAMP_TO_EDGE, FlagsToGLFlags(mFlags), SurfaceFormatToImageFormat(aSurface->GetFormat())); } ClearCachedFilter(); if (aDestRegion && !aSrcOffset && !aDestRegion->IsEqual(nsIntRect(0, 0, size.width, size.height))) { // UpdateFromDataSource will ignore our specified aDestRegion since the texture // hasn't been allocated with glTexImage2D yet. Call Resize() to force the // allocation (full size, but no upload), and then we'll only upload the pixels // we care about below. mTexImage->Resize(size); } } mTexImage->UpdateFromDataSource(aSurface, aDestRegion, aSrcOffset); if (mTexImage->InUpdate()) { mTexImage->EndUpdate(); } return true; }