Bug 1330945 - Part1. Apply opacity to webrender stacking context as an opacity filter. r=jrmuizel

This commit is contained in:
Ethan Lin 2017-02-02 15:09:09 +08:00
Родитель 16ff67be84
Коммит b4d6b03c03
13 изменённых файлов: 22 добавлений и 6 удалений

Просмотреть файл

@ -29,6 +29,7 @@ struct OpDPPushStackingContext {
WrRect bounds;
WrRect overflow;
MaybeImageMask mask;
float opacity;
Animation[] animations;
Matrix4x4 matrix;
WrMixBlendMode mixBlendMode;

Просмотреть файл

@ -47,6 +47,7 @@ WebRenderBorderLayer::RenderLayer()
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
Nothing(),
1.0f,
GetAnimations(),
transform,
WrMixBlendMode::Normal,

Просмотреть файл

@ -311,7 +311,7 @@ WebRenderBridgeParent::ProcessWebrenderCommands(InfallibleTArray<WebRenderComman
switch (cmd.type()) {
case WebRenderCommand::TOpDPPushStackingContext: {
const OpDPPushStackingContext& op = cmd.get_OpDPPushStackingContext();
builder.PushStackingContext(op.bounds(), op.overflow(), op.mask().ptrOr(nullptr), op.matrix(), op.mixBlendMode());
builder.PushStackingContext(op.bounds(), op.overflow(), op.mask().ptrOr(nullptr), op.opacity(), op.matrix(), op.mixBlendMode());
break;
}
case WebRenderCommand::TOpDPPopStackingContext: {

Просмотреть файл

@ -92,6 +92,7 @@ WebRenderCanvasLayer::RenderLayer()
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask,
1.0f,
GetAnimations(),
transform,
mixBlendMode,

Просмотреть файл

@ -50,6 +50,7 @@ WebRenderColorLayer::RenderLayer()
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask,
1.0f,
GetAnimations(),
transform,
mixBlendMode,

Просмотреть файл

@ -39,6 +39,7 @@ WebRenderContainerLayer::RenderLayer()
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask,
GetLocalOpacity(),
GetLayer()->GetAnimations(),
transform,
mixBlendMode,

Просмотреть файл

@ -160,6 +160,7 @@ WebRenderImageLayer::RenderLayer()
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask,
1.0f,
GetAnimations(),
transform,
mixBlendMode,

Просмотреть файл

@ -161,6 +161,7 @@ WrScrollFrameStackingContextGenerator::WrScrollFrameStackingContextGenerator(
OpDPPushStackingContext(wr::ToWrRect(bounds),
wr::ToWrRect(overflow),
Nothing(),
1.0f,
layer->GetAnimations(),
identity,
WrMixBlendMode::Normal,

Просмотреть файл

@ -162,6 +162,7 @@ WebRenderPaintedLayer::RenderLayer()
OpDPPushStackingContext(wr::ToWrRect(relBounds),
wr::ToWrRect(overflow),
mask,
1.0f,
GetAnimations(),
transform,
mixBlendMode,

Просмотреть файл

@ -342,10 +342,11 @@ void
DisplayListBuilder::PushStackingContext(const WrRect& aBounds,
const WrRect& aOverflow,
const WrImageMask* aMask,
const float aOpacity,
const gfx::Matrix4x4& aTransform,
const WrMixBlendMode& aMixBlendMode)
{
wr_dp_push_stacking_context(mWrState, aBounds, aOverflow, aMask,
wr_dp_push_stacking_context(mWrState, aBounds, aOverflow, aMask, aOpacity,
&aTransform.components[0], aMixBlendMode);
}

Просмотреть файл

@ -108,6 +108,7 @@ public:
void PushStackingContext(const WrRect& aBounds, // TODO: We should work with strongly typed rects
const WrRect& aOverflow,
const WrImageMask* aMask, // TODO: needs a wrapper.
const float aOpacity,
const gfx::Matrix4x4& aTransform,
const WrMixBlendMode& aMixBlendMode);

Просмотреть файл

@ -8,7 +8,7 @@ use gleam::gl;
use webrender_traits::{BorderSide, BorderStyle, BorderRadius};
use webrender_traits::{PipelineId, ClipRegion};
use webrender_traits::{Epoch, ColorF, GlyphInstance, ImageDescriptor};
use webrender_traits::{ImageData, ImageFormat, ImageKey, ImageMask, ImageRendering, RendererKind, MixBlendMode};
use webrender_traits::{FilterOp, ImageData, ImageFormat, ImageKey, ImageMask, ImageRendering, RendererKind, MixBlendMode};
use webrender_traits::{ExternalImageId, RenderApi, FontKey};
use webrender_traits::{DeviceUintSize, ExternalEvent};
use webrender_traits::{LayoutPoint, LayoutRect, LayoutSize, LayoutTransform};
@ -561,7 +561,7 @@ pub extern fn wr_window_dp_begin(window: &mut WrWindowState, state: &mut WrState
}
#[no_mangle]
pub extern fn wr_dp_push_stacking_context(state:&mut WrState, bounds: WrRect, overflow: WrRect, mask: *const WrImageMask, transform: &LayoutTransform, mix_blend_mode: WrMixBlendMode)
pub extern fn wr_dp_push_stacking_context(state:&mut WrState, bounds: WrRect, overflow: WrRect, mask: *const WrImageMask, opacity: f32, transform: &LayoutTransform, mix_blend_mode: WrMixBlendMode)
{
assert!( unsafe { is_in_compositor_thread() });
state.z_index += 1;
@ -574,6 +574,11 @@ pub extern fn wr_dp_push_stacking_context(state:&mut WrState, bounds: WrRect, ov
let clip_region = state.frame_builder.dl_builder.new_clip_region(&overflow, vec![], mask);
let mut filters: Vec<FilterOp> = Vec::new();
if opacity < 1.0 {
filters.push(FilterOp::Opacity(opacity));
}
state.frame_builder.dl_builder.push_stacking_context(webrender_traits::ScrollPolicy::Scrollable,
bounds,
clip_region,
@ -581,7 +586,7 @@ pub extern fn wr_dp_push_stacking_context(state:&mut WrState, bounds: WrRect, ov
transform,
&LayoutTransform::identity(),
mix_blend_mode,
Vec::new());
filters);
}

Просмотреть файл

@ -431,7 +431,8 @@ WR_FUNC;
WR_INLINE void
wr_dp_push_stacking_context(WrState *wrState, WrRect bounds,
WrRect overflow, const WrImageMask *mask,
const float* matrix, WrMixBlendMode mixBlendMode)
float opacity, const float* matrix,
WrMixBlendMode mixBlendMode)
WR_FUNC;
//XXX: matrix should use a proper type