]> git.sesse.net Git - vlc/commitdiff
* all : skeleton of a future bitmap font support
authorCyril Deguet <asmax@videolan.org>
Mon, 22 Mar 2004 20:38:15 +0000 (20:38 +0000)
committerCyril Deguet <asmax@videolan.org>
Mon, 22 Mar 2004 20:38:15 +0000 (20:38 +0000)
  * skin.dtd : new BitmapFont element

modules/gui/skins2/Modules.am
modules/gui/skins2/src/bitmap_font.cpp [new file with mode: 0644]
modules/gui/skins2/src/bitmap_font.hpp [new file with mode: 0644]
modules/gui/skins2/src/ft2_font.hpp
modules/gui/skins2/src/generic_bitmap.cpp [new file with mode: 0644]
modules/gui/skins2/src/generic_bitmap.hpp
modules/gui/skins2/src/generic_font.hpp
share/skins2/default/skin.dtd

index e35c6af2da9c6d5f76dc89f668317f71c1c63b68..deddb4a9ebcaa43b86e78663d3edf614a5863407 100644 (file)
@@ -79,12 +79,15 @@ SOURCES_skins2 = \
        \
        src/anchor.cpp \
        src/anchor.hpp \
+       src/bitmap_font.cpp \
+       src/bitmap_font.hpp \
        src/dialogs.cpp \
        src/dialogs.hpp \
        src/ft2_bitmap.cpp \
        src/ft2_bitmap.hpp \
        src/ft2_font.cpp \
        src/ft2_font.hpp \
+       src/generic_bitmap.cpp \
        src/generic_bitmap.hpp \
        src/generic_font.hpp \
        src/generic_layout.cpp \
diff --git a/modules/gui/skins2/src/bitmap_font.cpp b/modules/gui/skins2/src/bitmap_font.cpp
new file mode 100644 (file)
index 0000000..566c7c4
--- /dev/null
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * bitmap_font.cpp
+ *****************************************************************************
+ * Copyright (C) 2004 VideoLAN
+ * $Id$
+ *
+ * Authors: Cyril Deguet     <asmax@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include "bitmap_font.hpp"
+#include "generic_bitmap.hpp"
+
+
+BitmapFont::BitmapFont( intf_thread_t *pIntf, const GenericBitmap &rBitmap ):
+    GenericFont( pIntf ), m_rBitmap( rBitmap )
+{
+}
+
+
+GenericBitmap *BitmapFont::drawString( const UString &rString,
+                                       uint32_t color, int maxWidth ) const
+{
+    return NULL;
+}
+
diff --git a/modules/gui/skins2/src/bitmap_font.hpp b/modules/gui/skins2/src/bitmap_font.hpp
new file mode 100644 (file)
index 0000000..436abd0
--- /dev/null
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * bitmap_font.hpp
+ *****************************************************************************
+ * Copyright (C) 2004 VideoLAN
+ * $Id$
+ *
+ * Authors: Cyril Deguet     <asmax@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#ifndef BITMAP_FONT_HPP
+#define BITMAP_FONT_HPP
+
+#include "generic_font.hpp"
+
+class GenericBitmap;
+
+
+/// Class to handle bitmap fonts
+class BitmapFont: public GenericFont
+{
+    public:
+        BitmapFont( intf_thread_t *pIntf, const GenericBitmap &rBitmap );
+        virtual ~BitmapFont() {}
+
+        virtual bool init() { return true; }
+
+        /// Render a string on a bitmap.
+        /// If maxWidth != -1, the text is truncated with '...'
+        virtual GenericBitmap *drawString( const UString &rString,
+            uint32_t color, int maxWidth = -1 ) const;
+
+        /// Get the font size
+        virtual int getSize() const { return 12; }
+
+    private:
+        /// Bitmap
+        const GenericBitmap &m_rBitmap;
+};
+
+#endif
index b1b32a3ef8caffae18b2e36b05550e4dcf7af7b5..278ae85638891bb57397b14065fd308d16f9bb23 100644 (file)
@@ -2,7 +2,7 @@
  * ft2_font.hpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: ft2_font.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -47,9 +47,6 @@ class FT2Font: public GenericFont
 
         /// Render a string on a bitmap.
         /// If maxWidth != -1, the text is truncated with '...'
-        /// rAscent is filled with the maximum ascent of the glyphs in
-        /// the string (for explanations, see:
-        /// http://www.freetype.org/freetype2/docs/tutorial/step2.html)
         virtual GenericBitmap *drawString( const UString &rString,
             uint32_t color, int maxWidth = -1 ) const;
 
diff --git a/modules/gui/skins2/src/generic_bitmap.cpp b/modules/gui/skins2/src/generic_bitmap.cpp
new file mode 100644 (file)
index 0000000..b9a0887
--- /dev/null
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * generic_bitmap.cpp
+ *****************************************************************************
+ * Copyright (C) 2004 VideoLAN
+ * $Id$
+ *
+ * Authors: Cyril Deguet     <asmax@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include "generic_bitmap.hpp"
+
+
+SubBitmap::SubBitmap( intf_thread_t *pIntf, const GenericBitmap &rSource,
+                      int left, int top, int width, int height ):
+    GenericBitmap( pIntf ), m_width( width ), m_height( height ),
+    m_pData( NULL )
+{
+    m_pData = new uint8_t[width * height * 4];
+
+    uint32_t *pSrc = (uint32_t*)rSource.getData();
+    uint32_t *pDest = (uint32_t*)m_pData;
+    int srcWidth = rSource.getWidth();
+    for( int y = top; y < top + height; y++ )
+    {
+        memcpy( pDest, pSrc, 4 * width );
+        pSrc += srcWidth;
+        pDest += width;
+    }
+}
+
+
+SubBitmap::~SubBitmap()
+{
+    delete[] m_pData;
+}
+
index b88b1ac4dc7624f66212e557570edfdf41bcc039..f59a4e1518b9c334561f30212765311902fdd166 100644 (file)
@@ -2,7 +2,7 @@
  * generic_bitmap.hpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: generic_bitmap.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -29,7 +29,7 @@
 #include "../utils/pointer.hpp"
 
 
-/// base class for bitmaps
+/// Base class for bitmaps
 class GenericBitmap: public SkinObject
 {
     public:
@@ -49,6 +49,33 @@ class GenericBitmap: public SkinObject
         GenericBitmap( intf_thread_t *pIntf ): SkinObject( pIntf ) {}
 };
 
+
+/// Bitmap created from a region of another bitmap
+class SubBitmap: public GenericBitmap
+{
+    public:
+        SubBitmap( intf_thread_t *pIntf, const GenericBitmap &rSource,
+                   int left, int top, int width, int height );
+        ~SubBitmap();
+
+        /// Get the width of the bitmap
+        virtual int getWidth() const { return m_width; }
+
+        /// Get the heighth of the bitmap
+        virtual int getHeight() const { return m_height; }
+
+        /// Get a linear buffer containing the image data.
+        /// Each pixel is stored in 4 bytes in the order B,G,R,A
+        virtual uint8_t *getData() const { return m_pData; }
+
+    private:
+        /// Size of the bitmap.
+        int m_width, m_height;
+        /// Buffer containing the image data.
+        uint8_t *m_pData;
+};
+
+
 typedef CountedPtr<GenericBitmap> GenericBitmapPtr;
 
 #endif
index b67faafd93782c528b1cfc9dba842d76cc059c95..55fd2860286e22a2488a8a297e03059a7d2d9f99 100644 (file)
@@ -2,7 +2,7 @@
  * generic_font.hpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: generic_font.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -41,13 +41,10 @@ class GenericFont: public SkinObject
 
         /// Render a string on a bitmap.
         /// If maxWidth != -1, the text is truncated with '...'
-        /// rAscent is filled with the maximum ascent of the glyphs in
-        /// the string (for explanations, see:
-        /// http://www.freetype.org/freetype2/docs/tutorial/step2.html)
+        /// The Bitmap is _not_ owned by this object
         virtual GenericBitmap *drawString( const UString &rString,
             uint32_t color, int maxWidth = -1 ) const = 0;
 
-
         /// Get the font size
         virtual int getSize() const = 0;
 
index 17a67060191a5259f61879f70a15a2a1578778e3..9ff0b2a5fc5b34ed7554cf7fb43a6ca97bd0d4f9 100644 (file)
         italic      CDATA   "false"
         underline   CDATA   "false"
     >
+<!ELEMENT BitmapFont EMPTY>
+    <!ATTLIST Font
+        id          CDATA   #REQUIRED
+        file        CDATA   #REQUIRED
+        type        CDATA   "digits"
+    >
 <!ELEMENT ThemeInfo EMPTY>
     <!ATTLIST ThemeInfo
         name        CDATA   #IMPLIED