コード例 #1
0
void
TextureHostYCbCrD3D11::UpdateImpl(const SurfaceDescriptor& aImage, nsIntRegion *aRegion)
{
  MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TYCbCrImage);

  ShmemYCbCrImage shmemImage(aImage.get_YCbCrImage().data(),
                             aImage.get_YCbCrImage().offset());

  gfxIntSize gfxCbCrSize = shmemImage.GetCbCrSize();

  gfxIntSize size = shmemImage.GetYSize();

  D3D11_SUBRESOURCE_DATA initData;
  initData.pSysMem = shmemImage.GetYData();
  initData.SysMemPitch = shmemImage.GetYStride();

  CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_R8_UNORM, size.width, size.height,
                              1, 1, D3D11_BIND_SHADER_RESOURCE, D3D11_USAGE_IMMUTABLE);

  mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[0]));

  initData.pSysMem = shmemImage.GetCbData();
  initData.SysMemPitch = shmemImage.GetCbCrStride();
  desc.Width = shmemImage.GetCbCrSize().width;
  desc.Height = shmemImage.GetCbCrSize().height;

  mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[1]));

  initData.pSysMem = shmemImage.GetCrData();
  mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[2]));

  mSize = IntSize(size.width, size.height);
}
コード例 #2
0
ファイル: TextureD3D11.cpp プロジェクト: ncalexan/gecko-dev
void
DeprecatedTextureHostYCbCrD3D11::UpdateImpl(const SurfaceDescriptor& aImage,
        nsIntRegion* aRegion,
        nsIntPoint* aOffset)
{
    MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TYCbCrImage);

    YCbCrImageDataDeserializer yuvDeserializer(aImage.get_YCbCrImage().data().get<uint8_t>());

    gfx::IntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();

    gfx::IntSize size = yuvDeserializer.GetYSize();

    D3D11_SUBRESOURCE_DATA initData;
    initData.pSysMem = yuvDeserializer.GetYData();
    initData.SysMemPitch = yuvDeserializer.GetYStride();

    CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_A8_UNORM, size.width, size.height,
                               1, 1, D3D11_BIND_SHADER_RESOURCE,
                               D3D11_USAGE_IMMUTABLE);

    mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[0]));

    initData.pSysMem = yuvDeserializer.GetCbData();
    initData.SysMemPitch = yuvDeserializer.GetCbCrStride();
    desc.Width = yuvDeserializer.GetCbCrSize().width;
    desc.Height = yuvDeserializer.GetCbCrSize().height;

    mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[1]));

    initData.pSysMem = yuvDeserializer.GetCrData();
    mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[2]));

    mSize = IntSize(size.width, size.height);
}
コード例 #3
0
  void ConvertImageToRGB(const SurfaceDescriptor& aImage)
  {
    YCbCrImageDataDeserializer deserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
    PlanarYCbCrImage::Data data;
    DeserializerToPlanarYCbCrImageData(deserializer, data);

    gfxASurface::gfxImageFormat format = gfxASurface::ImageFormatRGB24;
    gfxIntSize size;
    gfxUtils::GetYCbCrToRGBDestFormatAndSize(data, format, size);
    if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
        size.height > PlanarYCbCrImage::MAX_DIMENSION) {
      NS_ERROR("Illegal image dest width or height");
      return;
    }

    mThebesSurface = mThebesImage =
      new gfxImageSurface(size, format);

    gfxUtils::ConvertYCbCrToRGB(data, format, size,
                                mThebesImage->Data(),
                                mThebesImage->Stride());

    mSize = IntSize(size.width, size.height);
    mFormat =
      (format == gfxASurface::ImageFormatARGB32) ? FORMAT_B8G8R8A8 :
                                                   FORMAT_B8G8R8X8;
  }
コード例 #4
0
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);
}
コード例 #5
0
bool IsSurfaceDescriptorOwned(const SurfaceDescriptor& aDescriptor)
{
  switch (aDescriptor.type()) {
    case SurfaceDescriptor::TYCbCrImage: {
      const YCbCrImage& ycbcr = aDescriptor.get_YCbCrImage();
      return ycbcr.owner() != 0;
    }
    case SurfaceDescriptor::TRGBImage: {
      const RGBImage& rgb = aDescriptor.get_RGBImage();
      return rgb.owner() != 0;
    }
    default:
      return false;
  }
  return false;
}
コード例 #6
0
void
DeprecatedTextureHostYCbCrD3D9::UpdateImpl(const SurfaceDescriptor& aImage,
                                 nsIntRegion *aRegion,
                                 nsIntPoint *aOffset)
{
  MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TYCbCrImage);

  if (!mCompositor->device()) {
    return;
  }

  YCbCrImageDataDeserializer yuvDeserializer(aImage.get_YCbCrImage().data().get<uint8_t>());

  mSize = yuvDeserializer.GetYSize();
  IntSize cbCrSize = yuvDeserializer.GetCbCrSize();
  mStereoMode = yuvDeserializer.GetStereoMode();

  DeviceManagerD3D9* deviceManager = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager();
  RefPtr<DataTextureSource> srcY;
  RefPtr<DataTextureSource> srcCb;
  RefPtr<DataTextureSource> srcCr;
  if (!mFirstSource) {
    srcY  = new DataTextureSourceD3D9(SurfaceFormat::A8, mCompositor,
                                      TEXTURE_DISALLOW_BIGIMAGE, mStereoMode);
    srcCb = new DataTextureSourceD3D9(SurfaceFormat::A8, mCompositor,
                                      TEXTURE_DISALLOW_BIGIMAGE, mStereoMode);
    srcCr = new DataTextureSourceD3D9(SurfaceFormat::A8, mCompositor,
                                      TEXTURE_DISALLOW_BIGIMAGE, mStereoMode);
    mFirstSource = srcY;
    srcY->SetNextSibling(srcCb);
    srcCb->SetNextSibling(srcCr);
  } else {
    MOZ_ASSERT(mFirstSource->GetNextSibling());
    MOZ_ASSERT(mFirstSource->GetNextSibling()->GetNextSibling());
    srcY = mFirstSource;
    srcCb = mFirstSource->GetNextSibling()->AsDataTextureSource();
    srcCr = mFirstSource->GetNextSibling()->GetNextSibling()->AsDataTextureSource();
  }

  RefPtr<DataSourceSurface> wrapperY =
    Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetYData(),
                                             yuvDeserializer.GetYStride(),
                                             yuvDeserializer.GetYSize(),
                                             SurfaceFormat::A8);
  RefPtr<DataSourceSurface> wrapperCb =
    Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCbData(),
                                             yuvDeserializer.GetCbCrStride(),
                                             yuvDeserializer.GetCbCrSize(),
                                             SurfaceFormat::A8);
  RefPtr<DataSourceSurface> wrapperCr =
    Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCrData(),
                                             yuvDeserializer.GetCbCrStride(),
                                             yuvDeserializer.GetCbCrSize(),
                                             SurfaceFormat::A8);
  // We don't support partial updates for YCbCr textures
  NS_ASSERTION(!aRegion, "Unsupported partial updates for YCbCr textures");
  if (!srcY->Update(wrapperY) ||
      !srcCb->Update(wrapperCb) ||
      !srcCr->Update(wrapperCr)) {
    NS_WARNING("failed to update the DataTextureSource");
    mSize.width = 0;
    mSize.height = 0;
    mFirstSource = nullptr;
    return;
  }
}