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); }
GPUBlurFilter::GPUBlurFilter(const IntPoint& size, PixelFormat pfSrc, PixelFormat pfDest, float stdDev, bool bClipBorders, bool bStandalone, bool bUseFloatKernel) : GPUFilter(pfSrc, pfDest, bStandalone, SHADERID_HORIZ, 2), m_bClipBorders(bClipBorders), m_bUseFloatKernel(bUseFloatKernel) { ObjectCounter::get()->incRef(&typeid(*this)); GLContext::getCurrent()->ensureFullShaders("GPUBlurFilter"); #ifndef AVG_ENABLE_EGL if (!m_bClipBorders) { //TODO: TO_BORDER DOES NOT EXIST IN GLESV2 m_WrapMode = WrapMode(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER); } #endif setDimensions(size, stdDev); GLContextManager* pCM = GLContextManager::get(); pCM->createShader(SHADERID_VERT); setStdDev(stdDev); m_pHorizWidthParam = pCM->createShaderParam<float>(SHADERID_HORIZ, "u_Width"); m_pHorizRadiusParam = pCM->createShaderParam<int>(SHADERID_HORIZ, "u_Radius"); m_pHorizTextureParam = pCM->createShaderParam<int>(SHADERID_HORIZ, "u_Texture"); m_pHorizKernelTexParam = pCM->createShaderParam<int>(SHADERID_HORIZ, "u_KernelTex"); m_pVertWidthParam = pCM->createShaderParam<float>(SHADERID_VERT, "u_Width"); m_pVertRadiusParam = pCM->createShaderParam<int>(SHADERID_VERT, "u_Radius"); m_pVertTextureParam = pCM->createShaderParam<int>(SHADERID_VERT, "u_Texture"); m_pVertKernelTexParam = pCM->createShaderParam<int>(SHADERID_VERT, "u_KernelTex"); }
FilledVectorNode::FilledVectorNode(const ArgList& args) : VectorNode(args), m_pFillShape(new Shape(WrapMode(GL_REPEAT, GL_REPEAT), false)) { m_FillTexHRef = args.getArgVal<UTF8String>("filltexhref"); setFillTexHRef(m_FillTexHRef); m_sFillColorName = args.getArgVal<UTF8String>("fillcolor"); m_FillColor = colorStringToColor(m_sFillColorName); }
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(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(); } }
void GPUBlurFilter::applyOnGPU(GLContext* pContext, GLTexturePtr pSrcTex) { int kernelWidth = m_pGaussCurveTex->getSize().x; getFBO(pContext, 1)->activate(); getShader()->activate(); m_pHorizWidthParam->set(pContext, float(kernelWidth)); m_pHorizRadiusParam->set(pContext, (kernelWidth-1)/2); m_pHorizTextureParam->set(pContext, 0); m_pHorizKernelTexParam->set(pContext, 1); m_pGaussCurveTex->getTex(pContext)->activate(WrapMode(), GL_TEXTURE1); draw(pContext, pSrcTex, m_WrapMode); getFBO(pContext, 0)->activate(); OGLShaderPtr pVShader = avg::getShader(SHADERID_VERT); pVShader->activate(); m_pVertWidthParam->set(pContext, float(kernelWidth)); m_pVertRadiusParam->set(pContext, (kernelWidth-1)/2); m_pVertTextureParam->set(pContext, 0); m_pVertKernelTexParam->set(pContext, 1); getDestTex(pContext, 1)->activate(m_WrapMode, GL_TEXTURE0); m_pProjection2->draw(pContext, pVShader); }
void GPUInvertFilter::applyOnGPU(GLContext* pContext, GLTexturePtr pSrcTex) { getShader()->activate(); m_pTextureParam->set(pContext, 0); draw(pContext, pSrcTex, WrapMode()); }