예제 #1
0
TextureFormat const *
TextureFormat::fromImageType(AbstractImage::Type type, bool is_depth)
{
  if (is_depth)
  {
    switch (type)
    {
      case AbstractImage::Type::LUMINANCE_16U : return DEPTH16();
      case AbstractImage::Type::LUMINANCE_32U : return DEPTH32();
      case AbstractImage::Type::LUMINANCE_32F : return DEPTH32F();
      default: throw Error("TextureFormat: No supported depth texture format corresponds to the specified image format");
    }
  }

  enum { COLOR_ORDER_RGB, COLOR_ORDER_BGR } color_order;
  color_order = (AbstractImage::Channel::RED < AbstractImage::Channel::BLUE ? COLOR_ORDER_RGB : COLOR_ORDER_BGR);

  switch (type)
  {
    case AbstractImage::Type::LUMINANCE_8U  : return L8();
    case AbstractImage::Type::LUMINANCE_16U : return L16();
    case AbstractImage::Type::LUMINANCE_32F : return L32F();
    case AbstractImage::Type::RGB_8U        : return color_order == COLOR_ORDER_RGB ? RGB8() : BGR8();
    case AbstractImage::Type::RGBA_8U       : return color_order == COLOR_ORDER_RGB ? RGBA8() : BGRA8();
    case AbstractImage::Type::RGB_16U       : return color_order == COLOR_ORDER_RGB ? RGB16() : BGR16();
    case AbstractImage::Type::RGBA_16U      : return color_order == COLOR_ORDER_RGB ? RGBA16() : BGRA16();
    case AbstractImage::Type::RGB_32F       : return color_order == COLOR_ORDER_RGB ? RGB32F() : BGR32F();
    case AbstractImage::Type::RGBA_32F      : return color_order == COLOR_ORDER_RGB ? RGBA32F() : BGRA32F();
    default: throw Error("TextureFormat: No supported texture format corresponds to the specified image format");
  }
}
예제 #2
0
const ImageFormat* ImageFormat::depth(int depthBits) {

    switch (depthBits) {
    case 16:
        return DEPTH16();

    case 24:
        return DEPTH24();

    case 32:
        return DEPTH32();

    default:
        debugAssertM(false, "Depth must be 16, 24, or 32.");
        return DEPTH32();
    }
}
예제 #3
0
TextureFormat const *
TextureFormat::depth(int depth_bits)
{
  switch (depth_bits)
  {
    case 16:
      return DEPTH16();

    case 24:
      return DEPTH24();

    case 32:
      return DEPTH32();

    default:
      alwaysAssertM(false, "TextureFormat: Number of depth bits must be 16, 24, or 32");
      return DEPTH32();
  }
}
예제 #4
0
TextureFormat const *
TextureFormat::fromCode(Code code)
{
  switch (code)
  {
    case Code::L8:
      return L8();

    case Code::L16:
      return L16();

    case Code::L16F:
      return L16F();

    case Code::L32F:
      return L32F();

    case Code::A8:
      return A8();

    case Code::A16:
      return A16();

    case Code::A16F:
      return A16F();

    case Code::A32F:
      return A32F();

    case Code::LA4:
      return LA4();

    case Code::LA8:
      return LA8();

    case Code::LA16:
      return LA16();

    case Code::LA16F:
      return LA16F();
      break;

    case Code::LA32F:
      return LA32F();

    case Code::RGB5:
      return RGB5();

    case Code::RGB5A1:
      return RGB5A1();

    case Code::RGB8:
      return RGB8();

    case Code::RGB10:
      return RGB10();

    case Code::RGB10A2:
      return RGB10A2();

    case Code::RGB16:
      return RGB16();

    case Code::RGB32F:
      return RGB32F();

    case Code::R11G11B10F:
      return R11G11B10F();

    case Code::RGB9E5F:
      return RGB9E5F();

    case Code::RGB8I:
      return RGB8I();

    case Code::RGB8UI:
      return RGB8UI();

    case Code::ARGB8:
      return NULL;

    case Code::BGR8:
      return BGR8();

    case Code::BGRA8:
      return BGRA8();

    case Code::BGR16:
      return BGR16();

    case Code::BGRA16:
      return BGRA16();

    case Code::BGR32F:
      return BGR32F();

    case Code::BGRA32F:
      return BGRA32F();

    case Code::R8:
      return R8();

    case Code::RG8:
      return RG8();

    case Code::RG8I:
      return RG8I();

    case Code::RG8UI:
      return RG8UI();

    case Code::RG16F:
      return RG16F();

    case Code::RGBA8:
      return RGBA8();

    case Code::RGBA16:
      return RGBA16();

    case Code::RGBA16F:
      return RGBA16F();

    case Code::RGBA32F:
      return RGBA32F();

    case Code::RGBA32UI:
      return RGBA32UI();

    case Code::BAYER_RGGB8:

      // TODO
    case Code::BAYER_GRBG8:

      // TODO
    case Code::BAYER_GBRG8:

      // TODO
    case Code::BAYER_BGGR8:

      // TODO
    case Code::BAYER_RGGB32F:

      // TODO
    case Code::BAYER_GRBG32F:

      // TODO
    case Code::BAYER_GBRG32F:

      // TODO
    case Code::BAYER_BGGR32F:

      // TODO
    case Code::HSV8:

      // TODO
    case Code::HSV32F:
      // TODO
      return NULL;
      break;

    case Code::RGB_DXT1:
      return RGB_DXT1();
      break;

    case Code::RGBA_DXT1:
      return RGBA_DXT1();
      break;

    case Code::RGBA_DXT3:
      return RGBA_DXT3();
      break;

    case Code::RGBA_DXT5:
      return RGBA_DXT5();
      break;

    case Code::SRGB8:
      return SRGB8();
      break;

    case Code::SRGBA8:
      return SRGBA8();
      break;

    case Code::SL8:
      return SL8();
      break;

    case Code::SLA8:
      return SLA8();
      break;

    case Code::SRGB_DXT1:
      return SRGB_DXT1();
      break;

    case Code::SRGBA_DXT1:
      return SRGBA_DXT1();
      break;

    case Code::SRGBA_DXT3:
      return SRGBA_DXT3();
      break;

    case Code::SRGBA_DXT5:
      return SRGBA_DXT5();
      break;

    case Code::DEPTH16:
      return DEPTH16();
      break;

    case Code::DEPTH24:
      return DEPTH24();
      break;

    case Code::DEPTH32:
      return DEPTH32();
      break;

    case Code::DEPTH32F:
      return DEPTH32F();
      break;

    case Code::STENCIL1:
      return STENCIL1();
      break;

    case Code::STENCIL4:
      return STENCIL4();
      break;

    case Code::STENCIL8:
      return STENCIL8();
      break;

    case Code::STENCIL16:
      return STENCIL16();
      break;

    case Code::DEPTH24_STENCIL8:
      return DEPTH24_STENCIL8();
      break;

    case Code::YUV420_PLANAR:
      return YUV420_PLANAR();
      break;

    case Code::YUV422:
      return YUV422();
      break;

    case Code::YUV444:
      return YUV444();
      break;

    default:
      return NULL;
  }
}
예제 #5
0
파일: stroke.c 프로젝트: mingpen/OpenNT
BOOL DrvStrokePath(
    SURFOBJ*   pso,
    PATHOBJ*   ppo,
    CLIPOBJ*   pco,
    XFORMOBJ*  pxo,
    BRUSHOBJ*  pbo,
    POINTL*    pptlBrush,
    LINEATTRS* pla,
    MIX        mix)
{
    STYLEPOS  aspLtoR[STYLE_MAX_COUNT];
    STYLEPOS  aspRtoL[STYLE_MAX_COUNT];
    LINESTATE ls;
    PFNSTRIP* apfn;
    FLONG     fl;
    PDEV*     ppdev;
    DSURF*    pdsurf;
    OH*       poh;
    ULONG     ulHwMix;
    RECTL     arclClip[4];                  // For rectangular clipping
    RECTL     rclBounds;
    RECTFX    rcfxBounds;

// Pass the surface off to GDI if it's a device bitmap that we've
// converted to a DIB:

    pdsurf = (DSURF*) pso->dhsurf;
    if (pdsurf->dt == DT_DIB)
    {
        return(EngStrokePath(pdsurf->pso, ppo, pco, pxo, pbo, pptlBrush,
                             pla, mix));
    }

// We'll be drawing to the screen or an off-screen DFB; copy the surface's
// offset now so that we won't need to refer to the DSURF again:

    poh   = pdsurf->poh;
    ppdev = (PDEV*) pso->dhpdev;
    ppdev->xOffset = poh->x;
    ppdev->yOffset = poh->y;

    ulHwMix = gajHwMixFromMix[mix & 0xf];

// x86 has special case ASM code for accelerating solid lines:

#if defined(_X86_)

    if ((pla->pstyle == NULL) && !(pla->fl & LA_ALTERNATE))
    {
    // We can accelerate solid lines:

        if (pco->iDComplexity == DC_TRIVIAL)
        {
            ppdev->pfnFastLine(ppdev, ppo, NULL, &gapfnStrip[0], 0,
                               pbo->iSolidColor, ulHwMix);

            return(TRUE);
        }
        else if (pco->iDComplexity == DC_RECT)
        {
        // We have to be sure that we don't overflow the hardware registers
        // for current position, line length, or DDA terms.  We check
        // here to make sure that the current position and line length
        // values won't overflow (for integer lines, this check is
        // sufficient to ensure that the DDA terms won't overflow; for GIQ
        // lines, we specifically check on every line in pfnFastLine that we
        // don't overflow).

            PATHOBJ_vGetBounds(ppo, &rcfxBounds);

            if (rcfxBounds.xLeft   + (ppdev->xOffset * F)
                                                >= (MIN_INTEGER_BOUND * F) &&
                rcfxBounds.xRight  + (ppdev->xOffset * F)
                                                <= (MAX_INTEGER_BOUND * F) &&
                rcfxBounds.yTop    + (ppdev->yOffset * F)
                                                >= (MIN_INTEGER_BOUND * F) &&
                rcfxBounds.yBottom + (ppdev->yOffset * F)
                                                <= (MAX_INTEGER_BOUND * F))
            {
            // Since we're going to be using the scissors registers to
            // do hardware clipping, we'll also have to make sure we don't
            // exceed its bounds.  ATI chips have a maximum limit of 1023,
            // which we could exceed if we're running at 1280x1024, or for
            // off-screen device bitmaps.

                if ((pco->rclBounds.right  + ppdev->xOffset < 1024) &&
                    (pco->rclBounds.bottom + ppdev->yOffset < 1024))
                {
                    arclClip[0]        =  pco->rclBounds;

                // FL_FLIP_D:

                    arclClip[1].top    =  pco->rclBounds.left;
                    arclClip[1].left   =  pco->rclBounds.top;
                    arclClip[1].bottom =  pco->rclBounds.right;
                    arclClip[1].right  =  pco->rclBounds.bottom;

                // FL_FLIP_V:

                    arclClip[2].top    = -pco->rclBounds.bottom + 1;
                    arclClip[2].left   =  pco->rclBounds.left;
                    arclClip[2].bottom = -pco->rclBounds.top + 1;
                    arclClip[2].right  =  pco->rclBounds.right;

                // FL_FLIP_V | FL_FLIP_D:

                    arclClip[3].top    =  pco->rclBounds.left;
                    arclClip[3].left   = -pco->rclBounds.bottom + 1;
                    arclClip[3].bottom =  pco->rclBounds.right;
                    arclClip[3].right  = -pco->rclBounds.top + 1;

                    rclBounds.left   = pco->rclBounds.left;
                    rclBounds.top    = pco->rclBounds.top;
                    rclBounds.right  = pco->rclBounds.right;
                    rclBounds.bottom = pco->rclBounds.bottom;

                    vSetClipping(ppdev, &rclBounds);

                    ppdev->pfnFastLine(ppdev, ppo, &arclClip[0], &gapfnStrip[0],
                                       FL_SIMPLE_CLIP, pbo->iSolidColor, ulHwMix);

                    vResetClipping(ppdev);
                    return(TRUE);
                }
            }
        }
    }

#endif // _X86_

// Get the device ready:

    if (DEPTH32(ppdev))
    {
        IO_FIFO_WAIT(ppdev, 4);
        MM_FRGD_COLOR32(ppdev, ppdev->pjMmBase, pbo->iSolidColor);
    }
    else
    {
        IO_FIFO_WAIT(ppdev, 3);
        IO_FRGD_COLOR(ppdev, pbo->iSolidColor);
    }

    IO_FRGD_MIX(ppdev, FOREGROUND_COLOR | ulHwMix);
    IO_PIX_CNTL(ppdev, ALL_ONES);

    fl = 0;

// Look after styling initialization:

    if (pla->fl & LA_ALTERNATE)
    {
        ls.cStyle      = 1;
        ls.spTotal     = 1;
        ls.spTotal2    = 2;
        ls.spRemaining = 1;
        ls.aspRtoL     = &gaspAlternateStyle[0];
        ls.aspLtoR     = &gaspAlternateStyle[0];
        ls.spNext      = HIWORD(pla->elStyleState.l);
        ls.xyDensity   = 1;
        fl            |= FL_ARBITRARYSTYLED;
        ls.ulStartMask = 0L;
    }
    else if (pla->pstyle != (FLOAT_LONG*) NULL)
    {
        PFLOAT_LONG pstyle;
        STYLEPOS*   pspDown;
        STYLEPOS*   pspUp;

        pstyle = &pla->pstyle[pla->cstyle];

        ls.xyDensity = STYLE_DENSITY;
        ls.spTotal   = 0;
        while (pstyle-- > pla->pstyle)
        {
            ls.spTotal += pstyle->l;
        }
        ls.spTotal *= STYLE_DENSITY;
        ls.spTotal2 = 2 * ls.spTotal;

    // Compute starting style position (this is guaranteed not to overflow):

        ls.spNext = HIWORD(pla->elStyleState.l) * STYLE_DENSITY +
                    LOWORD(pla->elStyleState.l);

        fl        |= FL_ARBITRARYSTYLED;
        ls.cStyle  = pla->cstyle;
        ls.aspRtoL = aspRtoL;
        ls.aspLtoR = aspLtoR;

        if (pla->fl & LA_STARTGAP)
            ls.ulStartMask = 0xffffffffL;
        else
            ls.ulStartMask = 0L;

        pstyle  = pla->pstyle;
        pspDown = &ls.aspRtoL[ls.cStyle - 1];
        pspUp   = &ls.aspLtoR[0];

        while (pspDown >= &ls.aspRtoL[0])
        {
            *pspDown = pstyle->l * STYLE_DENSITY;
            *pspUp   = *pspDown;

            pspUp++;
            pspDown--;
            pstyle++;
        }
    }

    apfn = &gapfnStrip[NUM_STRIP_DRAW_STYLES *
                            ((fl & FL_STYLE_MASK) >> FL_STYLE_SHIFT)];

// Set up to enumerate the path:

#if defined(_X86_)

// x86 ASM bLines supports DC_RECT clipping:

    if (pco->iDComplexity != DC_COMPLEX)

#else

// Non-x86 ASM bLines don't support DC_RECT clipping:

    if (pco->iDComplexity == DC_TRIVIAL)

#endif

    {
        PATHDATA  pd;
        RECTL*    prclClip = (RECTL*) NULL;
        BOOL      bMore;
        ULONG     cptfx;
        POINTFIX  ptfxStartFigure;
        POINTFIX  ptfxLast;
        POINTFIX* pptfxFirst;
        POINTFIX* pptfxBuf;

#if defined(_X86_)

        if (pco->iDComplexity == DC_RECT)
        {
            fl |= FL_SIMPLE_CLIP;

            arclClip[0]        =  pco->rclBounds;

        // FL_FLIP_D:

            arclClip[1].top    =  pco->rclBounds.left;
            arclClip[1].left   =  pco->rclBounds.top;
            arclClip[1].bottom =  pco->rclBounds.right;
            arclClip[1].right  =  pco->rclBounds.bottom;

        // FL_FLIP_V:

            arclClip[2].top    = -pco->rclBounds.bottom + 1;
            arclClip[2].left   =  pco->rclBounds.left;
            arclClip[2].bottom = -pco->rclBounds.top + 1;
            arclClip[2].right  =  pco->rclBounds.right;

        // FL_FLIP_V | FL_FLIP_D:

            arclClip[3].top    =  pco->rclBounds.left;
            arclClip[3].left   = -pco->rclBounds.bottom + 1;
            arclClip[3].bottom =  pco->rclBounds.right;
            arclClip[3].right  = -pco->rclBounds.top + 1;

            prclClip = arclClip;
        }

#endif // _X86_

        pd.flags = 0;

        do {
            bMore = PATHOBJ_bEnum(ppo, &pd);

            cptfx = pd.count;
            if (cptfx == 0)
            {
                break;
            }

            if (pd.flags & PD_BEGINSUBPATH)
            {
                ptfxStartFigure  = *pd.pptfx;
                pptfxFirst       = pd.pptfx;
                pptfxBuf         = pd.pptfx + 1;
                cptfx--;
            }
            else
            {
                pptfxFirst       = &ptfxLast;
                pptfxBuf         = pd.pptfx;
            }

            if (pd.flags & PD_RESETSTYLE)
                ls.spNext = 0;

            if (cptfx > 0)
            {
                if (!bLines(ppdev,
                            pptfxFirst,
                            pptfxBuf,
                            (RUN*) NULL,
                            cptfx,
                            &ls,
                            prclClip,
                            apfn,
                            fl))
                    return(FALSE);
            }

            ptfxLast = pd.pptfx[pd.count - 1];

            if (pd.flags & PD_CLOSEFIGURE)
            {
                if (!bLines(ppdev,
                            &ptfxLast,
                            &ptfxStartFigure,
                            (RUN*) NULL,
                            1,
                            &ls,
                            prclClip,
                            apfn,
                            fl))
                    return(FALSE);
            }
        } while (bMore);

        if (fl & FL_STYLED)
        {
        // Save the style state:

            ULONG ulHigh;
            ULONG ulLow;

        // Masked styles don't normalize the style state.  It's a good
        // thing to do, so let's do it now:

            if ((ULONG) ls.spNext >= (ULONG) ls.spTotal2)
                ls.spNext = (ULONG) ls.spNext % (ULONG) ls.spTotal2;

            ulHigh = ls.spNext / ls.xyDensity;
            ulLow  = ls.spNext % ls.xyDensity;

            pla->elStyleState.l = MAKELONG(ulLow, ulHigh);
        }
    }
    else
    {
    // Local state for path enumeration:

        BOOL bMore;
        union {
            BYTE     aj[offsetof(CLIPLINE, arun) + RUN_MAX * sizeof(RUN)];
            CLIPLINE cl;
        } cl;

        fl |= FL_COMPLEX_CLIP;

    // We use the clip object when non-simple clipping is involved:

        PATHOBJ_vEnumStartClipLines(ppo, pco, pso, pla);

        do {
            bMore = PATHOBJ_bEnumClipLines(ppo, sizeof(cl), &cl.cl);
            if (cl.cl.c != 0)
            {
                if (fl & FL_STYLED)
                {
                    ls.spComplex = HIWORD(cl.cl.lStyleState) * ls.xyDensity
                                 + LOWORD(cl.cl.lStyleState);
                }
                if (!bLines(ppdev,
                            &cl.cl.ptfxA,
                            &cl.cl.ptfxB,
                            &cl.cl.arun[0],
                            cl.cl.c,
                            &ls,
                            (RECTL*) NULL,
                            apfn,
                            fl))
                    return(FALSE);
            }
        } while (bMore);
    }

    return(TRUE);
}