Ejemplo n.º 1
0
already_AddRefed<TextureImage>
TextureImage::Create(GLContext* gl,
                     const gfx::IntSize& size,
                     TextureImage::ContentType contentType,
                     GLenum wrapMode,
                     TextureImage::Flags flags)
{
    return CreateTextureImage(gl, size, contentType, wrapMode, flags);
}
Ejemplo n.º 2
0
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());
}
Ejemplo n.º 3
0
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());
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
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;
}