specialcase02.c
来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C语言 代码 · 共 135 行
C
135 行
//
// Windows CE Software Graphics Library
// specialcase02.c
//
// Copyright (c) 2000 Microsoft Corporation. All rights reserved.
//
// This source file contains the implementations of the special case blitting
// routines that target 2Bpp surfaces.
//
// Currently, those routines are:
//
// SrcCopy0202
// SolidFill02
// SrcAnd0202
// SrcInvert0202
// SrcPaint0202
// Text02 (!TODO!)
// AlphaText02 (!TODO!)
#include "pch.h"
#include "swg.h"
// These helper arrays and functions are used by the templated functions.
static const BYTE LeftFillMask[] =
{
0xff,
0x3f,
0x0f,
0x03
};
static const BYTE RightFillMask[] =
{
0xff,
0xc0,
0xf0,
0xfc
};
static BYTE *
GetBltBuffer(
LONG ByteCount
);
// We can reuse the 2Bpp SD special case blit template for SRCCOPY, SRCAND,
// SRCPAINT, and SRCINVERT.
#define FUNCTION SrcCopy0202
#define BYTE_OP(D, S) (S)
#define BLOCK_OP(pD, pS, ByteCount) (memcpy((pD), (pS), (ByteCount)))
#include ".\templates\SD0202.h"
#undef FUNCTION
#undef BYTE_OP
#undef BLOCK_OP
#define FUNCTION SrcAnd0202
#define BYTE_OP(D, S) ((D) & (S))
#define DWORD_OP(D, S) ((D) & (S))
#include ".\templates\SD0202.h"
#undef FUNCTION
#undef BYTE_OP
#undef DWORD_OP
#define FUNCTION SrcPaint0202
#define BYTE_OP(D, S) ((D) | (S))
#define DWORD_OP(D, S) ((D) | (S))
#include ".\templates\SD0202.h"
#undef FUNCTION
#undef BYTE_OP
#undef DWORD_OP
#define FUNCTION SrcInvert0202
#define BYTE_OP(D, S) ((D) ^ (S))
#define DWORD_OP(D, S) ((D) ^ (S))
#include ".\templates\SD0202.h"
#undef FUNCTION
#undef BYTE_OP
#undef DWORD_OP
// Likewise, the special case 2Bpp PD blit template for PATFILL.
#define FUNCTION SolidFill02
#define BYTE_OP(D, P) (P)
#define BLOCK_OP(pD, P, ByteCount) (memset((pD), (P), (ByteCount)))
#include ".\templates\PDC02.h"
#undef FUNCTION
#undef BYTE_OP
#undef BLOCK_OP
BYTE *
GetBltBuffer(
LONG ByteCount
)
{
// GetBltBuffer
// This function is called in order to allocate a temporary buffer for
// the blitting functuion to realign bit data. Need to allocate a buffer
// large enough for one scanline (plus a little spare). Note that we
// only realloc when a wider blt comes along.
static DWORD * Buffer = NULL;
static LONG BufferSize = -1;
if (ByteCount > BufferSize) {
BufferSize = ByteCount;
// Allocate the buffer DWORD-aligned, even though we
// return it as a BYTE*. This way callers may perform
// DWORD-stride operations.
LocalFree(Buffer);
Buffer = LocalAlloc(LMEM_FIXED, ((ByteCount + 3) >> 2) * sizeof(DWORD));
// If allocation failed, try again next time.
if (Buffer == NULL) {
BufferSize = -1;
}
}
return (BYTE *)Buffer;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?