Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Primitive methods to PrimitiveInstance. #3228

Merged
merged 1 commit into from Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions webrender/src/batch.rs
Expand Up @@ -18,7 +18,7 @@ use picture::{Picture3DContext, PictureCompositeMode, PicturePrimitive, PictureS
use prim_store::{BrushKind, BrushPrimitive, BrushSegmentTaskId, DeferredResolve};
use prim_store::{EdgeAaSegmentMask, ImageSource};
use prim_store::{VisibleGradientTile, PrimitiveInstance};
use prim_store::{BrushSegment, BorderSource, Primitive, PrimitiveDetails};
use prim_store::{BrushSegment, BorderSource, PrimitiveDetails};
use render_task::{RenderTaskAddress, RenderTaskId, RenderTaskTree};
use renderer::{BlendMode, ImageBufferKind, ShaderColorMode};
use renderer::BLOCKS_PER_UV_RECT;
Expand Down Expand Up @@ -564,7 +564,7 @@ impl AlphaBatchBuilder {
.clip_task_id
.map_or(OPAQUE_TASK_ADDRESS, |id| render_tasks.get_task_address(id));

let specified_blend_mode = prim.get_blend_mode();
let specified_blend_mode = prim_instance.get_blend_mode(&prim.details);

let non_segmented_blend_mode = if !prim_instance.opacity.is_opaque ||
prim_instance.clip_task_id.is_some() ||
Expand Down Expand Up @@ -1733,9 +1733,12 @@ impl BrushPrimitive {
}
}

impl Primitive {
fn get_blend_mode(&self) -> BlendMode {
match self.details {
impl PrimitiveInstance {
fn get_blend_mode(
&self,
details: &PrimitiveDetails,
) -> BlendMode {
match *details {
// Can only resolve the TextRun's blend mode once glyphs are fetched.
PrimitiveDetails::TextRun(..) => {
BlendMode::PremultipliedAlpha
Expand Down Expand Up @@ -1768,9 +1771,10 @@ impl Primitive {

pub fn is_cacheable(
&self,
details: &PrimitiveDetails,
resource_cache: &ResourceCache
) -> bool {
let image_key = match self.details {
let image_key = match *details {
PrimitiveDetails::Brush(BrushPrimitive { kind: BrushKind::Image{ request, .. }, .. }) => {
request.key
}
Expand Down