Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar-wayland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
quasar-wayland
Commits
b27ca35d
Commit
b27ca35d
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Implement buffer creation from picture files
parent
df552e99
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
quasar-wayland.cabal
+2
-0
2 additions, 0 deletions
quasar-wayland.cabal
src/Quasar/Wayland/Client/JuicyPixels.hs
+36
-0
36 additions, 0 deletions
src/Quasar/Wayland/Client/JuicyPixels.hs
with
38 additions
and
0 deletions
quasar-wayland.cabal
+
2
−
0
View file @
b27ca35d
...
...
@@ -76,6 +76,7 @@ library
exposed-modules:
Quasar.Wayland.Client
Quasar.Wayland.Client.Buffer
Quasar.Wayland.Client.JuicyPixels
Quasar.Wayland.Client.Registry
Quasar.Wayland.Client.Socket
Quasar.Wayland.Client.Sync
...
...
@@ -96,6 +97,7 @@ library
exceptions,
filepath,
inline-c,
JuicyPixels,
mtl,
network,
quasar,
...
...
This diff is collapsed.
Click to expand it.
src/Quasar/Wayland/Client/JuicyPixels.hs
0 → 100644
+
36
−
0
View file @
b27ca35d
module
Quasar.Wayland.Client.JuicyPixels
(
loadImageBuffer
,
pixelRgba8ToWlARGB
,
)
where
import
Codec.Picture
import
Data.Bits
(
unsafeShiftL
,
unsafeShiftR
,
(
.|.
),
(
.&.
)
)
import
Foreign
import
Quasar.Prelude
import
Quasar.Wayland.Client.Buffer
import
Quasar.Wayland.Protocol
import
Quasar.Wayland.Protocol.Generated
loadImageBuffer
::
ShmBufferManager
->
FilePath
->
IO
(
Object
'Client
Interface_wl_buffer
)
loadImageBuffer
shm
path
=
do
image
<-
either
fail
(
pure
.
convertRGBA8
)
=<<
readImage
path
(
buffer
,
ptr
)
<-
newShmBuffer
shm
(
fromIntegral
(
imageWidth
image
))
(
fromIntegral
(
imageHeight
image
))
let
width
=
imageWidth
image
height
=
imageHeight
image
withForeignPtr
ptr
\
ptr'
->
forM
[(
x
,
y
)
|
x
<-
[
0
..
width
-
1
],
y
<-
[
0
..
height
-
1
]]
\
(
x
,
y
)
->
do
pokeByteOff
ptr'
((
x
+
(
y
*
width
))
*
4
)
(
pixelRgba8ToWlARGB
(
pixelAt
image
x
y
))
pure
buffer
pixelRgba8ToWlARGB
::
PixelRGBA8
->
Word32
{-# INLINE pixelRgba8ToWlARGB #-}
pixelRgba8ToWlARGB
(
PixelRGBA8
r
g
b
a
)
=
(
fi
b
`
unsafeShiftL
`
(
0
*
bitCount
))
.|.
(
fi
g
`
unsafeShiftL
`
(
1
*
bitCount
))
.|.
(
fi
r
`
unsafeShiftL
`
(
2
*
bitCount
))
.|.
(
fi
a
`
unsafeShiftL
`
(
3
*
bitCount
))
where
fi
=
fromIntegral
bitCount
=
8
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment