Bug 1328893 - Specify an ImageRendering for some WebRenderLayers r=kats

--HG--
extra : rebase_source : 7f5cc7445e156b47c2210d36d1db8eb35c8b1a44
extra : amend_source : 2d418c013850f2fff88596599bc2622a5eb82b2c
This commit is contained in:
Ryan Hunt 2017-01-13 11:59:07 -06:00
parent 1f97dac250
commit 5d82b6b00b
11 changed files with 61 additions and 15 deletions

View File

@ -13,6 +13,7 @@ include protocol PTexture;
using WRBorderSide from "mozilla/gfx/webrender.h";
using WRColor from "mozilla/gfx/webrender.h";
using WRImageKey from "mozilla/gfx/webrender.h";
using WRTextureFilter from "mozilla/gfx/webrender.h";
using WRLayoutSize from "mozilla/gfx/webrender.h";
using WRRect from "mozilla/gfx/webrender.h";
using WRGlyphArray from "mozilla/gfx/webrender.h";
@ -59,6 +60,7 @@ struct OpDPPushImage {
WRRect bounds;
WRRect clip;
MaybeImageMask mask;
WRTextureFilter filter;
WRImageKey key;
};
@ -66,6 +68,7 @@ struct OpDPPushExternalImageId {
WRRect bounds;
WRRect clip;
MaybeImageMask mask;
WRTextureFilter filter;
uint64_t externalImageId;
};

View File

@ -195,9 +195,10 @@ void
DisplayListBuilder::PushImage(const WRRect& aBounds,
const WRRect& aClip,
const WRImageMask* aMask,
const WRTextureFilter aFilter,
WRImageKey aImage)
{
wr_dp_push_image(mWRState, aBounds, aClip, aMask, aImage);
wr_dp_push_image(mWRState, aBounds, aClip, aMask, aFilter, aImage);
}
void

View File

@ -79,6 +79,7 @@ public:
void PushImage(const WRRect& aBounds,
const WRRect& aClip,
const WRImageMask* aMask,
const WRTextureFilter aFilter,
WRImageKey aImage);
void PushIFrame(const WRRect& aBounds,

View File

@ -319,7 +319,7 @@ WebRenderBridgeParent::ProcessWebrenderCommands(InfallibleTArray<WebRenderComman
case WebRenderCommand::TOpDPPushImage: {
const OpDPPushImage& op = cmd.get_OpDPPushImage();
builder.PushImage(op.bounds(), op.clip(),
op.mask().ptrOr(nullptr), op.key());
op.mask().ptrOr(nullptr), op.filter(), op.key());
break;
}
case WebRenderCommand::TOpDPPushExternalImageId: {
@ -340,7 +340,7 @@ WebRenderBridgeParent::ProcessWebrenderCommands(InfallibleTArray<WebRenderComman
}
gfx::IntSize size = dSurf->GetSize();
WRImageKey key = wr_add_image(mWRWindowState, size.width, size.height, map.mStride, RGBA8, map.mData, size.height * map.mStride);
builder.PushImage(op.bounds(), op.clip(), op.mask().ptrOr(nullptr), key);
builder.PushImage(op.bounds(), op.clip(), op.mask().ptrOr(nullptr), op.filter(), key);
keysToDelete.push_back(key);
dSurf->Unmap();
break;

View File

@ -69,15 +69,19 @@ WebRenderCanvasLayer::RenderLayer()
} else {
clip = rect;
}
if (gfxPrefs::LayersDump()) printf_stderr("CanvasLayer %p using rect:%s clip:%s\n", this, Stringify(rect).c_str(), Stringify(clip).c_str());
gfx::Rect relBounds = TransformedVisibleBoundsRelativeToParent();
gfx::Rect overflow(0, 0, relBounds.width, relBounds.height);
WRTextureFilter filter = (mFlags | TextureFlags::USE_NEAREST_FILTER) ? WRTextureFilter::Point : WRTextureFilter::Linear;
WRBridge()->AddWebRenderCommand(
OpDPPushStackingContext(ToWRRect(relBounds), ToWRRect(overflow), Nothing(), transform, FrameMetrics::NULL_SCROLL_ID));
WRBridge()->AddWebRenderCommand(OpDPPushExternalImageId(ToWRRect(rect), ToWRRect(clip), Nothing(), mExternalImageId));
WRBridge()->AddWebRenderCommand(OpDPPushExternalImageId(ToWRRect(rect), ToWRRect(clip), Nothing(), filter, mExternalImageId));
WRBridge()->AddWebRenderCommand(OpDPPopStackingContext());
if (gfxPrefs::LayersDump()) printf_stderr("CanvasLayer %p using %s as bounds/overflow, %s for transform\n", this, Stringify(relBounds).c_str(), Stringify(transform).c_str());
WRBridge()->AddWebRenderCommand(OpDPPopStackingContext());
}
void

View File

@ -138,18 +138,20 @@ WebRenderImageLayer::RenderLayer()
} else {
clip = rect;
}
if (gfxPrefs::LayersDump()) printf_stderr("ImageLayer %p using rect:%s clip:%s\n", this, Stringify(rect).c_str(), Stringify(clip).c_str());
Rect relBounds = TransformedVisibleBoundsRelativeToParent();
Rect overflow(0, 0, relBounds.width, relBounds.height);
Matrix4x4 transform;// = GetTransform();
WRTextureFilter filter = (mSamplingFilter == gfx::SamplingFilter::POINT) ? WRTextureFilter::Point : WRTextureFilter::Linear;
WRBridge()->AddWebRenderCommand(
OpDPPushStackingContext(ToWRRect(relBounds), ToWRRect(overflow), Nothing(), transform, FrameMetrics::NULL_SCROLL_ID));
WRBridge()->AddWebRenderCommand(OpDPPushExternalImageId(ToWRRect(rect), ToWRRect(clip), Nothing(), mExternalImageId));
WRBridge()->AddWebRenderCommand(OpDPPushExternalImageId(ToWRRect(rect), ToWRRect(clip), Nothing(), filter, mExternalImageId));
WRBridge()->AddWebRenderCommand(OpDPPopStackingContext());
if (gfxPrefs::LayersDump()) printf_stderr("ImageLayer %p using %s as bounds/overflow, %s for transform\n", this, Stringify(relBounds).c_str(), Stringify(transform).c_str());
WRBridge()->AddWebRenderCommand(OpDPPopStackingContext());
//mContainer->SetImageFactory(originalIF);
}

View File

@ -233,6 +233,15 @@ struct ParamTraits<WRImageMask>
}
};
template<>
struct ParamTraits<WRTextureFilter>
: public ContiguousEnumSerializer<
WRTextureFilter,
WRTextureFilter::Linear,
WRTextureFilter::Sentinel>
{
};
} // namespace IPC
#endif // GFX_WEBRENDERMESSAGEUTILS_H

View File

@ -74,7 +74,7 @@ WebRenderPaintedLayer::RenderLayer()
WRBridge()->AddWebRenderCommand(
OpDPPushStackingContext(ToWRRect(relBounds), ToWRRect(overflow), Nothing(), transform, FrameMetrics::NULL_SCROLL_ID));
WRBridge()->AddWebRenderCommand(OpDPPushImage(ToWRRect(rect), ToWRRect(clip), Nothing(), key));
WRBridge()->AddWebRenderCommand(OpDPPushImage(ToWRRect(rect), ToWRRect(clip), Nothing(), WRTextureFilter::Linear, key));
Manager()->AddImageKeyForDiscard(key);
if (gfxPrefs::LayersDump()) printf_stderr("PaintedLayer %p using %s as bounds/overflow, %s for transform\n", this, Stringify(relBounds).c_str(), Stringify(transform).c_str());

View File

@ -791,8 +791,26 @@ impl WrImageMask
}
}
#[repr(C)]
pub enum WrTextureFilter
{
Linear,
Point,
}
impl WrTextureFilter
{
pub fn to_image_rendering(self) -> ImageRendering
{
match self
{
WrTextureFilter::Linear => ImageRendering::Auto,
WrTextureFilter::Point => ImageRendering::Pixelated,
}
}
}
#[no_mangle]
pub extern fn wr_dp_push_image(state:&mut WrState, bounds: WrRect, clip : WrRect, mask: *const WrImageMask, key: ImageKey) {
pub extern fn wr_dp_push_image(state:&mut WrState, bounds: WrRect, clip : WrRect, mask: *const WrImageMask, filter: WrTextureFilter, key: ImageKey) {
assert!( unsafe { is_in_compositor_thread() });
let bounds = bounds.to_rect();
@ -800,6 +818,7 @@ pub extern fn wr_dp_push_image(state:&mut WrState, bounds: WrRect, clip : WrRect
// convert from the C type to the Rust type, mapping NULL to None
let mask = unsafe { mask.as_ref().map(|m| m.to_image_mask()) };
let image_rendering = filter.to_image_rendering();
let clip_region = state.frame_builder.dl_builder.new_clip_region(&clip, Vec::new(), mask);
state.frame_builder.dl_builder.push_image(
@ -807,7 +826,7 @@ pub extern fn wr_dp_push_image(state:&mut WrState, bounds: WrRect, clip : WrRect
clip_region,
bounds.size,
bounds.size,
ImageRendering::Auto,
image_rendering,
key
);
}

View File

@ -136,6 +136,13 @@ struct WRImageMask
}
};
enum class WRTextureFilter
{
Linear,
Point,
Sentinel,
};
typedef uint64_t WRImageIdType;
struct WRExternalImageId {
WRImageIdType id;
@ -340,7 +347,7 @@ WR_FUNC;
WR_INLINE void
wr_dp_push_image(WRState* wrState, WRRect bounds, WRRect clip,
const WRImageMask* mask, WRImageKey key)
const WRImageMask* mask, WRTextureFilter filter, WRImageKey key)
WR_FUNC;
// TODO: Remove.

View File

@ -87,7 +87,7 @@ fuzzy(20,999) != downscale-2c.html?205,53,bottom about:blank
fuzzy(20,999) != downscale-2d.html?205,53,bottom about:blank
fuzzy(20,999) fails-if(OSX>=1008&&!skiaContent) != downscale-2e.html?205,53,bottom about:blank
fuzzy(63,3391) skip-if(/^Linux\x20i686/.test(http.oscpu)) == downscale-moz-icon-1.html downscale-moz-icon-1-ref.html # linux32 timeout, bug 1328771
fuzzy(71,3391) skip-if(/^Linux\x20i686/.test(http.oscpu)) == downscale-moz-icon-1.html downscale-moz-icon-1-ref.html # linux32 timeout, bug 1328771
== downscale-png.html?16,16,interlaced downscale-png.html?16,16,normal
== downscale-png.html?24,24,interlaced downscale-png.html?24,24,normal
@ -171,7 +171,7 @@ fuzzy(20,999) != downscale-2e.html?205,53,bottom about:blank
fuzzy(20,999) != downscale-2f.html?205,53,bottom about:blank
# Skip on WinXP with skia content
fuzzy(71,4439) fails-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) skip-if(/^Linux\x20i686/.test(http.oscpu)) == downscale-moz-icon-1.html downscale-moz-icon-1-ref.html # linux32 timeout, bug 1328771
fuzzy(77,4439) fails-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) skip-if(/^Linux\x20i686/.test(http.oscpu)) == downscale-moz-icon-1.html downscale-moz-icon-1-ref.html # linux32 timeout, bug 1328771
== downscale-png.html?16,16,interlaced downscale-png.html?16,16,normal
== downscale-png.html?24,24,interlaced downscale-png.html?24,24,normal