framebuf-parameters.html

来自「ecos3.0 beta 的官方文档,html格式」· HTML 代码 · 共 760 行 · 第 1/2 页

HTML
760
字号
<!-- Copyright (C) 2009 Free Software Foundation, Inc.                                -->
<!-- This material may be distributed only subject to the terms      -->
<!-- and conditions set forth in the Open Publication License, v1.0  -->
<!-- or later (the latest version is presently available at          -->
<!-- http://www.opencontent.org/openpub/).                           -->
<!-- Distribution of the work or derivative of the work in any       -->
<!-- standard (paper) book form is prohibited unless prior           -->
<!-- permission is obtained from the copyright holder.               -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Framebuffer Parameters</TITLE
><meta name="MSSmartTagsPreventParsing" content="TRUE">
<META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="eCos Reference Manual"
HREF="ecos-ref.html"><LINK
REL="UP"
TITLE="Framebuffer Support"
HREF="io-framebuf.html"><LINK
REL="PREVIOUS"
TITLE="Overview"
HREF="framebuf.html"><LINK
REL="NEXT"
TITLE="Framebuffer Control Operations"
HREF="framebuf-control.html"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>eCos Reference Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="framebuf.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="framebuf-control.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="FRAMEBUF-PARAMETERS"
></A
>Framebuffer Parameters</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN10066"
></A
><H2
>Name</H2
>Parameters&nbsp;--&nbsp;determining framebuffer capabilities</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN10069"
></A
><H2
>Synopsis</H2
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN10070"
></A
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="FUNCSYNOPSISINFO"
>#include &lt;cyg/io/framebuf.h&gt;

typedef struct cyg_fb {
    cyg_ucount16    fb_depth;
    cyg_ucount16    fb_format;
    cyg_ucount16    fb_width;
    cyg_ucount16    fb_height;
#ifdef CYGHWR_IO_FRAMEBUF_FUNCTIONALITY_VIEWPORT
    cyg_ucount16    fb_viewport_width;
    cyg_ucount16    fb_viewport_height;
#endif
    void*           fb_base;
    cyg_ucount16    fb_stride;
    cyg_uint32      fb_flags0;
    &#8230;    
} cyg_fb;
      </PRE
></TD
></TR
></TABLE
><P
><CODE
><CODE
CLASS="FUNCDEF"
>cyg_fb* CYG_FB_STRUCT</CODE
>(FRAMEBUF);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>cyg_ucount16 CYG_FB_DEPTH</CODE
>(FRAMEBUF);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>cyg_ucount16 CYG_FB_FORMAT</CODE
>(FRAMEBUF);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>cyg_ucount16 CYG_FB_WIDTH</CODE
>(FRAMEBUF);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>cyg_ucount16 CYG_FB_HEIGHT</CODE
>(FRAMEBUF);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>cyg_ucount16 CYG_FB_VIEWPORT_WIDTH</CODE
>(FRAMEBUF);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>cyg_ucount16 CYG_FB_VIEWPORT_HEIGHT</CODE
>(FRAMEBUF);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>void* CYG_FB_BASE</CODE
>(FRAMEBUF);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>cyg_ucount16 CYG_FB_STRIDE</CODE
>(FRAMEBUF);</CODE
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>cyg_uint32 CYG_FB_FLAGS0</CODE
>(FRAMEBUF);</CODE
></P
><P
></P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="FRAMEBUF-PARAMETERS-DESCRIPTION"
></A
><H2
>Description</H2
><P
>When developing an application for a specific platform the various
framebuffer parameters such as width and height are known, and the
code can be written accordingly. However when writing code that should
work on many platforms with different framebuffer devices, for example
a graphics library, the code must be able to get these parameters and
adapt.
    </P
><P
>Code using the function API can extract the parameters from the
<CODE
CLASS="STRUCTNAME"
>cyg_fb</CODE
> structures at run-time. The macro API
provides dedicated macros for each parameter. These do not follow the
usual eCos convention where the result is provided via an extra
argument. Instead the result is returned as normal, and is guaranteed
to be a compile-time constant. This allows code like the following:
    </P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>#if CYG_FB_DEPTH(FRAMEBUF) &lt; 8
    &#8230;
#else
    &#8230;
#endif
    </PRE
></TD
></TR
></TABLE
><P
>or alternatively:
    </P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>    if (CYG_FB_DEPTH(FRAMEBUF) &#60; 8) {
        &#8230;
    } else {
        &#8230;
    }
    </PRE
></TD
></TR
></TABLE
><P
>or:
    </P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>    switch (CYG_FB_DEPTH(FRAMEBUF)) {
        case  1 : &#8230; break;
        case  2 : &#8230; break;
        case  4 : &#8230; break;
        case  8 : &#8230; break;
        case 16 : &#8230; break;
        case 32 : &#8230; break;
    }
    </PRE
></TD
></TR
></TABLE
><P
>In terms of the code actually generated by the compiler these
approaches have much the same effect. The macros expand to a
compile-time constant so unnecessary code can be easily eliminated.
    </P
><P
>The available parameters are as follows:
    </P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>depth</DT
><DD
><P
>The number of bits per pixel or bpp. The common depths are 1, 2, 4, 8,
16 and 32. 
        </P
></DD
><DT
>format</DT
><DD
><P
>How the pixel values are mapped on to visible <A
HREF="framebuf-colour.html"
>colours</A
>, for example true colour
or paletted or greyscale.
        </P
></DD
><DT
>width, height</DT
><DD
><P
>The number of framebuffer pixels horizontally and vertically.
        </P
></DD
><DT
>viewport width, viewport height</DT
><DD
><P
>With some devices the framebuffer height and/or width are greater than
what the display can actually show. The display is said to offer a
viewport into the larger framebuffer. The number of visible pixels is
determined from the viewport width and height. The position of the
viewport is controlled via an <A
HREF="framebuf-control.html#FRAMEBUF-CONTROL-IOCTL-VIEWPORT"
><CODE
CLASS="FUNCTION"
>ioctl</CODE
></A
>.
Within a <CODE
CLASS="STRUCTNAME"
>cyg_fb</CODE
> structure these fields are
only present if
<CODE
CLASS="VARNAME"
>CYGHWR_IO_FRAMEBUF_FUNCTIONALITY_VIEWPORT</CODE
>
is defined, to avoid wasting data space on fields that are unnecessary
for the current platform. For the macro API the viewport macros should only be used
if <TT
CLASS="LITERAL"
>CYG_FB_FLAGS0_VIEWPORT</TT
> is set for the framebuffer:
        </P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>#if (CYG_FB_FLAGS0(FRAMEBUF) &amp; CYG_FB_FLAGS0_VIEWPORT)
    &#8230;
#endif
        </PRE
></TD
></TR
></TABLE
></DD

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?