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

📄 pdc02.h

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 H
字号:
//
// Windows CE Software Graphics Library
// pdc02.h
//
// Copyright (c) 2000 Microsoft Corporation. All rights reserved.
//
// This header file contains the function template for special case blit
// fill routines with 2 Bpp destinations and constant fill values.
//
// This file MUST be included after the deceleration of the fill mask
// arrays and the blt temporary buffer helper within the source file.

#if !defined(FUNCTION)
#error Must define FUNCTION
#endif

#if !defined(BYTE_OP)
#error Must define BYTE_OP
#endif

#if !defined(BLOCK_OP) && !defined(DWORD_OP)
#error Must define either BLOCK_OP or DWORD_OP
#endif

#if defined(BLOCK_OP) && defined(DWORD_OP)
#error Cannot define both BLOCK_OP and DWORD_OP
#endif

BOOL 
FUNCTION(
  BLT_PARAM * Parameters
  )
{
  // Local variables.

  // Destination-related info.

  const RECT * DstRect = Parameters->DestRect;
  LONG         DstScanStride  = Parameters->Destination->Stride;
  BYTE       * DstScanLine = (BYTE *)Parameters->Destination->Ptr +
                             DstRect->top * DstScanStride  +
                             (DstRect->left >> 2);

  BYTE Color;

#ifdef DWORD_OP

  DWORD DwordColor;

  LONG LeftBytes;
  LONG MiddleDwords;
  LONG RightBytes;

  BYTE * Lim;

#endif

  ULONG Rows = RectHeight(DstRect);

  ULONG Row;

  LONG  TotalBytes = ((DstRect->right - 1) >> 2) - (DstRect->left >> 2) + 1;
  BYTE  LeftMask = LeftFillMask[DstRect->left    & 0x03];
  BYTE  RightMask = RightFillMask[DstRect->right & 0x03];

  register BYTE * Destination;
  BYTE            DstPixels;

  // Replicate the solid color to all four pixel positions in the byte

  Color  = (BYTE)Parameters->FillValue;
  Color |= Color << 2;
  Color |= Color << 4;

#ifdef DWORD_OP
    
  // Replicate Color into a DWORD
    
  DwordColor = Color;
  DwordColor |= DwordColor << 8;
  DwordColor |= DwordColor << 16;

#endif

  // Left and right edges in same byte?

  if (TotalBytes == 1) {

    LeftMask &= RightMask;
  }

  // Do the left strip of pixels (partial bytes.)

  if (DstRect->left & 0x03) {

    Destination = DstScanLine;
    for (Row = 0; Row < Rows; Row++) {

      DstPixels = *Destination;
      *Destination = (DstPixels                  & ~LeftMask) |
                     (BYTE_OP(DstPixels, Color) &  LeftMask);
      Destination += DstScanStride;
    }
    DstScanLine++;
    TotalBytes--;
  }

  // Do the right strip of pixels (partial bytes.)

  if ((DstRect->right & 0x03) && (TotalBytes > 0)) {

    Destination = DstScanLine + TotalBytes - 1;
    for (Row = 0; Row < Rows; Row++) {

      DstPixels = *Destination;
      *Destination = (DstPixels                  & ~RightMask) |
                     (BYTE_OP(DstPixels, Color) &  RightMask);
      Destination += DstScanStride;
    }
    TotalBytes--;
  }

#ifdef DWORD_OP

  // Calculate count of full bytes on left, dwords in middle,
  // and bytes on the right

  LeftBytes = min(4 - ((DWORD)DstScanLine & 0x03), (DWORD)TotalBytes) & 0x03;
  MiddleDwords = (TotalBytes - LeftBytes) & ~0x03;
  RightBytes = TotalBytes - LeftBytes - MiddleDwords;

  for (Row = 0; Row < Rows; Row++) {

    Destination = DstScanLine;
    Lim = Destination + LeftBytes;

    while (Destination < Lim) {

      *Destination = BYTE_OP(*Destination, Color);
      Destination++;
    }

    Lim = Destination + MiddleDwords;

#if defined(PPC821) || defined(PPC403)

    while (Destination < Lim) {
      *Destination = BYTE_OP(*Destination, Color);
      Destination++;
    }

#else

    while (Destination < Lim) {
      *(DWORD *)Destination = DWORD_OP(*(DWORD *)Destination, DwordColor);
      Destination += 4;
    }

#endif

    Lim = Destination + RightBytes;

    while (Destination < Lim) {

      *Destination = BYTE_OP(*Destination, Color);
      Destination++;
    }

    DstScanLine += DstScanStride;
  }

#endif

#ifdef BLOCK_OP

    // Do the full bytes of pixels in the middle.

  if (TotalBytes > 0) {

    Destination = DstScanLine;

    for (Row = 0; Row < Rows; Row++) {

      BLOCK_OP(Destination, Color, TotalBytes);
      Destination += DstScanStride;
    }
  }

#endif

  return TRUE;
}

⌨️ 快捷键说明

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