mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1345344 - Pass stride for ExternalImageBuffer r=nical
This commit is contained in:
parent
8704f07a03
commit
6a06e56c91
@ -313,9 +313,9 @@ WebRenderBridgeParent::ProcessWebRenderCommands(const gfx::IntSize &aSize,
|
||||
// XXX handling YUV
|
||||
gfx::SurfaceFormat format =
|
||||
wrTexture->GetFormat() == SurfaceFormat::YUV ? SurfaceFormat::B8G8R8A8 : wrTexture->GetFormat();
|
||||
wr::ImageDescriptor descriptor(wrTexture->GetSize(), wrTexture->GetRGBStride(), format);
|
||||
mApi->AddExternalImageBuffer(key,
|
||||
wrTexture->GetSize(),
|
||||
format,
|
||||
descriptor,
|
||||
wrTexture->GetExternalImageKey());
|
||||
mCompositableHolder->HoldExternalImage(aEpoch, texture->AsWebRenderTextureHost());
|
||||
keysToDelete.push_back(key);
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "WebRenderTextureHost.h"
|
||||
|
||||
#include "mozilla/layers/ImageDataSerializer.h"
|
||||
#include "mozilla/webrender/RenderTextureHost.h"
|
||||
#include "mozilla/webrender/RenderThread.h"
|
||||
|
||||
@ -105,5 +106,20 @@ WebRenderTextureHost::GetFormat() const
|
||||
return mWrappedTextureHost->GetFormat();
|
||||
}
|
||||
|
||||
int32_t
|
||||
WebRenderTextureHost::GetRGBStride()
|
||||
{
|
||||
if (!mWrappedTextureHost) {
|
||||
return 0;
|
||||
}
|
||||
gfx::SurfaceFormat format = GetFormat();
|
||||
if (GetFormat() == SurfaceFormat::YUV) {
|
||||
// XXX this stride is used until yuv image rendering by webrender is used.
|
||||
// Software converted RGB buffers strides are aliened to 16
|
||||
return GetAlignedStride<16>(GetSize().width, BytesPerPixel(SurfaceFormat::B8G8R8A8));
|
||||
}
|
||||
return ImageDataSerializer::ComputeRGBStride(format, GetSize().width);
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
@ -45,6 +45,8 @@ public:
|
||||
virtual WebRenderTextureHost* AsWebRenderTextureHost() override { return this; }
|
||||
|
||||
uint64_t GetExternalImageKey() { return mExternalImageId; }
|
||||
|
||||
int32_t GetRGBStride();
|
||||
protected:
|
||||
RefPtr<TextureHost> mWrappedTextureHost;
|
||||
uint64_t mExternalImageId;
|
||||
|
@ -292,12 +292,12 @@ WebRenderAPI::SetRootPipeline(PipelineId aPipeline)
|
||||
}
|
||||
|
||||
void
|
||||
WebRenderAPI::AddImage(ImageKey key, const ImageDescriptor& aDescritptor,
|
||||
WebRenderAPI::AddImage(ImageKey key, const ImageDescriptor& aDescriptor,
|
||||
Range<uint8_t> aBytes)
|
||||
{
|
||||
wr_api_add_image(mWrApi,
|
||||
key,
|
||||
&aDescritptor,
|
||||
&aDescriptor,
|
||||
&aBytes[0], aBytes.length());
|
||||
}
|
||||
|
||||
@ -316,25 +316,23 @@ WebRenderAPI::AddExternalImageHandle(ImageKey key,
|
||||
|
||||
void
|
||||
WebRenderAPI::AddExternalImageBuffer(ImageKey key,
|
||||
gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
const ImageDescriptor& aDescriptor,
|
||||
uint64_t aHandle)
|
||||
{
|
||||
auto format = SurfaceFormatToWrImageFormat(aFormat).value();
|
||||
wr_api_add_external_image_buffer(mWrApi,
|
||||
key,
|
||||
aSize.width, aSize.height, format,
|
||||
&aDescriptor,
|
||||
aHandle);
|
||||
}
|
||||
|
||||
void
|
||||
WebRenderAPI::UpdateImageBuffer(ImageKey aKey,
|
||||
const ImageDescriptor& aDescritptor,
|
||||
const ImageDescriptor& aDescriptor,
|
||||
Range<uint8_t> aBytes)
|
||||
{
|
||||
wr_api_update_image(mWrApi,
|
||||
aKey,
|
||||
&aDescritptor,
|
||||
&aDescriptor,
|
||||
&aBytes[0], aBytes.length());
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,7 @@ public:
|
||||
uint64_t aHandle);
|
||||
|
||||
void AddExternalImageBuffer(ImageKey key,
|
||||
gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
const ImageDescriptor& aDescriptor,
|
||||
uint64_t aHandle);
|
||||
|
||||
void UpdateImageBuffer(wr::ImageKey aKey,
|
||||
|
@ -742,10 +742,10 @@ pub extern fn wr_api_add_external_image_handle(api: &mut RenderApi, image_key: I
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn wr_api_add_external_image_buffer(api: &mut RenderApi, image_key: ImageKey, width: u32, height: u32, format: ImageFormat, external_image_id: u64) {
|
||||
pub extern fn wr_api_add_external_image_buffer(api: &mut RenderApi, image_key: ImageKey, descriptor: &WrImageDescriptor, external_image_id: u64) {
|
||||
assert!( unsafe { is_in_compositor_thread() });
|
||||
api.add_image(image_key,
|
||||
ImageDescriptor{width:width, height:height, stride:None, format: format, is_opaque: false, offset: 0},
|
||||
descriptor.to_descriptor(),
|
||||
ImageData::ExternalBuffer(ExternalImageId(external_image_id)),
|
||||
None
|
||||
);
|
||||
|
@ -450,8 +450,9 @@ wr_api_add_external_image_handle(WrAPI* api, WrImageKey key, uint32_t width, uin
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE void
|
||||
wr_api_add_external_image_buffer(WrAPI* api, WrImageKey key, uint32_t width, uint32_t height,
|
||||
WrImageFormat format, uint64_t external_image_id)
|
||||
wr_api_add_external_image_buffer(WrAPI* api, WrImageKey key,
|
||||
const WrImageDescriptor* descriptor,
|
||||
uint64_t external_image_id)
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE void
|
||||
|
Loading…
Reference in New Issue
Block a user