⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enable.c

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 C
📖 第 1 页 / 共 2 页
字号:

  memset(GdiInfo, 0, sizeof(GDIINFO));

  GdiInfo->ulVersion    = GetEngineVersion();
  GdiInfo->ulTechnology = DT_RASDISPLAY;
  GdiInfo->ulHorzRes    = CombinedDevMode->PublicData.dmPelsWidth;
  GdiInfo->ulVertRes    = CombinedDevMode->PublicData.dmPelsHeight;
  GdiInfo->cBitsPixel   = CombinedDevMode->PublicData.dmBitsPerPel;
  GdiInfo->cPlanes      = 1;

  // !TODO! Change this if we added palette support.
  GdiInfo->ulNumColors  = -1;  // Not a paletted device.

  // The GDIINFO structure requires that display devices set these members to
  // 96.

  GdiInfo->ulLogPixelsX = 96;
  GdiInfo->ulLogPixelsY = 96;

  // Fill in capabilities : DevInfo.

  memset(DevInfo, 0, sizeof(DEVINFO));

  // CE requires us to setup a default palette handle even if we do not run in
  // or support paletted modes. In direct color modes, this "palette" contains
  // our bit masks.

  GetDisplayModeMasks(DisplayMode,
                      &BitMasks[0],
                      &BitMasks[1],
                      &BitMasks[2],
                      &BitMasks[3]);

  // 4 masks for modes with alpha channels, 3 for others.

  MaskCount = (BitMasks[3] != 0) ? 4 : 3;

  DevInfo->hpalDefault = EngCreatePalette(PAL_BITFIELDS,
                                          MaskCount,
                                          BitMasks,
                                          0, 0, 0);

  Exit(L"DrvEnablePDEV");

  // !TODO! What to return here instead of garbage?

  return (DHPDEV)123;
}

HSURF 
DrvEnableSurface(
  DHPDEV DeviceHandle
  )
{
  // DrvEnableSurface
  // This function is called by GDI to allow the driver to help GDI allocate
  // it's internal structures for the primary surface. It is not called for
  // any other surface, or in any other condition beyond startup.

  // Local variables.

  ULONG           GdiFormat;
  HSURF           BitmapHandle = NULL;
  PERM3_SURFACE * Surface;

  // Check parameters.

  // !TODO! Change this once we return something real from DrvEnablePDEV.

  Assert((ULONG)DeviceHandle == 123);

  Enter(L"DrvEnableSurface");

  // This finishes setting up the primary surface. Note that this call
  // explicitly needs to happen AFTER the display mode has been set.

  Surface = GetPrimarySurface();
  GdiFormat = BPPToGdiFormat(Surface->Format->BitsPerPixel);

  BitmapHandle = EngCreateDeviceSurface((DHSURF)Surface,
                                        Surface->Size,
                                        GdiFormat);
  
  Surface->BitmapHandle = BitmapHandle;
  	
  Exit(L"DrvEnableSurface");

  return BitmapHandle;
}

BOOL 
DrvContrastControl(
  DHPDEV  DeviceHandle,
  ULONG   Command,
  ULONG * Value
  )
{
  // DrvContrastControl
  // The Permedia3 does not support changing the contrast of it's primary
  // video signal. However, CE requires that this call exist. If we were
  // to do anything but stub this out, this function should be moved to
  // a more appropriate source file.

  // Check parameters.

  // !TODO! Change this once we return something real from DrvEnablePDEV.

  Assert((ULONG)DeviceHandle == 123);

  Enter(L"DrvContrastControl");

  // Nothing for now.

  Exit(L"DrvContrastControl");

  return TRUE;  // Cannot fail, for now.
}

void 
DrvPowerHandler(
  DHPDEV DeviceHandle,
  BOOL   PowerOff
  )
{
  // DrvPowerHandler
  // The Permedia3 has power management options, but we are not implementing
  // power management in this driver.

  // Check parameters.

  // !TODO! Change this once we return something real from DrvEnablePDEV.

  Assert((ULONG)DeviceHandle == 123);

  Enter(L"DrvPowerHandler");

  // Nothing doing.

  Exit(L"DrvPowerHandler");
}
    
ULONG
DrvEscape(
  DHPDEV    DeviceHandle,
  SURFOBJ * Surface,
  ULONG     Escape,
  ULONG     InBufferSize,
  PVOID     InBuffer,
  ULONG     OutBufferSize,
  PVOID     OutBuffer
  )
{
  // DrvEscape
  // This mechanism allows applications tocall through (almost) directly to
  // the driver through the ExtEscape GDI API. We do not support any escapes
  // yet.

  // Check parameters.

  // !TODO! Change this once we return something real from DrvEnablePDEV.

  Assert((ULONG)DeviceHandle == 123);

  Enter(L"DrvEscape");

  // Do something here someday.

  Exit(L"DrvEscape");

  return 0;  // Return value is not examined by GDI: goes right back to user.
}

ULONG 
DrvRealizeColor(
  USHORT  DestinationType,
  ULONG   NumPalette,
  ULONG * Palette,
  ULONG   RgbColor
  )
{
  // DrvRealizeColor
  // This routine is called by GDI when it needs to have a xRGB packed, 8 bits
  // per component, color converted into a "device dependant color. That's to
  // say, something that can be written to the frame buffer and displayed as
  // the same color as the original xRGB color.

  // Local variables.

  PERM3_FORMAT DeviceFormat;
  const PERM3_FORMAT * DeviceFormatPtr;
  ULONG FnRetVal = 0;
  ULONG Masks[4];

  // Check parameters.

  // !TODO!

  Enter(L"DrvRealizeColor");

  // Fill out the DeviceFormat structure for the color converter.

  if (DestinationType == PAL_INDEXED) {

    DeviceFormat.FourCC = FOURCC_PAL;
    DeviceFormat.BitsPerPixel = Log2(NumPalette);
    DeviceFormat.Palette = Palette;
    DeviceFormat.FreePaletteMasks = FALSE;
    DeviceFormatPtr = &DeviceFormat;
  }
  else if (DestinationType == PAL_BITFIELDS) {

    // Note that the palette in this case is our masks in disguise.

    Assert(NumPalette == 3 || NumPalette == 4);

    memset(Masks, 0, sizeof(ULONG) * 4);
    memcpy(Masks, Palette, sizeof(ULONG) * NumPalette);

    DeviceFormat.FourCC = FOURCC_RGB;
    DeviceFormat.Masks = Masks;
    DeviceFormat.FreePaletteMasks = FALSE;
    DeviceFormatPtr = &DeviceFormat;

    // Note: GDI does NOT help our cause much by not providing the desired
    // bits per pixel. Luckily the Mask<->Mask color conversion code does
    // not use it.

    DeviceFormat.BitsPerPixel = 0;
  }
  else if (DestinationType == PAL_RGB) {

    DeviceFormatPtr = GetRGBFormat();
  }
  else if (DestinationType == PAL_BGR) {

    DeviceFormatPtr = GetBGRFormat();
  }
  else {

    Error(L"Unknown DestinationType!\n");
  }

  if (InitColorConverter((const FORMAT *)GetRGBFormat(), 
                         (const FORMAT *)DeviceFormatPtr)) {

    FnRetVal = ColorConvert(RgbColor);
    CleanupColorConverter();
  }

  Exit(L"DrvRealizeColor");

  return FnRetVal;
}

ULONG
DrvUnrealizeColor(
  USHORT  SourceType,
  ULONG   NumPalette,
  ULONG * Palette,
  ULONG   RealizedColor
  )
{
  // DrvUnrealizeColor
  // This function is called by GDI when it needs to convert a "device
  // dependant" color to a xRGB, packed, 8 bits-per-component value.

  // Local variables.

  PERM3_FORMAT DeviceFormat;
  const PERM3_FORMAT * DeviceFormatPtr;
  ULONG FnRetVal = 0;
  ULONG Masks[4];

  // Check parameters.

  // !TODO!

  Enter(L"DrvUnrealizeColor");

  // Fill out the DeviceFormat structure for the color converter.

  if (SourceType == PAL_INDEXED) {

    DeviceFormat.FourCC = FOURCC_PAL;
    DeviceFormat.BitsPerPixel = Log2(NumPalette);
    DeviceFormat.Palette = Palette;
    DeviceFormat.FreePaletteMasks = FALSE;
    DeviceFormatPtr = &DeviceFormat;
  }
  else if (SourceType == PAL_BITFIELDS) {

    // Note that the palette in this case is our masks in disguise.

    Assert(NumPalette == 3 || NumPalette == 4);

    memset(Masks, 0, sizeof(ULONG) * 4);
    memcpy(Masks, Palette, sizeof(ULONG) * NumPalette);

    DeviceFormat.FourCC = FOURCC_RGB;
    DeviceFormat.Masks = Masks;
    DeviceFormat.FreePaletteMasks = FALSE;
    DeviceFormatPtr = &DeviceFormat;

    // Note: GDI does NOT help our cause much by not providing the desired
    // bits per pixel. Luckily the Mask<->Mask color conversion code does
    // not use it.

    DeviceFormat.BitsPerPixel = 0;
  }
  else if (SourceType == PAL_RGB) {

    DeviceFormatPtr = GetRGBFormat();
  }
  else if (SourceType == PAL_BGR) {

    DeviceFormatPtr = GetBGRFormat();
  }
  else {

    Error(L"Unknown SourceType!\n");
  }

  if (InitColorConverter((const FORMAT *)DeviceFormatPtr, 
                         (const FORMAT *)GetRGBFormat())) {

    FnRetVal = ColorConvert(RealizedColor);
    CleanupColorConverter();
  }

  Exit(L"DrvUnrealizeColor");

  return FnRetVal;
}

ULONG
Log2(
  ULONG n
  )
{
  // Log2
  // This function returns the base-2 logarithm of the given value, with
  // one restriction. The given value must be a power of two.

  // Local variables.

  ULONG FnRetVal = 1;

  Enter(L"Log2");

  while ((n & 0x00000001) != 1) {
    n >>= 1;
    FnRetVal++;
  }

  Exit(L"Log2");

  return FnRetVal;
}





⌨️ 快捷键说明

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