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

Commit

Permalink
Merge pull request #53 from JuliaPlots/sd/perfbug
Browse files Browse the repository at this point in the history
use clear directly
  • Loading branch information
SimonDanisch authored Dec 9, 2019
2 parents d377efc + 4f51026 commit 25167fc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 133 deletions.
47 changes: 22 additions & 25 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
name = "GLMakie"
uuid = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
version = "0.0.8"
version = "0.0.9"

[deps]
AbstractPlotting = "537997a7-5e4e-5d89-9595-2241ea00577e"
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118"
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
FreeType = "b38be410-82b0-50bf-ab77-7b57e271db43"
FreeTypeAbstraction = "663a7486-cb36-511b-a19d-713bb74d65c9"
GLFW = "f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98"
GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb"
ImageAxes = "2803e5a7-5153-5ecf-9a86-9b4c37f5f5ac"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
ImageFiltering = "6a3955dd-da59-5b1f-98d4-e7296123deb5"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

GLFW = "f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98"
ModernGL = "66fc600b-dfda-50eb-8b99-91cfa97b1301"

LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118"
ModernGL = "66fc600b-dfda-50eb-8b99-91cfa97b1301"
Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
julia = "≥ 1.0"
AbstractPlotting = ">=0.9.9"
FreeTypeAbstraction = ">=0.3.0"
GLFW = ">=2.3.0"
GeometryTypes = ">=0.7.2"
StaticArrays = ">=0.6.6"
julia = "1"
AbstractPlotting = "^0.9.11"
Colors = "0.9"
ColorTypes = "0.8"
FileIO = "^1.1"
MeshIO = "^0.3"
FixedPointNumbers = "0.6"
GeometryTypes = "^0.7.2"
Observables = "0.2.0"
StaticArrays = "0.6.6,0.7,0.8,0.9,0.10,0.11,0.12"

GLFW = "^3"
ModernGL = "^1"

[extras]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
5 changes: 2 additions & 3 deletions src/GLMakie.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module GLMakie

using ModernGL, FixedPointNumbers, Colors, GeometryTypes, StaticArrays
using AbstractPlotting, FreeType, FreeTypeAbstraction, FileIO, IntervalSets
using ImageCore
using AbstractPlotting, FileIO

using AbstractPlotting: @key_str, Key, broadcast_foreach, to_ndim, NativeFont
using AbstractPlotting: Scene, Lines, Text, Image, Heatmap, Scatter
using AbstractPlotting: convert_attribute, @extractvalue, LineSegments
using AbstractPlotting: @get_attribute, to_value, to_colormap, extrema_nan
using IntervalSets: ClosedInterval, (..)
using AbstractPlotting: ClosedInterval, (..)

using Base: RefValue
import Base: push!, isopen, show
Expand Down
12 changes: 0 additions & 12 deletions src/GLVisualize/GLVisualize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,13 @@ using Colors
using AbstractPlotting
using FixedPointNumbers
using FileIO
using FreeType
import IterTools
using Markdown
using FreeTypeAbstraction
using ImageCore
import ColorVectorSpace
using Observables

import ImageCore
import AxisArrays, ImageAxes

import Base: merge, convert, show
using Base.Iterators: Repeated, repeated
using LinearAlgebra

using IndirectArrays
const HasAxesArray{T, N} = AxisArrays.AxisArray{T, N}
const AxisMatrix{T} = HasAxesArray{T, 2}

import AbstractPlotting: to_font, glyph_uv_width!, glyph_scale!
import ..GLMakie: get_texture!

Expand Down
91 changes: 0 additions & 91 deletions src/GLVisualize/visualize/image_like.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,97 +86,6 @@ function _default(main::MatTypes{T}, s::style"distancefield", data::Dict) where
_default((rect, Point2f0[0]), s, data)
end


export play
"""
play(img, timedim, t)
Slice a 3D array along axis `timedim` at time `t`.
This can be used to treat a 3D array like a video and create an image stream from it.
"""
function play(array::Array{T, 3}, timedim::Integer, t::Integer) where T
index = ntuple(dim-> dim == timedim ? t : Colon(), Val(3))
array[index...]
end

"""
play(buffer, video_stream, t)
Plays a video stream from VideoIO.jl. You need to supply the image `buffer`,
which will be reused for better performance.
"""
function play(buffer::Array{T, 2}, video_stream, t) where T
eof(video_stream) && seekstart(video_stream)
w, h = size(buffer)
buffer = reinterpret(UInt8, buffer, (3, w,h))
read!(video_stream, buffer) # looses type and shape
return reinterpret(T, buffer, (w,h))
end


unwrap(img::AxisArrays.AxisArray) = unwrap(img.data)
unwrap(img::AbstractArray) = img

GLAbstraction.gl_convert(::Type{T}, img::AbstractArray) where {T} = _gl_convert(T, unwrap(img))
_gl_convert(::Type{T}, img::Array) where {T} = gl_convert(T, img)

"""
play(img)
Turns an Image into a video stream
"""
function play(img::HasAxesArray{T, 3}) where T
ax = ImageAxes.timeaxis(img)
if ImageAxes.timeaxis(img) != nothing
return const_lift(play, unwrap(img), ImageAxes.timedim(img), loop(1:length(ax)))
end
error("Image has no time axis: axes(img) = $(axes(img))")
end

"""
Takes a 3D image and decides if it is a volume or an animated Image.
"""
function _default(img::HasAxesArray{T, 3}, s::Style, data::Dict) where T
# We could do this as a @traitfn, except that those don't
# currently mix well with non-trait specialization.
if ImageAxes.timeaxis(img) != nothing
data[:spatialorder] = "yx"
td = ImageAxes.timedim(img)
video_signal = const_lift(play, unwrap(img), td, loop(1:size(img, timedim)))
return _default(video_signal, s, data)
else
ps = ImageAxes.pixelspacing(img)
spacing = Vec3f0(map(x-> x / maximum(ps), ps))
pdims = Vec3f0(map(length, indices(img)))
dims = pdims .* spacing
dims = dims/maximum(dims)
data[:dimensions] = dims
_default(unwrap(img), s, data)
end
end
function _default(img::TOrSignal{T}, s::Style, data::Dict) where T <: AxisMatrix
@gen_defaults! data begin
ranges = const_lift(img) do img
ps = ImageAxes.pixelspacing(img)
spacing = Vec2f0(map(x-> x / maximum(ps), ps))
pdims = Vec2f0(map(length, indices(img)))
dims = pdims .* spacing
dims = dims / maximum(dims)
(0:dims[1], 0:dims[2])
end
end
_default(const_lift(unwrap, img), s, data)
end

"""
Displays 3D array as movie with 3rd dimension as time dimension
"""
function _default(img::AbstractArray{T, 3}, s::Style, data::Dict) where T
video_signal = const_lift(play, unwrap(img), 3, loop(1:size(img, 3)))
return _default(video_signal, s, data)
end


"""
Takes a shader as a parametric function. The shader should contain a function stubb
like this:
Expand Down
4 changes: 2 additions & 2 deletions src/rendering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function setup!(screen)
glViewport(rt...)
bits = GL_STENCIL_BUFFER_BIT
glClearStencil(id)
if scene.clear[]
if scene.clear
c = to_color(scene.backgroundcolor[])
glScissor(rt...)
glClearColor(red(c), green(c), blue(c), alpha(c))
Expand Down Expand Up @@ -135,7 +135,7 @@ function GLAbstraction.render(screen::Screen, fxaa::Bool)
found || continue
a = pixelarea(scene)[]
glViewport(minimum(a)..., widths(a)...)
if scene.clear[]
if scene.clear
glStencilFunc(GL_EQUAL, screenid, 0xff)
else
# if we don't clear, that means we have a screen that is overlaid
Expand Down

2 comments on commit 25167fc

@SimonDanisch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/6444

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.0.9 -m "<description of version>" 25167fc8969c77bfebbbed4a346803f77f28112d
git push origin v0.0.9

Please sign in to comment.