@@ 40,6 40,7 @@ instance PropertyParser (Backgrounds Text) where
inner [Ident "none"] = Just ""
inner [Ident "initial"] = Just ""
inner [Url ret] = Just ret
+ inner [Function "url", String ret, RightParen] = Just ret
inner _ = Nothing
longhand _ _ _ _ = Nothing
@@ 4,7 4,8 @@ module Graphics.Rendering.Rect.Image(
import qualified Data.HashMap.Lazy as HM
import Data.Text (Text)
-import Codec.Picture (DynamicImage(..), Image(..), PixelRGBA8(..), generateImage)
+import Codec.Picture (DynamicImage(..), Image(..), PixelRGBA8(..), PixelYCbCr8(..),
+ pixelMap, generateImage)
import Codec.Picture.Types (promoteImage, dynamicMap)
import Control.Monad.IO.Class (MonadIO(..))
@@ 36,7 37,7 @@ buildAtlas cb srcs = do
forM (zip textures imgs) $ \(texture, dyn) -> do
-- NOTE: `unsafe` crashes with a divide-by-zero given a `Vector ()`
- let img = dynamicMap (unsafeCast . imageData) dyn :: Vector Word
+ let img = dynamicMap (unsafeCast . imageData) $ adjustGL dyn :: Vector Word
let (format, word) = glFormat dyn
liftIO $ glBindTexture GL_TEXTURE_2D texture
liftIO $ unsafeWith img $ -- FIXME: Crashes
@@ 44,6 45,10 @@ buildAtlas cb srcs = do
(toEnum $ dynamicMap imageWidth dyn)
(toEnum $ dynamicMap imageHeight dyn)
0 format word . castPtr
+ liftIO $ glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER GL_LINEAR
+ liftIO $ glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_LINEAR
+ liftIO $ glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_S GL_REPEAT
+ liftIO $ glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_T GL_REPEAT
return $ Atlas $ HM.fromList $ zip srcs textures
@@ 51,7 56,10 @@ data Texture = Texture GLuint
atlasLookup :: Text -> Atlas -> Texture
atlasLookup key = Texture . fromMaybe 0 . HM.lookup key . unAtlas
-
+-- OpenGL deals in CrCb not CbCr...
+adjustGL (ImageYCbCr8 img) = ImageYCbCr8 $ pixelMap swapCrCb img
+ where swapCrCb (PixelYCbCr8 y cb cr) = PixelYCbCr8 y cr cb
+adjustGL img = img
glFormat (ImageY8 _) = (GL_LUMINANCE, GL_UNSIGNED_BYTE)
glFormat (ImageY16 _) = (GL_LUMINANCE, GL_UNSIGNED_SHORT)
glFormat (ImageY32 _) = (GL_LUMINANCE, GL_UNSIGNED_INT)