Bug 1384839 - Part4. Use A8 format when painting mask image. r=kats

MozReview-Commit-ID: 9vMkBxRNAUv

--HG--
extra : rebase_source : 164011beb656b7b97f0854baeedabbe85c2f9321
This commit is contained in:
Ethan Lin 2017-07-31 14:00:29 +08:00
parent fa25e69f8d
commit a1f704c881
3 changed files with 10 additions and 4 deletions

View File

@ -19,13 +19,16 @@ namespace layers {
class UpdateImageHelper
{
public:
UpdateImageHelper(ImageContainer* aImageContainer, ImageClient* aImageClient, gfx::IntSize aImageSize) :
UpdateImageHelper(ImageContainer* aImageContainer,
ImageClient* aImageClient,
gfx::IntSize aImageSize,
gfx::SurfaceFormat aFormat) :
mImageContainer(aImageContainer),
mImageClient(aImageClient),
mImageSize(aImageSize),
mIsLocked(false)
{
mTexture = mImageClient->GetTextureClientRecycler()->CreateOrRecycle(gfx::SurfaceFormat::B8G8R8A8,
mTexture = mImageClient->GetTextureClientRecycler()->CreateOrRecycle(aFormat,
mImageSize,
BackendSelector::Content,
TextureFlags::DEFAULT);

View File

@ -448,9 +448,12 @@ WebRenderLayerManager::GenerateFallbackData(nsDisplayItem* aItem,
}
}
gfx::SurfaceFormat format = aItem->GetType() == nsDisplayItem::TYPE_MASK ?
gfx::SurfaceFormat::A8 : gfx::SurfaceFormat::B8G8R8A8;
if (!geometry || !invalidRegion.IsEmpty() || fallbackData->IsInvalid()) {
if (gfxPrefs::WebRenderBlobImages()) {
RefPtr<gfx::DrawEventRecorderMemory> recorder = MakeAndAddRef<gfx::DrawEventRecorderMemory>();
// TODO: should use 'format' to replace gfx::SurfaceFormat::B8G8R8X8. Currently blob image doesn't support A8 format.
RefPtr<gfx::DrawTarget> dummyDt =
gfx::Factory::CreateDrawTarget(gfx::BackendType::SKIA, gfx::IntSize(1, 1), gfx::SurfaceFormat::B8G8R8X8);
RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateRecordingDrawTarget(recorder, dummyDt, imageSize.ToUnknownSize());
@ -467,7 +470,7 @@ WebRenderLayerManager::GenerateFallbackData(nsDisplayItem* aItem,
RefPtr<ImageContainer> imageContainer = LayerManager::CreateImageContainer();
{
UpdateImageHelper helper(imageContainer, imageClient, imageSize.ToUnknownSize());
UpdateImageHelper helper(imageContainer, imageClient, imageSize.ToUnknownSize(), format);
{
RefPtr<gfx::DrawTarget> dt = helper.GetDrawTarget();
PaintItemByDrawTarget(aItem, dt, aImageRect, aOffset, aDisplayListBuilder);

View File

@ -57,7 +57,7 @@ WebRenderPaintedLayer::UpdateImageClient()
IntRect bounds = visibleRegion.GetBounds();
IntSize imageSize = bounds.Size();
UpdateImageHelper helper(mImageContainer, mImageClient, imageSize);
UpdateImageHelper helper(mImageContainer, mImageClient, imageSize, gfx::SurfaceFormat::B8G8R8A8);
{
RefPtr<DrawTarget> target = helper.GetDrawTarget();