Skip to content
This repository was archived by the owner on Jul 13, 2021. It is now read-only.

Commit 2f71923

Browse files
committed
fix webgl low
1 parent 3f43c46 commit 2f71923

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/display.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ end
159159
160160
Creates a Stepper for generating progressive plot examples.
161161
162-
Each "step" is saved as a separate file in the folder
162+
Each "step" is saved as a separate file in the folder
163163
pointed to by `path`, and the format is customizable by
164164
`format`, which can be any output type your backend supports.
165165
"""

src/utilities/texture_atlas.jl

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ Base.size(atlas::TextureAtlas) = size(atlas.data)
1717
const TEXTURE_RESOLUTION = Ref((2048, 2048))
1818
const CACHE_RESOLUTION_PREFIX = Ref("high")
1919
const DOWN_SAMPLE_FACTOR = Ref(50)
20+
const DOWN_SAMPLE_HIGH = 50
21+
const DOWN_SAMPLE_LOW = 30
22+
23+
function size_factor()
24+
return DOWN_SAMPLE_HIGH / DOWN_SAMPLE_FACTOR[]
25+
end
2026

2127
function set_glyph_resolution!(res::GlyphResolution)
2228
if res == High
2329
TEXTURE_RESOLUTION[] = (2048, 2048)
2430
CACHE_RESOLUTION_PREFIX[] = "high"
25-
DOWN_SAMPLE_FACTOR[] = 50
31+
DOWN_SAMPLE_FACTOR[] = DOWN_SAMPLE_HIGH
2632
else
2733
TEXTURE_RESOLUTION[] = (1024, 1024)
2834
CACHE_RESOLUTION_PREFIX[] = "low"
29-
DOWN_SAMPLE_FACTOR[] = 30
35+
DOWN_SAMPLE_FACTOR[] = DOWN_SAMPLE_LOW
3036
end
3137
end
3238

@@ -157,9 +163,11 @@ glyph_uv_width!(c::Char) = glyph_uv_width!(get_texture_atlas(), c, defaultfont()
157163
function glyph_uv_width!(atlas::TextureAtlas, c::Char, font)
158164
atlas.attributes[glyph_index!(atlas, c, font)]
159165
end
166+
160167
function glyph_scale!(atlas::TextureAtlas, c::Char, font, scale)
161-
atlas.scale[glyph_index!(atlas, c, font)] .* (scale * 0.02)
168+
atlas.scale[glyph_index!(atlas, c, font)] .* (scale * 0.02) .* size_factor()
162169
end
170+
163171
function glyph_extent!(atlas::TextureAtlas, c::Char, font)
164172
atlas.extent[glyph_index!(atlas, c, font)]
165173
end
@@ -172,11 +180,11 @@ function bearing(extent)
172180
end
173181

174182
function glyph_bearing!(atlas::TextureAtlas, c::Char, font, scale)
175-
bearing(atlas.extent[glyph_index!(atlas, c, font)]) .* Point2f0(scale * 0.02)
183+
bearing(atlas.extent[glyph_index!(atlas, c, font)]) .* Point2f0(scale * 0.02) .* size_factor()
176184
end
177185

178186
function glyph_advance!(atlas::TextureAtlas, c::Char, font, scale)
179-
atlas.extent[glyph_index!(atlas, c, font)].advance .* (scale * 0.02)
187+
atlas.extent[glyph_index!(atlas, c, font)].advance .* (scale * 0.02) .* size_factor()
180188
end
181189

182190

@@ -239,15 +247,15 @@ function render(atlas::TextureAtlas, glyph::Char, font, downsample = 5, pad = 8)
239247
bitmap, extent = renderface(font, glyph, (DF*downsample, DF*downsample))
240248
sd = sdistancefield(bitmap, downsample, downsample*pad)
241249
sd = sd ./ downsample;
242-
extent = extent ./ Vec2f0(downsample)
250+
extent = (extent ./ Vec2f0(downsample))
243251
rect = SimpleRectangle(0, 0, size(sd)...)
244252
uv = push!(atlas.rectangle_packer, rect) #find out where to place the rectangle
245253
uv == nothing && error("texture atlas is too small. Resizing not implemented yet. Please file an issue at GLVisualize if you encounter this") #TODO resize surface
246254
atlas.data[uv.area] = sd
247255
for f in font_render_callbacks
248256
f(sd, uv.area)
249257
end
250-
uv.area, extent, Vec2f0(size(bitmap)) ./ downsample, pad
258+
uv.area, extent, Vec2f0(size(bitmap)) ./ (downsample), pad
251259
end
252260

253261
make_iter(x) = repeated(x)

0 commit comments

Comments
 (0)