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

ensure that we request glyphs without a transform for text shadows #2094

Merged
merged 2 commits into from Nov 24, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

ensure that we request glyphs without a transform for text shadows

  • Loading branch information
lsalzman committed Nov 23, 2017
commit f70f7607148db037a2e63c8020cd3050ed23bac2
@@ -25,7 +25,7 @@ use internal_types::{FastHashMap, FastHashSet};
use picture::{PictureCompositeMode, PictureKind, PicturePrimitive, RasterizationSpace};
use prim_store::{TexelRect, YuvImagePrimitiveCpu};
use prim_store::{GradientPrimitiveCpu, ImagePrimitiveCpu, LinePrimitive, PrimitiveKind};
use prim_store::{PrimitiveContainer, PrimitiveIndex};
use prim_store::{PrimitiveContainer, PrimitiveIndex, SpecificPrimitiveIndex};
use prim_store::{PrimitiveStore, RadialGradientPrimitiveCpu};
use prim_store::{RectangleContent, RectanglePrimitive, TextRunPrimitiveCpu};
use profiler::{FrameProfileCounters, GpuCacheProfileCounters, TextureCacheProfileCounters};
@@ -1582,6 +1582,7 @@ impl FrameBuilder {
profile_counters,
None,
scene_properties,
SpecificPrimitiveIndex(0),
);

let pic = &mut self.prim_store.cpu_pictures[0];
@@ -16,7 +16,7 @@ use glyph_rasterizer::{FontInstance, FontTransform};
use internal_types::FastHashMap;
use gpu_cache::{GpuBlockData, GpuCache, GpuCacheAddress, GpuCacheHandle, GpuDataRequest,
ToGpuBlocks};
use picture::{PictureKind, PicturePrimitive};
use picture::{PictureKind, PicturePrimitive, RasterizationSpace};
use profiler::FrameProfileCounters;
use render_task::{ClipWorkItem, ClipChainNode};
use render_task::{RenderTask, RenderTaskId, RenderTaskTree};
@@ -595,15 +595,19 @@ impl TextRunPrimitiveCpu {
&self,
device_pixel_ratio: f32,
transform: &LayerToWorldTransform,
rasterization_kind: RasterizationSpace,
) -> FontInstance {
let mut font = self.font.clone();
font.size = font.size.scale_by(device_pixel_ratio);
if font.render_mode == FontRenderMode::Subpixel {
if transform.has_perspective_component() || !transform.has_2d_inverse() {
font.render_mode = FontRenderMode::Alpha;
} else {
font.transform = FontTransform::from(transform).quantize();
match (font.render_mode, rasterization_kind) {
(FontRenderMode::Subpixel, RasterizationSpace::Screen) => {
if transform.has_perspective_component() || !transform.has_2d_inverse() {
font.render_mode = FontRenderMode::Alpha;
} else {
font.transform = FontTransform::from(transform).quantize();
}
}
_ => {}
}
font
}
@@ -615,8 +619,9 @@ impl TextRunPrimitiveCpu {
transform: &LayerToWorldTransform,
display_list: &BuiltDisplayList,
gpu_cache: &mut GpuCache,
rasterization_kind: RasterizationSpace,
) {
let font = self.get_font(device_pixel_ratio, transform);
let font = self.get_font(device_pixel_ratio, transform, rasterization_kind);

// Cache the glyph positions, if not in the cache already.
// TODO(gw): In the future, remove `glyph_instances`
@@ -1102,6 +1107,7 @@ impl PrimitiveStore {
render_tasks: &mut RenderTaskTree,
child_tasks: Vec<RenderTaskId>,
parent_tasks: &mut Vec<RenderTaskId>,
pic_index: SpecificPrimitiveIndex,
) {
let metadata = &mut self.cpu_metadata[prim_index.0];
match metadata.prim_kind {
@@ -1118,13 +1124,15 @@ impl PrimitiveStore {
);
}
PrimitiveKind::TextRun => {
let pic = &self.cpu_pictures[pic_index.0];
let text = &mut self.cpu_text_runs[metadata.cpu_prim_index.0];
text.prepare_for_render(
resource_cache,
prim_context.device_pixel_ratio,
&prim_context.scroll_node.world_content_transform,
prim_context.display_list,
gpu_cache,
pic.rasterization_kind,
);
}
PrimitiveKind::Image => {
@@ -1315,6 +1323,7 @@ impl PrimitiveStore {
parent_tasks: &mut Vec<RenderTaskId>,
scene_properties: &SceneProperties,
profile_counters: &mut FrameProfileCounters,
pic_index: SpecificPrimitiveIndex,
) -> Option<LayerRect> {
// Reset the visibility of this primitive.
// Do some basic checks first, that can early out
@@ -1373,6 +1382,7 @@ impl PrimitiveStore {
profile_counters,
rfid,
scene_properties,
cpu_prim_index,
);

let metadata = &mut self.cpu_metadata[prim_index.0];
@@ -1450,6 +1460,7 @@ impl PrimitiveStore {
render_tasks,
child_tasks,
parent_tasks,
pic_index,
);

Some(local_rect)
@@ -1479,6 +1490,7 @@ impl PrimitiveStore {
profile_counters: &mut FrameProfileCounters,
original_reference_frame_id: Option<ClipId>,
scene_properties: &SceneProperties,
pic_index: SpecificPrimitiveIndex,
) -> PrimitiveRunLocalRect {
let mut result = PrimitiveRunLocalRect {
local_rect_in_actual_parent_space: LayerRect::zero(),
@@ -1544,6 +1556,7 @@ impl PrimitiveStore {
parent_tasks,
scene_properties,
profile_counters,
pic_index,
) {
profile_counters.visible_primitives.inc();

@@ -20,7 +20,7 @@ use gpu_types::{CompositePrimitiveInstance, PrimitiveInstance, SimplePrimitiveIn
use gpu_types::{ClipScrollNodeIndex, ClipScrollNodeData};
use internal_types::{FastHashMap, SourceTexture};
use internal_types::BatchTextures;
use picture::{PictureCompositeMode, PictureKind, PicturePrimitive};
use picture::{PictureCompositeMode, PictureKind, PicturePrimitive, RasterizationSpace};
use plane_split::{BspSplitter, Polygon, Splitter};
use prim_store::{PrimitiveIndex, PrimitiveKind, PrimitiveMetadata, PrimitiveStore};
use prim_store::{BrushMaskKind, BrushKind, DeferredResolve, PrimitiveRun, RectangleContent};
@@ -547,6 +547,7 @@ fn add_to_batch(
let font = text_cpu.get_font(
ctx.device_pixel_ratio,
&scroll_node.transform,
RasterizationSpace::Screen,
);

ctx.resource_cache.fetch_glyphs(
@@ -1483,6 +1484,7 @@ impl RenderTarget for ColorRenderTarget {
let font = text.get_font(
ctx.device_pixel_ratio,
&LayerToWorldTransform::identity(),
RasterizationSpace::Local,
);

ctx.resource_cache.fetch_glyphs(
@@ -39,3 +39,4 @@ fuzzy(1,44) platform(linux) == text-masking.yaml text-masking-subpx.png
platform(linux) == subpixel-rotate.yaml subpixel-rotate.png
platform(linux) == subpixel-scale.yaml subpixel-scale.png
platform(linux) == subpixel-skew.yaml subpixel-skew.png
!= shadow-rotate.yaml blank.yaml
@@ -0,0 +1,18 @@
--- checks that transformed text shadows can locate glyphs in the glyph cache
root:
items:
- type: stacking-context
bounds: [0, 0, 430, 330]
transform: rotate(30)
items:
- type: "shadow"
bounds: [0, 0, 430, 330]
blur-radius: 1
offset: [0, 1]
color: blue
- text: "a Bcd Efgh Ijklm Nopqrs Tuvwxyz"
origin: 50 200
size: 20
font: "FreeSans.ttf"
- type: "pop-all-shadows"

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.